webr
Version:
The statistical programming language R compiled into WASM for use in a web browser and node.
8 lines (7 loc) • 66.5 kB
JavaScript
import { createRequire } from 'module';
import { fileURLToPath as urlESMPluginFileURLToPath } from "url";
import { dirname as pathESMPluginDirname} from "path";
const require = createRequire(import.meta.url);
var __filename = urlESMPluginFileURLToPath(import.meta.url);
var __dirname = pathESMPluginDirname(urlESMPluginFileURLToPath(import.meta.url));
var fr=Object.create;var Et=Object.defineProperty;var mr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var gr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var ze=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var w=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var wr=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Rr(e))!br.call(r,n)&&n!==t&&Et(r,n,{get:()=>e[n],enumerable:!(s=mr(e,n))||s.enumerable});return r};var xr=(r,e,t)=>(t=r!=null?fr(gr(r)):{},wr(e||!r||!r.__esModule?Et(t,"default",{value:r,enumerable:!0}):t,r));var fe=w(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.getUint64=k.getInt64=k.setInt64=k.setUint64=k.UINT32_MAX=void 0;k.UINT32_MAX=4294967295;function _r(r,e,t){let s=t/4294967296,n=t;r.setUint32(e,s),r.setUint32(e+4,n)}k.setUint64=_r;function kr(r,e,t){let s=Math.floor(t/4294967296),n=t;r.setUint32(e,s),r.setUint32(e+4,n)}k.setInt64=kr;function Mr(r,e){let t=r.getInt32(e),s=r.getUint32(e+4);return t*4294967296+s}k.getInt64=Mr;function Wr(r,e){let t=r.getUint32(e),s=r.getUint32(e+4);return t*4294967296+s}k.getUint64=Wr});var ke=w(E=>{"use strict";var Ye,Ze,et;Object.defineProperty(E,"__esModule",{value:!0});E.utf8DecodeTD=E.TEXT_DECODER_THRESHOLD=E.utf8DecodeJs=E.utf8EncodeTE=E.TEXT_ENCODER_THRESHOLD=E.utf8EncodeJs=E.utf8Count=void 0;var It=fe(),_e=(typeof process>"u"||((Ye=process==null?void 0:process.env)===null||Ye===void 0?void 0:Ye.TEXT_ENCODING)!=="never")&&typeof TextEncoder<"u"&&typeof TextDecoder<"u";function Ar(r){let e=r.length,t=0,s=0;for(;s<e;){let n=r.charCodeAt(s++);if((n&4294967168)===0){t++;continue}else if((n&4294965248)===0)t+=2;else{if(n>=55296&&n<=56319&&s<e){let o=r.charCodeAt(s);(o&64512)===56320&&(++s,n=((n&1023)<<10)+(o&1023)+65536)}(n&4294901760)===0?t+=3:t+=4}}return t}E.utf8Count=Ar;function Or(r,e,t){let s=r.length,n=t,o=0;for(;o<s;){let a=r.charCodeAt(o++);if((a&4294967168)===0){e[n++]=a;continue}else if((a&4294965248)===0)e[n++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&o<s){let i=r.charCodeAt(o);(i&64512)===56320&&(++o,a=((a&1023)<<10)+(i&1023)+65536)}(a&4294901760)===0?(e[n++]=a>>12&15|224,e[n++]=a>>6&63|128):(e[n++]=a>>18&7|240,e[n++]=a>>12&63|128,e[n++]=a>>6&63|128)}e[n++]=a&63|128}}E.utf8EncodeJs=Or;var me=_e?new TextEncoder:void 0;E.TEXT_ENCODER_THRESHOLD=_e?typeof process<"u"&&((Ze=process==null?void 0:process.env)===null||Ze===void 0?void 0:Ze.TEXT_ENCODING)!=="force"?200:0:It.UINT32_MAX;function Dr(r,e,t){e.set(me.encode(r),t)}function Cr(r,e,t){me.encodeInto(r,e.subarray(t))}E.utf8EncodeTE=me?.encodeInto?Cr:Dr;var Ir=4096;function Ur(r,e,t){let s=e,n=s+t,o=[],a="";for(;s<n;){let i=r[s++];if((i&128)===0)o.push(i);else if((i&224)===192){let c=r[s++]&63;o.push((i&31)<<6|c)}else if((i&240)===224){let c=r[s++]&63,R=r[s++]&63;o.push((i&31)<<12|c<<6|R)}else if((i&248)===240){let c=r[s++]&63,R=r[s++]&63,d=r[s++]&63,M=(i&7)<<18|c<<12|R<<6|d;M>65535&&(M-=65536,o.push(M>>>10&1023|55296),M=56320|M&1023),o.push(M)}else o.push(i);o.length>=Ir&&(a+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(a+=String.fromCharCode(...o)),a}E.utf8DecodeJs=Ur;var Nr=_e?new TextDecoder:null;E.TEXT_DECODER_THRESHOLD=_e?typeof process<"u"&&((et=process==null?void 0:process.env)===null||et===void 0?void 0:et.TEXT_DECODER)!=="force"?200:0:It.UINT32_MAX;function Br(r,e,t){let s=r.subarray(e,e+t);return Nr.decode(s)}E.utf8DecodeTD=Br});var rt=w(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.ExtData=void 0;var tt=class{constructor(e,t){this.type=e,this.data=t}};Me.ExtData=tt});var Ae=w(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.DecodeError=void 0;var st=class r extends Error{constructor(e){super(e);let t=Object.create(r.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:r.name})}};We.DecodeError=st});var nt=w(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b.timestampExtension=b.decodeTimestampExtension=b.decodeTimestampToTimeSpec=b.encodeTimestampExtension=b.encodeDateToTimeSpec=b.encodeTimeSpecToTimestamp=b.EXT_TIMESTAMP=void 0;var jr=Ae(),Ut=fe();b.EXT_TIMESTAMP=-1;var Lr=4294967296-1,Fr=17179869184-1;function Nt({sec:r,nsec:e}){if(r>=0&&e>=0&&r<=Fr)if(e===0&&r<=Lr){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,r),t}else{let t=r/4294967296,s=r&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,e<<2|t&3),o.setUint32(4,s),n}else{let t=new Uint8Array(12),s=new DataView(t.buffer);return s.setUint32(0,e),(0,Ut.setInt64)(s,4,r),t}}b.encodeTimeSpecToTimestamp=Nt;function Bt(r){let e=r.getTime(),t=Math.floor(e/1e3),s=(e-t*1e3)*1e6,n=Math.floor(s/1e9);return{sec:t+n,nsec:s-n*1e9}}b.encodeDateToTimeSpec=Bt;function jt(r){if(r instanceof Date){let e=Bt(r);return Nt(e)}else return null}b.encodeTimestampExtension=jt;function Lt(r){let e=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(r.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),s=e.getUint32(4),n=(t&3)*4294967296+s,o=t>>>2;return{sec:n,nsec:o}}case 12:{let t=(0,Ut.getInt64)(e,4),s=e.getUint32(0);return{sec:t,nsec:s}}default:throw new jr.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${r.length}`)}}b.decodeTimestampToTimeSpec=Lt;function Ft(r){let e=Lt(r);return new Date(e.sec*1e3+e.nsec/1e6)}b.decodeTimestampExtension=Ft;b.timestampExtension={type:b.EXT_TIMESTAMP,encode:jt,decode:Ft}});var Ce=w(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.ExtensionCodec=void 0;var Oe=rt(),qr=nt(),Re=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(qr.timestampExtension)}register({type:e,encode:t,decode:s}){if(e>=0)this.encoders[e]=t,this.decoders[e]=s;else{let n=1+e;this.builtInEncoders[n]=t,this.builtInDecoders[n]=s}}tryToEncode(e,t){for(let s=0;s<this.builtInEncoders.length;s++){let n=this.builtInEncoders[s];if(n!=null){let o=n(e,t);if(o!=null){let a=-1-s;return new Oe.ExtData(a,o)}}}for(let s=0;s<this.encoders.length;s++){let n=this.encoders[s];if(n!=null){let o=n(e,t);if(o!=null){let a=s;return new Oe.ExtData(a,o)}}}return e instanceof Oe.ExtData?e:null}decode(e,t,s){let n=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return n?n(e,t,s):new Oe.ExtData(t,e)}};De.ExtensionCodec=Re;Re.defaultCodec=new Re});var ot=w(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.createDataView=te.ensureUint8Array=void 0;function qt(r){return r instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r instanceof ArrayBuffer?new Uint8Array(r):Uint8Array.from(r)}te.ensureUint8Array=qt;function Vr(r){if(r instanceof ArrayBuffer)return new DataView(r);let e=qt(r);return new DataView(e.buffer,e.byteOffset,e.byteLength)}te.createDataView=Vr});var it=w(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.Encoder=D.DEFAULT_INITIAL_BUFFER_SIZE=D.DEFAULT_MAX_DEPTH=void 0;var ge=ke(),Jr=Ce(),Vt=fe(),Hr=ot();D.DEFAULT_MAX_DEPTH=100;D.DEFAULT_INITIAL_BUFFER_SIZE=2048;var at=class{constructor(e=Jr.ExtensionCodec.defaultCodec,t=void 0,s=D.DEFAULT_MAX_DEPTH,n=D.DEFAULT_INITIAL_BUFFER_SIZE,o=!1,a=!1,i=!1,c=!1){this.extensionCodec=e,this.context=t,this.maxDepth=s,this.initialBufferSize=n,this.sortKeys=o,this.forceFloat32=a,this.ignoreUndefined=i,this.forceIntegerToFloat=c,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}reinitializeState(){this.pos=0}encodeSharedRef(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}encode(e){return this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),s=new Uint8Array(t),n=new DataView(t);s.set(this.bytes),this.view=n,this.bytes=s}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){Number.isSafeInteger(e)&&!this.forceIntegerToFloat?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){if(e.length>ge.TEXT_ENCODER_THRESHOLD){let n=(0,ge.utf8Count)(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),(0,ge.utf8EncodeTE)(e,this.bytes,this.pos),this.pos+=n}else{let n=(0,ge.utf8Count)(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),(0,ge.utf8EncodeJs)(e,this.bytes,this.pos),this.pos+=n}}encodeObject(e,t){let s=this.extensionCodec.tryToEncode(e,this.context);if(s!=null)this.encodeExtension(s);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.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 s=(0,Hr.ensureUint8Array)(e);this.writeU8a(s)}encodeArray(e,t){let s=e.length;if(s<16)this.writeU8(144+s);else if(s<65536)this.writeU8(220),this.writeU16(s);else if(s<4294967296)this.writeU8(221),this.writeU32(s);else throw new Error(`Too large array: ${s}`);for(let n of e)this.doEncode(n,t+1)}countWithoutUndefined(e,t){let s=0;for(let n of t)e[n]!==void 0&&s++;return s}encodeMap(e,t){let s=Object.keys(e);this.sortKeys&&s.sort();let n=this.ignoreUndefined?this.countWithoutUndefined(e,s):s.length;if(n<16)this.writeU8(128+n);else if(n<65536)this.writeU8(222),this.writeU16(n);else if(n<4294967296)this.writeU8(223),this.writeU32(n);else throw new Error(`Too large map object: ${n}`);for(let o of s){let a=e[o];this.ignoreUndefined&&a===void 0||(this.encodeString(o),this.doEncode(a,t+1))}}encodeExtension(e){let t=e.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(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,Vt.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,Vt.setInt64)(this.view,this.pos,e),this.pos+=8}};D.Encoder=at});var Jt=w(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.encode=void 0;var zr=it(),Gr={};function $r(r,e=Gr){return new zr.Encoder(e.extensionCodec,e.context,e.maxDepth,e.initialBufferSize,e.sortKeys,e.forceFloat32,e.ignoreUndefined,e.forceIntegerToFloat).encodeSharedRef(r)}Ie.encode=$r});var Ht=w(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.prettyByte=void 0;function Xr(r){return`${r<0?"-":""}0x${Math.abs(r).toString(16).padStart(2,"0")}`}Ue.prettyByte=Xr});var zt=w(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.CachedKeyDecoder=void 0;var Kr=ke(),Qr=16,Yr=16,lt=class{constructor(e=Qr,t=Yr){this.maxKeyLength=e,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(let s=0;s<this.maxKeyLength;s++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,s){let n=this.caches[s-1];e:for(let o of n){let a=o.bytes;for(let i=0;i<s;i++)if(a[i]!==e[t+i])continue e;return o.str}return null}store(e,t){let s=this.caches[e.length-1],n={bytes:e,str:t};s.length>=this.maxLengthPerKey?s[Math.random()*s.length|0]=n:s.push(n)}decode(e,t,s){let n=this.find(e,t,s);if(n!=null)return this.hit++,n;this.miss++;let o=(0,Kr.utf8DecodeJs)(e,t,s),a=Uint8Array.prototype.slice.call(e,t,t+s);return this.store(a,o),o}};Ne.CachedKeyDecoder=lt});var Be=w(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.Decoder=j.DataViewIndexOutOfBoundsError=void 0;var ct=Ht(),Zr=Ce(),X=fe(),ut=ke(),pt=ot(),es=zt(),B=Ae(),ts=r=>{let e=typeof r;return e==="string"||e==="number"},be=-1,ht=new DataView(new ArrayBuffer(0)),rs=new Uint8Array(ht.buffer);j.DataViewIndexOutOfBoundsError=(()=>{try{ht.getInt8(0)}catch(r){return r.constructor}throw new Error("never reached")})();var Gt=new j.DataViewIndexOutOfBoundsError("Insufficient data"),ss=new es.CachedKeyDecoder,dt=class{constructor(e=Zr.ExtensionCodec.defaultCodec,t=void 0,s=X.UINT32_MAX,n=X.UINT32_MAX,o=X.UINT32_MAX,a=X.UINT32_MAX,i=X.UINT32_MAX,c=ss){this.extensionCodec=e,this.context=t,this.maxStrLength=s,this.maxBinLength=n,this.maxArrayLength=o,this.maxMapLength=a,this.maxExtLength=i,this.keyDecoder=c,this.totalPos=0,this.pos=0,this.view=ht,this.bytes=rs,this.headByte=be,this.stack=[]}reinitializeState(){this.totalPos=0,this.headByte=be,this.stack.length=0}setBuffer(e){this.bytes=(0,pt.ensureUint8Array)(e),this.view=(0,pt.createDataView)(this.bytes),this.pos=0}appendBuffer(e){if(this.headByte===be&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),s=(0,pt.ensureUint8Array)(e),n=new Uint8Array(t.length+s.length);n.set(t),n.set(s,t.length),this.setBuffer(n)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:s}=this;return new RangeError(`Extra ${t.byteLength-s} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}*decodeMulti(e){for(this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}async decodeAsync(e){let t=!1,s;for await(let i of e){if(t)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i);try{s=this.doDecodeSync(),t=!0}catch(c){if(!(c instanceof j.DataViewIndexOutOfBoundsError))throw c}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return s}let{headByte:n,pos:o,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${(0,ct.prettyByte)(n)} at ${a} (${o} in the current buffer)`)}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){let s=t,n=-1;for await(let o of e){if(t&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),s&&(n=this.readArraySize(),s=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(a){if(!(a instanceof j.DataViewIndexOutOfBoundsError))throw a}this.totalPos+=this.pos}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else t={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else t=[]}else{let n=e-160;t=this.decodeUtf8String(n,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)t=this.readI64();else if(e===217){let n=this.lookU8();t=this.decodeUtf8String(n,1)}else if(e===218){let n=this.lookU16();t=this.decodeUtf8String(n,2)}else if(e===219){let n=this.lookU32();t=this.decodeUtf8String(n,4)}else if(e===220){let n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else t=[]}else if(e===221){let n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else t=[]}else if(e===222){let n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else t={}}else if(e===223){let n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else t={}}else if(e===196){let n=this.lookU8();t=this.decodeBinary(n,1)}else if(e===197){let n=this.lookU16();t=this.decodeBinary(n,2)}else if(e===198){let n=this.lookU32();t=this.decodeBinary(n,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let n=this.lookU8();t=this.decodeExtension(n,1)}else if(e===200){let n=this.lookU16();t=this.decodeExtension(n,2)}else if(e===201){let n=this.lookU32();t=this.decodeExtension(n,4)}else throw new B.DecodeError(`Unrecognized type byte: ${(0,ct.prettyByte)(e)}`);this.complete();let s=this.stack;for(;s.length>0;){let n=s[s.length-1];if(n.type===0)if(n.array[n.position]=t,n.position++,n.position===n.size)s.pop(),t=n.array;else continue e;else if(n.type===1){if(!ts(t))throw new B.DecodeError("The type of key must be string or number but "+typeof t);if(t==="__proto__")throw new B.DecodeError("The key __proto__ is not allowed");n.key=t,n.type=2;continue e}else if(n.map[n.key]=t,n.readCount++,n.readCount===n.size)s.pop(),t=n.map;else{n.key=null,n.type=1;continue e}}return t}}readHeadByte(){return this.headByte===be&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=be}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new B.DecodeError(`Unrecognized array type byte: ${(0,ct.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new B.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})}pushArrayState(e){if(e>this.maxArrayLength)throw new B.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:0,size:e,array:new Array(e),position:0})}decodeUtf8String(e,t){var s;if(e>this.maxStrLength)throw new B.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Gt;let n=this.pos+t,o;return this.stateIsMapKey()&&(!((s=this.keyDecoder)===null||s===void 0)&&s.canBeCached(e))?o=this.keyDecoder.decode(this.bytes,n,e):e>ut.TEXT_DECODER_THRESHOLD?o=(0,ut.utf8DecodeTD)(this.bytes,n,e):o=(0,ut.utf8DecodeJs)(this.bytes,n,e),this.pos+=t+e,o}stateIsMapKey(){return this.stack.length>0?this.stack[this.stack.length-1].type===1:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new B.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Gt;let s=this.pos+t,n=this.bytes.subarray(s,s+e);return this.pos+=t+e,n}decodeExtension(e,t){if(e>this.maxExtLength)throw new B.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let s=this.view.getInt8(this.pos+t),n=this.decodeBinary(e,t+1);return this.extensionCodec.decode(n,s,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 e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,X.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,X.getInt64)(this.view,this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};j.Decoder=dt});var yt=w(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.decodeMulti=C.decode=C.defaultDecodeOptions=void 0;var $t=Be();C.defaultDecodeOptions={};function ns(r,e=C.defaultDecodeOptions){return new $t.Decoder(e.extensionCodec,e.context,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength).decode(r)}C.decode=ns;function os(r,e=C.defaultDecodeOptions){return new $t.Decoder(e.extensionCodec,e.context,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength).decodeMulti(r)}C.decodeMulti=os});var Qt=w(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.ensureAsyncIterable=V.asyncIterableFromStream=V.isAsyncIterable=void 0;function Xt(r){return r[Symbol.asyncIterator]!=null}V.isAsyncIterable=Xt;function as(r){if(r==null)throw new Error("Assertion Failure: value must not be null nor undefined")}async function*Kt(r){let e=r.getReader();try{for(;;){let{done:t,value:s}=await e.read();if(t)return;as(s),yield s}}finally{e.releaseLock()}}V.asyncIterableFromStream=Kt;function is(r){return Xt(r)?r:Kt(r)}V.ensureAsyncIterable=is});var Zt=w(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.decodeStream=I.decodeMultiStream=I.decodeArrayStream=I.decodeAsync=void 0;var ft=Be(),mt=Qt(),je=yt();async function ls(r,e=je.defaultDecodeOptions){let t=(0,mt.ensureAsyncIterable)(r);return new ft.Decoder(e.extensionCodec,e.context,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength).decodeAsync(t)}I.decodeAsync=ls;function cs(r,e=je.defaultDecodeOptions){let t=(0,mt.ensureAsyncIterable)(r);return new ft.Decoder(e.extensionCodec,e.context,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength).decodeArrayStream(t)}I.decodeArrayStream=cs;function Yt(r,e=je.defaultDecodeOptions){let t=(0,mt.ensureAsyncIterable)(r);return new ft.Decoder(e.extensionCodec,e.context,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength).decodeStream(t)}I.decodeMultiStream=Yt;function us(r,e=je.defaultDecodeOptions){return Yt(r,e)}I.decodeStream=us});var rr=w(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});u.decodeTimestampExtension=u.encodeTimestampExtension=u.decodeTimestampToTimeSpec=u.encodeTimeSpecToTimestamp=u.encodeDateToTimeSpec=u.EXT_TIMESTAMP=u.ExtData=u.ExtensionCodec=u.Encoder=u.DataViewIndexOutOfBoundsError=u.DecodeError=u.Decoder=u.decodeStream=u.decodeMultiStream=u.decodeArrayStream=u.decodeAsync=u.decodeMulti=u.decode=u.encode=void 0;var ps=Jt();Object.defineProperty(u,"encode",{enumerable:!0,get:function(){return ps.encode}});var er=yt();Object.defineProperty(u,"decode",{enumerable:!0,get:function(){return er.decode}});Object.defineProperty(u,"decodeMulti",{enumerable:!0,get:function(){return er.decodeMulti}});var Le=Zt();Object.defineProperty(u,"decodeAsync",{enumerable:!0,get:function(){return Le.decodeAsync}});Object.defineProperty(u,"decodeArrayStream",{enumerable:!0,get:function(){return Le.decodeArrayStream}});Object.defineProperty(u,"decodeMultiStream",{enumerable:!0,get:function(){return Le.decodeMultiStream}});Object.defineProperty(u,"decodeStream",{enumerable:!0,get:function(){return Le.decodeStream}});var tr=Be();Object.defineProperty(u,"Decoder",{enumerable:!0,get:function(){return tr.Decoder}});Object.defineProperty(u,"DataViewIndexOutOfBoundsError",{enumerable:!0,get:function(){return tr.DataViewIndexOutOfBoundsError}});var ds=Ae();Object.defineProperty(u,"DecodeError",{enumerable:!0,get:function(){return ds.DecodeError}});var hs=it();Object.defineProperty(u,"Encoder",{enumerable:!0,get:function(){return hs.Encoder}});var ys=Ce();Object.defineProperty(u,"ExtensionCodec",{enumerable:!0,get:function(){return ys.ExtensionCodec}});var fs=rt();Object.defineProperty(u,"ExtData",{enumerable:!0,get:function(){return fs.ExtData}});var re=nt();Object.defineProperty(u,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return re.EXT_TIMESTAMP}});Object.defineProperty(u,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return re.encodeDateToTimeSpec}});Object.defineProperty(u,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return re.encodeTimeSpecToTimestamp}});Object.defineProperty(u,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return re.decodeTimestampToTimeSpec}});Object.defineProperty(u,"encodeTimestampExtension",{enumerable:!0,get:function(){return re.encodeTimestampExtension}});Object.defineProperty(u,"decodeTimestampExtension",{enumerable:!0,get:function(){return re.decodeTimestampExtension}})});var P=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}},T=class extends P{},S=class extends P{},L=class extends P{};var h=typeof process<"u"&&process.release&&process.release.name==="node",Ge;if(globalThis.document)Ge=r=>new Promise((e,t)=>{let s=document.createElement("script");s.src=r,s.onload=()=>e(),s.onerror=t,document.head.appendChild(s)});else if(globalThis.importScripts)Ge=async r=>{try{globalThis.importScripts(r)}catch(e){if(e instanceof TypeError)await import(r);else throw e}};else if(h)Ge=async r=>{await import((await import("path")).default.resolve(r))};else throw new P("Cannot determine runtime environment");var W={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 oe(r){return!!r&&typeof r=="object"&&Object.keys(W).includes(r.type)}function H(r){return!!r&&typeof r=="object"&&"re"in r&&"im"in r}var l={};function vt(r){Object.keys(r).forEach(e=>l._free(r[e]))}function ae(r){return l._Rf_protect(A(r)),r}function y(r,e){return l._Rf_protect(A(r)),++e.n,r}function Pt(r){let e=l._malloc(4);return l._R_ProtectWithIndex(A(r),e),{loc:l.getValue(e,"i32"),ptr:e}}function Tt(r){l._Rf_unprotect(1),l._free(r.ptr)}function St(r,e){return l._R_Reprotect(A(r),e.loc),r}function g(r){l._Rf_unprotect(r)}function $e(r,e,t){l._Rf_defineVar(A(e),A(t),A(r))}function Xe(r,e){let t={},s={n:0};try{let n=new le(e);y(n,s),t.code=l.allocateUTF8(r);let o=l._R_ParseEvalString(t.code,n.ptr);return p.wrap(o)}finally{vt(t),g(s.n)}}function ie(r,e){return l.getWasmTableEntry(l.GOT.ffi_safe_eval.value)(A(r),A(e))}var Er=new WeakMap;function _t(r,e){return Er.set(r,e),r}function kt(r){return typeof r=="string"&&r.length===Ke}var Ke=63;function Q(){let r=Array.from({length:4},vr).join("-");if(r.length!==Ke)throw new Error("comlink internal error: UUID has the wrong length");return r}function vr(){let r=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16),e=15-r.length;return e>0&&(r=Array.from({length:e},()=>0).join("")+r),r}function A(r){return Te(r)?r.ptr:r}function G(r,e){if(l._TYPEOF(r.ptr)!==W[e])throw new Error(`Unexpected object type "${r.type()}" when expecting type "${e}"`)}function Mt(r){if(oe(r))return new(Wt(r.type))(r);if(typeof r>"u")return new ce;if(r&&typeof r=="object"&&"type"in r&&r.type==="null")return new ce;if(r===null)return new z({type:"logical",names:null,values:[null]});if(typeof r=="boolean")return new z(r);if(typeof r=="number")return new ye(r);if(typeof r=="string")return new N(r);if(H(r))return new ve(r);if(ArrayBuffer.isView(r)||r instanceof ArrayBuffer)return new Pe(r);if(Array.isArray(r))return Pr(r);if(typeof r=="object")return de.fromObject(r);throw new Error("R object construction for this JS object is not yet supported.")}function Pr(r){let e={n:0};if(r.every(s=>s&&typeof s=="object"&&!Te(s)&&!H(s))){let s=r,n=s.every(a=>Object.keys(a).filter(i=>!Object.keys(s[0]).includes(i)).length===0&&Object.keys(s[0]).filter(i=>!Object.keys(a).includes(i)).length===0),o=s.every(a=>Object.values(a).every(i=>Ot(i)||At(i)));if(n&&o)return de.fromD3(s)}if(r.every(s=>typeof s=="boolean"||s===null))return new z(r);if(r.every(s=>typeof s=="number"||s===null))return new ye(r);if(r.every(s=>typeof s=="string"||s===null))return new N(r);try{let s=new F([new _("c"),...r]);return y(s,e),s.eval()}finally{g(e.n)}}var f=class{constructor(e){this.ptr=e}type(){let e=l._TYPEOF(this.ptr);return Object.keys(W).find(s=>W[s]===e)}},p=class r extends f{constructor(e){if(!(e instanceof f))return Mt(e);super(e.ptr)}static wrap(e){let t=l._TYPEOF(e),s=Object.keys(W)[Object.values(W).indexOf(t)];return new(Wt(s))(new f(e))}get[Symbol.toStringTag](){return`RObject:${this.type()}`}static getPersistentObject(e){return x[e]}getPropertyValue(e){return this[e]}inspect(){Xe(".Internal(inspect(x))",{x:this})}isNull(){return l._TYPEOF(this.ptr)===W.null}isNa(){try{let e=Xe("is.na(x)",{x:this});return ae(e),e.toBoolean()}finally{g(1)}}isUnbound(){return this.ptr===x.unboundValue.ptr}attrs(){return ue.wrap(l._ATTRIB(this.ptr))}class(){let e={n:0},t=new F([new _("class"),this]);y(t,e);try{return t.eval()}finally{g(e.n)}}setNames(e){let t;if(e===null)t=x.null;else if(Array.isArray(e)&&e.every(s=>typeof s=="string"||s===null))t=new N(e);else throw new Error("Argument to setNames must be null or an Array of strings or null");return l._Rf_setAttrib(this.ptr,x.namesSymbol.ptr,t.ptr),this}names(){let e=N.wrap(l._Rf_getAttrib(this.ptr,x.namesSymbol.ptr));return e.isNull()?null:e.toArray()}includes(e){let t=this.names();return t&&t.includes(e)}toJs(e={depth:0},t=1){throw new Error("This R object cannot be converted to JS")}subset(e){return this.#e(e,x.bracketSymbol.ptr)}get(e){return this.#e(e,x.bracket2Symbol.ptr)}getDollar(e){return this.#e(e,x.dollarSymbol.ptr)}#e(e,t){let s={n:0};try{let n=new r(e);y(n,s);let o=l._Rf_lang3(t,this.ptr,n.ptr);return y(o,s),r.wrap(ie(o,x.baseEnv))}finally{g(s.n)}}pluck(...e){let t=Pt(x.null);try{let s=(o,a)=>{let i=o.get(a);return St(i,t)},n=e.reduce(s,this);return n.isNull()?void 0:n}finally{Tt(t)}}set(e,t){let s={n:0};try{let n=new r(e);y(n,s);let o=new r(t);y(o,s);let a=new _("[[<-"),i=l._Rf_lang4(a.ptr,this.ptr,n.ptr,o.ptr);return y(i,s),r.wrap(ie(i,x.baseEnv))}finally{g(s.n)}}static getMethods(e){let t=new Set,s=e;do Object.getOwnPropertyNames(s).map(n=>t.add(n));while(s=Object.getPrototypeOf(s));return[...t.keys()].filter(n=>typeof e[n]=="function")}},ce=class extends p{constructor(){return super(new f(l.getValue(l._R_NilValue,"*"))),this}toJs(){return{type:"null"}}},_=class extends p{constructor(e){if(e instanceof f){G(e,"symbol"),super(e);return}let t=l.allocateUTF8(e);try{super(new f(l._Rf_install(t)))}finally{l._free(t)}}toJs(){let e=this.toObject();return{type:"symbol",printname:e.printname,symvalue:e.symvalue,internal:e.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 he.wrap(l._PRINTNAME(this.ptr))}symvalue(){return p.wrap(l._SYMVALUE(this.ptr))}internal(){return p.wrap(l._INTERNAL(this.ptr))}},ue=class r extends p{constructor(e){if(e instanceof f)return G(e,"pairlist"),super(e),this;let t={n:0};try{let{names:s,values:n}=Z(e),o=r.wrap(l._Rf_allocList(n.length));y(o,t);for(let[a,i]=[0,o];!i.isNull();[a,i]=[a+1,i.cdr()])i.setcar(new p(n[a]));o.setNames(s),super(o)}finally{g(t.n)}}get length(){return this.toArray().length}toArray(e={depth:1}){return this.toJs(e).values}toObject({allowDuplicateKey:e=!0,allowEmptyKey:t=!1,depth:s=-1}={}){let n=this.entries({depth:s}),o=n.map(([a])=>a);if(!e&&new Set(o).size!==o.length)throw new Error("Duplicate key when converting pairlist without allowDuplicateKey enabled");if(!t&&o.some(a=>!a))throw new Error("Empty or null key when converting pairlist without allowEmptyKey enabled");return Object.fromEntries(n.filter((a,i)=>n.findIndex(c=>c[0]===a[0])===i))}entries(e={depth:1}){let t=this.toJs(e);return t.values.map((s,n)=>[t.names?t.names[n]:null,s])}toJs(e={depth:0},t=1){let s=[],n=!1,o=[];for(let i=this;!i.isNull();i=i.cdr()){let c=i.tag();c.isNull()?s.push(""):(n=!0,s.push(c.toString())),e.depth&&t>=e.depth?o.push(i.car()):o.push(i.car().toJs(e,t+1))}return{type:"pairlist",names:n?s:null,values:o}}includes(e){return e in this.toObject()}setcar(e){l._SETCAR(this.ptr,e.ptr)}car(){return p.wrap(l._CAR(this.ptr))}cdr(){return p.wrap(l._CDR(this.ptr))}tag(){return p.wrap(l._TAG(this.ptr))}},F=class r extends p{constructor(e){if(e instanceof f)return G(e,"call"),super(e),this;let t={n:0};try{let{values:s}=Z(e),n=s.map(a=>y(new p(a),t)),o=r.wrap(l._Rf_allocVector(W.call,s.length));y(o,t);for(let[a,i]=[0,o];!i.isNull();[a,i]=[a+1,i.cdr()])i.setcar(n[a]);super(o)}finally{g(t.n)}}setcar(e){l._SETCAR(this.ptr,e.ptr)}car(){return p.wrap(l._CAR(this.ptr))}cdr(){return p.wrap(l._CDR(this.ptr))}eval(){return l.webr.evalR(this,{env:x.baseEnv})}capture(e={}){return l.webr.captureR(this,e)}deparse(){let e={n:0};try{let t=l._Rf_lang2(new _("deparse1").ptr,l._Rf_lang2(new _("quote").ptr,this.ptr));y(t,e);let s=N.wrap(ie(t,x.baseEnv));return y(s,e),s.toString()}finally{g(e.n)}}},pe=class r extends p{constructor(e,t=null){if(e instanceof f){if(G(e,"list"),super(e),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 s={n:0};try{let n=Z(e),o=l._Rf_allocVector(W.list,n.values.length);y(o,s),n.values.forEach((i,c)=>{Dt(i)?l._SET_VECTOR_ELT(o,c,new r(i).ptr):l._SET_VECTOR_ELT(o,c,new p(i).ptr)});let a=t||n.names;if(a&&a.length!==n.values.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");p.wrap(o).setNames(a),super(new f(o))}finally{g(s.n)}}get length(){return l._LENGTH(this.ptr)}isDataFrame(){let e=ue.wrap(l._ATTRIB(this.ptr)).get("class");return!e.isNull()&&e.toArray().includes("data.frame")}toArray(e={depth:1}){return this.toJs(e).values}toObject({allowDuplicateKey:e=!0,allowEmptyKey:t=!1,depth:s=-1}={}){let n=this.entries({depth:s}),o=n.map(([a])=>a);if(!e&&new Set(o).size!==o.length)throw new Error("Duplicate key when converting list without allowDuplicateKey enabled");if(!t&&o.some(a=>!a))throw new Error("Empty or null key when converting list without allowEmptyKey enabled");return Object.fromEntries(n.filter((a,i)=>n.findIndex(c=>c[0]===a[0])===i))}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,s)=>(s[1].forEach((n,o)=>t[o]=Object.assign(t[o]||{},{[s[0]]:n})),t),[])}entries(e={depth:-1}){let t=this.toJs(e);return this.isDataFrame()&&e.depth<0&&(t.values=t.values.map(s=>s.toArray())),t.values.map((s,n)=>[t.names?t.names[n]:null,s])}toJs(e={depth:0},t=1){return{type:"list",names:this.names(),values:[...Array(this.length).keys()].map(s=>e.depth&&t>=e.depth?this.get(s+1):this.get(s+1).toJs(e,t+1))}}},de=class r extends pe{constructor(e){if(e instanceof f){if(super(e),!this.isDataFrame())throw new Error("Can't construct `RDataFrame`. Supplied R object is not a `data.frame`.");return this}return r.fromObject(e)}static fromObject(e){let{names:t,values:s}=Z(e),n={n:0};try{let o=!!t&&t.length>0&&t.every(i=>i),a=s.length>0&&s.every(i=>Array.isArray(i)||ArrayBuffer.isView(i)||i instanceof ArrayBuffer);if(o&&a){let i=s,c=i.every(d=>d.length===i[0].length),R=i.every(d=>Ot(d[0])||At(d[0]));if(c&&R){let d=new pe({type:"list",names:t,values:i.map(Ee=>Mt(Ee))});y(d,n);let M=new F([new _("as.data.frame"),d]);return y(M,n),new r(M.eval())}}}finally{g(n.n)}throw new Error("Can't construct `data.frame`. Source object is not eligible.")}static fromD3(e){return this.fromObject(Object.fromEntries(Object.keys(e[0]).map(t=>[t,e.map(s=>s[t])])))}},Y=class extends p{exec(...e){let t={n:0};try{let s=new F([this,...e]);return y(s,t),s.eval()}finally{g(t.n)}}capture(e={},...t){let s={n:0};try{let n=new F([this,...t]);return y(n,s),n.capture(e)}finally{g(s.n)}}},he=class r extends p{static{this.CEType={CE_NATIVE:0,CE_UTF8:1,CE_LATIN1:2,CE_BYTES:3,CE_SYMBOL:5,CE_ANY:99}}constructor(e){if(e instanceof f){G(e,"string"),super(e);return}let t=l.allocateUTF8(e);try{super(new f(l._Rf_mkCharCE(t,r.CEType.CE_UTF8)))}finally{l._free(t)}}toString(){let e=l._vmaxget();try{return l.UTF8ToString(l._Rf_translateCharUTF8(this.ptr))}finally{l._vmaxset(e)}}toJs(){return{type:"string",value:this.toString()}}},le=class extends p{constructor(e={}){if(e instanceof f)return G(e,"environment"),super(e),this;let t=0;try{let{names:s,values:n}=Z(e),o=ae(l._R_NewEnv(x.globalEnv.ptr,0,0));++t,n.forEach((a,i)=>{let c=s?s[i]:null;if(!c)throw new Error("Can't create object in new environment with empty symbol name");let R=new _(c),d=ae(new p(a));try{$e(o,R,d)}finally{g(1)}}),super(new f(o))}finally{g(t)}}ls(e=!1,t=!0){return N.wrap(l._R_lsInternal3(this.ptr,Number(e),Number(t))).toArray()}bind(e,t){let s=new _(e),n=ae(new p(t));try{$e(this,s,n)}finally{g(1)}}names(){return this.ls(!0,!0)}frame(){return p.wrap(l._FRAME(this.ptr))}subset(e){if(typeof e=="number")throw new Error("Object of type environment is not subsettable");return this.getDollar(e)}toObject({depth:e=-1}={}){let t=this.names();return Object.fromEntries([...Array(t.length).keys()].map(s=>{let n=this.getDollar(t[s]);return[t[s],e<0?n:n.toJs({depth:e})]}))}toJs(e={depth:0},t=1){let s=this.names(),n=[...Array(s.length).keys()].map(o=>e.depth&&t>=e.depth?this.getDollar(s[o]):this.getDollar(s[o]).toJs(e,t+1));return{type:"environment",names:s,values:n}}},q=class extends p{constructor(e,t,s){if(e instanceof f)return G(e,t),super(e),this;let n={n:0};try{let{names:o,values:a}=Z(e),i=l._Rf_allocVector(W[t],a.length);y(i,n),a.forEach(s(i)),p.wrap(i).setNames(o),super(new f(i))}finally{g(n.n)}}get length(){return l._LENGTH(this.ptr)}get(e){return super.get(e)}subset(e){return super.subset(e)}getDollar(){throw new Error("$ operator is invalid for atomic vectors")}detectMissing(){let e={n:0};try{let t=l._Rf_lang2(new _("is.na").ptr,this.ptr);y(t,e);let s=z.wrap(ie(t,x.baseEnv));y(s,e);let n=s.toTypedArray();return Array.from(n).map(o=>!!o)}finally{g(e.n)}}toArray(){let e=this.toTypedArray();return this.detectMissing().map((t,s)=>t?null:e[s])}toObject({allowDuplicateKey:e=!0,allowEmptyKey:t=!1}={}){let s=this.entries(),n=s.map(([o])=>o);if(!e&&new Set(n).size!==n.length)throw new Error("Duplicate key when converting atomic vector without allowDuplicateKey enabled");if(!t&&n.some(o=>!o))throw new Error("Empty or null key when converting atomic vector without allowEmptyKey enabled");return Object.fromEntries(s.filter((o,a)=>s.findIndex(i=>i[0]===o[0])===a))}entries(){let e=this.toArray(),t=this.names();return e.map((s,n)=>[t?t[n]:null,s])}toJs(){return{type:this.type(),names:this.names(),values:this.toArray()}}},z=class r extends q{constructor(e){super(e,"logical",r.#e)}static#e=e=>{let t=l._LOGICAL(e),s=l.getValue(l._R_NaInt,"i32");return(n,o)=>{l.setValue(t+4*o,n===null?s:!!n,"i32")}};getBoolean(e){return this.get(e).toArray()[0]}toBoolean(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let e=this.getBoolean(1);if(e===null)throw new Error("Can't convert missing value `NA` to a JS boolean");return e}toTypedArray(){return new Int32Array(l.HEAP32.subarray(l._LOGICAL(this.ptr)/4,l._LOGICAL(this.ptr)/4+this.length))}toArray(){let e=this.toTypedArray();return this.detectMissing().map((t,s)=>t?null:!!e[s])}},Qe=class r extends q{constructor(e){super(e,"integer",r.#e)}static#e=e=>{let t=l._INTEGER(e),s=l.getValue(l._R_NaInt,"i32");return(n,o)=>{l.setValue(t+4*o,n===null?s:Math.round(Number(n)),"i32")}};getNumber(e){return this.get(e).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let e=this.getNumber(1);if(e===null)throw new Error("Can't convert missing value `NA` to a JS number");return e}toTypedArray(){return new Int32Array(l.HEAP32.subarray(l._INTEGER(this.ptr)/4,l._INTEGER(this.ptr)/4+this.length))}},ye=class r extends q{constructor(e){super(e,"double",r.#e)}static#e=e=>{let t=l._REAL(e),s=l.getValue(l._R_NaReal,"double");return(n,o)=>{l.setValue(t+8*o,n===null?s:n,"double")}};getNumber(e){return this.get(e).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let e=this.getNumber(1);if(e===null)throw new Error("Can't convert missing value `NA` to a JS number");return e}toTypedArray(){return new Float64Array(l.HEAPF64.subarray(l._REAL(this.ptr)/8,l._REAL(this.ptr)/8+this.length))}},ve=class r extends q{constructor(e){super(e,"complex",r.#e)}static#e=e=>{let t=l._COMPLEX(e),s=l.getValue(l._R_NaReal,"double");return(n,o)=>{l.setValue(t+8*(2*o),n===null?s:n.re,"double"),l.setValue(t+8*(2*o+1),n===null?s:n.im,"double")}};getComplex(e){return this.get(e).toArray()[0]}toComplex(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let e=this.getComplex(1);if(e===null)throw new Error("Can't convert missing value `NA` to a JS object");return e}toTypedArray(){return new Float64Array(l.HEAPF64.subarray(l._COMPLEX(this.ptr)/8,l._COMPLEX(this.ptr)/8+2*this.length))}toArray(){let e=this.toTypedArray();return this.detectMissing().map((t,s)=>t?null:{re:e[2*s],im:e[2*s+1]})}},N=class r extends q{constructor(e){super(e,"character",r.#e)}static#e=e=>(t,s)=>{t===null?l._SET_STRING_ELT(e,s,x.naString.ptr):l._SET_STRING_ELT(e,s,new he(t).ptr)};getString(e){return this.get(e).toArray()[0]}toString(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let e=this.getString(1);if(e===null)throw new Error("Can't convert missing value `NA` to a JS string");return e}toTypedArray(){return new Uint32Array(l.HEAPU32.subarray(l._STRING_PTR(this.ptr)/4,l._STRING_PTR(this.ptr)/4+this.length))}toArray(){let e=l._vmaxget();try{return this.detectMissing().map((t,s)=>t?null:l.UTF8ToString(l._Rf_translateCharUTF8(l._STRING_ELT(this.ptr,s))))}finally{l._vmaxset(e)}}},Pe=class r extends q{constructor(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e)),super(e,"raw",r.#e)}static#e=e=>{let t=l._RAW(e);return(s,n)=>{l.setValue(t+n,Number(s),"i8")}};getNumber(e){return this.get(e).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let e=this.getNumber(1);if(e===null)throw new Error("Can't convert missing value `NA` to a JS number");return e}toTypedArray(){return new Uint8Array(l.HEAPU8.subarray(l._RAW(this.ptr),l._RAW(this.ptr)+this.length))}};function Z(r){return oe(r)?r:Array.isArray(r)||ArrayBuffer.isView(r)?{names:null,values:r}:r&&typeof r=="object"&&!H(r)?{names:Object.keys(r),values:Object.values(r)}:{names:null,values:[r]}}function Wt(r){let e={object:p,null:ce,symbol:_,pairlist:ue,closure:Y,environment:le,call:F,special:Y,builtin:Y,string:he,logical:z,integer:Qe,double:ye,complex:ve,character:N,list:pe,raw:Pe,function:Y,dataframe:de};return r in e?e[r]:p}function Te(r){return r instanceof p}function At(r){let e=["logical","integer","double","complex","character"];return Te(r)&&e.includes(r.type())||Te(r)&&r.isNa()}function Ot(r){return r===null||typeof r=="number"||typeof r=="boolean"||typeof r=="string"||H(r)}var x;function $(){let r={resolve:(()=>{}),reject:(()=>{}),promise:Promise.resolve()},e=new Promise((t,s)=>{r.resolve=t,r.reject=s});return r.promise=e,r}function Ct(r){return new Promise(e=>setTimeout(e,r))}function O(r,e,t,...s){return r==null||Sr(r)?r:r instanceof ArrayBuffer?new Uint8Array(r):e(r)?t(r,...s):Array.isArray(r)||ArrayBuffer.isView(r)?r.map(n=>O(n,e,t,...s)):r instanceof f?r:typeof r=="object"?Object.fromEntries(Object.entries(r).map(([n,o])=>[n,O(o,e,t,...s)])):r}function ee(r,e,t,s,n=!0){let o=new XMLHttpRequest;o.open("get",r,n),o.onload=()=>{if(o.status>=200&&o.status<300)try{let a=new Worker(URL.createObjectURL(new Blob([o.responseText])),s);e(a)}catch(a){if(t)t(a instanceof Error?a:new Error(String(a)));else throw a}else t?t(new Error(`Worker loading error: HTTP ${o.status}`)):console.error(`HTTP Error: ${o.status}`)},o.onerror=()=>{t?t(new Error(`Network error loading ${r}`)):console.error(`Network error loading ${r}`)},o.send()}function Se(r){if(h)return!1;let e=new URL(location.href),t=new URL(r,location.origin);return!(e.host===t.host&&e.port===t.port&&e.protocol===t.protocol)}function Sr(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}function Dt(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&!ArrayBuffer.isView(r)&&!H(r)&&!oe(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&!(r instanceof Error)&&!(r instanceof f)&&Object.getPrototypeOf(r)===Object.prototype}var or=xr(rr());var ms=new TextEncoder;async function K(r,e,t){try{let{taskId:s,sizeBuffer:n,dataBuffer:o,signalBuffer:a}=e,i=(0,or.encode)(t),c=i.length<=o.length;if(Atomics.store(n,0,i.length),Atomics.store(n,1,+c),!c){let[R,d]=Rs(r);o.set(ms.encode(R)),await sr(a,s),o=(await d).dataBuffer}o.set(i),Atomics.store(n,1,1),await sr(a,s)}catch(s){console.warn(s)}}function Rs(r){let e=Q();return[e,new Promise(t=>{h?r.once("message",s=>{!s.id||s.id!==e||t(s)}):r.addEventListener("message",function s(n){!n.data||!n.data.id||n.data.id!==e||(r.removeEventListener("message",s),t(n.data))}),r.start&&r.start()})]}async function sr(r,e){let t=(e>>1)%32,s=1;for(;Atomics.compareExchange(r,t+1,0,e)!==0;)await Ct(s),s<32&&(s*=2);Atomics.or(r,0,1<<t),Atomics.notify(r,0)}var se=class{#e;#t;constructor(){this.#t=[],this.#e=[]}reset(){this.#t=[],this.#e=[]}put(e){this.#t.length||this.#r(),this.#t.shift()(e)}async get(){return this.#e.length||this.#r(),this.#e.shift()}isEmpty(){return!this.#e.length}isBlocked(){return!!this.#t.length}get length(){return this.#e.length-this.#t.length}#r(){this.#e.push(new Promise(e=>{this.#t.push(e)}))}};function gt(r,e){return ir({type:"request",data:{uuid:Q(),msg:r}},e)}function ar(r,e,t){return ir({type:"response",data:{uuid:r,resp:e}},t)}function ir(r,e){return e&&_t(r,e),r}function lr(r){let e=new T(r.obj.message);return r.obj.name=="ErrnoError"?e.message=`ErrnoError: ${String(r.obj.errno)}`:r.obj.name!=="Error"&&(e.name=r.obj.name),e.stack=r.obj.stack,e}function gs(r){return!!r&&typeof r=="object"&&"payloadType"in r&&"obj"in r}function Fe(r){return gs(r)&&r.payloadType==="ptr"}var ne=class{constructor(){this.inputQueue=new se;this.outputQueue=new se;this.systemQueue=new se;this.eventQueue=new Array;this.#e=new Map;this.#t=!1}#e;#t;async read(){return await this.outputQueue.get()}async flush(){let e=[];for(;!this.outputQueue.isEmpty();)e.push(await this.read());return e}async readSystem(){return await this.systemQueue.get()}write(e){if(this.#t)throw new S("The webR communication channel has been closed.");this.inputQueue.put(e)}async request(e,t){let s=gt(e,t),{resolve:n,reject:o,promise:a}=$();return this.#e.set(s.data.uuid,{resolve:n,reject:o}),this.write(s),a}putClosedMessage(){this.#t=!0,this.outputQueue.put({type:"closed"})}resolveResponse(e){let t=e.data.uuid,s=this.#e.get(t);if(s){let n=e.data.resp.data;this.#e.delete(t),n.payloadType==="err"?s.reject(lr(n)):s.resolve(n)}else console.warn("Can't find request.")}};var io=new TextDecoder("utf-8");var lo=new Int32Array(new ArrayBuffer(4));var qe=class{constructor(e){this.chan=e;this.WebSocket=h?ze("ws"):WebSocket}#e=new Map;new(e,t,s){let n=new this.WebSocket(t,s||[]);n.binaryType="arraybuffer",n.addEventListener("open",()=>{this.chan.emit({type:"websocket-open",data:{uuid:e}})}),n.addEventListener("message",o=>{let a=new Uint8Array(o.data);this.chan.emit({type:"websocket-message",data:{uuid:e,data:a}})}),n.addEventListener("close",o=>{this.chan.emit({type:"websocket-close",data:{uuid:e,code:o.code,reason:o.reason}})}),n.addEventListener("error",()=>{this.chan.emit({type:"websocket-error",data:{uuid:e