diff --git a/_extensions/live/resources/live-runtime.js b/_extensions/live/resources/live-runtime.js
index fc23e7d..de76f77 100644
--- a/_extensions/live/resources/live-runtime.js
+++ b/_extensions/live/resources/live-runtime.js
@@ -9,7 +9,7 @@ var gO=Object.defineProperty;var ci=(i=>typeof require<"u"?require:typeof Proxy<
`});var iO=jt((RP,zk)=>{zk.exports=``});var oO=jt((ZP,Gk)=>{Gk.exports="CmltcG9ydCBweW9kaWRlICMgdHlwZTogaWdub3JlW2F0dHItZGVmaW5lZF0KaW1wb3J0IHN5cwoKIyBDbGVhbnVwIGFueSBsZWZ0b3ZlciBtYXRwbG90bGliIHBsb3RzCnRyeToKICBpbXBvcnQgbWF0cGxvdGxpYi5weXBsb3QgYXMgcGx0CiAgcGx0LmNsb3NlKCJhbGwiKQpleGNlcHQgTW9kdWxlTm90Rm91bmRFcnJvcjoKICBwYXNzCgpmcm9tIElQeXRob24udXRpbHMgaW1wb3J0IGNhcHR1cmUKZnJvbSBJUHl0aG9uLmRpc3BsYXkgaW1wb3J0IGRpc3BsYXkKZnJvbSBJUHl0aG9uLmNvcmUuaW50ZXJhY3RpdmVzaGVsbCBpbXBvcnQgSW50ZXJhY3RpdmVTaGVsbApJbnRlcmFjdGl2ZVNoZWxsKCkuaW5zdGFuY2UoKQoKd2l0aCBjYXB0dXJlLmNhcHR1cmVfb3V0cHV0KCkgYXMgb3V0cHV0OgogIHZhbHVlID0gTm9uZQogIHRyeToKICAgIHZhbHVlID0gcHlvZGlkZS5jb2RlLmV2YWxfY29kZShjb2RlLCBnbG9iYWxzID0gZW52aXJvbm1lbnQpICMgdHlwZTogaWdub3JlW2F0dHItZGVmaW5lZF0KICBleGNlcHQgRXhjZXB0aW9uIGFzIGVycjoKICAgIHByaW50KGVyciwgZmlsZT1zeXMuc3RkZXJyKQogIGlmICh2YWx1ZSBpcyBub3QgTm9uZSk6CiAgICBkaXNwbGF5KHZhbHVlKQoKewogICJ2YWx1ZSI6IHZhbHVlLAogICJzdGRvdXQiO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hdGUuaGFuZGxlciIgPSBldmFsdWF0ZTo6bmV3X291dHB1dF9oYW5kbGVyKAogIHZhbHVlID0gZnVuY3Rpb24oeCwgdmlzaWJsZSkgewogICAga25pdF9vcHRpb25zID0gbGlzdChzY3JlZW5zaG90LmZvcmNlID0gRkFMU0UpCiAgICBrbml0X3ByaW50LmRmIDwtIGZ1bmN0aW9uICh4KSB7CiAgICAgIG1ldGhvZCA8LSBnZXRPcHRpb24oIndlYnIucmVuZGVyLmRmIikKICAgICAgaWYgKG1ldGhvZCA9PSAia2FibGUiKSB7CiAgICAgICAga25pdHI6OmtuaXRfcHJpbnQoa25pdHI6OmthYmxlKHgpKQogICAgICB9IGVsc2UgaWYgKG1ldGhvZCA9PSAicGFnZWQtdGFibGUiKSB7CiAgICAgICAga25pdHI6OmtuaXRfcHJpbnQocm1hcmtkb3duOjpwYWdlZF90YWJsZSh4KSkKICAgICAgfSBlbHNlIGlmIChtZXRob2QgPT0gImd0IikgewogICAgICAgIGtuaXRyOjprbml0X3ByaW50KGd0OjpndCh4KSkKICAgICAgfSBlbHNlIGlmIChtZXRob2QgPT0gImd0LWludGVyYWN0aXZlIikgewogICAgICAgIGtuaXRyOjprbml0X3ByaW50KHggfD4gZ3Q6Omd0KCkgfD4gZ3Q6Om9wdF9pbnRlcmFjdGl2ZSgpKQogICAgICB9IGVsc2UgaWYgKG1ldGhvZCA9PSAicmVhY3RhYmxlIikgewogICAgICAgIGtuaXRyOjprbml0X3ByaW50KHJlYWN0YWJsZTo6cmVhY3RhYmxlKHgpLCBvcHRpb25zID0ga25pdF9vcHRpb25zKQogICAgICB9IGVsc2UgewogICAgICAgIGtuaXRyOjprbml0X3ByaW50KHgsIG9wdGlvbnMgPSBrbml0X29wdGlvbnMpCiAgICAgIH0KICAgIH0KCiAgICByZXMgPC0gaWYgKHZpc2libGUpIHsKICAgICAgd2l0aFZpc2libGUoaWYgKCJkYXRhLmZyYW1lIiAlaW4lIGNsYXNzKHgpKSB7CiAgICAgICAga25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jbGlwKCkKCiAgICBkZWYgc2V0X2Rhc2hlcyhzZWxmLCBkYXNoX29mZnNldCwgZGFzaF9saXN0KToKICAgICAgICBzZWxmLl9kYXNoZXMgPSBkYXNoX29mZnNldCwgZGFzaF9saXN0CiAgICAgICAgaWYgZGFzaF9vZmZzZXQgaXMgbm90IE5vbmU6CiAgICAgICAgICAgIHNlbGYucmVuZGVyZXIuY3R4LmxpbmVEYXNoT2Zmc2V0ID0gZGFzaF9vZmZzZXQKICAgICAgICBpZiBkYXNoX2xpc3QgaXMgTm9uZToKICAgICAgICAgICAgc2VsZi5yZW5kZXJlci5jdHguc2V0TGluZURhc2goW10pCiAgICAgICAgZWxzZToKICAgICAgICAgICAgZGxuID0gbnAuYXNhcnJheShkYXNoX2xpc3QpCiAgICAgICAgICAgIGRsID0gbGlzdChzZWxmLnJlbmRlcmVyLnBvaW50c190b19waXhlbHMoZGxuKSkKICAgICAgICAgICAgc2VsZi5yZW5kZXJlci5jdHguc2V0TGluZURhc2goZGwpCgogICAgZGVmIHNldF9qb2luc3R5bGUoc2VsZiwganMpOgogICAgICAgIGlmIGpzIGluIFsibWl0ZXIiLCAicm91bmQiLCAiYmV2ZWwiXToKICAgICAgICAgICAgc2VsZi5fam9pbnN0eWxlID0ganMKICAgICAgICAgICAgc2VsZi5yZW5kZXJlci5jdHgubGluZUpvaW4gPSBqcwogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHJhaXNlIFZhbHVlRXJyb3IoZiJVbnJlY29nbml6ZWQgam9pbiBzdHlsZS4gRm91bmQge2pzfSIpCgogICAgZGVmIHNldF9saW5ld2lkdGgoc2VsZiwgdyk6CiAgICAgICAgc2VsZi5zdHJva2UgPSB3ICE9IDAKICAgICAgICBzZWxmLl9saW5ld2lkdGggPSBmbG9hdCh3KQogICAgICAgIHNlbGYucmVuZGVyZXIuY3R4LmxpbmVXaWR0aCA9IHNlbGYucmVuZGVyZXIucG9pbnRzX3RvX3BpeGVscyhmbG9hdCh3KSkKCmNsY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2xvciA9IChSLCBHLCBCKQoKICAgICAgICBpZiAobGVuKGNvbG9yKSA9PSA0KSBhbmQgKGFscGhhIGlzIE5vbmUpOgogICAgICAgICAgICBhbHBoYSA9IGNvbG9yWzNdCgogICAgICAgIGlmIGFscGhhIGlzIE5vbmU6CiAgICAgICAgICAgIENTU19jb2xvciA9IHJnYjJoZXgoY29sb3JbOjNdKQoKICAgICAgICBlbHNlOgogICAgICAgICAgICBSID0gaW50KGNvbG9yWzBdICogMjU1KQogICAgICAgICAgICBHID0gaW50KGNvbG9yWzFdICogMjU1KQogICAgICAgICAgICBCID0gaW50KGNvbG9yWzJdICogMjU1KQogICAgICAgICAgICBpZiBsZW4oY29sb3IpID09IDMgb3IgYWxwaGFfb3ZlcnJpZGVzOgogICAgICAgICAgICAgICAgQ1NTX2NvbG9yID0gZiIiInJnYmEoe1I6ZH0sIHtHOmR9LCB7QjpkfSwge2FscGhhOi4zZ30pIiIiCiAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICBDU1NfY29sb3IgPSAiIiJyZ2JhKHs6ZH0sIHs6ZH0sIHs6ZH0sIHs6LjNnfSkiIiIuZm9ybWF0KAogICAgICAgICAgICAgICAgICAgIFIsIEcsIEIsIGNvbG9yWzNdCiAgICAgICAgICAgICAgICApCgogICAgICAgIHJldHVybiBDU1NfY29sb3IKCiAgICBkZWYgX3NldF9zdHlsZShzZWxmLCBnYywgcmdiRmFjZT1Ob25lKToKICAgICAgICBpZiByZ2JGYWNlIGlzIG5vdCBOb25lOgogICAgICAgICAgICBzZWxmLmN0eC5maWxsU3R5bGUgPSBzZWxmLl9tYXRwbG90bGliX2NvbG9yX3RvX0NTUygKICAgICAgICAgICAgICAgIHJnYkZhY2UsIGdjLmdldF9hbHBoYSgpLCBnYy5nZXRfZm9yY2VkX2FscGhhKCkKICAgICAgICAgICAgKQoKICAgICAgICBpZiBnYy5nZXRfY2Fwc3R5bGUoKToKICAgICAgICAgICAgc2VsZi5jdHgubGluZUNhcCA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aXMgTm9uZToKICAgICAgICAgICAgZm5hbWUgPSBmaW5kZm9udChwcm9wKQogICAgICAgICAgICBmb250X3ZhbHVlID0gc2VsZi5mb250ZC5nZXQoZm5hbWUpCiAgICAgICAgICAgIGlmIGZvbnRfdmFsdWUgaXMgTm9uZToKICAgICAgICAgICAgICAgIGZvbnQgPSBGVDJGb250KHN0cihmbmFtZSkpCiAgICAgICAgICAgICAgICBmb250X2ZpbGVfbmFtZSA9IGZuYW1lW2ZuYW1lLnJmaW5kKCIvIikgKyAxIDpdCiAgICAgICAgICAgICAgICBmb250X3ZhbHVlID0gZm9udCwgZm9udF9maWxlX25hbWUKICAgICAgICAgICAgICAgIHNlbGYuZm9udGRbZm5hbWVdID0gZm9udF92YWx1ZQogICAgICAgICAgICBzZWxmLmZvbnRkW2tleV0gPSBmb250X3ZhbHVlCiAgICAgICAgZm9udCwgZm9udF9maWxlX25hbWUgPSBmb250X3ZhbHVlCiAgICAgICAgZm9udC5jbGVhcigpCiAgICAgICAgZm9udC5zZXRfc2l6ZShwcm9wLmdldF9zaXplX2luX3BvaW50cygpLCBzZWxmLmRwaSkKICAgICAgICByZXR1cm4gZm9udCwgZm9udF9maWxlX25hbWUKCiAgICBkZWYgZ2V0X3RleHRfd2lkdGhfaGVpZ2h0X2Rlc2NlbnQoc2VsZiwgcywgcHJvcCwgaXNtYXRoKToKICAgICAgICB3OiBmbG9hdAogICAgICAgIGg6IGZsb2F0CiAgICAgICAgaWYgaXNtYXRoOgogICAgICAgICAgICBpbWFnZSwgZCA9IHNlbGYubWF0aHRleHRfcGFyc2VyLnBhcnNlKHMsIHNlbGYuZHBpLCBwcm9wKQogICAgICAgICAgICBpbWFnZV9hcnIgPSBucC5hc2FycmF5KGltYWdlKQogICAgICAgICAgICBoLCB3ID0gaW1hZ2VfYXJyLnNoYXBlCiAgICAgICAgZWxzZToKICAgICAgICAgICAgZm9udCwgXyA9IHNlbGYuX2dldF9mb250KHByb3ApCiAgICAgICAgICAgIGZvbnQuc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Y2FudmFzLnNob3coKmFyZ3MsICoqa3dhcmdzKQoKICAgIEBzdGF0aWNtZXRob2QKICAgIGRlZiBkZXN0cm95KCphcmdzLCAqKmt3YXJncyk6CiAgICAgICAgZnJvbSBtYXRwbG90bGliIGltcG9ydCBweXBsb3QgYXMgcGx0CiAgICAgICAgcGx0LmdjZigpLmNhbnZhcy5kZXN0cm95KCphcmdzLCAqKmt3YXJncykK"});var Gl={};OO(Gl,{ChannelType:()=>Qt,Console:()=>R0,Shelter:()=>$l,WebR:()=>Nf,WebRChannelError:()=>pt,WebRError:()=>di,WebRPayloadError:()=>$n,WebRWorkerError:()=>Of,isRCall:()=>Hl,isRCharacter:()=>Ui,isRComplex:()=>k0,isRDouble:()=>x0,isREnvironment:()=>b0,isRFunction:()=>fs,isRInteger:()=>v0,isRList:()=>ot,isRLogical:()=>w0,isRNull:()=>Se,isRObject:()=>se,isRPairlist:()=>y0,isRRaw:()=>S0,isRSymbol:()=>O0});var yO=Object.create,ff=Object.defineProperty,bO=Object.getOwnPropertyDescriptor,wO=Object.getOwnPropertyNames,vO=Object.getPrototypeOf,xO=Object.prototype.hasOwnProperty,Xi=(i=>typeof ci<"u"?ci:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof ci<"u"?ci:e)[t]}):i)(function(i){if(typeof ci<"u")return ci.apply(this,arguments);throw new Error('Dynamic require of "'+i+'" is not supported')}),ke=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),kO=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of wO(e))!xO.call(i,r)&&r!==t&&ff(i,r,{get:()=>e[r],enumerable:!(n=bO(e,r))||n.enumerable});return i},Bi=(i,e,t)=>(t=i!=null?yO(vO(i)):{},kO(e||!i||!i.__esModule?ff(t,"default",{value:i,enumerable:!0}):t,i)),Ll=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},x=(i,e,t)=>(Ll(i,e,"read from private field"),t?t.call(i):e.get(i)),V=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},me=(i,e,t,n)=>(Ll(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);var Je=(i,e,t)=>(Ll(i,e,"access private method"),t),ss=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.getUint64=i.getInt64=i.setInt64=i.setUint64=i.UINT32_MAX=void 0,i.UINT32_MAX=4294967295;function e(s,o,l){let a=l/4294967296,h=l;s.setUint32(o,a),s.setUint32(o+4,h)}i.setUint64=e;function t(s,o,l){let a=Math.floor(l/4294967296),h=l;s.setUint32(o,a),s.setUint32(o+4,h)}i.setInt64=t;function n(s,o){let l=s.getInt32(o),a=s.getUint32(o+4);return l*4294967296+a}i.getInt64=n;function r(s,o){let l=s.getUint32(o),a=s.getUint32(o+4);return l*4294967296+a}i.getUint64=r}),Vl=ke(i=>{"use strict";var e,t,n;Object.defineProperty(i,"__esModule",{value:!0}),i.utf8DecodeTD=i.TEXT_DECODER_THRESHOLD=i.utf8DecodeJs=i.utf8EncodeTE=i.TEXT_ENCODER_THRESHOLD=i.utf8EncodeJs=i.utf8Count=void 0;var r=ss(),s=(typeof process>"u"||((e=process==null?void 0:process.env)===null||e===void 0?void 0:e.TEXT_ENCODING)!=="never")&&typeof TextEncoder<"u"&&typeof TextDecoder<"u";function o(p){let g=p.length,O=0,y=0;for(;y=55296&&k<=56319&&y>6&31|192;else{if(w>=55296&&w<=56319&&v>18&7|240,g[k++]=w>>12&63|128,g[k++]=w>>6&63|128):(g[k++]=w>>12&15|224,g[k++]=w>>6&63|128)}else{g[k++]=w;continue}g[k++]=w&63|128}}i.utf8EncodeJs=l;var a=s?new TextEncoder:void 0;i.TEXT_ENCODER_THRESHOLD=s?typeof process<"u"&&((t=process==null?void 0:process.env)===null||t===void 0?void 0:t.TEXT_ENCODING)!=="force"?200:0:r.UINT32_MAX;function h(p,g,O){g.set(a.encode(p),O)}function c(p,g,O){a.encodeInto(p,g.subarray(O))}i.utf8EncodeTE=a!=null&&a.encodeInto?c:h;var f=4096;function u(p,g,O){let y=g,k=y+O,v=[],w="";for(;y65535&&(L-=65536,v.push(L>>>10&1023|55296),L=56320|L&1023),v.push(L)}else v.push(P);v.length>=f&&(w+=String.fromCharCode(...v),v.length=0)}return v.length>0&&(w+=String.fromCharCode(...v)),w}i.utf8DecodeJs=u;var d=s?new TextDecoder:null;i.TEXT_DECODER_THRESHOLD=s?typeof process<"u"&&((n=process==null?void 0:process.env)===null||n===void 0?void 0:n.TEXT_DECODER)!=="force"?200:0:r.UINT32_MAX;function m(p,g,O){let y=p.subarray(g,g+O);return d.decode(y)}i.utf8DecodeTD=m}),uf=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ExtData=void 0;var e=class{constructor(t,n){this.type=t,this.data=n}};i.ExtData=e}),ql=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.DecodeError=void 0;var e=class extends Error{constructor(t){super(t);let n=Object.create(e.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};i.DecodeError=e}),df=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.timestampExtension=i.decodeTimestampExtension=i.decodeTimestampToTimeSpec=i.encodeTimestampExtension=i.encodeDateToTimeSpec=i.encodeTimeSpecToTimestamp=i.EXT_TIMESTAMP=void 0;var e=ql(),t=ss();i.EXT_TIMESTAMP=-1;var n=4294967296-1,r=17179869184-1;function s({sec:c,nsec:f}){if(c>=0&&f>=0&&c<=r)if(f===0&&c<=n){let u=new Uint8Array(4);return new DataView(u.buffer).setUint32(0,c),u}else{let u=c/4294967296,d=c&4294967295,m=new Uint8Array(8),p=new DataView(m.buffer);return p.setUint32(0,f<<2|u&3),p.setUint32(4,d),m}else{let u=new Uint8Array(12),d=new DataView(u.buffer);return d.setUint32(0,f),(0,t.setInt64)(d,4,c),u}}i.encodeTimeSpecToTimestamp=s;function o(c){let f=c.getTime(),u=Math.floor(f/1e3),d=(f-u*1e3)*1e6,m=Math.floor(d/1e9);return{sec:u+m,nsec:d-m*1e9}}i.encodeDateToTimeSpec=o;function l(c){if(c instanceof Date){let f=o(c);return s(f)}else return null}i.encodeTimestampExtension=l;function a(c){let f=new DataView(c.buffer,c.byteOffset,c.byteLength);switch(c.byteLength){case 4:return{sec:f.getUint32(0),nsec:0};case 8:{let u=f.getUint32(0),d=f.getUint32(4),m=(u&3)*4294967296+d,p=u>>>2;return{sec:m,nsec:p}}case 12:{let u=(0,t.getInt64)(f,4),d=f.getUint32(0);return{sec:u,nsec:d}}default:throw new e.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${c.length}`)}}i.decodeTimestampToTimeSpec=a;function h(c){let f=a(c);return new Date(f.sec*1e3+f.nsec/1e6)}i.decodeTimestampExtension=h,i.timestampExtension={type:i.EXT_TIMESTAMP,encode:l,decode:h}}),Xl=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ExtensionCodec=void 0;var e=uf(),t=df(),n=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(t.timestampExtension)}register({type:r,encode:s,decode:o}){if(r>=0)this.encoders[r]=s,this.decoders[r]=o;else{let l=1+r;this.builtInEncoders[l]=s,this.builtInDecoders[l]=o}}tryToEncode(r,s){for(let o=0;o{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.createDataView=i.ensureUint8Array=void 0;function e(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n instanceof ArrayBuffer?new Uint8Array(n):Uint8Array.from(n)}i.ensureUint8Array=e;function t(n){if(n instanceof ArrayBuffer)return new DataView(n);let r=e(n);return new DataView(r.buffer,r.byteOffset,r.byteLength)}i.createDataView=t}),mf=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Encoder=i.DEFAULT_INITIAL_BUFFER_SIZE=i.DEFAULT_MAX_DEPTH=void 0;var e=Vl(),t=Xl(),n=ss(),r=pf();i.DEFAULT_MAX_DEPTH=100,i.DEFAULT_INITIAL_BUFFER_SIZE=2048;var s=class{constructor(o=t.ExtensionCodec.defaultCodec,l=void 0,a=i.DEFAULT_MAX_DEPTH,h=i.DEFAULT_INITIAL_BUFFER_SIZE,c=!1,f=!1,u=!1,d=!1){this.extensionCodec=o,this.context=l,this.maxDepth=a,this.initialBufferSize=h,this.sortKeys=c,this.forceFloat32=f,this.ignoreUndefined=u,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(o){return this.reinitializeState(),this.doEncode(o,1),this.bytes.subarray(0,this.pos)}encode(o){return this.reinitializeState(),this.doEncode(o,1),this.bytes.slice(0,this.pos)}doEncode(o,l){if(l>this.maxDepth)throw new Error(`Too deep objects in depth ${l}`);o==null?this.encodeNil():typeof o=="boolean"?this.encodeBoolean(o):typeof o=="number"?this.encodeNumber(o):typeof o=="string"?this.encodeString(o):this.encodeObject(o,l)}ensureBufferSizeToWrite(o){let l=this.pos+o;this.view.byteLength=0?o<128?this.writeU8(o):o<256?(this.writeU8(204),this.writeU8(o)):o<65536?(this.writeU8(205),this.writeU16(o)):o<4294967296?(this.writeU8(206),this.writeU32(o)):(this.writeU8(207),this.writeU64(o)):o>=-32?this.writeU8(224|o+32):o>=-128?(this.writeU8(208),this.writeI8(o)):o>=-32768?(this.writeU8(209),this.writeI16(o)):o>=-2147483648?(this.writeU8(210),this.writeI32(o)):(this.writeU8(211),this.writeI64(o)):this.forceFloat32?(this.writeU8(202),this.writeF32(o)):(this.writeU8(203),this.writeF64(o))}writeStringHeader(o){if(o<32)this.writeU8(160+o);else if(o<256)this.writeU8(217),this.writeU8(o);else if(o<65536)this.writeU8(218),this.writeU16(o);else if(o<4294967296)this.writeU8(219),this.writeU32(o);else throw new Error(`Too long string: ${o} bytes in UTF-8`)}encodeString(o){if(o.length>e.TEXT_ENCODER_THRESHOLD){let l=(0,e.utf8Count)(o);this.ensureBufferSizeToWrite(5+l),this.writeStringHeader(l),(0,e.utf8EncodeTE)(o,this.bytes,this.pos),this.pos+=l}else{let l=(0,e.utf8Count)(o);this.ensureBufferSizeToWrite(5+l),this.writeStringHeader(l),(0,e.utf8EncodeJs)(o,this.bytes,this.pos),this.pos+=l}}encodeObject(o,l){let a=this.extensionCodec.tryToEncode(o,this.context);if(a!=null)this.encodeExtension(a);else if(Array.isArray(o))this.encodeArray(o,l);else if(ArrayBuffer.isView(o))this.encodeBinary(o);else if(typeof o=="object")this.encodeMap(o,l);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(o)}`)}encodeBinary(o){let l=o.byteLength;if(l<256)this.writeU8(196),this.writeU8(l);else if(l<65536)this.writeU8(197),this.writeU16(l);else if(l<4294967296)this.writeU8(198),this.writeU32(l);else throw new Error(`Too large binary: ${l}`);let a=(0,r.ensureUint8Array)(o);this.writeU8a(a)}encodeArray(o,l){let a=o.length;if(a<16)this.writeU8(144+a);else if(a<65536)this.writeU8(220),this.writeU16(a);else if(a<4294967296)this.writeU8(221),this.writeU32(a);else throw new Error(`Too large array: ${a}`);for(let h of o)this.doEncode(h,l+1)}countWithoutUndefined(o,l){let a=0;for(let h of l)o[h]!==void 0&&a++;return a}encodeMap(o,l){let a=Object.keys(o);this.sortKeys&&a.sort();let h=this.ignoreUndefined?this.countWithoutUndefined(o,a):a.length;if(h<16)this.writeU8(128+h);else if(h<65536)this.writeU8(222),this.writeU16(h);else if(h<4294967296)this.writeU8(223),this.writeU32(h);else throw new Error(`Too large map object: ${h}`);for(let c of a){let f=o[c];this.ignoreUndefined&&f===void 0||(this.encodeString(c),this.doEncode(f,l+1))}}encodeExtension(o){let l=o.data.length;if(l===1)this.writeU8(212);else if(l===2)this.writeU8(213);else if(l===4)this.writeU8(214);else if(l===8)this.writeU8(215);else if(l===16)this.writeU8(216);else if(l<256)this.writeU8(199),this.writeU8(l);else if(l<65536)this.writeU8(200),this.writeU16(l);else if(l<4294967296)this.writeU8(201),this.writeU32(l);else throw new Error(`Too large extension object: ${l}`);this.writeI8(o.type),this.writeU8a(o.data)}writeU8(o){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,o),this.pos++}writeU8a(o){let l=o.length;this.ensureBufferSizeToWrite(l),this.bytes.set(o,this.pos),this.pos+=l}writeI8(o){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,o),this.pos++}writeU16(o){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,o),this.pos+=2}writeI16(o){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,o),this.pos+=2}writeU32(o){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,o),this.pos+=4}writeI32(o){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,o),this.pos+=4}writeF32(o){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,o),this.pos+=4}writeF64(o){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,o),this.pos+=8}writeU64(o){this.ensureBufferSizeToWrite(8),(0,n.setUint64)(this.view,this.pos,o),this.pos+=8}writeI64(o){this.ensureBufferSizeToWrite(8),(0,n.setInt64)(this.view,this.pos,o),this.pos+=8}};i.Encoder=s}),SO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.encode=void 0;var e=mf(),t={};function n(r,s=t){return new e.Encoder(s.extensionCodec,s.context,s.maxDepth,s.initialBufferSize,s.sortKeys,s.forceFloat32,s.ignoreUndefined,s.forceIntegerToFloat).encodeSharedRef(r)}i.encode=n}),TO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.prettyByte=void 0;function e(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}i.prettyByte=e}),PO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.CachedKeyDecoder=void 0;var e=Vl(),t=16,n=16,r=class{constructor(s=t,o=n){this.maxKeyLength=s,this.maxLengthPerKey=o,this.hit=0,this.miss=0,this.caches=[];for(let l=0;l0&&s<=this.maxKeyLength}find(s,o,l){let a=this.caches[l-1];e:for(let h of a){let c=h.bytes;for(let f=0;f=this.maxLengthPerKey?l[Math.random()*l.length|0]=a:l.push(a)}decode(s,o,l){let a=this.find(s,o,l);if(a!=null)return this.hit++,a;this.miss++;let h=(0,e.utf8DecodeJs)(s,o,l),c=Uint8Array.prototype.slice.call(s,o,o+l);return this.store(c,h),h}};i.CachedKeyDecoder=r}),Bl=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Decoder=i.DataViewIndexOutOfBoundsError=void 0;var e=TO(),t=Xl(),n=ss(),r=Vl(),s=pf(),o=PO(),l=ql(),a=p=>{let g=typeof p;return g==="string"||g==="number"},h=-1,c=new DataView(new ArrayBuffer(0)),f=new Uint8Array(c.buffer);i.DataViewIndexOutOfBoundsError=(()=>{try{c.getInt8(0)}catch(p){return p.constructor}throw new Error("never reached")})();var u=new i.DataViewIndexOutOfBoundsError("Insufficient data"),d=new o.CachedKeyDecoder,m=class{constructor(p=t.ExtensionCodec.defaultCodec,g=void 0,O=n.UINT32_MAX,y=n.UINT32_MAX,k=n.UINT32_MAX,v=n.UINT32_MAX,w=n.UINT32_MAX,P=d){this.extensionCodec=p,this.context=g,this.maxStrLength=O,this.maxBinLength=y,this.maxArrayLength=k,this.maxMapLength=v,this.maxExtLength=w,this.keyDecoder=P,this.totalPos=0,this.pos=0,this.view=c,this.bytes=f,this.headByte=h,this.stack=[]}reinitializeState(){this.totalPos=0,this.headByte=h,this.stack.length=0}setBuffer(p){this.bytes=(0,s.ensureUint8Array)(p),this.view=(0,s.createDataView)(this.bytes),this.pos=0}appendBuffer(p){if(this.headByte===h&&!this.hasRemaining(1))this.setBuffer(p);else{let g=this.bytes.subarray(this.pos),O=(0,s.ensureUint8Array)(p),y=new Uint8Array(g.length+O.length);y.set(g),y.set(O,g.length),this.setBuffer(y)}}hasRemaining(p){return this.view.byteLength-this.pos>=p}createExtraByteError(p){let{view:g,pos:O}=this;return new RangeError(`Extra ${g.byteLength-O} of ${g.byteLength} byte(s) found at buffer[${p}]`)}decode(p){this.reinitializeState(),this.setBuffer(p);let g=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return g}*decodeMulti(p){for(this.reinitializeState(),this.setBuffer(p);this.hasRemaining(1);)yield this.doDecodeSync()}async decodeAsync(p){let g=!1,O;for await(let w of p){if(g)throw this.createExtraByteError(this.totalPos);this.appendBuffer(w);try{O=this.doDecodeSync(),g=!0}catch(P){if(!(P instanceof i.DataViewIndexOutOfBoundsError))throw P}this.totalPos+=this.pos}if(g){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return O}let{headByte:y,pos:k,totalPos:v}=this;throw new RangeError(`Insufficient data in parsing ${(0,e.prettyByte)(y)} at ${v} (${k} in the current buffer)`)}decodeArrayStream(p){return this.decodeMultiAsync(p,!0)}decodeStream(p){return this.decodeMultiAsync(p,!1)}async*decodeMultiAsync(p,g){let O=g,y=-1;for await(let k of p){if(g&&y===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(k),O&&(y=this.readArraySize(),O=!1,this.complete());try{for(;yield this.doDecodeSync(),--y!==0;);}catch(v){if(!(v instanceof i.DataViewIndexOutOfBoundsError))throw v}this.totalPos+=this.pos}}doDecodeSync(){e:for(;;){let p=this.readHeadByte(),g;if(p>=224)g=p-256;else if(p<192)if(p<128)g=p;else if(p<144){let y=p-128;if(y!==0){this.pushMapState(y),this.complete();continue e}else g={}}else if(p<160){let y=p-144;if(y!==0){this.pushArrayState(y),this.complete();continue e}else g=[]}else{let y=p-160;g=this.decodeUtf8String(y,0)}else if(p===192)g=null;else if(p===194)g=!1;else if(p===195)g=!0;else if(p===202)g=this.readF32();else if(p===203)g=this.readF64();else if(p===204)g=this.readU8();else if(p===205)g=this.readU16();else if(p===206)g=this.readU32();else if(p===207)g=this.readU64();else if(p===208)g=this.readI8();else if(p===209)g=this.readI16();else if(p===210)g=this.readI32();else if(p===211)g=this.readI64();else if(p===217){let y=this.lookU8();g=this.decodeUtf8String(y,1)}else if(p===218){let y=this.lookU16();g=this.decodeUtf8String(y,2)}else if(p===219){let y=this.lookU32();g=this.decodeUtf8String(y,4)}else if(p===220){let y=this.readU16();if(y!==0){this.pushArrayState(y),this.complete();continue e}else g=[]}else if(p===221){let y=this.readU32();if(y!==0){this.pushArrayState(y),this.complete();continue e}else g=[]}else if(p===222){let y=this.readU16();if(y!==0){this.pushMapState(y),this.complete();continue e}else g={}}else if(p===223){let y=this.readU32();if(y!==0){this.pushMapState(y),this.complete();continue e}else g={}}else if(p===196){let y=this.lookU8();g=this.decodeBinary(y,1)}else if(p===197){let y=this.lookU16();g=this.decodeBinary(y,2)}else if(p===198){let y=this.lookU32();g=this.decodeBinary(y,4)}else if(p===212)g=this.decodeExtension(1,0);else if(p===213)g=this.decodeExtension(2,0);else if(p===214)g=this.decodeExtension(4,0);else if(p===215)g=this.decodeExtension(8,0);else if(p===216)g=this.decodeExtension(16,0);else if(p===199){let y=this.lookU8();g=this.decodeExtension(y,1)}else if(p===200){let y=this.lookU16();g=this.decodeExtension(y,2)}else if(p===201){let y=this.lookU32();g=this.decodeExtension(y,4)}else throw new l.DecodeError(`Unrecognized type byte: ${(0,e.prettyByte)(p)}`);this.complete();let O=this.stack;for(;O.length>0;){let y=O[O.length-1];if(y.type===0)if(y.array[y.position]=g,y.position++,y.position===y.size)O.pop(),g=y.array;else continue e;else if(y.type===1){if(!a(g))throw new l.DecodeError("The type of key must be string or number but "+typeof g);if(g==="__proto__")throw new l.DecodeError("The key __proto__ is not allowed");y.key=g,y.type=2;continue e}else if(y.map[y.key]=g,y.readCount++,y.readCount===y.size)O.pop(),g=y.map;else{y.key=null,y.type=1;continue e}}return g}}readHeadByte(){return this.headByte===h&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=h}readArraySize(){let p=this.readHeadByte();switch(p){case 220:return this.readU16();case 221:return this.readU32();default:{if(p<160)return p-144;throw new l.DecodeError(`Unrecognized array type byte: ${(0,e.prettyByte)(p)}`)}}}pushMapState(p){if(p>this.maxMapLength)throw new l.DecodeError(`Max length exceeded: map length (${p}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:1,size:p,key:null,readCount:0,map:{}})}pushArrayState(p){if(p>this.maxArrayLength)throw new l.DecodeError(`Max length exceeded: array length (${p}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:0,size:p,array:new Array(p),position:0})}decodeUtf8String(p,g){var O;if(p>this.maxStrLength)throw new l.DecodeError(`Max length exceeded: UTF-8 byte length (${p}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLengthr.TEXT_DECODER_THRESHOLD?k=(0,r.utf8DecodeTD)(this.bytes,y,p):k=(0,r.utf8DecodeJs)(this.bytes,y,p),this.pos+=g+p,k}stateIsMapKey(){return this.stack.length>0?this.stack[this.stack.length-1].type===1:!1}decodeBinary(p,g){if(p>this.maxBinLength)throw new l.DecodeError(`Max length exceeded: bin length (${p}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(p+g))throw u;let O=this.pos+g,y=this.bytes.subarray(O,O+p);return this.pos+=g+p,y}decodeExtension(p,g){if(p>this.maxExtLength)throw new l.DecodeError(`Max length exceeded: ext length (${p}) > maxExtLength (${this.maxExtLength})`);let O=this.view.getInt8(this.pos+g),y=this.decodeBinary(p,g+1);return this.extensionCodec.decode(y,O,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 p=this.view.getUint8(this.pos);return this.pos++,p}readI8(){let p=this.view.getInt8(this.pos);return this.pos++,p}readU16(){let p=this.view.getUint16(this.pos);return this.pos+=2,p}readI16(){let p=this.view.getInt16(this.pos);return this.pos+=2,p}readU32(){let p=this.view.getUint32(this.pos);return this.pos+=4,p}readI32(){let p=this.view.getInt32(this.pos);return this.pos+=4,p}readU64(){let p=(0,n.getUint64)(this.view,this.pos);return this.pos+=8,p}readI64(){let p=(0,n.getInt64)(this.view,this.pos);return this.pos+=8,p}readF32(){let p=this.view.getFloat32(this.pos);return this.pos+=4,p}readF64(){let p=this.view.getFloat64(this.pos);return this.pos+=8,p}};i.Decoder=m}),gf=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.decodeMulti=i.decode=i.defaultDecodeOptions=void 0;var e=Bl();i.defaultDecodeOptions={};function t(r,s=i.defaultDecodeOptions){return new e.Decoder(s.extensionCodec,s.context,s.maxStrLength,s.maxBinLength,s.maxArrayLength,s.maxMapLength,s.maxExtLength).decode(r)}i.decode=t;function n(r,s=i.defaultDecodeOptions){return new e.Decoder(s.extensionCodec,s.context,s.maxStrLength,s.maxBinLength,s.maxArrayLength,s.maxMapLength,s.maxExtLength).decodeMulti(r)}i.decodeMulti=n}),CO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ensureAsyncIterable=i.asyncIterableFromStream=i.isAsyncIterable=void 0;function e(s){return s[Symbol.asyncIterator]!=null}i.isAsyncIterable=e;function t(s){if(s==null)throw new Error("Assertion Failure: value must not be null nor undefined")}async function*n(s){let o=s.getReader();try{for(;;){let{done:l,value:a}=await o.read();if(l)return;t(a),yield a}}finally{o.releaseLock()}}i.asyncIterableFromStream=n;function r(s){return e(s)?s:n(s)}i.ensureAsyncIterable=r}),RO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.decodeStream=i.decodeMultiStream=i.decodeArrayStream=i.decodeAsync=void 0;var e=Bl(),t=CO(),n=gf();async function r(a,h=n.defaultDecodeOptions){let c=(0,t.ensureAsyncIterable)(a);return new e.Decoder(h.extensionCodec,h.context,h.maxStrLength,h.maxBinLength,h.maxArrayLength,h.maxMapLength,h.maxExtLength).decodeAsync(c)}i.decodeAsync=r;function s(a,h=n.defaultDecodeOptions){let c=(0,t.ensureAsyncIterable)(a);return new e.Decoder(h.extensionCodec,h.context,h.maxStrLength,h.maxBinLength,h.maxArrayLength,h.maxMapLength,h.maxExtLength).decodeArrayStream(c)}i.decodeArrayStream=s;function o(a,h=n.defaultDecodeOptions){let c=(0,t.ensureAsyncIterable)(a);return new e.Decoder(h.extensionCodec,h.context,h.maxStrLength,h.maxBinLength,h.maxArrayLength,h.maxMapLength,h.maxExtLength).decodeStream(c)}i.decodeMultiStream=o;function l(a,h=n.defaultDecodeOptions){return o(a,h)}i.decodeStream=l}),Wl=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.decodeTimestampExtension=i.encodeTimestampExtension=i.decodeTimestampToTimeSpec=i.encodeTimeSpecToTimestamp=i.encodeDateToTimeSpec=i.EXT_TIMESTAMP=i.ExtData=i.ExtensionCodec=i.Encoder=i.DataViewIndexOutOfBoundsError=i.DecodeError=i.Decoder=i.decodeStream=i.decodeMultiStream=i.decodeArrayStream=i.decodeAsync=i.decodeMulti=i.decode=i.encode=void 0;var e=SO();Object.defineProperty(i,"encode",{enumerable:!0,get:function(){return e.encode}});var t=gf();Object.defineProperty(i,"decode",{enumerable:!0,get:function(){return t.decode}}),Object.defineProperty(i,"decodeMulti",{enumerable:!0,get:function(){return t.decodeMulti}});var n=RO();Object.defineProperty(i,"decodeAsync",{enumerable:!0,get:function(){return n.decodeAsync}}),Object.defineProperty(i,"decodeArrayStream",{enumerable:!0,get:function(){return n.decodeArrayStream}}),Object.defineProperty(i,"decodeMultiStream",{enumerable:!0,get:function(){return n.decodeMultiStream}}),Object.defineProperty(i,"decodeStream",{enumerable:!0,get:function(){return n.decodeStream}});var r=Bl();Object.defineProperty(i,"Decoder",{enumerable:!0,get:function(){return r.Decoder}}),Object.defineProperty(i,"DataViewIndexOutOfBoundsError",{enumerable:!0,get:function(){return r.DataViewIndexOutOfBoundsError}});var s=ql();Object.defineProperty(i,"DecodeError",{enumerable:!0,get:function(){return s.DecodeError}});var o=mf();Object.defineProperty(i,"Encoder",{enumerable:!0,get:function(){return o.Encoder}});var l=Xl();Object.defineProperty(i,"ExtensionCodec",{enumerable:!0,get:function(){return l.ExtensionCodec}});var a=uf();Object.defineProperty(i,"ExtData",{enumerable:!0,get:function(){return a.ExtData}});var h=df();Object.defineProperty(i,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return h.EXT_TIMESTAMP}}),Object.defineProperty(i,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return h.encodeDateToTimeSpec}}),Object.defineProperty(i,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return h.encodeTimeSpecToTimestamp}}),Object.defineProperty(i,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return h.decodeTimestampToTimeSpec}}),Object.defineProperty(i,"encodeTimestampExtension",{enumerable:!0,get:function(){return h.encodeTimestampExtension}}),Object.defineProperty(i,"decodeTimestampExtension",{enumerable:!0,get:function(){return h.decodeTimestampExtension}})}),di=class extends Error{constructor(i){super(i),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}},Of=class extends di{},pt=class extends di{},$n=class extends di{},Ie=typeof process<"u"&&process.release&&process.release.name==="node",ul;if(globalThis.document)ul=i=>new Promise((e,t)=>{let n=document.createElement("script");n.src=i,n.onload=()=>e(),n.onerror=t,document.head.appendChild(n)});else if(globalThis.importScripts)ul=async i=>{try{globalThis.importScripts(i)}catch(e){if(e instanceof TypeError)await Promise.resolve().then(()=>Bi(Xi(i)));else throw e}};else if(Ie)ul=async i=>{let e=(await Promise.resolve().then(()=>Bi(Xi("path")))).default;await Promise.resolve().then(()=>Bi(Xi(e.resolve(i))))};else throw new di("Cannot determine runtime environment");var T={};function EO(i){Object.keys(i).forEach(e=>T._free(i[e]))}var mt={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 yf(i){return!!i&&typeof i=="object"&&Object.keys(mt).includes(i.type)}function os(i){return!!i&&typeof i=="object"&&"re"in i&&"im"in i}function zr(i){return T._Rf_protect(Mt(i)),i}function le(i,e){return T._Rf_protect(Mt(i)),++e.n,i}function AO(i){let e=T._malloc(4);return T._R_ProtectWithIndex(Mt(i),e),{loc:T.getValue(e,"i32"),ptr:e}}function QO(i){T._Rf_unprotect(1),T._free(i.ptr)}function MO(i,e){return T._R_Reprotect(Mt(i),e.loc),i}function Oe(i){T._Rf_unprotect(i)}function rf(i,e,t){T._Rf_defineVar(Mt(e),Mt(t),Mt(i))}function sf(i,e){let t={},n={n:0};try{let r=new xf(e);le(r,n),t.code=T.allocateUTF8(i);let s=T._R_ParseEvalString(t.code,r.ptr);return z.wrap(s)}finally{EO(t),Oe(n.n)}}function ls(i,e){return T.getWasmTableEntry(T.GOT.ffi_safe_eval.value)(Mt(i),Mt(e))}var _O=new WeakMap;function DO(i,e){return _O.set(i,e),i}var $O=63;function bf(){let i=Array.from({length:4},LO).join("-");if(i.length!==$O)throw new Error("comlink internal error: UUID has the wrong length");return i}function LO(){let i=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16),e=15-i.length;return e>0&&(i=Array.from({length:e},()=>0).join("")+i),i}function Mt(i){return Kr(i)?i.ptr:i}function pi(i,e){if(T._TYPEOF(i.ptr)!==mt[e])throw new Error(`Unexpected object type "${i.type()}" when expecting type "${e}"`)}function wf(i){if(yf(i))return new(Af(i.type))(i);if(i&&typeof i=="object"&&"type"in i&&i.type==="null")return new vf;if(i===null)return new Ni({type:"logical",names:null,values:[null]});if(typeof i=="boolean")return new Ni(i);if(typeof i=="number")return new hs(i);if(typeof i=="string")return new zt(i);if(os(i))return new Nl(i);if(ArrayBuffer.isView(i)||i instanceof ArrayBuffer)return new jl(i);if(Array.isArray(i))return VO(i);if(typeof i=="object")return Ln.fromObject(i);throw new Error("Robj construction for this JS object is not yet supported")}function VO(i){let e={n:0};if(i.every(t=>t&&typeof t=="object"&&!Kr(t)&&!os(t))){let t=i,n=t.every(s=>Object.keys(s).filter(o=>!Object.keys(t[0]).includes(o)).length===0&&Object.keys(t[0]).filter(o=>!Object.keys(s).includes(o)).length===0),r=t.every(s=>Object.values(s).every(o=>Mf(o)||Qf(o)));if(n&&r)return Ln.fromD3(t)}if(i.every(t=>typeof t=="boolean"||t===null))return new Ni(i);if(i.every(t=>typeof t=="number"||t===null))return new hs(i);if(i.every(t=>typeof t=="string"||t===null))return new zt(i);try{let t=new ui([new gt("c"),...i]);return le(t,e),t.eval()}finally{Oe(e.n)}}var ye=class{constructor(i){this.ptr=i}type(){let i=T._TYPEOF(this.ptr);return Object.keys(mt).find(e=>mt[e]===i)}},En,Ur,Wi=class extends ye{constructor(i){if(!(i instanceof ye))return wf(i);super(i.ptr),V(this,En)}static wrap(i){let e=T._TYPEOF(i),t=Object.keys(mt)[Object.values(mt).indexOf(e)];return new(Af(t))(new ye(i))}get[Symbol.toStringTag](){return`RObject:${this.type()}`}static getPersistentObject(i){return xe[i]}getPropertyValue(i){return this[i]}inspect(){sf(".Internal(inspect(x))",{x:this})}isNull(){return T._TYPEOF(this.ptr)===mt.null}isNa(){try{let i=sf("is.na(x)",{x:this});return zr(i),i.toBoolean()}finally{Oe(1)}}isUnbound(){return this.ptr===xe.unboundValue.ptr}attrs(){return as.wrap(T._ATTRIB(this.ptr))}class(){let i={n:0},e=new ui([new gt("class"),this]);le(e,i);try{return e.eval()}finally{Oe(i.n)}}setNames(i){let e;if(i===null)e=xe.null;else if(Array.isArray(i)&&i.every(t=>typeof t=="string"||t===null))e=new zt(i);else throw new Error("Argument to setNames must be null or an Array of strings or null");return T._Rf_setAttrib(this.ptr,xe.namesSymbol.ptr,e.ptr),this}names(){let i=zt.wrap(T._Rf_getAttrib(this.ptr,xe.namesSymbol.ptr));return i.isNull()?null:i.toArray()}includes(i){let e=this.names();return e&&e.includes(i)}toJs(i={depth:0},e=1){throw new Error("This R object cannot be converted to JS")}subset(i){return Je(this,En,Ur).call(this,i,xe.bracketSymbol.ptr)}get(i){return Je(this,En,Ur).call(this,i,xe.bracket2Symbol.ptr)}getDollar(i){return Je(this,En,Ur).call(this,i,xe.dollarSymbol.ptr)}pluck(...i){let e=AO(xe.null);try{let t=(r,s)=>{let o=r.get(s);return MO(o,e)},n=i.reduce(t,this);return n.isNull()?void 0:n}finally{QO(e)}}set(i,e){let t={n:0};try{let n=new Wi(i);le(n,t);let r=new Wi(e);le(r,t);let s=new gt("[[<-"),o=T._Rf_lang4(s.ptr,this.ptr,n.ptr,r.ptr);return le(o,t),Wi.wrap(ls(o,xe.baseEnv))}finally{Oe(t.n)}}static getMethods(i){let e=new Set,t=i;do Object.getOwnPropertyNames(t).map(n=>e.add(n));while(t=Object.getPrototypeOf(t));return[...e.keys()].filter(n=>typeof i[n]=="function")}},z=Wi;En=new WeakSet,Ur=function(i,e){let t={n:0};try{let n=new Wi(i);le(n,t);let r=T._Rf_lang3(e,this.ptr,n.ptr);return le(r,t),Wi.wrap(ls(r,xe.baseEnv))}finally{Oe(t.n)}};var vf=class extends z{constructor(){return super(new ye(T.getValue(T._R_NilValue,"*"))),this}toJs(){return{type:"null"}}},gt=class extends z{constructor(i){if(i instanceof ye){pi(i,"symbol"),super(i);return}let e=T.allocateUTF8(i);try{super(new ye(T._Rf_install(e)))}finally{T._free(e)}}toJs(){let i=this.toObject();return{type:"symbol",printname:i.printname,symvalue:i.symvalue,internal:i.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 Il.wrap(T._PRINTNAME(this.ptr))}symvalue(){return z.wrap(T._SYMVALUE(this.ptr))}internal(){return z.wrap(T._INTERNAL(this.ptr))}},as=class extends z{constructor(i){if(i instanceof ye)return pi(i,"pairlist"),super(i),this;let e={n:0};try{let{names:t,values:n}=zi(i),r=as.wrap(T._Rf_allocList(n.length));le(r,e);for(let[s,o]=[0,r];!o.isNull();[s,o]=[s+1,o.cdr()])o.setcar(new z(n[s]));r.setNames(t),super(r)}finally{Oe(e.n)}}get length(){return this.toArray().length}toArray(i={depth:1}){return this.toJs(i).values}toObject({allowDuplicateKey:i=!0,allowEmptyKey:e=!1,depth:t=-1}={}){let n=this.entries({depth:t}),r=n.map(([s])=>s);if(!i&&new Set(r).size!==r.length)throw new Error("Duplicate key when converting pairlist without allowDuplicateKey enabled");if(!e&&r.some(s=>!s))throw new Error("Empty or null key when converting pairlist without allowEmptyKey enabled");return Object.fromEntries(n.filter((s,o)=>n.findIndex(l=>l[0]===s[0])===o))}entries(i={depth:1}){let e=this.toJs(i);return e.values.map((t,n)=>[e.names?e.names[n]:null,t])}toJs(i={depth:0},e=1){let t=[],n=!1,r=[];for(let s=this;!s.isNull();s=s.cdr()){let o=s.tag();o.isNull()?t.push(""):(n=!0,t.push(o.toString())),i.depth&&e>=i.depth?r.push(s.car()):r.push(s.car().toJs(i,e+1))}return{type:"pairlist",names:n?t:null,values:r}}includes(i){return i in this.toObject()}setcar(i){T._SETCAR(this.ptr,i.ptr)}car(){return z.wrap(T._CAR(this.ptr))}cdr(){return z.wrap(T._CDR(this.ptr))}tag(){return z.wrap(T._TAG(this.ptr))}},ui=class extends z{constructor(i){if(i instanceof ye)return pi(i,"call"),super(i),this;let e={n:0};try{let{values:t}=zi(i),n=t.map(s=>le(new z(s),e)),r=ui.wrap(T._Rf_allocVector(mt.call,t.length));le(r,e);for(let[s,o]=[0,r];!o.isNull();[s,o]=[s+1,o.cdr()])o.setcar(n[s]);super(r)}finally{Oe(e.n)}}setcar(i){T._SETCAR(this.ptr,i.ptr)}car(){return z.wrap(T._CAR(this.ptr))}cdr(){return z.wrap(T._CDR(this.ptr))}eval(){return T.webr.evalR(this,{env:xe.baseEnv})}capture(i={}){return T.webr.captureR(this,i)}deparse(){let i={n:0};try{let e=T._Rf_lang2(new gt("deparse1").ptr,T._Rf_lang2(new gt("quote").ptr,this.ptr));le(e,i);let t=zt.wrap(ls(e,xe.baseEnv));return le(t,i),t.toString()}finally{Oe(i.n)}}},pl=class extends z{constructor(i,e=null){if(i instanceof ye){if(pi(i,"list"),super(i),e){if(e.length!==this.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");this.setNames(e)}return this}let t={n:0};try{let n=zi(i),r=T._Rf_allocVector(mt.list,n.values.length);le(r,t),n.values.forEach((o,l)=>{T._SET_VECTOR_ELT(r,l,new z(o).ptr)});let s=e||n.names;if(s&&s.length!==n.values.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");z.wrap(r).setNames(s),super(new ye(r))}finally{Oe(t.n)}}get length(){return T._LENGTH(this.ptr)}isDataFrame(){let i=as.wrap(T._ATTRIB(this.ptr)).get("class");return!i.isNull()&&i.toArray().includes("data.frame")}toArray(i={depth:1}){return this.toJs(i).values}toObject({allowDuplicateKey:i=!0,allowEmptyKey:e=!1,depth:t=-1}={}){let n=this.entries({depth:t}),r=n.map(([s])=>s);if(!i&&new Set(r).size!==r.length)throw new Error("Duplicate key when converting list without allowDuplicateKey enabled");if(!e&&r.some(s=>!s))throw new Error("Empty or null key when converting list without allowEmptyKey enabled");return Object.fromEntries(n.filter((s,o)=>n.findIndex(l=>l[0]===s[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((i,e)=>(e[1].forEach((t,n)=>i[n]=Object.assign(i[n]||{},{[e[0]]:t})),i),[])}entries(i={depth:-1}){let e=this.toJs(i);return this.isDataFrame()&&i.depth<0&&(e.values=e.values.map(t=>t.toArray())),e.values.map((t,n)=>[e.names?e.names[n]:null,t])}toJs(i={depth:0},e=1){return{type:"list",names:this.names(),values:[...Array(this.length).keys()].map(t=>i.depth&&e>=i.depth?this.get(t+1):this.get(t+1).toJs(i,e+1))}}},Ln=class extends pl{constructor(i){if(i instanceof ye){if(super(i),!this.isDataFrame())throw new Error("Can't construct `RDataFrame`. Supplied R object is not a `data.frame`.");return this}return Ln.fromObject(i)}static fromObject(i){let{names:e,values:t}=zi(i),n={n:0};try{let r=!!e&&e.length>0&&e.every(o=>o),s=t.length>0&&t.every(o=>Array.isArray(o)||ArrayBuffer.isView(o)||o instanceof ArrayBuffer);if(r&&s){let o=t,l=o.every(h=>h.length===o[0].length),a=o.every(h=>Mf(h[0])||Qf(h[0]));if(l&&a){let h=new pl({type:"list",names:e,values:o.map(f=>wf(f))});le(h,n);let c=new ui([new gt("as.data.frame"),h]);return le(c,n),new Ln(c.eval())}}}finally{Oe(n.n)}throw new Error("Can't construct `data.frame`. Source object is not eligible.")}static fromD3(i){return this.fromObject(Object.fromEntries(Object.keys(i[0]).map(e=>[e,i.map(t=>t[e])])))}},jr=class extends z{exec(...i){let e={n:0};try{let t=new ui([this,...i]);return le(t,e),t.eval()}finally{Oe(e.n)}}capture(i={},...e){let t={n:0};try{let n=new ui([this,...e]);return le(n,t),n.capture(i)}finally{Oe(t.n)}}},Il=class extends z{constructor(i){if(i instanceof ye){pi(i,"string"),super(i);return}let e=T.allocateUTF8(i);try{super(new ye(T._Rf_mkChar(e)))}finally{T._free(e)}}toString(){return T.UTF8ToString(T._R_CHAR(this.ptr))}toJs(){return{type:"string",value:this.toString()}}},xf=class extends z{constructor(i={}){if(i instanceof ye)return pi(i,"environment"),super(i),this;let e=0;try{let{names:t,values:n}=zi(i),r=zr(T._R_NewEnv(xe.globalEnv.ptr,0,0));++e,n.forEach((s,o)=>{let l=t?t[o]:null;if(!l)throw new Error("Can't create object in new environment with empty symbol name");let a=new gt(l),h=zr(new z(s));try{rf(r,a,h)}finally{Oe(1)}}),super(new ye(r))}finally{Oe(e)}}ls(i=!1,e=!0){return zt.wrap(T._R_lsInternal3(this.ptr,Number(i),Number(e))).toArray()}bind(i,e){let t=new gt(i),n=zr(new z(e));try{rf(this,t,n)}finally{Oe(1)}}names(){return this.ls(!0,!0)}frame(){return z.wrap(T._FRAME(this.ptr))}subset(i){if(typeof i=="number")throw new Error("Object of type environment is not subsettable");return this.getDollar(i)}toObject({depth:i=-1}={}){let e=this.names();return Object.fromEntries([...Array(e.length).keys()].map(t=>{let n=this.getDollar(e[t]);return[e[t],i<0?n:n.toJs({depth:i})]}))}toJs(i={depth:0},e=1){let t=this.names(),n=[...Array(t.length).keys()].map(r=>i.depth&&e>=i.depth?this.getDollar(t[r]):this.getDollar(t[r]).toJs(i,e+1));return{type:"environment",names:t,values:n}}},ji=class extends z{constructor(i,e,t){if(i instanceof ye)return pi(i,e),super(i),this;let n={n:0};try{let{names:r,values:s}=zi(i),o=T._Rf_allocVector(mt[e],s.length);le(o,n),s.forEach(t(o)),z.wrap(o).setNames(r),super(new ye(o))}finally{Oe(n.n)}}get length(){return T._LENGTH(this.ptr)}get(i){return super.get(i)}subset(i){return super.subset(i)}getDollar(){throw new Error("$ operator is invalid for atomic vectors")}detectMissing(){let i={n:0};try{let e=T._Rf_lang2(new gt("is.na").ptr,this.ptr);le(e,i);let t=Ni.wrap(ls(e,xe.baseEnv));le(t,i);let n=t.toTypedArray();return Array.from(n).map(r=>!!r)}finally{Oe(i.n)}}toArray(){let i=this.toTypedArray();return this.detectMissing().map((e,t)=>e?null:i[t])}toObject({allowDuplicateKey:i=!0,allowEmptyKey:e=!1}={}){let t=this.entries(),n=t.map(([r])=>r);if(!i&&new Set(n).size!==n.length)throw new Error("Duplicate key when converting atomic vector without allowDuplicateKey enabled");if(!e&&n.some(r=>!r))throw new Error("Empty or null key when converting atomic vector without allowEmptyKey enabled");return Object.fromEntries(t.filter((r,s)=>t.findIndex(o=>o[0]===r[0])===s))}entries(){let i=this.toArray(),e=this.names();return i.map((t,n)=>[e?e[n]:null,t])}toJs(){return{type:this.type(),names:this.names(),values:this.toArray()}}},ml,kf=class extends ji{constructor(i){super(i,"logical",x(kf,ml))}getBoolean(i){return this.get(i).toArray()[0]}toBoolean(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getBoolean(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS boolean");return i}toTypedArray(){return new Int32Array(T.HEAP32.subarray(T._LOGICAL(this.ptr)/4,T._LOGICAL(this.ptr)/4+this.length))}toArray(){let i=this.toTypedArray();return this.detectMissing().map((e,t)=>e?null:!!i[t])}},Ni=kf;ml=new WeakMap,V(Ni,ml,i=>{let e=T._LOGICAL(i),t=T.getValue(T._R_NaInt,"i32");return(n,r)=>{T.setValue(e+4*r,n===null?t:!!n,"i32")}});var gl,Sf=class extends ji{constructor(i){super(i,"integer",x(Sf,gl))}getNumber(i){return this.get(i).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getNumber(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS number");return i}toTypedArray(){return new Int32Array(T.HEAP32.subarray(T._INTEGER(this.ptr)/4,T._INTEGER(this.ptr)/4+this.length))}},Tf=Sf;gl=new WeakMap,V(Tf,gl,i=>{let e=T._INTEGER(i),t=T.getValue(T._R_NaInt,"i32");return(n,r)=>{T.setValue(e+4*r,n===null?t:Math.round(Number(n)),"i32")}});var Ol,Pf=class extends ji{constructor(i){super(i,"double",x(Pf,Ol))}getNumber(i){return this.get(i).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getNumber(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS number");return i}toTypedArray(){return new Float64Array(T.HEAPF64.subarray(T._REAL(this.ptr)/8,T._REAL(this.ptr)/8+this.length))}},hs=Pf;Ol=new WeakMap,V(hs,Ol,i=>{let e=T._REAL(i),t=T.getValue(T._R_NaReal,"double");return(n,r)=>{T.setValue(e+8*r,n===null?t:n,"double")}});var yl,Cf=class extends ji{constructor(i){super(i,"complex",x(Cf,yl))}getComplex(i){return this.get(i).toArray()[0]}toComplex(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getComplex(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS object");return i}toTypedArray(){return new Float64Array(T.HEAPF64.subarray(T._COMPLEX(this.ptr)/8,T._COMPLEX(this.ptr)/8+2*this.length))}toArray(){let i=this.toTypedArray();return this.detectMissing().map((e,t)=>e?null:{re:i[2*t],im:i[2*t+1]})}},Nl=Cf;yl=new WeakMap,V(Nl,yl,i=>{let e=T._COMPLEX(i),t=T.getValue(T._R_NaReal,"double");return(n,r)=>{T.setValue(e+8*(2*r),n===null?t:n.re,"double"),T.setValue(e+8*(2*r+1),n===null?t:n.im,"double")}});var bl,Rf=class extends ji{constructor(i){super(i,"character",x(Rf,bl))}getString(i){return this.get(i).toArray()[0]}toString(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getString(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS string");return i}toTypedArray(){return new Uint32Array(T.HEAPU32.subarray(T._STRING_PTR(this.ptr)/4,T._STRING_PTR(this.ptr)/4+this.length))}toArray(){return this.detectMissing().map((i,e)=>i?null:T.UTF8ToString(T._R_CHAR(T._STRING_ELT(this.ptr,e))))}},zt=Rf;bl=new WeakMap,V(zt,bl,i=>(e,t)=>{e===null?T._SET_STRING_ELT(i,t,xe.naString.ptr):T._SET_STRING_ELT(i,t,new Il(e).ptr)});var wl,Ef=class extends ji{constructor(i){i instanceof ArrayBuffer&&(i=new Uint8Array(i)),super(i,"raw",x(Ef,wl))}getNumber(i){return this.get(i).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getNumber(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS number");return i}toTypedArray(){return new Uint8Array(T.HEAPU8.subarray(T._RAW(this.ptr),T._RAW(this.ptr)+this.length))}},jl=Ef;wl=new WeakMap,V(jl,wl,i=>{let e=T._RAW(i);return(t,n)=>{T.setValue(e+n,Number(t),"i8")}});function zi(i){return yf(i)?i:Array.isArray(i)||ArrayBuffer.isView(i)?{names:null,values:i}:i&&typeof i=="object"&&!os(i)?{names:Object.keys(i),values:Object.values(i)}:{names:null,values:[i]}}function Af(i){let e={object:z,null:vf,symbol:gt,pairlist:as,closure:jr,environment:xf,call:ui,special:jr,builtin:jr,string:Il,logical:Ni,integer:Tf,double:hs,complex:Nl,character:zt,list:pl,raw:jl,function:jr,dataframe:Ln};return i in e?e[i]:z}function Kr(i){return i instanceof z}function Qf(i){let e=["logical","integer","double","complex","character"];return Kr(i)&&e.includes(i.type())||Kr(i)&&i.isNa()}function Mf(i){return i===null||typeof i=="number"||typeof i=="boolean"||typeof i=="string"||os(i)}var xe;function cs(){let i={resolve:()=>{},reject:()=>{},promise:Promise.resolve()},e=new Promise((t,n)=>{i.resolve=t,i.reject=n});return i.promise=e,i}function qO(i){return new Promise(e=>setTimeout(e,i))}function Ut(i,e,t,...n){return i==null||XO(i)?i:i instanceof ArrayBuffer?new Uint8Array(i):e(i)?t(i,...n):Array.isArray(i)||ArrayBuffer.isView(i)?i.map(r=>Ut(r,e,t,...n)):i instanceof ye?i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([r,s])=>[r,Ut(s,e,t,...n)])):i}function zl(i,e){let t=new XMLHttpRequest;t.open("get",i,!0),t.onload=()=>{let n=new Worker(URL.createObjectURL(new Blob([t.responseText])));e(n)},t.send()}function Ul(i){if(Ie)return!1;let e=new URL(location.href),t=new URL(i,location.origin);return!(e.host===t.host&&e.port===t.port&&e.protocol===t.protocol)}function XO(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}var BO=Bi(Wl()),WO=new TextEncoder;async function IO(i,e,t){try{let{taskId:n,sizeBuffer:r,dataBuffer:s,signalBuffer:o}=e,l=(0,BO.encode)(t),a=l.length<=s.length;if(Atomics.store(r,0,l.length),Atomics.store(r,1,+a),!a){let[h,c]=NO(i);s.set(WO.encode(h)),await of(o,n),s=(await c).dataBuffer}s.set(l),Atomics.store(r,1,1),await of(o,n)}catch(n){console.warn(n)}}function NO(i){let e=bf();return[e,new Promise(t=>{Ie?i.once("message",n=>{!n.id||n.id!==e||t(n)}):i.addEventListener("message",function n(r){!r.data||!r.data.id||r.data.id!==e||(i.removeEventListener("message",n),t(r.data))}),i.start&&i.start()})]}async function of(i,e){let t=(e>>1)%32,n=1;for(;Atomics.compareExchange(i,t+1,0,e)!==0;)await qO(n),n<32&&(n*=2);Atomics.or(i,0,1<{x(this,At).push(i)}))};function jO(i,e){return _f({type:"request",data:{uuid:bf(),msg:i}},e)}function xl(i,e,t){return _f({type:"response",data:{uuid:i,resp:e}},t)}function _f(i,e){return e&&DO(i,e),i}function zO(i){let e=new Of(i.obj.message);return i.obj.name!=="Error"&&(e.name=i.obj.name),e.stack=i.obj.stack,e}function UO(i){return!!i&&typeof i=="object"&&"payloadType"in i&&"obj"in i}function Df(i){return UO(i)&&i.payloadType==="ptr"}var An,Fl=class{constructor(){this.inputQueue=new dl,this.outputQueue=new dl,this.systemQueue=new dl,V(this,An,new Map)}async read(){return await this.outputQueue.get()}async flush(){let i=[];for(;!this.outputQueue.isEmpty();)i.push(await this.read());return i}async readSystem(){return await this.systemQueue.get()}write(i){this.inputQueue.put(i)}async request(i,e){let t=jO(i,e),{resolve:n,reject:r,promise:s}=cs();return x(this,An).set(t.data.uuid,{resolve:n,reject:r}),this.write(t),s}putClosedMessage(){this.outputQueue.put({type:"closed"})}resolveResponse(i){let e=i.data.uuid,t=x(this,An).get(e);if(t){let n=i.data.resp;x(this,An).delete(e),n.payloadType==="err"?t.reject(zO(n)):t.resolve(n)}else console.warn("Can't find request.")}};An=new WeakMap;var lS=Bi(Wl()),aS=new TextDecoder("utf-8"),FO,HO,GO,YO,ZO;FO=new WeakMap,HO=new WeakMap,GO=new WeakMap,YO=new WeakMap,ZO=new WeakMap;var hS=new Int32Array(new ArrayBuffer(4));Ie&&(globalThis.Worker=Xi("worker_threads").Worker);var Qn,kl,$f,Hr,lf=class extends Fl{constructor(i){super(),V(this,kl),V(this,Qn,void 0),this.close=()=>{},V(this,Hr,async(t,n)=>{if(!(!n||!n.type))switch(n.type){case"resolve":me(this,Qn,new Int32Array(n.data)),this.resolve();return;case"response":this.resolveResponse(n);return;case"system":this.systemQueue.put(n.data);return;default:this.outputQueue.put(n);return;case"sync-request":{let r=n,s=r.data.msg,o=r.data.reqData;switch(s.type){case"read":{let l=await this.inputQueue.get();await IO(t,o,l);break}default:throw new pt(`Unsupported request type '${s.type}'.`)}return}case"request":throw new pt("Can't send messages of type 'request' from a worker. Please Use 'sync-request' instead.")}});let e=t=>{Je(this,kl,$f).call(this,t),this.close=()=>{t.terminate(),this.putClosedMessage()};let n={type:"init",data:{config:i,channelType:Qt.SharedArrayBuffer}};t.postMessage(n)};if(Ul(i.baseUrl))zl(`${i.baseUrl}webr-worker.js`,t=>e(t));else{let t=new Worker(`${i.baseUrl}webr-worker.js`);e(t)}({resolve:this.resolve,promise:this.initialised}=cs())}interrupt(){if(!x(this,Qn))throw new pt("Failed attempt to interrupt before initialising interruptBuffer");this.inputQueue.reset(),x(this,Qn)[0]=1}};Qn=new WeakMap,kl=new WeakSet,$f=function(i){Ie?i.on("message",e=>{x(this,Hr).call(this,i,e)}):i.onmessage=e=>x(this,Hr).call(this,i,e.data)},Hr=new WeakMap;var JO,KO,e0,t0;JO=new WeakMap,KO=new WeakMap,e0=new WeakMap,t0=new WeakMap;var cS=Bi(Wl());Ie&&(globalThis.Worker=Xi("worker_threads").Worker);var _n,Ii,Dn,Sl,Lf,Tl,af,Pl,Vf,Gr,i0=class extends Fl{constructor(i){super(),V(this,Sl),V(this,Tl),V(this,Pl),this.close=()=>{},V(this,_n,new Map),V(this,Ii,void 0),V(this,Dn,!1),V(this,Gr,(t,n)=>{if(!(!n||!n.type))switch(n.type){case"resolve":this.resolve();return;case"response":this.resolveResponse(n);return;case"system":this.systemQueue.put(n.data);return;default:this.outputQueue.put(n);return;case"sync-request":{let r=n.data;x(this,_n).set(r.data.uuid,r.data.msg);return}case"request":throw new pt("Can't send messages of type 'request' from a worker.Use service worker fetch request instead.")}}),console.warn("The ServiceWorker communication channel is deprecated and will be removed in a future version of webR. Consider using the PostMessage channel instead. If blocking input is required (for example, `browser()`) the SharedArrayBuffer channel should be used. See https://docs.r-wasm.org/webr/latest/serving.html for further information.");let e=t=>{Je(this,Pl,Vf).call(this,t),this.close=()=>{t.terminate(),this.putClosedMessage()},Je(this,Sl,Lf).call(this,`${i.serviceWorkerUrl}webr-serviceworker.js`).then(n=>{let r={type:"init",data:{config:i,channelType:Qt.ServiceWorker,clientId:n,location:window.location.href}};t.postMessage(r)})};if(Ul(i.serviceWorkerUrl))zl(`${i.serviceWorkerUrl}webr-worker.js`,t=>e(t));else{let t=new Worker(`${i.serviceWorkerUrl}webr-worker.js`);e(t)}({resolve:this.resolve,promise:this.initialised}=cs())}activeRegistration(){var i;if(!((i=x(this,Ii))!=null&&i.active))throw new pt("Attempted to obtain a non-existent active registration.");return x(this,Ii).active}interrupt(){me(this,Dn,!0)}};_n=new WeakMap,Ii=new WeakMap,Dn=new WeakMap,Sl=new WeakSet,Lf=async function(i){me(this,Ii,await navigator.serviceWorker.register(i)),await navigator.serviceWorker.ready,window.addEventListener("beforeunload",()=>{var t;(t=x(this,Ii))==null||t.unregister()});let e=await new Promise(t=>{navigator.serviceWorker.addEventListener("message",function n(r){r.data.type==="registration-successful"&&(navigator.serviceWorker.removeEventListener("message",n),t(r.data.clientId))}),this.activeRegistration().postMessage({type:"register-client-main"})});return navigator.serviceWorker.addEventListener("message",t=>{Je(this,Tl,af).call(this,t)}),e},Tl=new WeakSet,af=async function(i){if(i.data.type==="request"){let e=i.data.data,t=x(this,_n).get(e);if(!t)throw new pt("Request not found during service worker XHR request");switch(x(this,_n).delete(e),t.type){case"read":{let n=await this.inputQueue.get();this.activeRegistration().postMessage({type:"wasm-webr-fetch-response",uuid:e,response:xl(e,n)});break}case"interrupt":{let n=x(this,Dn);this.activeRegistration().postMessage({type:"wasm-webr-fetch-response",uuid:e,response:xl(e,n)}),this.inputQueue.reset(),me(this,Dn,!1);break}default:throw new pt(`Unsupported request type '${t.type}'.`)}return}},Pl=new WeakSet,Vf=function(i){Ie?i.on("message",e=>{x(this,Gr).call(this,i,e)}):i.onmessage=e=>x(this,Gr).call(this,i,e.data)},Gr=new WeakMap;var n0,r0,s0,o0,l0,a0;n0=new WeakMap,r0=new WeakMap,s0=new WeakMap,o0=new WeakMap,l0=new WeakMap,a0=new WeakMap;Ie&&(globalThis.Worker=Xi("worker_threads").Worker);var Mn,Cl,qf,Yr,hf=class extends Fl{constructor(i){super(),V(this,Cl),this.close=()=>{},V(this,Mn,void 0),V(this,Yr,async(t,n)=>{if(!(!n||!n.type))switch(n.type){case"resolve":this.resolve();return;case"response":this.resolveResponse(n);return;case"system":this.systemQueue.put(n.data);return;default:this.outputQueue.put(n);return;case"request":{let r=n,s=r.data.msg;switch(s.type){case"read":{let o=await this.inputQueue.get();if(x(this,Mn)){let l=xl(r.data.uuid,o);x(this,Mn).postMessage(l)}break}default:throw new pt(`Unsupported request type '${s.type}'.`)}return}case"sync-request":throw new pt("Can't send messages of type 'sync-request' in PostMessage mode. Use 'request' instead.")}});let e=t=>{me(this,Mn,t),Je(this,Cl,qf).call(this,t),this.close=()=>t.terminate();let n={type:"init",data:{config:i,channelType:Qt.PostMessage}};t.postMessage(n)};if(Ul(i.baseUrl))zl(`${i.baseUrl}webr-worker.js`,t=>e(t));else{let t=new Worker(`${i.baseUrl}webr-worker.js`);e(t)}({resolve:this.resolve,promise:this.initialised}=cs())}interrupt(){console.error("Interrupting R execution is not available when using the PostMessage channel")}};Mn=new WeakMap,Cl=new WeakSet,qf=function(i){Ie?i.on("message",e=>{x(this,Yr).call(this,i,e)}):i.onmessage=e=>x(this,Yr).call(this,i,e.data)},Yr=new WeakMap;var h0,c0,f0,u0,d0;h0=new WeakMap,c0=new WeakMap,f0=new WeakMap,u0=new WeakMap,d0=new WeakMap;var Qt={Automatic:0,SharedArrayBuffer:1,ServiceWorker:2,PostMessage:3};function p0(i){switch(i.channelType){case Qt.SharedArrayBuffer:return new lf(i);case Qt.ServiceWorker:return new i0(i);case Qt.PostMessage:return new hf(i);case Qt.Automatic:default:return typeof SharedArrayBuffer<"u"?new lf(i):new hf(i)}}var m0=Ie?__dirname+"/":"https://webr.r-wasm.org/v0.4.0/",g0="https://repo.r-wasm.org",Xf="0.4.0";function se(i){return!!i&&(typeof i=="object"||typeof i=="function")&&"payloadType"in i&&Df(i._payload)}function Se(i){return se(i)&&i._payload.obj.type==="null"}function O0(i){return se(i)&&i._payload.obj.type==="symbol"}function y0(i){return se(i)&&i._payload.obj.type==="pairlist"}function b0(i){return se(i)&&i._payload.obj.type==="environment"}function w0(i){return se(i)&&i._payload.obj.type==="logical"}function v0(i){return se(i)&&i._payload.obj.type==="integer"}function x0(i){return se(i)&&i._payload.obj.type==="double"}function k0(i){return se(i)&&i._payload.obj.type==="complex"}function Ui(i){return se(i)&&i._payload.obj.type==="character"}function ot(i){return se(i)&&i._payload.obj.type==="list"}function S0(i){return se(i)&&i._payload.obj.type==="raw"}function Hl(i){return se(i)&&i._payload.obj.type==="call"}function fs(i){var e;return!!(se(i)&&(e=i._payload.obj.methods)!=null&&e.includes("exec"))}function T0(){}function P0(i,e){return async function*(){let t={type:"callRObjectMethod",data:{payload:e._payload,prop:"getPropertyValue",args:[{payloadType:"raw",obj:"length"}],shelter:void 0}},n=await i.request(t);if(typeof n.obj!="number")throw new di("Cannot iterate over object, unexpected type for length property.");for(let r=1;r<=n.obj;r++)yield e.get(r)}}function Bf(i,e,t){return async(...n)=>{let r=n.map(l=>se(l)?l._payload:{obj:Ut(l,se,a=>a._payload),payloadType:"raw"}),s={type:"callRObjectMethod",data:{payload:t,prop:e,args:r}},o=await i.request(s);switch(o.payloadType){case"ptr":return fi(i,o);case"raw":return Ut(o,Df,(l,a)=>fi(a,l),i).obj}}}async function C0(i,e,t,...n){let r={type:"newRObject",data:{objType:e,args:Ut(n,se,o=>o._payload),shelter:t}},s=await i.request(r);switch(s.payloadType){case"raw":throw new $n("Unexpected raw payload type returned from newRObject");case"ptr":return fi(i,s)}}function fi(i,e){var t;let n=new Proxy((t=e.obj.methods)!=null&&t.includes("exec")?Object.assign(T0,{...e}):e,{get:(r,s)=>{var o;if(s==="_payload")return e;if(s===Symbol.asyncIterator)return P0(i,n);if((o=e.obj.methods)!=null&&o.includes(s.toString()))return Bf(i,s.toString(),e)},apply:async(r,s,o)=>{let l=await fi(i,e).exec(...o);return fs(l)?l:l.toJs()}});return n}function Le(i,e,t){return new Proxy(z,{construct:(n,r)=>C0(i,t,e,...r),get:(n,r)=>Bf(i,r.toString())})}var es,ts,is,ns,rs,Rl,El,Al,Ql,Ml,_l,Wf,R0=class{constructor(i={},e={REnv:{R_HOME:"/usr/lib/R",FONTCONFIG_PATH:"/etc/fonts",R_ENABLE_JIT:"0"}}){V(this,_l),V(this,es,void 0),V(this,ts,void 0),V(this,is,void 0),V(this,ns,void 0),V(this,rs,void 0),V(this,Rl,t=>{console.log(t)}),V(this,El,t=>{console.error(t)}),V(this,Al,t=>{let n=prompt(t);n&&this.stdin(`${n}
+`});var oO=jt((ZP,Gk)=>{Gk.exports="CmltcG9ydCBweW9kaWRlICMgdHlwZTogaWdub3JlW2F0dHItZGVmaW5lZF0KaW1wb3J0IHN5cwoKIyBDbGVhbnVwIGFueSBsZWZ0b3ZlciBtYXRwbG90bGliIHBsb3RzCnRyeToKICBpbXBvcnQgbWF0cGxvdGxpYi5weXBsb3QgYXMgcGx0CiAgcGx0LmNsb3NlKCJhbGwiKQpleGNlcHQgTW9kdWxlTm90Rm91bmRFcnJvcjoKICBwYXNzCgpmcm9tIElQeXRob24udXRpbHMgaW1wb3J0IGNhcHR1cmUKZnJvbSBJUHl0aG9uLmRpc3BsYXkgaW1wb3J0IGRpc3BsYXkKZnJvbSBJUHl0aG9uLmNvcmUuaW50ZXJhY3RpdmVzaGVsbCBpbXBvcnQgSW50ZXJhY3RpdmVTaGVsbApJbnRlcmFjdGl2ZVNoZWxsKCkuaW5zdGFuY2UoKQoKd2l0a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CiAgICBkZWYgc2V0X2Rhc2hlcyhzZWxmLCBkYXNoX29mZnNldCwgZGFzaF9saXN0KToKICAgICAgICBzZWxmLl9kYXNoZXMgPSBkYXNoX29mZnNldCwgZGFzaF9saXN0CiAgICAgICAgaWYgZGFzaF9vZmZzZXQgaXMgbm90IE5vbmU6CiAgICAgICAgICAgIHNlbGYucmVuZGVyZXIuY3R4LmxpbmVEYXNoT2Zmc2V0ID0gZGFzaF9vZmZzZXQKICAgICAgICBpZiBkYXNoX2xpc3QgaXMgTm9uZToKICAgICAgICAgICAgc2VsZi5yZW5kZXJlci5jdHguc2V0TGluZURhc2goW10pCiAgICAgICAgZWxzZToKICAgICAgICAgICAgZGxuID0gbnAuYXNhcnJheShkYXNoX2xpc3QpCiAgICAgICAgICAgIGRsID0gbGlzdChzZWxmLnJlbmRlcmVyLnBvaW50c190b19waXhlbHMoZGxuKSkKICAgICAgICAgICAgc2VsZi5yZW5kZXJlci5jdHguc2V0TGluZURhc2goZGwpCgogICAgZGVmIHNldF9qb2luc3R5bGUoc2VsZiwganMpOgogICAgICAgIGlmIGpzIGluIFsibWl0ZXIiLCAicm91bmQiLCAiYmV2ZWwiXToKICAgICAgICAgICAgc2VsZi5fam9pbnN0eWxlID0ganMKICAgICAgICAgICAgc2VsZi5yZW5kZXJlci5jdHgubGluZUpvaW4gPSBqcwogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHJhaXNlIFZhbHVlRXJyb3IoZiJVbnJlY29nbml6ZWQgam9pbiBzdHlsZS4gRm91bmQge2pzfSIpCgogICAgZGVmIHNldF9saW5ld2lkdGgoc2VsZiwgdyk6CiAgICAgICAgc2VsZi5zdHJva2UgPSB3ICE9IDAKICAgICAgICBzZWxmLl9saW5ld2lkdGggPSBmbG9hdCh3KQogICAgICAgIHNlbGYucmVuZGVyZXIuY3R4LmxpbmVXaWR0aCA9IHNlbGYucmVuZGVyZXIucG9pbnRzX3RvX3BpeGVscyhmbG9hdCh3KSkKCmNsYXNzIFJlbm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LCBHLCBCKQoKICAgICAgICBpZiAobGVuKGNvbG9yKSA9PSA0KSBhbmQgKGFscGhhIGlzIE5vbmUpOgogICAgICAgICAgICBhbHBoYSA9IGNvbG9yWzNdCgogICAgICAgIGlmIGFscGhhIGlzIE5vbmU6CiAgICAgICAgICAgIENTU19jb2xvciA9IHJnYjJoZXgoY29sb3JbOjNdKQoKICAgICAgICBlbHNlOgogICAgICAgICAgICBSID0gaW50KGNvbG9yWzBdICogMjU1KQogICAgICAgICAgICBHID0gaW50KGNvbG9yWzFdICogMjU1KQogICAgICAgICAgICBCID0gaW50KGNvbG9yWzJdICogMjU1KQogICAgICAgICAgICBpZiBsZW4oY29sb3IpID09IDMgb3IgYWxwaGFfb3ZlcnJpZGVzOgogICAgICAgICAgICAgICAgQ1NTX2NvbG9yID0gZiIiInJnYmEoe1I6ZH0sIHtHOmR9LCB7QjpkfSwge2FscGhhOi4zZ30pIiIiCiAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICBDU1NfY29sb3IgPSAiIiJyZ2JhKHs6ZH0sIHs6ZH0sIHs6ZH0sIHs6LjNnfSkiIiIuZm9ybWF0KAogICAgICAgICAgICAgICAgICAgIFIsIEcsIEIsIGNvbG9yWzNdCiAgICAgICAgICAgICAgICApCgogICAgICAgIHJldHVybiBDU1NfY29sb3IKCiAgICBkZWYgX3NldF9zdHlsZShzZWxmLCBnYywgcmdiRmFjZT1Ob25lKToKICAgICAgICBpZiByZ2JGYWNlIGlzIG5vdCBOb25lOgogICAgICAgICAgICBzZWxmLmN0eC5maWxsU3R5bGUgPSBzZWxmLl9tYXRwbG90bGliX2NvbG9yX3RvX0NTUygKICAgICAgICAgICAgICAgIHJnYkZhY2UsIGdjLmdldF9hbHBoYSgpLCBnYy5nZXRfZm9yY2VkX2FscGhhKCkKICAgICAgICAgICAgKQoKICAgICAgICBpZiBnYy5nZXRfY2Fwc3R5bGUoKToKICAgICAgICAgICAgc2VsZi5jdHgubGluZUNhcCA9IF9jYXBz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ToKICAgICAgICAgICAgZm5hbWUgPSBmaW5kZm9udChwcm9wKQogICAgICAgICAgICBmb250X3ZhbHVlID0gc2VsZi5mb250ZC5nZXQoZm5hbWUpCiAgICAgICAgICAgIGlmIGZvbnRfdmFsdWUgaXMgTm9uZToKICAgICAgICAgICAgICAgIGZvbnQgPSBGVDJGb250KHN0cihmbmFtZSkpCiAgICAgICAgICAgICAgICBmb250X2ZpbGVfbmFtZSA9IGZuYW1lW2ZuYW1lLnJmaW5kKCIvIikgKyAxIDpdCiAgICAgICAgICAgICAgICBmb250X3ZhbHVlID0gZm9udCwgZm9udF9maWxlX25hbWUKICAgICAgICAgICAgICAgIHNlbGYuZm9udGRbZm5hbWVdID0gZm9udF92YWx1ZQogICAgICAgICAgICBzZWxmLmZvbnRkW2tleV0gPSBmb250X3ZhbHVlCiAgICAgICAgZm9udCwgZm9udF9maWxlX25hbWUgPSBmb250X3ZhbHVlCiAgICAgICAgZm9udC5jbGVhcigpCiAgICAgICAgZm9udC5zZXRfc2l6ZShwcm9wLmdldF9zaXplX2luX3BvaW50cygpLCBzZWxmLmRwaSkKICAgICAgICByZXR1cm4gZm9udCwgZm9udF9maWxlX25hbWUKCiAgICBkZWYgZ2V0X3RleHRfd2lkdGhfaGVpZ2h0X2Rlc2NlbnQoc2VsZiwgcywgcHJvcCwgaXNtYXRoKToKICAgICAgICB3OiBmbG9hdAogICAgICAgIGg6IGZsb2F0CiAgICAgICAgaWYgaXNtYXRoOgogICAgICAgICAgICBpbWFnZSwgZCA9IHNlbGYubWF0aHRleHRfcGFyc2VyLnBhcnNlKHMsIHNlbGYuZHBpLCBwcm9wKQogICAgICAgICAgICBpbWFnZV9hcnIgPSBucC5hc2FycmF5KGltYWdlKQogICAgICAgICAgICBoLCB3ID0gaW1hZ2VfYXJyLnNoYXBlCiAgICAgICAgZWxzZToKICAgICAgICAgICAgZm9udCwgXyA9IHNlbGYuX2dldF9mb250KHByb3ApCiAgICAgICAgICAgIGZvbnQuc2V0X3RleHQ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Nob3coKmFyZ3MsICoqa3dhcmdzKQoKICAgIEBzdGF0aWNtZXRob2QKICAgIGRlZiBkZXN0cm95KCphcmdzLCAqKmt3YXJncyk6CiAgICAgICAgZnJvbSBtYXRwbG90bGliIGltcG9ydCBweXBsb3QgYXMgcGx0CiAgICAgICAgcGx0LmdjZigpLmNhbnZhcy5kZXN0cm95KCphcmdzLCAqKmt3YXJncykK"});var Gl={};OO(Gl,{ChannelType:()=>Qt,Console:()=>R0,Shelter:()=>$l,WebR:()=>Nf,WebRChannelError:()=>pt,WebRError:()=>di,WebRPayloadError:()=>$n,WebRWorkerError:()=>Of,isRCall:()=>Hl,isRCharacter:()=>Ui,isRComplex:()=>k0,isRDouble:()=>x0,isREnvironment:()=>b0,isRFunction:()=>fs,isRInteger:()=>v0,isRList:()=>ot,isRLogical:()=>w0,isRNull:()=>Se,isRObject:()=>se,isRPairlist:()=>y0,isRRaw:()=>S0,isRSymbol:()=>O0});var yO=Object.create,ff=Object.defineProperty,bO=Object.getOwnPropertyDescriptor,wO=Object.getOwnPropertyNames,vO=Object.getPrototypeOf,xO=Object.prototype.hasOwnProperty,Xi=(i=>typeof ci<"u"?ci:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof ci<"u"?ci:e)[t]}):i)(function(i){if(typeof ci<"u")return ci.apply(this,arguments);throw new Error('Dynamic require of "'+i+'" is not supported')}),ke=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),kO=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of wO(e))!xO.call(i,r)&&r!==t&&ff(i,r,{get:()=>e[r],enumerable:!(n=bO(e,r))||n.enumerable});return i},Bi=(i,e,t)=>(t=i!=null?yO(vO(i)):{},kO(e||!i||!i.__esModule?ff(t,"default",{value:i,enumerable:!0}):t,i)),Ll=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},x=(i,e,t)=>(Ll(i,e,"read from private field"),t?t.call(i):e.get(i)),V=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},me=(i,e,t,n)=>(Ll(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);var Je=(i,e,t)=>(Ll(i,e,"access private method"),t),ss=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.getUint64=i.getInt64=i.setInt64=i.setUint64=i.UINT32_MAX=void 0,i.UINT32_MAX=4294967295;function e(s,o,l){let a=l/4294967296,h=l;s.setUint32(o,a),s.setUint32(o+4,h)}i.setUint64=e;function t(s,o,l){let a=Math.floor(l/4294967296),h=l;s.setUint32(o,a),s.setUint32(o+4,h)}i.setInt64=t;function n(s,o){let l=s.getInt32(o),a=s.getUint32(o+4);return l*4294967296+a}i.getInt64=n;function r(s,o){let l=s.getUint32(o),a=s.getUint32(o+4);return l*4294967296+a}i.getUint64=r}),Vl=ke(i=>{"use strict";var e,t,n;Object.defineProperty(i,"__esModule",{value:!0}),i.utf8DecodeTD=i.TEXT_DECODER_THRESHOLD=i.utf8DecodeJs=i.utf8EncodeTE=i.TEXT_ENCODER_THRESHOLD=i.utf8EncodeJs=i.utf8Count=void 0;var r=ss(),s=(typeof process>"u"||((e=process==null?void 0:process.env)===null||e===void 0?void 0:e.TEXT_ENCODING)!=="never")&&typeof TextEncoder<"u"&&typeof TextDecoder<"u";function o(p){let g=p.length,O=0,y=0;for(;y=55296&&k<=56319&&y>6&31|192;else{if(w>=55296&&w<=56319&&v>18&7|240,g[k++]=w>>12&63|128,g[k++]=w>>6&63|128):(g[k++]=w>>12&15|224,g[k++]=w>>6&63|128)}else{g[k++]=w;continue}g[k++]=w&63|128}}i.utf8EncodeJs=l;var a=s?new TextEncoder:void 0;i.TEXT_ENCODER_THRESHOLD=s?typeof process<"u"&&((t=process==null?void 0:process.env)===null||t===void 0?void 0:t.TEXT_ENCODING)!=="force"?200:0:r.UINT32_MAX;function h(p,g,O){g.set(a.encode(p),O)}function c(p,g,O){a.encodeInto(p,g.subarray(O))}i.utf8EncodeTE=a!=null&&a.encodeInto?c:h;var f=4096;function u(p,g,O){let y=g,k=y+O,v=[],w="";for(;y65535&&(L-=65536,v.push(L>>>10&1023|55296),L=56320|L&1023),v.push(L)}else v.push(P);v.length>=f&&(w+=String.fromCharCode(...v),v.length=0)}return v.length>0&&(w+=String.fromCharCode(...v)),w}i.utf8DecodeJs=u;var d=s?new TextDecoder:null;i.TEXT_DECODER_THRESHOLD=s?typeof process<"u"&&((n=process==null?void 0:process.env)===null||n===void 0?void 0:n.TEXT_DECODER)!=="force"?200:0:r.UINT32_MAX;function m(p,g,O){let y=p.subarray(g,g+O);return d.decode(y)}i.utf8DecodeTD=m}),uf=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ExtData=void 0;var e=class{constructor(t,n){this.type=t,this.data=n}};i.ExtData=e}),ql=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.DecodeError=void 0;var e=class extends Error{constructor(t){super(t);let n=Object.create(e.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};i.DecodeError=e}),df=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.timestampExtension=i.decodeTimestampExtension=i.decodeTimestampToTimeSpec=i.encodeTimestampExtension=i.encodeDateToTimeSpec=i.encodeTimeSpecToTimestamp=i.EXT_TIMESTAMP=void 0;var e=ql(),t=ss();i.EXT_TIMESTAMP=-1;var n=4294967296-1,r=17179869184-1;function s({sec:c,nsec:f}){if(c>=0&&f>=0&&c<=r)if(f===0&&c<=n){let u=new Uint8Array(4);return new DataView(u.buffer).setUint32(0,c),u}else{let u=c/4294967296,d=c&4294967295,m=new Uint8Array(8),p=new DataView(m.buffer);return p.setUint32(0,f<<2|u&3),p.setUint32(4,d),m}else{let u=new Uint8Array(12),d=new DataView(u.buffer);return d.setUint32(0,f),(0,t.setInt64)(d,4,c),u}}i.encodeTimeSpecToTimestamp=s;function o(c){let f=c.getTime(),u=Math.floor(f/1e3),d=(f-u*1e3)*1e6,m=Math.floor(d/1e9);return{sec:u+m,nsec:d-m*1e9}}i.encodeDateToTimeSpec=o;function l(c){if(c instanceof Date){let f=o(c);return s(f)}else return null}i.encodeTimestampExtension=l;function a(c){let f=new DataView(c.buffer,c.byteOffset,c.byteLength);switch(c.byteLength){case 4:return{sec:f.getUint32(0),nsec:0};case 8:{let u=f.getUint32(0),d=f.getUint32(4),m=(u&3)*4294967296+d,p=u>>>2;return{sec:m,nsec:p}}case 12:{let u=(0,t.getInt64)(f,4),d=f.getUint32(0);return{sec:u,nsec:d}}default:throw new e.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${c.length}`)}}i.decodeTimestampToTimeSpec=a;function h(c){let f=a(c);return new Date(f.sec*1e3+f.nsec/1e6)}i.decodeTimestampExtension=h,i.timestampExtension={type:i.EXT_TIMESTAMP,encode:l,decode:h}}),Xl=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ExtensionCodec=void 0;var e=uf(),t=df(),n=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(t.timestampExtension)}register({type:r,encode:s,decode:o}){if(r>=0)this.encoders[r]=s,this.decoders[r]=o;else{let l=1+r;this.builtInEncoders[l]=s,this.builtInDecoders[l]=o}}tryToEncode(r,s){for(let o=0;o{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.createDataView=i.ensureUint8Array=void 0;function e(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n instanceof ArrayBuffer?new Uint8Array(n):Uint8Array.from(n)}i.ensureUint8Array=e;function t(n){if(n instanceof ArrayBuffer)return new DataView(n);let r=e(n);return new DataView(r.buffer,r.byteOffset,r.byteLength)}i.createDataView=t}),mf=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Encoder=i.DEFAULT_INITIAL_BUFFER_SIZE=i.DEFAULT_MAX_DEPTH=void 0;var e=Vl(),t=Xl(),n=ss(),r=pf();i.DEFAULT_MAX_DEPTH=100,i.DEFAULT_INITIAL_BUFFER_SIZE=2048;var s=class{constructor(o=t.ExtensionCodec.defaultCodec,l=void 0,a=i.DEFAULT_MAX_DEPTH,h=i.DEFAULT_INITIAL_BUFFER_SIZE,c=!1,f=!1,u=!1,d=!1){this.extensionCodec=o,this.context=l,this.maxDepth=a,this.initialBufferSize=h,this.sortKeys=c,this.forceFloat32=f,this.ignoreUndefined=u,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(o){return this.reinitializeState(),this.doEncode(o,1),this.bytes.subarray(0,this.pos)}encode(o){return this.reinitializeState(),this.doEncode(o,1),this.bytes.slice(0,this.pos)}doEncode(o,l){if(l>this.maxDepth)throw new Error(`Too deep objects in depth ${l}`);o==null?this.encodeNil():typeof o=="boolean"?this.encodeBoolean(o):typeof o=="number"?this.encodeNumber(o):typeof o=="string"?this.encodeString(o):this.encodeObject(o,l)}ensureBufferSizeToWrite(o){let l=this.pos+o;this.view.byteLength=0?o<128?this.writeU8(o):o<256?(this.writeU8(204),this.writeU8(o)):o<65536?(this.writeU8(205),this.writeU16(o)):o<4294967296?(this.writeU8(206),this.writeU32(o)):(this.writeU8(207),this.writeU64(o)):o>=-32?this.writeU8(224|o+32):o>=-128?(this.writeU8(208),this.writeI8(o)):o>=-32768?(this.writeU8(209),this.writeI16(o)):o>=-2147483648?(this.writeU8(210),this.writeI32(o)):(this.writeU8(211),this.writeI64(o)):this.forceFloat32?(this.writeU8(202),this.writeF32(o)):(this.writeU8(203),this.writeF64(o))}writeStringHeader(o){if(o<32)this.writeU8(160+o);else if(o<256)this.writeU8(217),this.writeU8(o);else if(o<65536)this.writeU8(218),this.writeU16(o);else if(o<4294967296)this.writeU8(219),this.writeU32(o);else throw new Error(`Too long string: ${o} bytes in UTF-8`)}encodeString(o){if(o.length>e.TEXT_ENCODER_THRESHOLD){let l=(0,e.utf8Count)(o);this.ensureBufferSizeToWrite(5+l),this.writeStringHeader(l),(0,e.utf8EncodeTE)(o,this.bytes,this.pos),this.pos+=l}else{let l=(0,e.utf8Count)(o);this.ensureBufferSizeToWrite(5+l),this.writeStringHeader(l),(0,e.utf8EncodeJs)(o,this.bytes,this.pos),this.pos+=l}}encodeObject(o,l){let a=this.extensionCodec.tryToEncode(o,this.context);if(a!=null)this.encodeExtension(a);else if(Array.isArray(o))this.encodeArray(o,l);else if(ArrayBuffer.isView(o))this.encodeBinary(o);else if(typeof o=="object")this.encodeMap(o,l);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(o)}`)}encodeBinary(o){let l=o.byteLength;if(l<256)this.writeU8(196),this.writeU8(l);else if(l<65536)this.writeU8(197),this.writeU16(l);else if(l<4294967296)this.writeU8(198),this.writeU32(l);else throw new Error(`Too large binary: ${l}`);let a=(0,r.ensureUint8Array)(o);this.writeU8a(a)}encodeArray(o,l){let a=o.length;if(a<16)this.writeU8(144+a);else if(a<65536)this.writeU8(220),this.writeU16(a);else if(a<4294967296)this.writeU8(221),this.writeU32(a);else throw new Error(`Too large array: ${a}`);for(let h of o)this.doEncode(h,l+1)}countWithoutUndefined(o,l){let a=0;for(let h of l)o[h]!==void 0&&a++;return a}encodeMap(o,l){let a=Object.keys(o);this.sortKeys&&a.sort();let h=this.ignoreUndefined?this.countWithoutUndefined(o,a):a.length;if(h<16)this.writeU8(128+h);else if(h<65536)this.writeU8(222),this.writeU16(h);else if(h<4294967296)this.writeU8(223),this.writeU32(h);else throw new Error(`Too large map object: ${h}`);for(let c of a){let f=o[c];this.ignoreUndefined&&f===void 0||(this.encodeString(c),this.doEncode(f,l+1))}}encodeExtension(o){let l=o.data.length;if(l===1)this.writeU8(212);else if(l===2)this.writeU8(213);else if(l===4)this.writeU8(214);else if(l===8)this.writeU8(215);else if(l===16)this.writeU8(216);else if(l<256)this.writeU8(199),this.writeU8(l);else if(l<65536)this.writeU8(200),this.writeU16(l);else if(l<4294967296)this.writeU8(201),this.writeU32(l);else throw new Error(`Too large extension object: ${l}`);this.writeI8(o.type),this.writeU8a(o.data)}writeU8(o){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,o),this.pos++}writeU8a(o){let l=o.length;this.ensureBufferSizeToWrite(l),this.bytes.set(o,this.pos),this.pos+=l}writeI8(o){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,o),this.pos++}writeU16(o){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,o),this.pos+=2}writeI16(o){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,o),this.pos+=2}writeU32(o){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,o),this.pos+=4}writeI32(o){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,o),this.pos+=4}writeF32(o){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,o),this.pos+=4}writeF64(o){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,o),this.pos+=8}writeU64(o){this.ensureBufferSizeToWrite(8),(0,n.setUint64)(this.view,this.pos,o),this.pos+=8}writeI64(o){this.ensureBufferSizeToWrite(8),(0,n.setInt64)(this.view,this.pos,o),this.pos+=8}};i.Encoder=s}),SO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.encode=void 0;var e=mf(),t={};function n(r,s=t){return new e.Encoder(s.extensionCodec,s.context,s.maxDepth,s.initialBufferSize,s.sortKeys,s.forceFloat32,s.ignoreUndefined,s.forceIntegerToFloat).encodeSharedRef(r)}i.encode=n}),TO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.prettyByte=void 0;function e(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}i.prettyByte=e}),PO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.CachedKeyDecoder=void 0;var e=Vl(),t=16,n=16,r=class{constructor(s=t,o=n){this.maxKeyLength=s,this.maxLengthPerKey=o,this.hit=0,this.miss=0,this.caches=[];for(let l=0;l0&&s<=this.maxKeyLength}find(s,o,l){let a=this.caches[l-1];e:for(let h of a){let c=h.bytes;for(let f=0;f=this.maxLengthPerKey?l[Math.random()*l.length|0]=a:l.push(a)}decode(s,o,l){let a=this.find(s,o,l);if(a!=null)return this.hit++,a;this.miss++;let h=(0,e.utf8DecodeJs)(s,o,l),c=Uint8Array.prototype.slice.call(s,o,o+l);return this.store(c,h),h}};i.CachedKeyDecoder=r}),Bl=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Decoder=i.DataViewIndexOutOfBoundsError=void 0;var e=TO(),t=Xl(),n=ss(),r=Vl(),s=pf(),o=PO(),l=ql(),a=p=>{let g=typeof p;return g==="string"||g==="number"},h=-1,c=new DataView(new ArrayBuffer(0)),f=new Uint8Array(c.buffer);i.DataViewIndexOutOfBoundsError=(()=>{try{c.getInt8(0)}catch(p){return p.constructor}throw new Error("never reached")})();var u=new i.DataViewIndexOutOfBoundsError("Insufficient data"),d=new o.CachedKeyDecoder,m=class{constructor(p=t.ExtensionCodec.defaultCodec,g=void 0,O=n.UINT32_MAX,y=n.UINT32_MAX,k=n.UINT32_MAX,v=n.UINT32_MAX,w=n.UINT32_MAX,P=d){this.extensionCodec=p,this.context=g,this.maxStrLength=O,this.maxBinLength=y,this.maxArrayLength=k,this.maxMapLength=v,this.maxExtLength=w,this.keyDecoder=P,this.totalPos=0,this.pos=0,this.view=c,this.bytes=f,this.headByte=h,this.stack=[]}reinitializeState(){this.totalPos=0,this.headByte=h,this.stack.length=0}setBuffer(p){this.bytes=(0,s.ensureUint8Array)(p),this.view=(0,s.createDataView)(this.bytes),this.pos=0}appendBuffer(p){if(this.headByte===h&&!this.hasRemaining(1))this.setBuffer(p);else{let g=this.bytes.subarray(this.pos),O=(0,s.ensureUint8Array)(p),y=new Uint8Array(g.length+O.length);y.set(g),y.set(O,g.length),this.setBuffer(y)}}hasRemaining(p){return this.view.byteLength-this.pos>=p}createExtraByteError(p){let{view:g,pos:O}=this;return new RangeError(`Extra ${g.byteLength-O} of ${g.byteLength} byte(s) found at buffer[${p}]`)}decode(p){this.reinitializeState(),this.setBuffer(p);let g=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return g}*decodeMulti(p){for(this.reinitializeState(),this.setBuffer(p);this.hasRemaining(1);)yield this.doDecodeSync()}async decodeAsync(p){let g=!1,O;for await(let w of p){if(g)throw this.createExtraByteError(this.totalPos);this.appendBuffer(w);try{O=this.doDecodeSync(),g=!0}catch(P){if(!(P instanceof i.DataViewIndexOutOfBoundsError))throw P}this.totalPos+=this.pos}if(g){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return O}let{headByte:y,pos:k,totalPos:v}=this;throw new RangeError(`Insufficient data in parsing ${(0,e.prettyByte)(y)} at ${v} (${k} in the current buffer)`)}decodeArrayStream(p){return this.decodeMultiAsync(p,!0)}decodeStream(p){return this.decodeMultiAsync(p,!1)}async*decodeMultiAsync(p,g){let O=g,y=-1;for await(let k of p){if(g&&y===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(k),O&&(y=this.readArraySize(),O=!1,this.complete());try{for(;yield this.doDecodeSync(),--y!==0;);}catch(v){if(!(v instanceof i.DataViewIndexOutOfBoundsError))throw v}this.totalPos+=this.pos}}doDecodeSync(){e:for(;;){let p=this.readHeadByte(),g;if(p>=224)g=p-256;else if(p<192)if(p<128)g=p;else if(p<144){let y=p-128;if(y!==0){this.pushMapState(y),this.complete();continue e}else g={}}else if(p<160){let y=p-144;if(y!==0){this.pushArrayState(y),this.complete();continue e}else g=[]}else{let y=p-160;g=this.decodeUtf8String(y,0)}else if(p===192)g=null;else if(p===194)g=!1;else if(p===195)g=!0;else if(p===202)g=this.readF32();else if(p===203)g=this.readF64();else if(p===204)g=this.readU8();else if(p===205)g=this.readU16();else if(p===206)g=this.readU32();else if(p===207)g=this.readU64();else if(p===208)g=this.readI8();else if(p===209)g=this.readI16();else if(p===210)g=this.readI32();else if(p===211)g=this.readI64();else if(p===217){let y=this.lookU8();g=this.decodeUtf8String(y,1)}else if(p===218){let y=this.lookU16();g=this.decodeUtf8String(y,2)}else if(p===219){let y=this.lookU32();g=this.decodeUtf8String(y,4)}else if(p===220){let y=this.readU16();if(y!==0){this.pushArrayState(y),this.complete();continue e}else g=[]}else if(p===221){let y=this.readU32();if(y!==0){this.pushArrayState(y),this.complete();continue e}else g=[]}else if(p===222){let y=this.readU16();if(y!==0){this.pushMapState(y),this.complete();continue e}else g={}}else if(p===223){let y=this.readU32();if(y!==0){this.pushMapState(y),this.complete();continue e}else g={}}else if(p===196){let y=this.lookU8();g=this.decodeBinary(y,1)}else if(p===197){let y=this.lookU16();g=this.decodeBinary(y,2)}else if(p===198){let y=this.lookU32();g=this.decodeBinary(y,4)}else if(p===212)g=this.decodeExtension(1,0);else if(p===213)g=this.decodeExtension(2,0);else if(p===214)g=this.decodeExtension(4,0);else if(p===215)g=this.decodeExtension(8,0);else if(p===216)g=this.decodeExtension(16,0);else if(p===199){let y=this.lookU8();g=this.decodeExtension(y,1)}else if(p===200){let y=this.lookU16();g=this.decodeExtension(y,2)}else if(p===201){let y=this.lookU32();g=this.decodeExtension(y,4)}else throw new l.DecodeError(`Unrecognized type byte: ${(0,e.prettyByte)(p)}`);this.complete();let O=this.stack;for(;O.length>0;){let y=O[O.length-1];if(y.type===0)if(y.array[y.position]=g,y.position++,y.position===y.size)O.pop(),g=y.array;else continue e;else if(y.type===1){if(!a(g))throw new l.DecodeError("The type of key must be string or number but "+typeof g);if(g==="__proto__")throw new l.DecodeError("The key __proto__ is not allowed");y.key=g,y.type=2;continue e}else if(y.map[y.key]=g,y.readCount++,y.readCount===y.size)O.pop(),g=y.map;else{y.key=null,y.type=1;continue e}}return g}}readHeadByte(){return this.headByte===h&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=h}readArraySize(){let p=this.readHeadByte();switch(p){case 220:return this.readU16();case 221:return this.readU32();default:{if(p<160)return p-144;throw new l.DecodeError(`Unrecognized array type byte: ${(0,e.prettyByte)(p)}`)}}}pushMapState(p){if(p>this.maxMapLength)throw new l.DecodeError(`Max length exceeded: map length (${p}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:1,size:p,key:null,readCount:0,map:{}})}pushArrayState(p){if(p>this.maxArrayLength)throw new l.DecodeError(`Max length exceeded: array length (${p}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:0,size:p,array:new Array(p),position:0})}decodeUtf8String(p,g){var O;if(p>this.maxStrLength)throw new l.DecodeError(`Max length exceeded: UTF-8 byte length (${p}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLengthr.TEXT_DECODER_THRESHOLD?k=(0,r.utf8DecodeTD)(this.bytes,y,p):k=(0,r.utf8DecodeJs)(this.bytes,y,p),this.pos+=g+p,k}stateIsMapKey(){return this.stack.length>0?this.stack[this.stack.length-1].type===1:!1}decodeBinary(p,g){if(p>this.maxBinLength)throw new l.DecodeError(`Max length exceeded: bin length (${p}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(p+g))throw u;let O=this.pos+g,y=this.bytes.subarray(O,O+p);return this.pos+=g+p,y}decodeExtension(p,g){if(p>this.maxExtLength)throw new l.DecodeError(`Max length exceeded: ext length (${p}) > maxExtLength (${this.maxExtLength})`);let O=this.view.getInt8(this.pos+g),y=this.decodeBinary(p,g+1);return this.extensionCodec.decode(y,O,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 p=this.view.getUint8(this.pos);return this.pos++,p}readI8(){let p=this.view.getInt8(this.pos);return this.pos++,p}readU16(){let p=this.view.getUint16(this.pos);return this.pos+=2,p}readI16(){let p=this.view.getInt16(this.pos);return this.pos+=2,p}readU32(){let p=this.view.getUint32(this.pos);return this.pos+=4,p}readI32(){let p=this.view.getInt32(this.pos);return this.pos+=4,p}readU64(){let p=(0,n.getUint64)(this.view,this.pos);return this.pos+=8,p}readI64(){let p=(0,n.getInt64)(this.view,this.pos);return this.pos+=8,p}readF32(){let p=this.view.getFloat32(this.pos);return this.pos+=4,p}readF64(){let p=this.view.getFloat64(this.pos);return this.pos+=8,p}};i.Decoder=m}),gf=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.decodeMulti=i.decode=i.defaultDecodeOptions=void 0;var e=Bl();i.defaultDecodeOptions={};function t(r,s=i.defaultDecodeOptions){return new e.Decoder(s.extensionCodec,s.context,s.maxStrLength,s.maxBinLength,s.maxArrayLength,s.maxMapLength,s.maxExtLength).decode(r)}i.decode=t;function n(r,s=i.defaultDecodeOptions){return new e.Decoder(s.extensionCodec,s.context,s.maxStrLength,s.maxBinLength,s.maxArrayLength,s.maxMapLength,s.maxExtLength).decodeMulti(r)}i.decodeMulti=n}),CO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ensureAsyncIterable=i.asyncIterableFromStream=i.isAsyncIterable=void 0;function e(s){return s[Symbol.asyncIterator]!=null}i.isAsyncIterable=e;function t(s){if(s==null)throw new Error("Assertion Failure: value must not be null nor undefined")}async function*n(s){let o=s.getReader();try{for(;;){let{done:l,value:a}=await o.read();if(l)return;t(a),yield a}}finally{o.releaseLock()}}i.asyncIterableFromStream=n;function r(s){return e(s)?s:n(s)}i.ensureAsyncIterable=r}),RO=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.decodeStream=i.decodeMultiStream=i.decodeArrayStream=i.decodeAsync=void 0;var e=Bl(),t=CO(),n=gf();async function r(a,h=n.defaultDecodeOptions){let c=(0,t.ensureAsyncIterable)(a);return new e.Decoder(h.extensionCodec,h.context,h.maxStrLength,h.maxBinLength,h.maxArrayLength,h.maxMapLength,h.maxExtLength).decodeAsync(c)}i.decodeAsync=r;function s(a,h=n.defaultDecodeOptions){let c=(0,t.ensureAsyncIterable)(a);return new e.Decoder(h.extensionCodec,h.context,h.maxStrLength,h.maxBinLength,h.maxArrayLength,h.maxMapLength,h.maxExtLength).decodeArrayStream(c)}i.decodeArrayStream=s;function o(a,h=n.defaultDecodeOptions){let c=(0,t.ensureAsyncIterable)(a);return new e.Decoder(h.extensionCodec,h.context,h.maxStrLength,h.maxBinLength,h.maxArrayLength,h.maxMapLength,h.maxExtLength).decodeStream(c)}i.decodeMultiStream=o;function l(a,h=n.defaultDecodeOptions){return o(a,h)}i.decodeStream=l}),Wl=ke(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.decodeTimestampExtension=i.encodeTimestampExtension=i.decodeTimestampToTimeSpec=i.encodeTimeSpecToTimestamp=i.encodeDateToTimeSpec=i.EXT_TIMESTAMP=i.ExtData=i.ExtensionCodec=i.Encoder=i.DataViewIndexOutOfBoundsError=i.DecodeError=i.Decoder=i.decodeStream=i.decodeMultiStream=i.decodeArrayStream=i.decodeAsync=i.decodeMulti=i.decode=i.encode=void 0;var e=SO();Object.defineProperty(i,"encode",{enumerable:!0,get:function(){return e.encode}});var t=gf();Object.defineProperty(i,"decode",{enumerable:!0,get:function(){return t.decode}}),Object.defineProperty(i,"decodeMulti",{enumerable:!0,get:function(){return t.decodeMulti}});var n=RO();Object.defineProperty(i,"decodeAsync",{enumerable:!0,get:function(){return n.decodeAsync}}),Object.defineProperty(i,"decodeArrayStream",{enumerable:!0,get:function(){return n.decodeArrayStream}}),Object.defineProperty(i,"decodeMultiStream",{enumerable:!0,get:function(){return n.decodeMultiStream}}),Object.defineProperty(i,"decodeStream",{enumerable:!0,get:function(){return n.decodeStream}});var r=Bl();Object.defineProperty(i,"Decoder",{enumerable:!0,get:function(){return r.Decoder}}),Object.defineProperty(i,"DataViewIndexOutOfBoundsError",{enumerable:!0,get:function(){return r.DataViewIndexOutOfBoundsError}});var s=ql();Object.defineProperty(i,"DecodeError",{enumerable:!0,get:function(){return s.DecodeError}});var o=mf();Object.defineProperty(i,"Encoder",{enumerable:!0,get:function(){return o.Encoder}});var l=Xl();Object.defineProperty(i,"ExtensionCodec",{enumerable:!0,get:function(){return l.ExtensionCodec}});var a=uf();Object.defineProperty(i,"ExtData",{enumerable:!0,get:function(){return a.ExtData}});var h=df();Object.defineProperty(i,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return h.EXT_TIMESTAMP}}),Object.defineProperty(i,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return h.encodeDateToTimeSpec}}),Object.defineProperty(i,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return h.encodeTimeSpecToTimestamp}}),Object.defineProperty(i,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return h.decodeTimestampToTimeSpec}}),Object.defineProperty(i,"encodeTimestampExtension",{enumerable:!0,get:function(){return h.encodeTimestampExtension}}),Object.defineProperty(i,"decodeTimestampExtension",{enumerable:!0,get:function(){return h.decodeTimestampExtension}})}),di=class extends Error{constructor(i){super(i),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}},Of=class extends di{},pt=class extends di{},$n=class extends di{},Ie=typeof process<"u"&&process.release&&process.release.name==="node",ul;if(globalThis.document)ul=i=>new Promise((e,t)=>{let n=document.createElement("script");n.src=i,n.onload=()=>e(),n.onerror=t,document.head.appendChild(n)});else if(globalThis.importScripts)ul=async i=>{try{globalThis.importScripts(i)}catch(e){if(e instanceof TypeError)await Promise.resolve().then(()=>Bi(Xi(i)));else throw e}};else if(Ie)ul=async i=>{let e=(await Promise.resolve().then(()=>Bi(Xi("path")))).default;await Promise.resolve().then(()=>Bi(Xi(e.resolve(i))))};else throw new di("Cannot determine runtime environment");var T={};function EO(i){Object.keys(i).forEach(e=>T._free(i[e]))}var mt={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 yf(i){return!!i&&typeof i=="object"&&Object.keys(mt).includes(i.type)}function os(i){return!!i&&typeof i=="object"&&"re"in i&&"im"in i}function zr(i){return T._Rf_protect(Mt(i)),i}function le(i,e){return T._Rf_protect(Mt(i)),++e.n,i}function AO(i){let e=T._malloc(4);return T._R_ProtectWithIndex(Mt(i),e),{loc:T.getValue(e,"i32"),ptr:e}}function QO(i){T._Rf_unprotect(1),T._free(i.ptr)}function MO(i,e){return T._R_Reprotect(Mt(i),e.loc),i}function Oe(i){T._Rf_unprotect(i)}function rf(i,e,t){T._Rf_defineVar(Mt(e),Mt(t),Mt(i))}function sf(i,e){let t={},n={n:0};try{let r=new xf(e);le(r,n),t.code=T.allocateUTF8(i);let s=T._R_ParseEvalString(t.code,r.ptr);return z.wrap(s)}finally{EO(t),Oe(n.n)}}function ls(i,e){return T.getWasmTableEntry(T.GOT.ffi_safe_eval.value)(Mt(i),Mt(e))}var _O=new WeakMap;function DO(i,e){return _O.set(i,e),i}var $O=63;function bf(){let i=Array.from({length:4},LO).join("-");if(i.length!==$O)throw new Error("comlink internal error: UUID has the wrong length");return i}function LO(){let i=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16),e=15-i.length;return e>0&&(i=Array.from({length:e},()=>0).join("")+i),i}function Mt(i){return Kr(i)?i.ptr:i}function pi(i,e){if(T._TYPEOF(i.ptr)!==mt[e])throw new Error(`Unexpected object type "${i.type()}" when expecting type "${e}"`)}function wf(i){if(yf(i))return new(Af(i.type))(i);if(i&&typeof i=="object"&&"type"in i&&i.type==="null")return new vf;if(i===null)return new Ni({type:"logical",names:null,values:[null]});if(typeof i=="boolean")return new Ni(i);if(typeof i=="number")return new hs(i);if(typeof i=="string")return new zt(i);if(os(i))return new Nl(i);if(ArrayBuffer.isView(i)||i instanceof ArrayBuffer)return new jl(i);if(Array.isArray(i))return VO(i);if(typeof i=="object")return Ln.fromObject(i);throw new Error("Robj construction for this JS object is not yet supported")}function VO(i){let e={n:0};if(i.every(t=>t&&typeof t=="object"&&!Kr(t)&&!os(t))){let t=i,n=t.every(s=>Object.keys(s).filter(o=>!Object.keys(t[0]).includes(o)).length===0&&Object.keys(t[0]).filter(o=>!Object.keys(s).includes(o)).length===0),r=t.every(s=>Object.values(s).every(o=>Mf(o)||Qf(o)));if(n&&r)return Ln.fromD3(t)}if(i.every(t=>typeof t=="boolean"||t===null))return new Ni(i);if(i.every(t=>typeof t=="number"||t===null))return new hs(i);if(i.every(t=>typeof t=="string"||t===null))return new zt(i);try{let t=new ui([new gt("c"),...i]);return le(t,e),t.eval()}finally{Oe(e.n)}}var ye=class{constructor(i){this.ptr=i}type(){let i=T._TYPEOF(this.ptr);return Object.keys(mt).find(e=>mt[e]===i)}},En,Ur,Wi=class extends ye{constructor(i){if(!(i instanceof ye))return wf(i);super(i.ptr),V(this,En)}static wrap(i){let e=T._TYPEOF(i),t=Object.keys(mt)[Object.values(mt).indexOf(e)];return new(Af(t))(new ye(i))}get[Symbol.toStringTag](){return`RObject:${this.type()}`}static getPersistentObject(i){return xe[i]}getPropertyValue(i){return this[i]}inspect(){sf(".Internal(inspect(x))",{x:this})}isNull(){return T._TYPEOF(this.ptr)===mt.null}isNa(){try{let i=sf("is.na(x)",{x:this});return zr(i),i.toBoolean()}finally{Oe(1)}}isUnbound(){return this.ptr===xe.unboundValue.ptr}attrs(){return as.wrap(T._ATTRIB(this.ptr))}class(){let i={n:0},e=new ui([new gt("class"),this]);le(e,i);try{return e.eval()}finally{Oe(i.n)}}setNames(i){let e;if(i===null)e=xe.null;else if(Array.isArray(i)&&i.every(t=>typeof t=="string"||t===null))e=new zt(i);else throw new Error("Argument to setNames must be null or an Array of strings or null");return T._Rf_setAttrib(this.ptr,xe.namesSymbol.ptr,e.ptr),this}names(){let i=zt.wrap(T._Rf_getAttrib(this.ptr,xe.namesSymbol.ptr));return i.isNull()?null:i.toArray()}includes(i){let e=this.names();return e&&e.includes(i)}toJs(i={depth:0},e=1){throw new Error("This R object cannot be converted to JS")}subset(i){return Je(this,En,Ur).call(this,i,xe.bracketSymbol.ptr)}get(i){return Je(this,En,Ur).call(this,i,xe.bracket2Symbol.ptr)}getDollar(i){return Je(this,En,Ur).call(this,i,xe.dollarSymbol.ptr)}pluck(...i){let e=AO(xe.null);try{let t=(r,s)=>{let o=r.get(s);return MO(o,e)},n=i.reduce(t,this);return n.isNull()?void 0:n}finally{QO(e)}}set(i,e){let t={n:0};try{let n=new Wi(i);le(n,t);let r=new Wi(e);le(r,t);let s=new gt("[[<-"),o=T._Rf_lang4(s.ptr,this.ptr,n.ptr,r.ptr);return le(o,t),Wi.wrap(ls(o,xe.baseEnv))}finally{Oe(t.n)}}static getMethods(i){let e=new Set,t=i;do Object.getOwnPropertyNames(t).map(n=>e.add(n));while(t=Object.getPrototypeOf(t));return[...e.keys()].filter(n=>typeof i[n]=="function")}},z=Wi;En=new WeakSet,Ur=function(i,e){let t={n:0};try{let n=new Wi(i);le(n,t);let r=T._Rf_lang3(e,this.ptr,n.ptr);return le(r,t),Wi.wrap(ls(r,xe.baseEnv))}finally{Oe(t.n)}};var vf=class extends z{constructor(){return super(new ye(T.getValue(T._R_NilValue,"*"))),this}toJs(){return{type:"null"}}},gt=class extends z{constructor(i){if(i instanceof ye){pi(i,"symbol"),super(i);return}let e=T.allocateUTF8(i);try{super(new ye(T._Rf_install(e)))}finally{T._free(e)}}toJs(){let i=this.toObject();return{type:"symbol",printname:i.printname,symvalue:i.symvalue,internal:i.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 Il.wrap(T._PRINTNAME(this.ptr))}symvalue(){return z.wrap(T._SYMVALUE(this.ptr))}internal(){return z.wrap(T._INTERNAL(this.ptr))}},as=class extends z{constructor(i){if(i instanceof ye)return pi(i,"pairlist"),super(i),this;let e={n:0};try{let{names:t,values:n}=zi(i),r=as.wrap(T._Rf_allocList(n.length));le(r,e);for(let[s,o]=[0,r];!o.isNull();[s,o]=[s+1,o.cdr()])o.setcar(new z(n[s]));r.setNames(t),super(r)}finally{Oe(e.n)}}get length(){return this.toArray().length}toArray(i={depth:1}){return this.toJs(i).values}toObject({allowDuplicateKey:i=!0,allowEmptyKey:e=!1,depth:t=-1}={}){let n=this.entries({depth:t}),r=n.map(([s])=>s);if(!i&&new Set(r).size!==r.length)throw new Error("Duplicate key when converting pairlist without allowDuplicateKey enabled");if(!e&&r.some(s=>!s))throw new Error("Empty or null key when converting pairlist without allowEmptyKey enabled");return Object.fromEntries(n.filter((s,o)=>n.findIndex(l=>l[0]===s[0])===o))}entries(i={depth:1}){let e=this.toJs(i);return e.values.map((t,n)=>[e.names?e.names[n]:null,t])}toJs(i={depth:0},e=1){let t=[],n=!1,r=[];for(let s=this;!s.isNull();s=s.cdr()){let o=s.tag();o.isNull()?t.push(""):(n=!0,t.push(o.toString())),i.depth&&e>=i.depth?r.push(s.car()):r.push(s.car().toJs(i,e+1))}return{type:"pairlist",names:n?t:null,values:r}}includes(i){return i in this.toObject()}setcar(i){T._SETCAR(this.ptr,i.ptr)}car(){return z.wrap(T._CAR(this.ptr))}cdr(){return z.wrap(T._CDR(this.ptr))}tag(){return z.wrap(T._TAG(this.ptr))}},ui=class extends z{constructor(i){if(i instanceof ye)return pi(i,"call"),super(i),this;let e={n:0};try{let{values:t}=zi(i),n=t.map(s=>le(new z(s),e)),r=ui.wrap(T._Rf_allocVector(mt.call,t.length));le(r,e);for(let[s,o]=[0,r];!o.isNull();[s,o]=[s+1,o.cdr()])o.setcar(n[s]);super(r)}finally{Oe(e.n)}}setcar(i){T._SETCAR(this.ptr,i.ptr)}car(){return z.wrap(T._CAR(this.ptr))}cdr(){return z.wrap(T._CDR(this.ptr))}eval(){return T.webr.evalR(this,{env:xe.baseEnv})}capture(i={}){return T.webr.captureR(this,i)}deparse(){let i={n:0};try{let e=T._Rf_lang2(new gt("deparse1").ptr,T._Rf_lang2(new gt("quote").ptr,this.ptr));le(e,i);let t=zt.wrap(ls(e,xe.baseEnv));return le(t,i),t.toString()}finally{Oe(i.n)}}},pl=class extends z{constructor(i,e=null){if(i instanceof ye){if(pi(i,"list"),super(i),e){if(e.length!==this.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");this.setNames(e)}return this}let t={n:0};try{let n=zi(i),r=T._Rf_allocVector(mt.list,n.values.length);le(r,t),n.values.forEach((o,l)=>{T._SET_VECTOR_ELT(r,l,new z(o).ptr)});let s=e||n.names;if(s&&s.length!==n.values.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");z.wrap(r).setNames(s),super(new ye(r))}finally{Oe(t.n)}}get length(){return T._LENGTH(this.ptr)}isDataFrame(){let i=as.wrap(T._ATTRIB(this.ptr)).get("class");return!i.isNull()&&i.toArray().includes("data.frame")}toArray(i={depth:1}){return this.toJs(i).values}toObject({allowDuplicateKey:i=!0,allowEmptyKey:e=!1,depth:t=-1}={}){let n=this.entries({depth:t}),r=n.map(([s])=>s);if(!i&&new Set(r).size!==r.length)throw new Error("Duplicate key when converting list without allowDuplicateKey enabled");if(!e&&r.some(s=>!s))throw new Error("Empty or null key when converting list without allowEmptyKey enabled");return Object.fromEntries(n.filter((s,o)=>n.findIndex(l=>l[0]===s[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((i,e)=>(e[1].forEach((t,n)=>i[n]=Object.assign(i[n]||{},{[e[0]]:t})),i),[])}entries(i={depth:-1}){let e=this.toJs(i);return this.isDataFrame()&&i.depth<0&&(e.values=e.values.map(t=>t.toArray())),e.values.map((t,n)=>[e.names?e.names[n]:null,t])}toJs(i={depth:0},e=1){return{type:"list",names:this.names(),values:[...Array(this.length).keys()].map(t=>i.depth&&e>=i.depth?this.get(t+1):this.get(t+1).toJs(i,e+1))}}},Ln=class extends pl{constructor(i){if(i instanceof ye){if(super(i),!this.isDataFrame())throw new Error("Can't construct `RDataFrame`. Supplied R object is not a `data.frame`.");return this}return Ln.fromObject(i)}static fromObject(i){let{names:e,values:t}=zi(i),n={n:0};try{let r=!!e&&e.length>0&&e.every(o=>o),s=t.length>0&&t.every(o=>Array.isArray(o)||ArrayBuffer.isView(o)||o instanceof ArrayBuffer);if(r&&s){let o=t,l=o.every(h=>h.length===o[0].length),a=o.every(h=>Mf(h[0])||Qf(h[0]));if(l&&a){let h=new pl({type:"list",names:e,values:o.map(f=>wf(f))});le(h,n);let c=new ui([new gt("as.data.frame"),h]);return le(c,n),new Ln(c.eval())}}}finally{Oe(n.n)}throw new Error("Can't construct `data.frame`. Source object is not eligible.")}static fromD3(i){return this.fromObject(Object.fromEntries(Object.keys(i[0]).map(e=>[e,i.map(t=>t[e])])))}},jr=class extends z{exec(...i){let e={n:0};try{let t=new ui([this,...i]);return le(t,e),t.eval()}finally{Oe(e.n)}}capture(i={},...e){let t={n:0};try{let n=new ui([this,...e]);return le(n,t),n.capture(i)}finally{Oe(t.n)}}},Il=class extends z{constructor(i){if(i instanceof ye){pi(i,"string"),super(i);return}let e=T.allocateUTF8(i);try{super(new ye(T._Rf_mkChar(e)))}finally{T._free(e)}}toString(){return T.UTF8ToString(T._R_CHAR(this.ptr))}toJs(){return{type:"string",value:this.toString()}}},xf=class extends z{constructor(i={}){if(i instanceof ye)return pi(i,"environment"),super(i),this;let e=0;try{let{names:t,values:n}=zi(i),r=zr(T._R_NewEnv(xe.globalEnv.ptr,0,0));++e,n.forEach((s,o)=>{let l=t?t[o]:null;if(!l)throw new Error("Can't create object in new environment with empty symbol name");let a=new gt(l),h=zr(new z(s));try{rf(r,a,h)}finally{Oe(1)}}),super(new ye(r))}finally{Oe(e)}}ls(i=!1,e=!0){return zt.wrap(T._R_lsInternal3(this.ptr,Number(i),Number(e))).toArray()}bind(i,e){let t=new gt(i),n=zr(new z(e));try{rf(this,t,n)}finally{Oe(1)}}names(){return this.ls(!0,!0)}frame(){return z.wrap(T._FRAME(this.ptr))}subset(i){if(typeof i=="number")throw new Error("Object of type environment is not subsettable");return this.getDollar(i)}toObject({depth:i=-1}={}){let e=this.names();return Object.fromEntries([...Array(e.length).keys()].map(t=>{let n=this.getDollar(e[t]);return[e[t],i<0?n:n.toJs({depth:i})]}))}toJs(i={depth:0},e=1){let t=this.names(),n=[...Array(t.length).keys()].map(r=>i.depth&&e>=i.depth?this.getDollar(t[r]):this.getDollar(t[r]).toJs(i,e+1));return{type:"environment",names:t,values:n}}},ji=class extends z{constructor(i,e,t){if(i instanceof ye)return pi(i,e),super(i),this;let n={n:0};try{let{names:r,values:s}=zi(i),o=T._Rf_allocVector(mt[e],s.length);le(o,n),s.forEach(t(o)),z.wrap(o).setNames(r),super(new ye(o))}finally{Oe(n.n)}}get length(){return T._LENGTH(this.ptr)}get(i){return super.get(i)}subset(i){return super.subset(i)}getDollar(){throw new Error("$ operator is invalid for atomic vectors")}detectMissing(){let i={n:0};try{let e=T._Rf_lang2(new gt("is.na").ptr,this.ptr);le(e,i);let t=Ni.wrap(ls(e,xe.baseEnv));le(t,i);let n=t.toTypedArray();return Array.from(n).map(r=>!!r)}finally{Oe(i.n)}}toArray(){let i=this.toTypedArray();return this.detectMissing().map((e,t)=>e?null:i[t])}toObject({allowDuplicateKey:i=!0,allowEmptyKey:e=!1}={}){let t=this.entries(),n=t.map(([r])=>r);if(!i&&new Set(n).size!==n.length)throw new Error("Duplicate key when converting atomic vector without allowDuplicateKey enabled");if(!e&&n.some(r=>!r))throw new Error("Empty or null key when converting atomic vector without allowEmptyKey enabled");return Object.fromEntries(t.filter((r,s)=>t.findIndex(o=>o[0]===r[0])===s))}entries(){let i=this.toArray(),e=this.names();return i.map((t,n)=>[e?e[n]:null,t])}toJs(){return{type:this.type(),names:this.names(),values:this.toArray()}}},ml,kf=class extends ji{constructor(i){super(i,"logical",x(kf,ml))}getBoolean(i){return this.get(i).toArray()[0]}toBoolean(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getBoolean(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS boolean");return i}toTypedArray(){return new Int32Array(T.HEAP32.subarray(T._LOGICAL(this.ptr)/4,T._LOGICAL(this.ptr)/4+this.length))}toArray(){let i=this.toTypedArray();return this.detectMissing().map((e,t)=>e?null:!!i[t])}},Ni=kf;ml=new WeakMap,V(Ni,ml,i=>{let e=T._LOGICAL(i),t=T.getValue(T._R_NaInt,"i32");return(n,r)=>{T.setValue(e+4*r,n===null?t:!!n,"i32")}});var gl,Sf=class extends ji{constructor(i){super(i,"integer",x(Sf,gl))}getNumber(i){return this.get(i).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getNumber(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS number");return i}toTypedArray(){return new Int32Array(T.HEAP32.subarray(T._INTEGER(this.ptr)/4,T._INTEGER(this.ptr)/4+this.length))}},Tf=Sf;gl=new WeakMap,V(Tf,gl,i=>{let e=T._INTEGER(i),t=T.getValue(T._R_NaInt,"i32");return(n,r)=>{T.setValue(e+4*r,n===null?t:Math.round(Number(n)),"i32")}});var Ol,Pf=class extends ji{constructor(i){super(i,"double",x(Pf,Ol))}getNumber(i){return this.get(i).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getNumber(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS number");return i}toTypedArray(){return new Float64Array(T.HEAPF64.subarray(T._REAL(this.ptr)/8,T._REAL(this.ptr)/8+this.length))}},hs=Pf;Ol=new WeakMap,V(hs,Ol,i=>{let e=T._REAL(i),t=T.getValue(T._R_NaReal,"double");return(n,r)=>{T.setValue(e+8*r,n===null?t:n,"double")}});var yl,Cf=class extends ji{constructor(i){super(i,"complex",x(Cf,yl))}getComplex(i){return this.get(i).toArray()[0]}toComplex(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getComplex(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS object");return i}toTypedArray(){return new Float64Array(T.HEAPF64.subarray(T._COMPLEX(this.ptr)/8,T._COMPLEX(this.ptr)/8+2*this.length))}toArray(){let i=this.toTypedArray();return this.detectMissing().map((e,t)=>e?null:{re:i[2*t],im:i[2*t+1]})}},Nl=Cf;yl=new WeakMap,V(Nl,yl,i=>{let e=T._COMPLEX(i),t=T.getValue(T._R_NaReal,"double");return(n,r)=>{T.setValue(e+8*(2*r),n===null?t:n.re,"double"),T.setValue(e+8*(2*r+1),n===null?t:n.im,"double")}});var bl,Rf=class extends ji{constructor(i){super(i,"character",x(Rf,bl))}getString(i){return this.get(i).toArray()[0]}toString(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getString(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS string");return i}toTypedArray(){return new Uint32Array(T.HEAPU32.subarray(T._STRING_PTR(this.ptr)/4,T._STRING_PTR(this.ptr)/4+this.length))}toArray(){return this.detectMissing().map((i,e)=>i?null:T.UTF8ToString(T._R_CHAR(T._STRING_ELT(this.ptr,e))))}},zt=Rf;bl=new WeakMap,V(zt,bl,i=>(e,t)=>{e===null?T._SET_STRING_ELT(i,t,xe.naString.ptr):T._SET_STRING_ELT(i,t,new Il(e).ptr)});var wl,Ef=class extends ji{constructor(i){i instanceof ArrayBuffer&&(i=new Uint8Array(i)),super(i,"raw",x(Ef,wl))}getNumber(i){return this.get(i).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let i=this.getNumber(1);if(i===null)throw new Error("Can't convert missing value `NA` to a JS number");return i}toTypedArray(){return new Uint8Array(T.HEAPU8.subarray(T._RAW(this.ptr),T._RAW(this.ptr)+this.length))}},jl=Ef;wl=new WeakMap,V(jl,wl,i=>{let e=T._RAW(i);return(t,n)=>{T.setValue(e+n,Number(t),"i8")}});function zi(i){return yf(i)?i:Array.isArray(i)||ArrayBuffer.isView(i)?{names:null,values:i}:i&&typeof i=="object"&&!os(i)?{names:Object.keys(i),values:Object.values(i)}:{names:null,values:[i]}}function Af(i){let e={object:z,null:vf,symbol:gt,pairlist:as,closure:jr,environment:xf,call:ui,special:jr,builtin:jr,string:Il,logical:Ni,integer:Tf,double:hs,complex:Nl,character:zt,list:pl,raw:jl,function:jr,dataframe:Ln};return i in e?e[i]:z}function Kr(i){return i instanceof z}function Qf(i){let e=["logical","integer","double","complex","character"];return Kr(i)&&e.includes(i.type())||Kr(i)&&i.isNa()}function Mf(i){return i===null||typeof i=="number"||typeof i=="boolean"||typeof i=="string"||os(i)}var xe;function cs(){let i={resolve:()=>{},reject:()=>{},promise:Promise.resolve()},e=new Promise((t,n)=>{i.resolve=t,i.reject=n});return i.promise=e,i}function qO(i){return new Promise(e=>setTimeout(e,i))}function Ut(i,e,t,...n){return i==null||XO(i)?i:i instanceof ArrayBuffer?new Uint8Array(i):e(i)?t(i,...n):Array.isArray(i)||ArrayBuffer.isView(i)?i.map(r=>Ut(r,e,t,...n)):i instanceof ye?i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([r,s])=>[r,Ut(s,e,t,...n)])):i}function zl(i,e){let t=new XMLHttpRequest;t.open("get",i,!0),t.onload=()=>{let n=new Worker(URL.createObjectURL(new Blob([t.responseText])));e(n)},t.send()}function Ul(i){if(Ie)return!1;let e=new URL(location.href),t=new URL(i,location.origin);return!(e.host===t.host&&e.port===t.port&&e.protocol===t.protocol)}function XO(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}var BO=Bi(Wl()),WO=new TextEncoder;async function IO(i,e,t){try{let{taskId:n,sizeBuffer:r,dataBuffer:s,signalBuffer:o}=e,l=(0,BO.encode)(t),a=l.length<=s.length;if(Atomics.store(r,0,l.length),Atomics.store(r,1,+a),!a){let[h,c]=NO(i);s.set(WO.encode(h)),await of(o,n),s=(await c).dataBuffer}s.set(l),Atomics.store(r,1,1),await of(o,n)}catch(n){console.warn(n)}}function NO(i){let e=bf();return[e,new Promise(t=>{Ie?i.once("message",n=>{!n.id||n.id!==e||t(n)}):i.addEventListener("message",function n(r){!r.data||!r.data.id||r.data.id!==e||(i.removeEventListener("message",n),t(r.data))}),i.start&&i.start()})]}async function of(i,e){let t=(e>>1)%32,n=1;for(;Atomics.compareExchange(i,t+1,0,e)!==0;)await qO(n),n<32&&(n*=2);Atomics.or(i,0,1<{x(this,At).push(i)}))};function jO(i,e){return _f({type:"request",data:{uuid:bf(),msg:i}},e)}function xl(i,e,t){return _f({type:"response",data:{uuid:i,resp:e}},t)}function _f(i,e){return e&&DO(i,e),i}function zO(i){let e=new Of(i.obj.message);return i.obj.name!=="Error"&&(e.name=i.obj.name),e.stack=i.obj.stack,e}function UO(i){return!!i&&typeof i=="object"&&"payloadType"in i&&"obj"in i}function Df(i){return UO(i)&&i.payloadType==="ptr"}var An,Fl=class{constructor(){this.inputQueue=new dl,this.outputQueue=new dl,this.systemQueue=new dl,V(this,An,new Map)}async read(){return await this.outputQueue.get()}async flush(){let i=[];for(;!this.outputQueue.isEmpty();)i.push(await this.read());return i}async readSystem(){return await this.systemQueue.get()}write(i){this.inputQueue.put(i)}async request(i,e){let t=jO(i,e),{resolve:n,reject:r,promise:s}=cs();return x(this,An).set(t.data.uuid,{resolve:n,reject:r}),this.write(t),s}putClosedMessage(){this.outputQueue.put({type:"closed"})}resolveResponse(i){let e=i.data.uuid,t=x(this,An).get(e);if(t){let n=i.data.resp;x(this,An).delete(e),n.payloadType==="err"?t.reject(zO(n)):t.resolve(n)}else console.warn("Can't find request.")}};An=new WeakMap;var lS=Bi(Wl()),aS=new TextDecoder("utf-8"),FO,HO,GO,YO,ZO;FO=new WeakMap,HO=new WeakMap,GO=new WeakMap,YO=new WeakMap,ZO=new WeakMap;var hS=new Int32Array(new ArrayBuffer(4));Ie&&(globalThis.Worker=Xi("worker_threads").Worker);var Qn,kl,$f,Hr,lf=class extends Fl{constructor(i){super(),V(this,kl),V(this,Qn,void 0),this.close=()=>{},V(this,Hr,async(t,n)=>{if(!(!n||!n.type))switch(n.type){case"resolve":me(this,Qn,new Int32Array(n.data)),this.resolve();return;case"response":this.resolveResponse(n);return;case"system":this.systemQueue.put(n.data);return;default:this.outputQueue.put(n);return;case"sync-request":{let r=n,s=r.data.msg,o=r.data.reqData;switch(s.type){case"read":{let l=await this.inputQueue.get();await IO(t,o,l);break}default:throw new pt(`Unsupported request type '${s.type}'.`)}return}case"request":throw new pt("Can't send messages of type 'request' from a worker. Please Use 'sync-request' instead.")}});let e=t=>{Je(this,kl,$f).call(this,t),this.close=()=>{t.terminate(),this.putClosedMessage()};let n={type:"init",data:{config:i,channelType:Qt.SharedArrayBuffer}};t.postMessage(n)};if(Ul(i.baseUrl))zl(`${i.baseUrl}webr-worker.js`,t=>e(t));else{let t=new Worker(`${i.baseUrl}webr-worker.js`);e(t)}({resolve:this.resolve,promise:this.initialised}=cs())}interrupt(){if(!x(this,Qn))throw new pt("Failed attempt to interrupt before initialising interruptBuffer");this.inputQueue.reset(),x(this,Qn)[0]=1}};Qn=new WeakMap,kl=new WeakSet,$f=function(i){Ie?i.on("message",e=>{x(this,Hr).call(this,i,e)}):i.onmessage=e=>x(this,Hr).call(this,i,e.data)},Hr=new WeakMap;var JO,KO,e0,t0;JO=new WeakMap,KO=new WeakMap,e0=new WeakMap,t0=new WeakMap;var cS=Bi(Wl());Ie&&(globalThis.Worker=Xi("worker_threads").Worker);var _n,Ii,Dn,Sl,Lf,Tl,af,Pl,Vf,Gr,i0=class extends Fl{constructor(i){super(),V(this,Sl),V(this,Tl),V(this,Pl),this.close=()=>{},V(this,_n,new Map),V(this,Ii,void 0),V(this,Dn,!1),V(this,Gr,(t,n)=>{if(!(!n||!n.type))switch(n.type){case"resolve":this.resolve();return;case"response":this.resolveResponse(n);return;case"system":this.systemQueue.put(n.data);return;default:this.outputQueue.put(n);return;case"sync-request":{let r=n.data;x(this,_n).set(r.data.uuid,r.data.msg);return}case"request":throw new pt("Can't send messages of type 'request' from a worker.Use service worker fetch request instead.")}}),console.warn("The ServiceWorker communication channel is deprecated and will be removed in a future version of webR. Consider using the PostMessage channel instead. If blocking input is required (for example, `browser()`) the SharedArrayBuffer channel should be used. See https://docs.r-wasm.org/webr/latest/serving.html for further information.");let e=t=>{Je(this,Pl,Vf).call(this,t),this.close=()=>{t.terminate(),this.putClosedMessage()},Je(this,Sl,Lf).call(this,`${i.serviceWorkerUrl}webr-serviceworker.js`).then(n=>{let r={type:"init",data:{config:i,channelType:Qt.ServiceWorker,clientId:n,location:window.location.href}};t.postMessage(r)})};if(Ul(i.serviceWorkerUrl))zl(`${i.serviceWorkerUrl}webr-worker.js`,t=>e(t));else{let t=new Worker(`${i.serviceWorkerUrl}webr-worker.js`);e(t)}({resolve:this.resolve,promise:this.initialised}=cs())}activeRegistration(){var i;if(!((i=x(this,Ii))!=null&&i.active))throw new pt("Attempted to obtain a non-existent active registration.");return x(this,Ii).active}interrupt(){me(this,Dn,!0)}};_n=new WeakMap,Ii=new WeakMap,Dn=new WeakMap,Sl=new WeakSet,Lf=async function(i){me(this,Ii,await navigator.serviceWorker.register(i)),await navigator.serviceWorker.ready,window.addEventListener("beforeunload",()=>{var t;(t=x(this,Ii))==null||t.unregister()});let e=await new Promise(t=>{navigator.serviceWorker.addEventListener("message",function n(r){r.data.type==="registration-successful"&&(navigator.serviceWorker.removeEventListener("message",n),t(r.data.clientId))}),this.activeRegistration().postMessage({type:"register-client-main"})});return navigator.serviceWorker.addEventListener("message",t=>{Je(this,Tl,af).call(this,t)}),e},Tl=new WeakSet,af=async function(i){if(i.data.type==="request"){let e=i.data.data,t=x(this,_n).get(e);if(!t)throw new pt("Request not found during service worker XHR request");switch(x(this,_n).delete(e),t.type){case"read":{let n=await this.inputQueue.get();this.activeRegistration().postMessage({type:"wasm-webr-fetch-response",uuid:e,response:xl(e,n)});break}case"interrupt":{let n=x(this,Dn);this.activeRegistration().postMessage({type:"wasm-webr-fetch-response",uuid:e,response:xl(e,n)}),this.inputQueue.reset(),me(this,Dn,!1);break}default:throw new pt(`Unsupported request type '${t.type}'.`)}return}},Pl=new WeakSet,Vf=function(i){Ie?i.on("message",e=>{x(this,Gr).call(this,i,e)}):i.onmessage=e=>x(this,Gr).call(this,i,e.data)},Gr=new WeakMap;var n0,r0,s0,o0,l0,a0;n0=new WeakMap,r0=new WeakMap,s0=new WeakMap,o0=new WeakMap,l0=new WeakMap,a0=new WeakMap;Ie&&(globalThis.Worker=Xi("worker_threads").Worker);var Mn,Cl,qf,Yr,hf=class extends Fl{constructor(i){super(),V(this,Cl),this.close=()=>{},V(this,Mn,void 0),V(this,Yr,async(t,n)=>{if(!(!n||!n.type))switch(n.type){case"resolve":this.resolve();return;case"response":this.resolveResponse(n);return;case"system":this.systemQueue.put(n.data);return;default:this.outputQueue.put(n);return;case"request":{let r=n,s=r.data.msg;switch(s.type){case"read":{let o=await this.inputQueue.get();if(x(this,Mn)){let l=xl(r.data.uuid,o);x(this,Mn).postMessage(l)}break}default:throw new pt(`Unsupported request type '${s.type}'.`)}return}case"sync-request":throw new pt("Can't send messages of type 'sync-request' in PostMessage mode. Use 'request' instead.")}});let e=t=>{me(this,Mn,t),Je(this,Cl,qf).call(this,t),this.close=()=>t.terminate();let n={type:"init",data:{config:i,channelType:Qt.PostMessage}};t.postMessage(n)};if(Ul(i.baseUrl))zl(`${i.baseUrl}webr-worker.js`,t=>e(t));else{let t=new Worker(`${i.baseUrl}webr-worker.js`);e(t)}({resolve:this.resolve,promise:this.initialised}=cs())}interrupt(){console.error("Interrupting R execution is not available when using the PostMessage channel")}};Mn=new WeakMap,Cl=new WeakSet,qf=function(i){Ie?i.on("message",e=>{x(this,Yr).call(this,i,e)}):i.onmessage=e=>x(this,Yr).call(this,i,e.data)},Yr=new WeakMap;var h0,c0,f0,u0,d0;h0=new WeakMap,c0=new WeakMap,f0=new WeakMap,u0=new WeakMap,d0=new WeakMap;var Qt={Automatic:0,SharedArrayBuffer:1,ServiceWorker:2,PostMessage:3};function p0(i){switch(i.channelType){case Qt.SharedArrayBuffer:return new lf(i);case Qt.ServiceWorker:return new i0(i);case Qt.PostMessage:return new hf(i);case Qt.Automatic:default:return typeof SharedArrayBuffer<"u"?new lf(i):new hf(i)}}var m0=Ie?__dirname+"/":"https://webr.r-wasm.org/v0.4.0/",g0="https://repo.r-wasm.org",Xf="0.4.0";function se(i){return!!i&&(typeof i=="object"||typeof i=="function")&&"payloadType"in i&&Df(i._payload)}function Se(i){return se(i)&&i._payload.obj.type==="null"}function O0(i){return se(i)&&i._payload.obj.type==="symbol"}function y0(i){return se(i)&&i._payload.obj.type==="pairlist"}function b0(i){return se(i)&&i._payload.obj.type==="environment"}function w0(i){return se(i)&&i._payload.obj.type==="logical"}function v0(i){return se(i)&&i._payload.obj.type==="integer"}function x0(i){return se(i)&&i._payload.obj.type==="double"}function k0(i){return se(i)&&i._payload.obj.type==="complex"}function Ui(i){return se(i)&&i._payload.obj.type==="character"}function ot(i){return se(i)&&i._payload.obj.type==="list"}function S0(i){return se(i)&&i._payload.obj.type==="raw"}function Hl(i){return se(i)&&i._payload.obj.type==="call"}function fs(i){var e;return!!(se(i)&&(e=i._payload.obj.methods)!=null&&e.includes("exec"))}function T0(){}function P0(i,e){return async function*(){let t={type:"callRObjectMethod",data:{payload:e._payload,prop:"getPropertyValue",args:[{payloadType:"raw",obj:"length"}],shelter:void 0}},n=await i.request(t);if(typeof n.obj!="number")throw new di("Cannot iterate over object, unexpected type for length property.");for(let r=1;r<=n.obj;r++)yield e.get(r)}}function Bf(i,e,t){return async(...n)=>{let r=n.map(l=>se(l)?l._payload:{obj:Ut(l,se,a=>a._payload),payloadType:"raw"}),s={type:"callRObjectMethod",data:{payload:t,prop:e,args:r}},o=await i.request(s);switch(o.payloadType){case"ptr":return fi(i,o);case"raw":return Ut(o,Df,(l,a)=>fi(a,l),i).obj}}}async function C0(i,e,t,...n){let r={type:"newRObject",data:{objType:e,args:Ut(n,se,o=>o._payload),shelter:t}},s=await i.request(r);switch(s.payloadType){case"raw":throw new $n("Unexpected raw payload type returned from newRObject");case"ptr":return fi(i,s)}}function fi(i,e){var t;let n=new Proxy((t=e.obj.methods)!=null&&t.includes("exec")?Object.assign(T0,{...e}):e,{get:(r,s)=>{var o;if(s==="_payload")return e;if(s===Symbol.asyncIterator)return P0(i,n);if((o=e.obj.methods)!=null&&o.includes(s.toString()))return Bf(i,s.toString(),e)},apply:async(r,s,o)=>{let l=await fi(i,e).exec(...o);return fs(l)?l:l.toJs()}});return n}function Le(i,e,t){return new Proxy(z,{construct:(n,r)=>C0(i,t,e,...r),get:(n,r)=>Bf(i,r.toString())})}var es,ts,is,ns,rs,Rl,El,Al,Ql,Ml,_l,Wf,R0=class{constructor(i={},e={REnv:{R_HOME:"/usr/lib/R",FONTCONFIG_PATH:"/etc/fonts",R_ENABLE_JIT:"0"}}){V(this,_l),V(this,es,void 0),V(this,ts,void 0),V(this,is,void 0),V(this,ns,void 0),V(this,rs,void 0),V(this,Rl,t=>{console.log(t)}),V(this,El,t=>{console.error(t)}),V(this,Al,t=>{let n=prompt(t);n&&this.stdin(`${n}
`)}),V(this,Ql,t=>{if(Ie)throw new Error("Plotting with HTML canvas is not yet supported under Node");this.canvas.getContext("2d").drawImage(t,0,0)}),V(this,Ml,()=>{if(Ie)throw new Error("Plotting with HTML canvas is not yet supported under Node");this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height)}),this.webR=new Nf(e),Ie||(this.canvas=document.createElement("canvas"),this.canvas.setAttribute("width","1008"),this.canvas.setAttribute("height","1008")),me(this,es,i.stdout||x(this,Rl)),me(this,ts,i.stderr||x(this,El)),me(this,is,i.prompt||x(this,Al)),me(this,ns,i.canvasImage||x(this,Ql)),me(this,rs,i.canvasNewPage||x(this,Ml)),this.webR.evalRVoid("options(device=webr::canvas)")}stdin(i){this.webR.writeConsole(i)}interrupt(){this.webR.interrupt()}run(){Je(this,_l,Wf).call(this)}};es=new WeakMap,ts=new WeakMap,is=new WeakMap,ns=new WeakMap,rs=new WeakMap,Rl=new WeakMap,El=new WeakMap,Al=new WeakMap,Ql=new WeakMap,Ml=new WeakMap,_l=new WeakSet,Wf=async function(){for(;;){let i=await this.webR.read();switch(i.type){case"stdout":x(this,es).call(this,i.data);break;case"stderr":x(this,ts).call(this,i.data);break;case"prompt":x(this,is).call(this,i.data);break;case"canvas":i.data.event==="canvasImage"?x(this,ns).call(this,i.data.image):i.data.event==="canvasNewPage"&&x(this,rs).call(this);break;case"closed":return;default:console.warn(`Unhandled output type for webR Console: ${i.type}.`)}}};var E0={FONTCONFIG_PATH:"/etc/fonts",R_HOME:"/usr/lib/R",R_ENABLE_JIT:"0",WEBR:"1",WEBR_VERSION:Xf},cf={RArgs:[],REnv:E0,baseUrl:m0,serviceWorkerUrl:"",repoUrl:g0,homedir:"/home/web_user",interactive:!0,channelType:Qt.Automatic,createLazyFilesystem:!0},ie,Zr,Dl,If,Nf=class{constructor(i={}){V(this,Dl),V(this,ie,void 0),V(this,Zr,void 0),this.version=Xf,this.FS={lookupPath:async t=>{let n={type:"lookupPath",data:{path:t}};return(await x(this,ie).request(n)).obj},mkdir:async t=>{let n={type:"mkdir",data:{path:t}};return(await x(this,ie).request(n)).obj},mount:async(t,n,r)=>{let s={type:"mount",data:{type:t,options:n,mountpoint:r}};await x(this,ie).request(s)},syncfs:async t=>{let n={type:"syncfs",data:{populate:t}};await x(this,ie).request(n)},readFile:async(t,n)=>{let r={type:"readFile",data:{path:t,flags:n}};return(await x(this,ie).request(r)).obj},rmdir:async t=>{let n={type:"rmdir",data:{path:t}};await x(this,ie).request(n)},writeFile:async(t,n,r)=>{let s={type:"writeFile",data:{path:t,data:n,flags:r}};await x(this,ie).request(s)},unlink:async t=>{let n={type:"unlink",data:{path:t}};await x(this,ie).request(n)},unmount:async t=>{let n={type:"unmount",data:{path:t}};await x(this,ie).request(n)}};let e={...cf,...i,REnv:{...cf.REnv,...i.REnv}};me(this,ie,p0(e)),this.objs={},this.Shelter=A0(x(this,ie)),me(this,Zr,x(this,ie).initialised.then(async()=>{this.globalShelter=await new this.Shelter,this.RObject=this.globalShelter.RObject,this.RLogical=this.globalShelter.RLogical,this.RInteger=this.globalShelter.RInteger,this.RDouble=this.globalShelter.RDouble,this.RComplex=this.globalShelter.RComplex,this.RCharacter=this.globalShelter.RCharacter,this.RRaw=this.globalShelter.RRaw,this.RList=this.globalShelter.RList,this.RDataFrame=this.globalShelter.RDataFrame,this.RPairlist=this.globalShelter.RPairlist,this.REnvironment=this.globalShelter.REnvironment,this.RSymbol=this.globalShelter.RSymbol,this.RString=this.globalShelter.RString,this.RCall=this.globalShelter.RCall,this.objs={baseEnv:await this.RObject.getPersistentObject("baseEnv"),globalEnv:await this.RObject.getPersistentObject("globalEnv"),null:await this.RObject.getPersistentObject("null"),true:await this.RObject.getPersistentObject("true"),false:await this.RObject.getPersistentObject("false"),na:await this.RObject.getPersistentObject("na")},Je(this,Dl,If).call(this)}))}async init(){return x(this,Zr)}close(){x(this,ie).close()}async read(){return await x(this,ie).read()}async flush(){return await x(this,ie).flush()}write(i){x(this,ie).write(i)}writeConsole(i){this.write({type:"stdin",data:i+`
`})}interrupt(){x(this,ie).interrupt()}async installPackages(i,e){let t=Object.assign({quiet:!1,mount:!0},e),n={type:"installPackages",data:{name:i,options:t}};await x(this,ie).request(n)}async destroy(i){await this.globalShelter.destroy(i)}async evalR(i,e){return this.globalShelter.evalR(i,e)}async evalRVoid(i,e){return this.evalRRaw(i,"void",e)}async evalRBoolean(i,e){return this.evalRRaw(i,"boolean",e)}async evalRNumber(i,e){return this.evalRRaw(i,"number",e)}async evalRString(i,e){return this.evalRRaw(i,"string",e)}async evalRRaw(i,e,t={}){let n=Ut(t,se,o=>o._payload),r={type:"evalRRaw",data:{code:i,options:n,outputType:e}},s=await x(this,ie).request(r);switch(s.payloadType){case"raw":return s.obj;case"ptr":throw new $n("Unexpected ptr payload type returned from evalRVoid")}}async invokeWasmFunction(i,...e){let t={type:"invokeWasmFunction",data:{ptr:i,args:e}};return(await x(this,ie).request(t)).obj}};ie=new WeakMap,Zr=new WeakMap,Dl=new WeakSet,If=async function(){for(;;){let i=await x(this,ie).readSystem();switch(i.type){case"setTimeoutWasm":setTimeout((e,t)=>{this.invokeWasmFunction(e,...t)},i.data.delay,i.data.ptr,i.data.args);break;case"console.log":console.log(i.data);break;case"console.warn":console.warn(i.data);break;case"console.error":console.error(i.data);break;default:throw new di("Unknown system message type `"+i.type+"`")}}};var re,Z,Jr,$l=class{constructor(i){V(this,re,""),V(this,Z,void 0),V(this,Jr,!1),me(this,Z,i)}async init(){if(x(this,Jr))return;let i={type:"newShelter"},e=await x(this,Z).request(i);me(this,re,e.obj),this.RObject=Le(x(this,Z),x(this,re),"object"),this.RLogical=Le(x(this,Z),x(this,re),"logical"),this.RInteger=Le(x(this,Z),x(this,re),"integer"),this.RDouble=Le(x(this,Z),x(this,re),"double"),this.RComplex=Le(x(this,Z),x(this,re),"complex"),this.RCharacter=Le(x(this,Z),x(this,re),"character"),this.RRaw=Le(x(this,Z),x(this,re),"raw"),this.RList=Le(x(this,Z),x(this,re),"list"),this.RDataFrame=Le(x(this,Z),x(this,re),"dataframe"),this.RPairlist=Le(x(this,Z),x(this,re),"pairlist"),this.REnvironment=Le(x(this,Z),x(this,re),"environment"),this.RSymbol=Le(x(this,Z),x(this,re),"symbol"),this.RString=Le(x(this,Z),x(this,re),"string"),this.RCall=Le(x(this,Z),x(this,re),"call"),me(this,Jr,!0)}async purge(){let i={type:"shelterPurge",data:x(this,re)};await x(this,Z).request(i)}async destroy(i){let e={type:"shelterDestroy",data:{id:x(this,re),obj:i._payload}};await x(this,Z).request(e)}async size(){let i={type:"shelterSize",data:x(this,re)};return(await x(this,Z).request(i)).obj}async evalR(i,e={}){let t=Ut(e,se,s=>s._payload),n={type:"evalR",data:{code:i,options:t,shelter:x(this,re)}},r=await x(this,Z).request(n);switch(r.payloadType){case"raw":throw new $n("Unexpected payload type returned from evalR");default:return fi(x(this,Z),r)}}async captureR(i,e={}){let t=Ut(e,se,s=>s._payload),n={type:"captureR",data:{code:i,options:t,shelter:x(this,re)}},r=await x(this,Z).request(n);switch(r.payloadType){case"ptr":throw new $n("Unexpected payload type returned from evalR");case"raw":{let s=r.obj,o=fi(x(this,Z),s.result),l=s.output,a=s.images;for(let h=0;h{let e=new $l(i);return await e.init(),e}})}var zf=Symbol("Comlink.proxy"),Jl=Symbol("Comlink.endpoint"),Q0=Symbol("Comlink.releaseProxy"),Yl=Symbol("Comlink.finalizer"),ds=Symbol("Comlink.thrown"),Uf=i=>typeof i=="object"&&i!==null||typeof i=="function",M0={canHandle:i=>Uf(i)&&i[zf],serialize(i){let{port1:e,port2:t}=new MessageChannel;return Os(i,e),[t,[t]]},deserialize(i){return i.start(),Vn(i)}},_0={canHandle:i=>Uf(i)&&ds in i,serialize({value:i}){let e;return i instanceof Error?e={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:e={isError:!1,value:i},[e,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},gi=new Map([["proxy",M0],["throw",_0]]);function D0(i,e){for(let t of i)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Os(i,e=globalThis,t=["*"]){e.addEventListener("message",function n(r){if(!r||!r.data)return;if(!D0(t,r.origin)){console.warn(`Invalid origin '${r.origin}' for comlink proxy`);return}let{id:s,type:o,path:l}=Object.assign({path:[]},r.data),a=(r.data.argumentList||[]).map(mi),h;try{let c=l.slice(0,-1).reduce((u,d)=>u[d],i),f=l.reduce((u,d)=>u[d],i);switch(o){case"GET":h=f;break;case"SET":c[l.slice(-1)[0]]=mi(r.data.value),h=!0;break;case"APPLY":h=f.apply(c,a);break;case"CONSTRUCT":{let u=new f(...a);h=B0(u)}break;case"ENDPOINT":{let{port1:u,port2:d}=new MessageChannel;Os(i,d),h=X0(u,[u])}break;case"RELEASE":h=void 0;break;default:return}}catch(c){h={value:c,[ds]:0}}Promise.resolve(h).catch(c=>({value:c,[ds]:0})).then(c=>{let[f,u]=gs(c);e.postMessage(Object.assign(Object.assign({},f),{id:s}),u),o==="RELEASE"&&(e.removeEventListener("message",n),Ff(e),Yl in i&&typeof i[Yl]=="function"&&i[Yl]())}).catch(c=>{let[f,u]=gs({value:new TypeError("Unserializable return value"),[ds]:0});e.postMessage(Object.assign(Object.assign({},f),{id:s}),u)})}),e.start&&e.start()}function $0(i){return i.constructor.name==="MessagePort"}function Ff(i){$0(i)&&i.close()}function Vn(i,e){return Zl(i,[],e)}function us(i){if(i)throw new Error("Proxy has been released and is not useable")}function Hf(i){return Fi(i,{type:"RELEASE"}).then(()=>{Ff(i)})}var ps=new WeakMap,ms="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{let e=(ps.get(i)||0)-1;ps.set(i,e),e===0&&Hf(i)});function L0(i,e){let t=(ps.get(e)||0)+1;ps.set(e,t),ms&&ms.register(i,e,i)}function V0(i){ms&&ms.unregister(i)}function Zl(i,e=[],t=function(){}){let n=!1,r=new Proxy(t,{get(s,o){if(us(n),o===Q0)return()=>{V0(r),Hf(i),n=!0};if(o==="then"){if(e.length===0)return{then:()=>r};let l=Fi(i,{type:"GET",path:e.map(a=>a.toString())}).then(mi);return l.then.bind(l)}return Zl(i,[...e,o])},set(s,o,l){us(n);let[a,h]=gs(l);return Fi(i,{type:"SET",path:[...e,o].map(c=>c.toString()),value:a},h).then(mi)},apply(s,o,l){us(n);let a=e[e.length-1];if(a===Jl)return Fi(i,{type:"ENDPOINT"}).then(mi);if(a==="bind")return Zl(i,e.slice(0,-1));let[h,c]=jf(l);return Fi(i,{type:"APPLY",path:e.map(f=>f.toString()),argumentList:h},c).then(mi)},construct(s,o){us(n);let[l,a]=jf(o);return Fi(i,{type:"CONSTRUCT",path:e.map(h=>h.toString()),argumentList:l},a).then(mi)}});return L0(r,i),r}function q0(i){return Array.prototype.concat.apply([],i)}function jf(i){let e=i.map(gs);return[e.map(t=>t[0]),q0(e.map(t=>t[1]))]}var Gf=new WeakMap;function X0(i,e){return Gf.set(i,e),i}function B0(i){return Object.assign(i,{[zf]:!0})}function gs(i){for(let[e,t]of gi)if(t.canHandle(i)){let[n,r]=t.serialize(i);return[{type:"HANDLER",name:e,value:n},r]}return[{type:"RAW",value:i},Gf.get(i)||[]]}function mi(i){switch(i.type){case"HANDLER":return gi.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Fi(i,e,t){return new Promise(n=>{let r=W0();i.addEventListener("message",function s(o){!o.data||!o.data.id||o.data.id!==r||(i.removeEventListener("message",s),n(o.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:r},e),t)})}function W0(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Hi=[],Ke=class{constructor(e){this.isRunning=!1;this.isDestroyed=!1;Hi.push(this),e?this.callbacks=e:this.callbacks={busyCallback:()=>{},idleCallback:()=>{},runningCallback:()=>{},finishedCallback:()=>{}}}running(){this.isRunning=!0,Hi.forEach(e=>e.callbacks.busyCallback()),this.callbacks.runningCallback()}finished(){this.isRunning=!1,this.callbacks.finishedCallback(),this.status().busy||Hi.forEach(e=>e.callbacks.idleCallback())}status(){let e=this.isRunning,t=this.isDestroyed,n=Hi.some(r=>r.isRunning);return{running:e,busy:n,destroyed:t}}destroy(){this.isDestroyed=!0;let e=Hi.indexOf(this);Hi.splice(e,1)}};var W=class i{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=en(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Yi.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=en(this,e,t);let n=[];return this.decompose(e,t,n,0),Yi.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new bi(this),s=new bi(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(e=1){return new bi(this,e)}iterRange(e,t=this.length){return new vs(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new xs(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?i.empty:e.length<=32?new Ne(e):Yi.from(Ne.split(e,[]))}},Ne=class i extends W{constructor(e,t=I0(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?n:l)>=e)return new ea(r,l,n,o);r=l+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new i(Zf(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),l=ws(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new i(l,o.length+s.length));else{let a=l.length>>1;n.push(new i(l.slice(0,a)),new i(l.slice(a)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof i))return super.replace(e,t,n);[e,t]=en(this,e,t);let r=ws(this.text,ws(n.text,Zf(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new i(r,s):Yi.from(i.split(r,[]),s)}sliceString(e,t=this.length,n=`
`){[e,t]=en(this,e,t);let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=n),es&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new i(n,r)),n=[],r=-1);return r>-1&&t.push(new i(n,r)),t}},Yi=class i extends W{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=n+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,n,r);r=l+1,n=a+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?n.push(l):l.decompose(e-o,t-o,n,h)}o=a+1}}replace(e,t,n){if([e,t]=en(this,e,t),n.lines=s&&t<=l){let a=o.replace(e-s,t-s,n),h=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new i(c,this.length-(t-e)+n.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
diff --git a/docs/exercises/grading.qmd b/docs/exercises/grading.qmd
index 40cc2db..10d1a98 100644
--- a/docs/exercises/grading.qmd
+++ b/docs/exercises/grading.qmd
@@ -43,3 +43,47 @@ if (!is.function(.result)) {
}
```
+## Find any result in learner output
+
+Write R code that returns 2468 somewhere, even invisibly:
+
+```{webr}
+#| caption: Sample Exercise 2
+#| exercise: example_2
+123
+invisible(2468)
+456
+```
+
+```{webr}
+#| exercise: example_2
+#| check: true
+results <- Filter(\(x) inherits(x, "result"), .evaluate_result)
+if(is.null(Find(\(x) x$value == 2468, results))) {
+ list(correct = FALSE, message = "Incorrect, sorry.")
+} else {
+ list(correct = TRUE, message = "Correct!")
+}
+```
+
+## Feedback for a specific learner error
+
+```{webr}
+#| caption: Sample Exercise 3
+#| exercise: example_3
+123 + "456"
+```
+
+```{webr}
+#| exercise: example_3
+#| check: true
+errors <- Filter(\(x) inherits(x, "error"), .evaluate_result)
+this_error <- Filter(\(x) x$message == "non-numeric argument to binary operator", errors)
+if (length(this_error) > 0) {
+ list(
+ correct = FALSE,
+ type = "info",
+ message = "Be careful! In R you cannot add a number and a character string!"
+ )
+}
+```
diff --git a/live-runtime/src/scripts/R/setup.R b/live-runtime/src/scripts/R/setup.R
index aa66344..51e0970 100644
--- a/live-runtime/src/scripts/R/setup.R
+++ b/live-runtime/src/scripts/R/setup.R
@@ -23,29 +23,22 @@ options(pager = function(files, ...) {
options("webr.evaluate.handler" = evaluate::new_output_handler(
value = function(x, visible) {
knit_options = list(screenshot.force = FALSE)
- knit_print.df <- function (x) {
- method <- getOption("webr.render.df")
- if (method == "kable") {
- knitr::knit_print(knitr::kable(x))
- } else if (method == "paged-table") {
- knitr::knit_print(rmarkdown::paged_table(x))
- } else if (method == "gt") {
- knitr::knit_print(gt::gt(x))
- } else if (method == "gt-interactive") {
- knitr::knit_print(x |> gt::gt() |> gt::opt_interactive())
- } else if (method == "reactable") {
- knitr::knit_print(reactable::reactable(x), options = knit_options)
- } else {
- knitr::knit_print(x, options = knit_options)
- }
- }
-
res <- if (visible) {
- withVisible(if ("data.frame" %in% class(x)) {
- knit_print.df(x)
- } else {
- knitr::knit_print(x, options = knit_options)
- })
+ withVisible(
+ knitr::knit_print(
+ if (inherits(x, "data.frame")) {
+ switch(
+ getOption("webr.render.df"),
+ "kable" = knitr::kable(x),
+ "paged-table" = markdown::paged_table(x),
+ "gt" = gt::gt(x),
+ "gt-interactive" = gt::opt_interactive(gt::gt(x)),
+ "reactable" = reactable::reactable(x),
+ x
+ )
+ } else x,
+ options = knit_options)
+ )
} else list(value = x, visible = FALSE)
class(res) <- "result"
res