glassjar 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/glassjar.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(a,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(a=typeof globalThis<"u"?globalThis:a||self,x(a.engine={}))})(this,(function(a){"use strict";var x=typeof document<"u"?document.currentScript:null;function LA(Q){return Q&&Q.__esModule&&Object.prototype.hasOwnProperty.call(Q,"default")?Q.default:Q}var P={exports:{}},DA;function hA(){if(DA)return P.exports;DA=1;var Q=typeof Reflect=="object"?Reflect:null,A=Q&&typeof Q.apply=="function"?Q.apply:function(E,o,M){return Function.prototype.apply.call(E,o,M)},g;Q&&typeof Q.ownKeys=="function"?g=Q.ownKeys:Object.getOwnPropertySymbols?g=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:g=function(E){return Object.getOwnPropertyNames(E)};function I(w){console&&console.warn&&console.warn(w)}var C=Number.isNaN||function(E){return E!==E};function B(){B.init.call(this)}P.exports=B,P.exports.once=d,B.EventEmitter=B,B.prototype._events=void 0,B.prototype._eventsCount=0,B.prototype._maxListeners=void 0;var i=10;function D(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(B,"defaultMaxListeners",{enumerable:!0,get:function(){return i},set:function(w){if(typeof w!="number"||w<0||C(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");i=w}}),B.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},B.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||C(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function N(w){return w._maxListeners===void 0?B.defaultMaxListeners:w._maxListeners}B.prototype.getMaxListeners=function(){return N(this)},B.prototype.emit=function(E){for(var o=[],M=1;M<arguments.length;M++)o.push(arguments[M]);var G=E==="error",R=this._events;if(R!==void 0)G=G&&R.error===void 0;else if(!G)return!1;if(G){var k;if(o.length>0&&(k=o[0]),k instanceof Error)throw k;var p=new Error("Unhandled error."+(k?" ("+k.message+")":""));throw p.context=k,p}var b=R[E];if(b===void 0)return!1;if(typeof b=="function")A(b,this,o);else for(var JA=b.length,uA=q(b,JA),M=0;M<JA;++M)A(uA[M],this,o);return!0};function K(w,E,o,M){var G,R,k;if(D(o),R=w._events,R===void 0?(R=w._events=Object.create(null),w._eventsCount=0):(R.newListener!==void 0&&(w.emit("newListener",E,o.listener?o.listener:o),R=w._events),k=R[E]),k===void 0)k=R[E]=o,++w._eventsCount;else if(typeof k=="function"?k=R[E]=M?[o,k]:[k,o]:M?k.unshift(o):k.push(o),G=N(w),G>0&&k.length>G&&!k.warned){k.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+k.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=w,p.type=E,p.count=k.length,I(p)}return w}B.prototype.addListener=function(E,o){return K(this,E,o,!1)},B.prototype.on=B.prototype.addListener,B.prototype.prependListener=function(E,o){return K(this,E,o,!0)};function J(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function S(w,E,o){var M={fired:!1,wrapFn:void 0,target:w,type:E,listener:o},G=J.bind(M);return G.listener=o,M.wrapFn=G,G}B.prototype.once=function(E,o){return D(o),this.on(E,S(this,E,o)),this},B.prototype.prependOnceListener=function(E,o){return D(o),this.prependListener(E,S(this,E,o)),this},B.prototype.removeListener=function(E,o){var M,G,R,k,p;if(D(o),G=this._events,G===void 0)return this;if(M=G[E],M===void 0)return this;if(M===o||M.listener===o)--this._eventsCount===0?this._events=Object.create(null):(delete G[E],G.removeListener&&this.emit("removeListener",E,M.listener||o));else if(typeof M!="function"){for(R=-1,k=M.length-1;k>=0;k--)if(M[k]===o||M[k].listener===o){p=M[k].listener,R=k;break}if(R<0)return this;R===0?M.shift():m(M,R),M.length===1&&(G[E]=M[0]),G.removeListener!==void 0&&this.emit("removeListener",E,p||o)}return this},B.prototype.off=B.prototype.removeListener,B.prototype.removeAllListeners=function(E){var o,M,G;if(M=this._events,M===void 0)return this;if(M.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):M[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete M[E]),this;if(arguments.length===0){var R=Object.keys(M),k;for(G=0;G<R.length;++G)k=R[G],k!=="removeListener"&&this.removeAllListeners(k);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(o=M[E],typeof o=="function")this.removeListener(E,o);else if(o!==void 0)for(G=o.length-1;G>=0;G--)this.removeListener(E,o[G]);return this};function U(w,E,o){var M=w._events;if(M===void 0)return[];var G=M[E];return G===void 0?[]:typeof G=="function"?o?[G.listener||G]:[G]:o?EA(G):q(G,G.length)}B.prototype.listeners=function(E){return U(this,E,!0)},B.prototype.rawListeners=function(E){return U(this,E,!1)},B.listenerCount=function(w,E){return typeof w.listenerCount=="function"?w.listenerCount(E):s.call(w,E)},B.prototype.listenerCount=s;function s(w){var E=this._events;if(E!==void 0){var o=E[w];if(typeof o=="function")return 1;if(o!==void 0)return o.length}return 0}B.prototype.eventNames=function(){return this._eventsCount>0?g(this._events):[]};function q(w,E){for(var o=new Array(E),M=0;M<E;++M)o[M]=w[M];return o}function m(w,E){for(;E+1<w.length;E++)w[E]=w[E+1];w.pop()}function EA(w){for(var E=new Array(w.length),o=0;o<E.length;++o)E[o]=w[o].listener||w[o];return E}function d(w,E){return new Promise(function(o,M){function G(k){w.removeListener(E,R),M(k)}function R(){typeof w.removeListener=="function"&&w.removeListener("error",G),o([].slice.call(arguments))}YA(w,E,R,{once:!0}),E!=="error"&&vA(w,G,{once:!0})})}function vA(w,E,o){typeof w.on=="function"&&YA(w,"error",E,o)}function YA(w,E,o,M){if(typeof w.on=="function")M.once?w.once(E,o):w.on(E,o);else if(typeof w.addEventListener=="function")w.addEventListener(E,function G(R){M.once&&w.removeEventListener(E,G),o(R)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return P.exports}var SA=hA();const wA=LA(SA);class _{__destroy_into_raw(){const A=this.__wbg_ptr;return this.__wbg_ptr=0,NA.unregister(this),A}free(){const A=this.__destroy_into_raw();F.__wbg_dapadapter_free(A,0)}attach(A){F.dapadapter_attach(this.__wbg_ptr,A)}detach(){F.dapadapter_detach(this.__wbg_ptr)}constructor(){const A=F.dapadapter_new();return this.__wbg_ptr=A>>>0,NA.register(this,this.__wbg_ptr,this),this}on(A){F.dapadapter_on(this.__wbg_ptr,A)}resetRun(){F.dapadapter_resetRun(this.__wbg_ptr)}sendMessage(A){return F.dapadapter_sendMessage(this.__wbg_ptr,A)}setFilterInternals(A){F.dapadapter_setFilterInternals(this.__wbg_ptr,A)}}Symbol.dispose&&(_.prototype[Symbol.dispose]=_.prototype.free);class j{static __wrap(A){A=A>>>0;const g=Object.create(j.prototype);return g.__wbg_ptr=A,FA.register(g,g.__wbg_ptr,g),g}__destroy_into_raw(){const A=this.__wbg_ptr;return this.__wbg_ptr=0,FA.unregister(this),A}free(){const A=this.__destroy_into_raw();F.__wbg_trap_free(A,0)}static __wbg_wasmer_trap(){F.trap___wbg_wasmer_trap()}}Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);function sA(){let Q,A;try{const g=F.cpp_exception_hash();return Q=g[0],A=g[1],c(g[0],g[1])}finally{F.__wbindgen_free(Q,A,1)}}function iA(Q){const A=O(Q,F.__wbindgen_malloc,F.__wbindgen_realloc),g=T,I=F.prefetch_urls(A,g);var C=MA(I[0],I[1]).slice();return F.__wbindgen_free(I[0],I[1]*4,4),C}function cA(){return{__proto__:null,"./engine_bg.js":{__proto__:null,__wbg_BigInt_b7bbccdff258c9f2:function(A){return BigInt(A)},__wbg_Error_8c4e43fe74559d73:function(A,g){return Error(c(A,g))},__wbg_Number_04624de7d0e8332d:function(A){return Number(A)},__wbg_String_8f0eb39a4a4c2f66:function(A,g){const I=String(g),C=O(I,F.__wbindgen_malloc,F.__wbindgen_realloc),B=T;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2:function(A,g){const I=g,C=typeof I=="bigint"?I:void 0;L().setBigInt64(A+8,Z(C)?BigInt(0):C,!0),L().setInt32(A+0,!Z(C),!0)},__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25:function(A){const g=A,I=typeof g=="boolean"?g:void 0;return Z(I)?16777215:I?1:0},__wbg___wbindgen_debug_string_0bc8482c6e3508ae:function(A,g){const I=$(g),C=O(I,F.__wbindgen_malloc,F.__wbindgen_realloc),B=T;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg___wbindgen_function_table_5ae7216dfcbcc506:function(){return F.__wbindgen_export},__wbg___wbindgen_in_47fa6863be6f2f25:function(A,g){return A in g},__wbg___wbindgen_is_bigint_31b12575b56f32fc:function(A){return typeof A=="bigint"},__wbg___wbindgen_is_function_0095a73b8b156f76:function(A){return typeof A=="function"},__wbg___wbindgen_is_object_5ae8e5880f2c1fbd:function(A){const g=A;return typeof g=="object"&&g!==null},__wbg___wbindgen_is_string_cd444516edc5b180:function(A){return typeof A=="string"},__wbg___wbindgen_is_undefined_9e4d92534c42d778:function(A){return A===void 0},__wbg___wbindgen_jsval_eq_11888390b0186270:function(A,g){return A===g},__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811:function(A,g){return A==g},__wbg___wbindgen_lt_bb59cc3d23526e0d:function(A,g){return A<g},__wbg___wbindgen_neg_6b4d356dff49dcc6:function(A){return-A},__wbg___wbindgen_number_get_8ff4255516ccad3e:function(A,g){const I=g,C=typeof I=="number"?I:void 0;L().setFloat64(A+8,Z(C)?0:C,!0),L().setInt32(A+0,!Z(C),!0)},__wbg___wbindgen_rethrow_05525c567f154472:function(A){throw A},__wbg___wbindgen_shr_ef8e07cce709eb54:function(A,g){return A>>g},__wbg___wbindgen_string_get_72fb696202c56729:function(A,g){const I=g,C=typeof I=="string"?I:void 0;var B=Z(C)?0:O(C,F.__wbindgen_malloc,F.__wbindgen_realloc),i=T;L().setInt32(A+4,i,!0),L().setInt32(A+0,B,!0)},__wbg___wbindgen_throw_be289d5034ed271b:function(A,g){throw new Error(c(A,g))},__wbg__wbg_cb_unref_d9b87ff7982e3b21:function(A){A._wbg_cb_unref()},__wbg_addEventListener_3acb0aad4483804c:function(){return y(function(A,g,I,C){A.addEventListener(c(g,I),C)},arguments)},__wbg_apply_2e22c45cb4f12415:function(){return y(function(A,g,I){return Reflect.apply(A,g,I)},arguments)},__wbg_apply_ada2ee1a60ac7b3c:function(){return y(function(A,g,I){return A.apply(g,I)},arguments)},__wbg_arrayBuffer_bb54076166006c39:function(){return y(function(A){return A.arrayBuffer()},arguments)},__wbg_bind_1dc37de2b9939128:function(A,g,I,C){return A.bind(g,I,C)},__wbg_bind_29ba380591735d8c:function(A,g,I){return A.bind(g,I)},__wbg_buffer_7b5f53e46557d8f1:function(A){return A.buffer},__wbg_byteLength_7b03c17ff1e4037f:function(A){return A.byteLength},__wbg_byteLength_b5d783d06792ed2c:function(A){return A.byteLength},__wbg_call_389efe28435a9388:function(){return y(function(A,g){return A.call(g)},arguments)},__wbg_call_4708e0c13bdc8e95:function(){return y(function(A,g,I){return A.call(g,I)},arguments)},__wbg_compareExchange_b578410c358e695e:function(){return y(function(A,g,I,C){return Atomics.compareExchange(A,g>>>0,I,C)},arguments)},__wbg_constructor_ad6c0ed428f55d34:function(A){return A.constructor},__wbg_crypto_86f2631e91b51511:function(A){return A.crypto},__wbg_customSections_193491b069139fb1:function(A,g,I){return WebAssembly.Module.customSections(A,c(g,I))},__wbg_data_5330da50312d0bc1:function(A){return A.data},__wbg_done_57b39ecd9addfe81:function(A){return A.done},__wbg_entries_58c7934c745daac7:function(A){return Object.entries(A)},__wbg_error_7534b8e9a36f1ab4:function(A,g){let I,C;try{I=A,C=g,console.error(c(A,g))}finally{F.__wbindgen_free(I,C,1)}},__wbg_exports_794a42000dacd046:function(A){return WebAssembly.Module.exports(A)},__wbg_exports_86b4926134c40288:function(A){return A.exports},__wbg_fetch_d1488f40cef1e210:function(A,g,I){return A.fetch(c(g,I))},__wbg_from_bddd64e7d5ff6941:function(A){return Array.from(A)},__wbg_getPrototypeOf_2653517f1dc884d5:function(){return y(function(A){return Reflect.getPrototypeOf(A)},arguments)},__wbg_getRandomValues_b3f15fcbfabb0f8b:function(){return y(function(A,g){A.getRandomValues(g)},arguments)},__wbg_getTime_1e3cd1391c5c3995:function(A){return A.getTime()},__wbg_getTimezoneOffset_81776d10a4ec18a8:function(A){return A.getTimezoneOffset()},__wbg_getUint32_bb6f5a401408e7fa:function(A,g,I){return A.getUint32(g>>>0,I!==0)},__wbg_get_7efbcc3819719b0f:function(){return y(function(A,g){return A.get(g>>>0)},arguments)},__wbg_get_9b94d73e6221f75c:function(A,g){return A[g>>>0]},__wbg_get_b3ed3ad4be2bc8ac:function(){return y(function(A,g){return Reflect.get(A,g)},arguments)},__wbg_get_index_253dd2a9e007656d:function(A,g){return A[g>>>0]},__wbg_get_index_9a5bfdd2ca49c65f:function(A,g){return A[g>>>0]},__wbg_get_with_ref_key_1dc361bd10053bfe:function(A,g){return A[g]},__wbg_grow_5d42bf28c2da22cb:function(){return y(function(A,g){return A.grow(g>>>0)},arguments)},__wbg_grow_d034989fce14cc8e:function(){return y(function(A,g){return A.grow(g>>>0)},arguments)},__wbg_imports_8333d40ab24779ad:function(A){return WebAssembly.Module.imports(A)},__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04:function(A){let g;try{g=A instanceof ArrayBuffer}catch{g=!1}return g},__wbg_instanceof_Error_8573fe0b0b480f46:function(A){let g;try{g=A instanceof Error}catch{g=!1}return g},__wbg_instanceof_Function_2a29eec978bb3b11:function(A){let g;try{g=A instanceof Function}catch{g=!1}return g},__wbg_instanceof_Global_2db767b6b2347f01:function(A){let g;try{g=A instanceof WebAssembly.Global}catch{g=!1}return g},__wbg_instanceof_Map_53af74335dec57f4:function(A){let g;try{g=A instanceof Map}catch{g=!1}return g},__wbg_instanceof_Memory_dc8c61e3f831ee37:function(A){let g;try{g=A instanceof WebAssembly.Memory}catch{g=!1}return g},__wbg_instanceof_Module_d0d412b14363ba9a:function(A){let g;try{g=A instanceof WebAssembly.Module}catch{g=!1}return g},__wbg_instanceof_Object_1c6af87502b733ed:function(A){let g;try{g=A instanceof Object}catch{g=!1}return g},__wbg_instanceof_RangeError_0b0dd056bc557b89:function(A){let g;try{g=A instanceof RangeError}catch{g=!1}return g},__wbg_instanceof_Response_ee1d54d79ae41977:function(A){let g;try{g=A instanceof Response}catch{g=!1}return g},__wbg_instanceof_SharedArrayBuffer_91d8a2fa16a2cc26:function(A){let g;try{g=A instanceof SharedArrayBuffer}catch{g=!1}return g},__wbg_instanceof_Table_127f216e592f4159:function(A){let g;try{g=A instanceof WebAssembly.Table}catch{g=!1}return g},__wbg_instanceof_Tag_f1d6b24a98b95210:function(A){let g;try{g=A instanceof WebAssembly.Tag}catch{g=!1}return g},__wbg_instanceof_Uint8Array_9b9075935c74707c:function(A){let g;try{g=A instanceof Uint8Array}catch{g=!1}return g},__wbg_isArray_d314bb98fcf08331:function(A){return Array.isArray(A)},__wbg_isSafeInteger_bfbc7332a9768d2a:function(A){return Number.isSafeInteger(A)},__wbg_is_f29129f676e5410c:function(A,g){return Object.is(A,g)},__wbg_iterator_6ff6560ca1568e55:function(){return Symbol.iterator},__wbg_length_32ed9a279acd054c:function(A){return A.length},__wbg_length_35a7bace40f36eac:function(A){return A.length},__wbg_length_aeb94ff17a8a8556:function(A){return A.length},__wbg_load_eff64ff5e429a422:function(){return y(function(A,g){return Atomics.load(A,g>>>0)},arguments)},__wbg_message_9ddc4b9a62a7c379:function(A){return A.message},__wbg_msCrypto_d562bbe83e0d4b91:function(A){return A.msCrypto},__wbg_new_0728bd2d4c5d41dd:function(){return y(function(A){return new WebAssembly.Tag(A)},arguments)},__wbg_new_0_73afc35eb544e539:function(){return new Date},__wbg_new_245cd5c49157e602:function(A){return new Date(A)},__wbg_new_2ac7fa8be584d280:function(A,g,I){return new DataView(A,g>>>0,I>>>0)},__wbg_new_361308b2356cecd0:function(){return new Object},__wbg_new_3eb36ae241fe6f44:function(){return new Array},__wbg_new_4a996a46a82782b6:function(){return y(function(A,g){return new WebAssembly.Global(A,g)},arguments)},__wbg_new_57c27ff3ddf5b62c:function(){return y(function(A){return new WebAssembly.Module(A)},arguments)},__wbg_new_67274f72d5abea37:function(){return y(function(A){return new WebAssembly.Table(A)},arguments)},__wbg_new_8a6f238a6ece86ea:function(){return new Error},__wbg_new_a4e3cab1cdd635ba:function(){return y(function(A,g){return new WebAssembly.Instance(A,g)},arguments)},__wbg_new_b061c0550d9f3281:function(){return y(function(A){return new WebAssembly.Memory(A)},arguments)},__wbg_new_b5d9e2fb389fef91:function(A,g){try{var I={a:A,b:g},C=(i,D)=>{const N=I.a;I.a=0;try{return ZA(N,I.b,i,D)}finally{I.a=N}};return new Promise(C)}finally{I.a=I.b=0}},__wbg_new_ca409f861989e0c5:function(A){return new SharedArrayBuffer(A>>>0)},__wbg_new_dca287b076112a51:function(){return new Map},__wbg_new_dd2b680c8bf6ae29:function(A){return new Uint8Array(A)},__wbg_new_from_slice_a3d2629dc1826784:function(A,g){return new Uint8Array(n(A,g))},__wbg_new_no_args_1c7c842f08d00ebb:function(A,g){return new Function(c(A,g))},__wbg_new_with_args_7bba34e94b1cfa40:function(A,g,I,C){return new Function(c(A,g),c(I,C))},__wbg_new_with_byte_offset_9120ba79e057895b:function(A,g){return new Uint8Array(A,g>>>0)},__wbg_new_with_byte_offset_and_length_aa261d9c9da49eb1:function(A,g,I){return new Uint8Array(A,g>>>0,I>>>0)},__wbg_new_with_byte_offset_and_length_bc2e7b72cc96d1c1:function(A,g,I){return new Int32Array(A,g>>>0,I>>>0)},__wbg_new_with_length_1763c527b2923202:function(A){return new Array(A>>>0)},__wbg_new_with_length_a2c39cbe88fd8ff1:function(A){return new Uint8Array(A>>>0)},__wbg_next_3482f54c49e8af19:function(){return y(function(A){return A.next()},arguments)},__wbg_next_418f80d8f5303233:function(A){return A.next},__wbg_node_e1f24f89a7336c2e:function(A){return A.node},__wbg_notify_78a90977fab74963:function(){return y(function(A,g){return Atomics.notify(A,g>>>0)},arguments)},__wbg_now_a3af9a2f4bbaa4d1:function(){return Date.now()},__wbg_now_ebffdf7e580f210d:function(A){return A.now()},__wbg_ok_87f537440a0acf85:function(A){return A.ok},__wbg_postMessage_2041f4e90af61318:function(){return y(function(A,g){A.postMessage(g)},arguments)},__wbg_process_3975fd6c72f520aa:function(A){return A.process},__wbg_prototypesetcall_bdcdcc5842e4d77d:function(A,g,I){Uint8Array.prototype.set.call(n(A,g),I)},__wbg_push_8ffdcb2063340ba5:function(A,g){return A.push(g)},__wbg_queueMicrotask_0aa0a927f78f5d98:function(A){return A.queueMicrotask},__wbg_queueMicrotask_5bb536982f78a56f:function(A){queueMicrotask(A)},__wbg_randomFillSync_f8c153b79f285817:function(){return y(function(A,g){A.randomFillSync(g)},arguments)},__wbg_removeEventListener_e63328781a5b9af9:function(){return y(function(A,g,I,C){A.removeEventListener(c(g,I),C)},arguments)},__wbg_require_b74f47fc2d022fd6:function(){return y(function(){return module.require},arguments)},__wbg_resolve_002c4b7d9d8f6b64:function(A){return Promise.resolve(A)},__wbg_setTimeout_e0aacd5a637418a6:function(){return y(function(A,g,I){return A.setTimeout(g,I)},arguments)},__wbg_setUint32_d168af7751a8557e:function(A,g,I,C){A.setUint32(g>>>0,I>>>0,C!==0)},__wbg_set_0af2522656c2a71b:function(){return y(function(A,g,I){A.set(g>>>0,I)},arguments)},__wbg_set_1eb0999cf5d27fc8:function(A,g,I){return A.set(g,I)},__wbg_set_25cf9deff6bf0ea8:function(A,g,I){A.set(g,I>>>0)},__wbg_set_3f1d0b984ed272ed:function(A,g,I){A[g]=I},__wbg_set_6cb8631f80447a67:function(){return y(function(A,g,I){return Reflect.set(A,g,I)},arguments)},__wbg_set_cc56eefd2dd91957:function(A,g,I){A.set(n(g,I))},__wbg_set_f43e577aea94465b:function(A,g,I){A[g>>>0]=I},__wbg_set_index_b3244a6c458021e4:function(A,g,I){A[g>>>0]=I},__wbg_set_index_f259b54e97f7b177:function(A,g,I){A[g>>>0]=I},__wbg_set_onmessage_ea7cc2ba099021cd:function(A,g){A.onmessage=g},__wbg_set_value_fc06e541de098215:function(A,g){A.value=g},__wbg_slice_8bbd46adb2100583:function(A,g,I){return A.slice(g>>>0,I>>>0)},__wbg_stack_0ed75d68575b0f3c:function(A,g){const I=g.stack,C=O(I,F.__wbindgen_malloc,F.__wbindgen_realloc),B=T;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg_static_accessor_GLOBAL_12837167ad935116:function(){const A=typeof global>"u"?null:global;return Z(A)?0:V(A)},__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f:function(){const A=typeof globalThis>"u"?null:globalThis;return Z(A)?0:V(A)},__wbg_static_accessor_SELF_a621d3dfbb60d0ce:function(){const A=typeof self>"u"?null:self;return Z(A)?0:V(A)},__wbg_static_accessor_WINDOW_f8727f0cf888e0bd:function(){const A=typeof window>"u"?null:window;return Z(A)?0:V(A)},__wbg_store_d1d951c98d9bed41:function(){return y(function(A,g,I){return Atomics.store(A,g>>>0,I)},arguments)},__wbg_subarray_a96e1fef17ed23cb:function(A,g,I){return A.subarray(g>>>0,I>>>0)},__wbg_then_0d9fe2c7b1857d32:function(A,g,I){return A.then(g,I)},__wbg_then_b9e7b3b5f1a9e1b5:function(A,g){return A.then(g)},__wbg_toString_56d946daff83867b:function(A,g,I){const C=g.toString(I),B=O(C,F.__wbindgen_malloc,F.__wbindgen_realloc),i=T;L().setInt32(A+4,i,!0),L().setInt32(A+0,B,!0)},__wbg_toString_964ff7fe6eca8362:function(A){return A.toString()},__wbg_trap_new:function(A){return j.__wrap(A)},__wbg_validate_71c2d02a71bda62f:function(){return y(function(A){return WebAssembly.validate(A)},arguments)},__wbg_value_0546255b415e96c1:function(A){return A.value},__wbg_value_ce37a60e576310ff:function(A){return A.value},__wbg_versions_4e31226f5e8dc909:function(A){return A.versions},__wbg_wait_be5dae1e53f590f1:function(){return y(function(A,g,I){return Atomics.wait(A,g>>>0,I)},arguments)},__wbg_warn_81ab00e6e16e886d:function(A,g,I){console.warn(A,g,I)},__wbindgen_cast_0000000000000001:function(A,g){return dA(A,g,F.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__Fn__web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent____Output_______,HA)},__wbindgen_cast_0000000000000002:function(A,g){return z(A,g,F.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__Fn__web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent____Output_______,aA)},__wbindgen_cast_0000000000000003:function(A,g){return z(A,g,F.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,oA)},__wbindgen_cast_0000000000000004:function(A,g){return z(A,g,F.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,oA)},__wbindgen_cast_0000000000000005:function(A,g){return z(A,g,F.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,pA)},__wbindgen_cast_0000000000000006:function(A,g){return z(A,g,F.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__FnMut__wasm_bindgen_36932265c58943ab___JsValue____Output_______,qA)},__wbindgen_cast_0000000000000007:function(A){return A},__wbindgen_cast_0000000000000008:function(A){return A},__wbindgen_cast_0000000000000009:function(A,g){return n(A,g)},__wbindgen_cast_000000000000000a:function(A,g){return c(A,g)},__wbindgen_cast_000000000000000b:function(A,g){return BigInt.asUintN(64,A)|BigInt.asUintN(64,g)<<BigInt(64)},__wbindgen_cast_000000000000000c:function(A){return BigInt.asUintN(64,A)},__wbindgen_cast_000000000000000d:function(A,g){var I=MA(A,g).slice();return F.__wbindgen_free(A,g*4,4),I},__wbindgen_init_externref_table:function(){const A=F.__wbindgen_externrefs,g=A.grow(4);A.set(0,void 0),A.set(g+0,void 0),A.set(g+1,null),A.set(g+2,!0),A.set(g+3,!1)}}}}function HA(Q,A,g){F.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent_____(Q,A,g)}function aA(Q,A,g){F.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent______1_(Q,A,g)}function qA(Q,A,g){F.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___wasm_bindgen_36932265c58943ab___JsValue_____(Q,A,g)}function pA(Q,A,g){const I=F.wasm_bindgen_36932265c58943ab___convert__closures________invoke___js_sys_9eaf8169b8189500___Array__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_36932265c58943ab___JsValue__(Q,A,g);if(I[1])throw AA(I[0])}function oA(Q,A,g){const I=F.wasm_bindgen_36932265c58943ab___convert__closures________invoke___js_sys_9eaf8169b8189500___Array__core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue__(Q,A,g);if(I[2])throw AA(I[1]);return AA(I[0])}function ZA(Q,A,g,I){F.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___wasm_bindgen_36932265c58943ab___JsValue__wasm_bindgen_36932265c58943ab___JsValue_____(Q,A,g,I)}const NA=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>F.__wbg_dapadapter_free(Q>>>0,1)),FA=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>F.__wbg_trap_free(Q>>>0,1));function V(Q){const A=F.__externref_table_alloc();return F.__wbindgen_externrefs.set(A,Q),A}const r=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>Q.dtor(Q.a,Q.b));function $(Q){const A=typeof Q;if(A=="number"||A=="boolean"||Q==null)return`${Q}`;if(A=="string")return`"${Q}"`;if(A=="symbol"){const C=Q.description;return C==null?"Symbol":`Symbol(${C})`}if(A=="function"){const C=Q.name;return typeof C=="string"&&C.length>0?`Function(${C})`:"Function"}if(Array.isArray(Q)){const C=Q.length;let B="[";C>0&&(B+=$(Q[0]));for(let i=1;i<C;i++)B+=", "+$(Q[i]);return B+="]",B}const g=/\[object ([^\]]+)\]/.exec(toString.call(Q));let I;if(g&&g.length>1)I=g[1];else return toString.call(Q);if(I=="Object")try{return"Object("+JSON.stringify(Q)+")"}catch{return"Object"}return Q instanceof Error?`${Q.name}: ${Q.message}
|
|
2
|
-
${Q.stack}`:I}function MA(Q,A){Q=Q>>>0;const g=L(),I=[];for(let C=Q;C<Q+4*A;C+=4)I.push(F.__wbindgen_externrefs.get(g.getUint32(C,!0)));return F.__externref_drop_slice(Q,A),I}function n(Q,A){return Q=Q>>>0,l().subarray(Q/1,Q/1+A)}let W=null;function L(){return(W===null||W.buffer.detached===!0||W.buffer.detached===void 0&&W.buffer!==F.memory.buffer)&&(W=new DataView(F.memory.buffer)),W}function c(Q,A){return Q=Q>>>0,xA(Q,A)}let t=null;function l(){return(t===null||t.byteLength===0)&&(t=new Uint8Array(F.memory.buffer)),t}function y(Q,A){try{return Q.apply(this,A)}catch(g){const I=V(g);F.__wbindgen_exn_store(I)}}function Z(Q){return Q==null}function dA(Q,A,g,I){const C={a:Q,b:A,cnt:1,dtor:g},B=(...i)=>{C.cnt++;try{return I(C.a,C.b,...i)}finally{B._wbg_cb_unref()}};return B._wbg_cb_unref=()=>{--C.cnt===0&&(C.dtor(C.a,C.b),C.a=0,r.unregister(C))},r.register(B,C,C),B}function z(Q,A,g,I){const C={a:Q,b:A,cnt:1,dtor:g},B=(...i)=>{C.cnt++;const D=C.a;C.a=0;try{return I(D,C.b,...i)}finally{C.a=D,B._wbg_cb_unref()}};return B._wbg_cb_unref=()=>{--C.cnt===0&&(C.dtor(C.a,C.b),C.a=0,r.unregister(C))},r.register(B,C,C),B}function O(Q,A,g){if(g===void 0){const D=f.encode(Q),N=A(D.length,1)>>>0;return l().subarray(N,N+D.length).set(D),T=D.length,N}let I=Q.length,C=A(I,1)>>>0;const B=l();let i=0;for(;i<I;i++){const D=Q.charCodeAt(i);if(D>127)break;B[C+i]=D}if(i!==I){i!==0&&(Q=Q.slice(i)),C=g(C,I,I=i+Q.length*3,1)>>>0;const D=l().subarray(C+i,C+I),N=f.encodeInto(Q,D);i+=N.written,C=g(C,I,i,1)>>>0}return T=i,C}function AA(Q){const A=F.__wbindgen_externrefs.get(Q);return F.__externref_table_dealloc(Q),A}let v=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});v.decode();const TA=2146435072;let gA=0;function xA(Q,A){return gA+=A,gA>=TA&&(v=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),v.decode(),gA=A),v.decode(l().subarray(Q,Q+A))}const f=new TextEncoder;"encodeInto"in f||(f.encodeInto=function(Q,A){const g=f.encode(Q);return A.set(g),{read:Q.length,written:g.length}});let T=0,F;function WA(Q,A){return F=Q.exports,W=null,t=null,F.__wbindgen_start(),F}async function OA(Q,A){if(typeof Response=="function"&&Q instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(Q,A)}catch(C){if(Q.ok&&g(Q.type)&&Q.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",C);else throw C}const I=await Q.arrayBuffer();return await WebAssembly.instantiate(I,A)}else{const I=await WebAssembly.instantiate(Q,A);return I instanceof WebAssembly.Instance?{instance:I,module:Q}:I}function g(I){switch(I){case"basic":case"cors":case"default":return!0}return!1}}async function jA(Q){if(F!==void 0)return F;Q!==void 0&&(Object.getPrototypeOf(Q)===Object.prototype?{module_or_path:Q}=Q:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),Q===void 0&&(Q=new URL("",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:x&&x.tagName.toUpperCase()==="SCRIPT"&&x.src||new URL("glassjar.umd.cjs",document.baseURI).href));const A=cA();(typeof Q=="string"||typeof Request=="function"&&Q instanceof Request||typeof URL=="function"&&Q instanceof URL)&&(Q=fetch(Q));const{instance:g,module:I}=await OA(await Q,A);return WA(g)}const VA=new URL("https://cdn.jsdelivr.net/npm/glassjar@0.5.2/dist/engine_bg.wasm"),tA=Object.freeze({maxObjectBytes:128*1024*1024,maxEntries:256,maxMetadataBytes:8*1024*1024,maxEntryMetadataBytes:1024*1024});class lA{records=new Map;staged=new Map;stagingFailed=!1;objectBytes=0;metadataBytes=0;evictions=0;oversized=0;limits;constructor(A={}){this.limits=Object.freeze({...tA,...A});for(const g of Object.values(this.limits))if(!Number.isSafeInteger(g)||g<0)throw new RangeError("C++ cache limits must be nonnegative safe integers")}beginBatch(){this.discardBatch(),this.stagingFailed=!1}stage(A){if(this.stagingFailed)return;const g=this.recordSize(A);if(g===void 0||this.staged.has(A.source)){this.failBatch();return}const I=this.limits;for(;this.records.size&&(this.records.size+this.staged.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes);)this.remove(this.records.keys().next().value),this.evictions++;if(this.records.size+this.staged.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes||g>I.maxEntryMetadataBytes){this.oversized++,this.failBatch();return}this.staged.set(A.source,{...A,object:new Uint8Array(A.object),metadataBytes:g}),this.objectBytes+=A.object.byteLength,this.metadataBytes+=g}abandonBatch(){this.failBatch()}failBatch(){this.discardBatch(),this.stagingFailed=!0}recordSize(A){if(!(typeof A.source!="string"||!A.source.startsWith("/")||A.source.split("/").slice(1).some(g=>!g||g==="."||g==="..")||typeof A.key!="string"||typeof A.object_hash!="string"||!/^[a-f0-9]{64}$/.test(A.key)||!/^[a-f0-9]{64}$/.test(A.object_hash)||A.receipt!=null&&typeof A.receipt!="string"||!(A.object instanceof Uint8Array)))return new TextEncoder().encode(JSON.stringify({source:A.source,key:A.key,object_hash:A.object_hash,...A.receipt==null?{}:{receipt:A.receipt}})).byteLength}async validateBatch(){if(this.stagingFailed)return!1;const A=[...this.staged.values()];for(const g of A){if(!zA(g.object))return!1;const I=await crypto.subtle.digest("SHA-256",g.object);if(Array.from(new Uint8Array(I),B=>B.toString(16).padStart(2,"0")).join("")!==g.object_hash)return!1}return!0}commitBatch(){for(const[A,g]of this.staged)this.remove(A),this.records.set(A,g);this.staged.clear(),this.stagingFailed=!1}discardBatch(){for(const A of this.staged.values())this.objectBytes-=A.object.byteLength,this.metadataBytes-=A.metadataBytes;this.staged.clear()}snapshot(){return[...this.records.values()].map(({source:A,key:g,object_hash:I,object:C,receipt:B})=>({source:A,key:g,object_hash:I,...B==null?{}:{receipt:B},object:C.slice()}))}touch(A){const g=this.records.get(A);g&&(this.records.delete(A),this.records.set(A,g))}put(A){if(typeof A.source!="string"||!A.source.startsWith("/")||A.source.split("/").slice(1).some(B=>!B||B==="."||B==="..")||typeof A.key!="string"||typeof A.object_hash!="string"||!/^[a-f0-9]{64}$/.test(A.object_hash)||!/^[a-f0-9]{64}$/.test(A.key)||!(A.object instanceof Uint8Array))return;const g=this.recordSize(A);if(g===void 0)return;const I=this.limits;if(this.remove(A.source),I.maxEntries===0||A.object.byteLength>I.maxObjectBytes||g>I.maxMetadataBytes||g>I.maxEntryMetadataBytes){this.oversized++;return}for(;this.records.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes;)this.remove(this.records.keys().next().value),this.evictions++;const C={...A,object:new Uint8Array(A.object),metadataBytes:g};this.records.set(A.source,C),this.objectBytes+=C.object.byteLength,this.metadataBytes+=g}delete(A){this.remove(A)}remove(A){const g=this.records.get(A);g&&(this.objectBytes-=g.object.byteLength,this.metadataBytes-=g.metadataBytes,this.records.delete(A))}clear(){this.records.clear(),this.staged.clear(),this.stagingFailed=!1,this.objectBytes=this.metadataBytes=0}stats(){return{objectBytes:this.objectBytes,metadataBytes:this.metadataBytes,entries:this.records.size,stagingEntries:this.staged.size,stagingObjectBytes:[...this.staged.values()].reduce((A,g)=>A+g.object.byteLength,0),stagingMetadataBytes:[...this.staged.values()].reduce((A,g)=>A+g.metadataBytes,0),evictions:this.evictions,oversized:this.oversized}}}function zA(Q){if(!WebAssembly.validate(Q)||Q.length<8)return!1;let A=8,g=!1;const I=()=>{let C=0,B=0;for(let i=0;i<5&&A<Q.length;i++,B+=7){const D=Q[A++];if(C+=(D&127)*2**B,!(D&128))return C}throw new Error("Malformed object section")};try{for(;A<Q.length;){const C=Q[A++],B=I(),i=A+B;if(i>Q.length||C===8)return!1;if(C===0){const D=I();if(A+D>i)return!1;const N=new TextDecoder().decode(Q.subarray(A,A+D));if(A+=D,N==="linking"){if(g||I()!==2)return!1;g=!0}}A=i}return g}catch{return!1}}const Y=Symbol();function h(Q){return Q instanceof Error?{type:"error",error:{type:Q.constructor.name,message:Q.message}}:{type:"error",error:{type:typeof Q,message:String(Q)}}}class GA{name;data;constructor(A,g){this.name=A,this.data=g}download(){const A=new Uint8Array(this.data),g=new Blob([A]),I=URL.createObjectURL(g),C=document.createElement("a");C.href=I,C.download=this.name,document.body.appendChild(C),C.click(),document.body.removeChild(C),URL.revokeObjectURL(I)}}class kA extends wA{[Y];dap;enabled=!0;set filterInternals(A){this.dap.setFilterInternals(A)}constructor(){super(),this[Y]={attach:this.attach.bind(this),detach:this.detach.bind(this),beginRun:()=>this.dap.resetRun()},this.onMessage=this.onMessage.bind(this),this.dap=new _,this.dap.on(this.onMessage)}send(A){return this.dap.sendMessage(A)}artifactListener=A=>{if(A.data.type!=="artifact")return;const g=new GA(A.data.name,new Uint8Array(A.data.data));this.emit("artifact",g)};attach(A){A.addEventListener("message",this.artifactListener),this.dap.attach(A)}detach(A){A.removeEventListener("message",this.artifactListener),this.dap.detach()}onMessage(A){this.emit("event",A)}}const fA="glassjar-wasm:";function XA(Q,A){const g=new URL(String(Q),A);if(g.protocol!=="https:"&&g.protocol!=="http:")throw new TypeError(`Engine Wasm must be served over http(s), not ${g.protocol}`);return g.href}function mA(Q){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/worker-DZhDh6SZ.js").href:new URL("assets/worker-DZhDh6SZ.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),{type:"module",name:Q?.name})}function bA(Q){return new mA(Q?{name:fA+Q}:void 0)}const PA="/dev/debugger-sh-host";class yA{buffer=new SharedArrayBuffer(4+64*1024);length=new Int32Array(this.buffer,0,1);bytes=new Uint8Array(this.buffer,4);publish(A){Atomics.store(this.length,0,A),Atomics.notify(this.length,0)}}function IA(Q){try{return new Error(`Host device callback failed: ${Q instanceof Error?Q.message:String(Q)}`)}catch{return new Error("Host device callback failed")}}function KA(Q){try{const A=Q?.();if(A&&typeof A.then=="function")return Promise.resolve(A).catch(()=>{}),new TypeError("Host device cleanup must be synchronous")}catch(A){return IA(A)}}class rA{constructor(A){this.onFailure=A}incoming=new yA;outgoing=new yA;workerStart={guest_to_host:this.incoming.buffer,host_to_guest:this.outgoing.buffer};abort=new AbortController;listeners=new Set;cleanup;worker;writing=!1;open(A){let g;try{g=A({signal:this.abort.signal,onData:I=>{if(this.assertOpen(),typeof I!="function")throw new TypeError("Host device listener must be a function");return this.listeners.add(I),()=>{this.listeners.delete(I)}},write:I=>this.write(I)})}catch(I){throw IA(I)}if(g!==void 0&&typeof g!="function")throw Promise.resolve(g).catch(()=>{}),new TypeError("Host device opener must return a cleanup function or undefined");if(typeof g=="function")if(this.abort.signal.aborted){const I=KA(g);if(I)throw I}else this.cleanup=g}attach(A){this.assertOpen(),this.worker=A,A.addEventListener("message",this.onMessage)}assertOpen(){if(this.abort.signal.aborted)throw new Error("Host device is closed")}async write(A){if(this.assertOpen(),!(A instanceof Uint8Array))throw new TypeError("Host device writes require Uint8Array");if(this.writing)throw new Error("Await the previous host device write before writing again");this.writing=!0;try{const g=new Uint8Array(A),I=this.outgoing;let C=0;for(;C<g.length;){this.assertOpen();const B=Atomics.load(I.length,0);if(B!==0){await Atomics.waitAsync(I.length,0,B).value;continue}const i=g.subarray(C,C+I.bytes.length);I.bytes.set(i),I.publish(i.length),C+=i.length}}finally{this.writing=!1}}onMessage=A=>{if(!(this.abort.signal.aborted||A.data?.type!=="host_wake"))try{const g=Atomics.load(this.incoming.length,0);if(g<=0)return;const I=this.incoming.bytes.slice(0,g);this.incoming.publish(0);for(const C of this.listeners){if(this.abort.signal.aborted)break;Promise.resolve(C(I)).catch(B=>this.fail(B))}}catch(g){this.fail(g)}};fail(A){this.abort.signal.aborted||(this.close(),this.onFailure(IA(A)))}close(){if(this.abort.signal.aborted)return;this.worker?.removeEventListener("message",this.onMessage),this.worker=void 0,this.incoming.publish(-1),this.outgoing.publish(-1),this.abort.abort(),this.listeners.clear();const A=this.cleanup;return this.cleanup=void 0,KA(A)}}const nA=["4847c7cda81eb51b1cec18fe40b396605579fe84e17eca2760702b8a9666e4e1"],u=Object.freeze({compiler:"2d2c6ae498b27592a3cec7a270f274a08848a834e762cc08818c78626c32053a",sysroot:"8745c6af23fd841fa507d0c73f6b6b8e8da1b4ec216a6339739a28b38ff7227b",exceptions:"20986166552953de0e3ca5c1e9f341e7aec8b9ba54dcb244d0d2b2f9ca843ab4"});function RA(Q="legacy"){if(Q==="legacy")return{profile:Q,digests:u};if(Q==="stock-certified-v1"&&nA.length>0)return{profile:Q,digests:u};throw new Error(`The ${Q} toolchain is not available in this build`)}class X{#A;hashCount=3;hashMs;constructor(A,g){this.#A=A,this.hashMs=g}static async load(A,g,I,C=u.exceptions,B="legacy"){const i=RA(B);if(A.length!==2)throw new Error("Missing C++ toolchain assets");let D,N;const K=await Promise.allSettled(A.map(async(m,EA)=>{try{const d=await fetch(m,{cache:"force-cache",signal:I});if(!d.ok)throw new Error(`Cannot load C++ toolchain (${d.status})`);return EA===0&&g&&typeof WebAssembly.compileStreaming=="function"&&typeof d.clone=="function"&&(N=WebAssembly.compileStreaming(d.clone()).catch(()=>{})),new Uint8Array(await d.arrayBuffer())}catch(d){throw D??={error:d},d}}));if(K[0].status==="rejected"||K[1].status==="rejected")throw D?.error;const[J,S]=[K[0].value,K[1].value],[U,s]=await Promise.allSettled([X.ingestOwned(J,S,!1,C),g?(N??Promise.resolve(void 0)).then(m=>m??WebAssembly.compile(J)):Promise.resolve(void 0)]);if(U.status==="rejected")throw U.reason;const q=U.value;if(q.#A.compilerHash!==i.digests.compiler||q.#A.sysrootHash!==i.digests.sysroot||q.#A.exceptionsHash!==i.digests.exceptions)throw new Error("C++ toolchain integrity mismatch");if(I?.aborted)throw new DOMException("Toolchain loading aborted","AbortError");if(s.status==="rejected")throw s.reason;return q.#A.stockProfile=i.profile==="stock-certified-v1",q.#A.module=s.value,q}static async fromBytes(A,g,I){const C=new Uint8Array(A),B=new Uint8Array(g);return X.ingestOwned(C,B,I,u.exceptions)}static async ingestOwned(A,g,I,C){const B=performance.now(),i=await Promise.allSettled([UA(A),UA(g)]);if(i[0].status==="rejected")throw i[0].reason;if(i[1].status==="rejected")throw i[1].reason;const[D,N]=[i[0].value,i[1].value],K=I?await WebAssembly.compile(A):void 0;return new X({compiler:A,sysroot:g,compilerHash:D,sysrootHash:N,exceptionsHash:C,module:K},performance.now()-B)}matchesExpectation(A){return A.compilerSha256===this.#A.compilerHash&&A.sysrootSha256===this.#A.sysrootHash&&A.exceptionsSha256===this.#A.exceptionsHash}get identity(){return`${this.#A.compilerHash}:${this.#A.sysrootHash}:${this.#A.exceptionsHash}`}get identityBytes(){return this.#A.compiler.byteLength+this.#A.sysroot.byteLength}get compilerBytes(){return this.#A.compiler.byteLength}configure(A,g){try{return A.postMessage({...g,toolchain:this.#A}),!!this.#A.module}catch(I){if(!(I instanceof DOMException)||I.name!=="DataCloneError"||!this.#A.module)throw I;return A.postMessage({...g,toolchain:{...this.#A,module:void 0}}),!1}}}async function UA(Q){const A=await crypto.subtle.digest("SHA-256",Q);return Array.from(new Uint8Array(A),g=>g.toString(16).padStart(2,"0")).join("")}let CA,e;class QA{stdout=new BA(1);stderr=new BA(2);stdin=new H;debugger;lang;scope;fs={};binaryFiles={};cppArtifacts;hostDevice;options;retain;idleTimeoutMs;wasmUrl;objects;generation=0;scopeEpoch=0;operationId=0;disposed=!1;active;promise;slot;idleTimer;toolchain;toolchainLoading;toolchainController;initializing=new Set;toolchainIdentity;toolchainIngestions=0;toolchainHashCount=0;toolchainHashMs=0;compilerModuleCloned=!1;disposal;cancellationDraining;releaseDrain;releases=new Set;retirements=0;latest;cacheValidation;static async create(A,g={}){const{wasmUrl:I,...C}=g,B=I===void 0?void 0:XA(I,globalThis.location?.href),i=structuredClone(C),D=B??null;if(e!==void 0&&e!==D)throw new Error("The engine Wasm is already loaded from a different wasmUrl");e=D,CA??=jA({module_or_path:B??VA}).catch(K=>{throw CA=void 0,e=void 0,K}),await CA;const N=new QA(A,i);if(N.wasmUrl=B,A!=="c"&&typeof window<"u"&&typeof fetch<"u")for(const K of iA(A))fetch(K,{cache:"force-cache"}).then(J=>J.arrayBuffer()).catch(()=>{});return N}constructor(A,g){const I=g.cpp;this.retain=g.retainWorker??I?.retainWorker??!0;const C=g.idleTimeoutMs??I?.idleTimeoutMs??3e4;if(!Number.isSafeInteger(C)||C<1||C>3e5)throw new RangeError("Worker idle timeout must be between 1 and 300000 milliseconds");if(this.idleTimeoutMs=C,I){if(A!=="c")throw new TypeError("C++ performance options require C/C++");if(!I.scope?.projectId||!I.scope.accountId)throw new TypeError("C++ performance options require project and account identity");if(I.compilerLifetime!==void 0&&!["idle","project"].includes(I.compilerLifetime))throw new TypeError("Invalid compiler lifetime");RA(I.toolchainProfile),this.scope=Object.freeze({...I.scope}),this.options=Object.freeze({...I,scope:this.scope,idleTimeoutMs:C})}this.objects=new lA(typeof I?.objectCache=="object"?I.objectCache:{}),this.debugger=new kA,this.lang=A}get cacheCompilerModule(){return this.options?.cacheCompilerModule??this.retain}get cacheStats(){return structuredClone({...this.objects.stats(),generation:this.generation,scopeEpoch:this.scopeEpoch,operationId:this.operationId,cacheEpoch:this.generation,toolchainProfile:this.options?.toolchainProfile??"legacy",cacheEligible:this.cacheValidation?.eligible??!1,stockCertificateSha256:this.cacheValidation?.certificate,cacheEligibilitySnapshot:this.cacheValidation?.snapshot,cacheEligibilityOperationId:this.cacheValidation?.operationId,cacheEligibilityReason:this.cacheValidation?.reason,toolchainIdentityBytes:this.toolchain?.identityBytes??0,toolchainIngestions:this.toolchainIngestions,toolchainHashCount:this.toolchainHashCount,toolchainHashMs:this.toolchainHashMs,compilerModuleCloned:this.compilerModuleCloned,workerRetained:!!this.slot&&!this.active,workerRetirements:this.retirements,compilerModuleIdentityBytes:this.cacheCompilerModule?this.toolchain?.compilerBytes??0:0,latest:this.active?.stats??this.latest})}clearCaches(){this.cacheValidation=void 0,this.generation++,this.objects.clear(),this.toolchain=void 0,this.active||(this.toolchainController?.abort(),this.toolchainLoading=void 0),this.active||this.retireWorker()}stop(){return this.clearCaches(),this.cancelCurrentOperation()}cancelCurrentOperation(){if(this.cancellationDraining)return this.cancellationDraining;this.operationId++;const A=this.promise,g=this.active?.publication;this.retireWorker(),this.objects.discardBatch(),this.active&&this.finish(this.active,{type:"stopped"});const I=Promise.allSettled([A,g]).then(()=>{this.cancellationDraining===I&&(this.cancellationDraining=void 0)});return this.cancellationDraining=I,I}releaseCompilerResources(A={}){const g=A.signal;return g?.aborted?Promise.resolve("cancelled"):this.disposed?Promise.resolve("released"):new Promise(I=>{const C={resolve:I,signal:g,abort:()=>this.settleRelease(C,"cancelled")};this.releases.add(C),g?.addEventListener("abort",C.abort,{once:!0}),this.flushReleases()})}settleRelease(A,g){this.releases.delete(A)&&(A.signal?.removeEventListener("abort",A.abort),A.resolve(g))}flushReleases(){if(!(this.active||!this.releases.size||this.releaseDrain)){if(this.initializing.size){this.toolchainController?.abort();const A=[...this.initializing];this.toolchainLoading=void 0,this.releaseDrain=Promise.allSettled(A).then(()=>{this.releaseDrain=void 0,this.flushReleases()});return}this.retireWorker(),this.toolchainController?.abort(),this.toolchain=void 0,this.toolchainLoading=void 0;for(const A of this.releases)this.settleRelease(A,"released")}}dispose(){if(this.disposal)return this.disposal;this.disposed=!0,this.scopeEpoch++,this.fs={},this.binaryFiles={},this.cppArtifacts=void 0,this.hostDevice=void 0,this.stdout.removeAllListeners(),this.stderr.removeAllListeners(),this.debugger.removeAllListeners();const A=[...this.initializing];return this.toolchainController?.abort(),this.disposal=Promise.allSettled([this.stop(),...A]).then(()=>{this.latest=void 0,this.flushReleases()}),this.disposal}prepareCompiler(A){if(A?.validateCacheInputs!==void 0&&typeof A.validateCacheInputs!="boolean")return Promise.resolve(h(new TypeError("Invalid compiler preparation options")));const g=A?.validateCacheInputs===!0&&this.options?.toolchainProfile==="stock-certified-v1"&&!!this.options?.objectCache&&this.objects.limits.maxEntries>0&&this.objects.limits.maxObjectBytes>0&&this.objects.limits.maxMetadataBytes>0&&this.objects.limits.maxEntryMetadataBytes>0;return this.submit(!0,!0,g)}run(){return this.submit(!1)}compile(){return this.submit(!0)}submit(A,g=!1,I=!1){if(this.disposed)return Promise.resolve(h(new Error("Engine is disposed")));if(this.active||this.cancellationDraining)return Promise.resolve(h(new Error("An engine job is already active")));if(A&&this.lang!=="c")return Promise.resolve(h(new Error("Compile-only is supported for C/C++")));this.cacheValidation=void 0;const C=g&&!I;let B;try{const U=C||!this.cppArtifacts?null:{...this.cppArtifacts};if(U?.cacheCertificate!==void 0){const s=U.cacheCertificate;(typeof s!="string"||s.length>1024*1024||new TextEncoder().encode(s).byteLength>1024*1024)&&delete U.cacheCertificate}B={fs:C?{}:structuredClone(this.fs),binary_files:Object.fromEntries(Object.entries(C?{}:this.binaryFiles).map(([s,q])=>[s,new Uint8Array(q)])),cpp_artifacts:structuredClone(U)}}catch(U){return Promise.resolve(h(U))}const i=!A&&this.debugger.enabled,D=A?void 0:this.hostDevice;if(D!==void 0&&(typeof D!="function"||!["c","python"].includes(this.lang)))return Promise.resolve(h(new TypeError("Invalid host device configuration")));clearTimeout(this.idleTimer),this.stdin[Y].clear();const N=!!this.slot;let K;const J=new Promise(U=>{K=U});this.promise=J;const S={generation:this.generation,scopeEpoch:this.scopeEpoch,operationId:++this.operationId,cacheEpoch:this.generation,prepareOnly:g,validateCacheInputs:I,settled:!1,buildOnly:A,debug:i,opener:D,startedAt:performance.now(),resolve:K,stats:{operation:g?"prepare_compiler":A?"compile":"run",workerReadyMs:0,workerReused:N},start:{...B,lang:this.lang,prepare_compiler:g,validate_cache_inputs:I,scope_epoch:this.scopeEpoch,operation_id:this.operationId,cache_epoch:this.generation,is_debug:i,build_only:A,stdin_buffer:this.stdin[Y].buffer,cpp_cache:this.options?.objectCache&&!i&&!g?{generation:this.generation,entries:this.objects.snapshot(),max_entry_metadata_bytes:Math.min(this.objects.limits.maxEntryMetadataBytes,this.objects.limits.maxMetadataBytes,1024*1024)}:null}};this.objects.beginBatch(),this.active=S;try{if(this.slot||this.makeWorker(),!this.current(S))return J;const U=this.slot;this.lang==="c"&&!this.toolchain&&this.ensureToolchain().catch(s=>{this.current(S)&&this.slot===U&&this.finish(S,h(s))}),this.slot.ready&&this.dispatch(S)}catch(U){this.finish(S,h(U))}return J}current(A){return this.active===A&&!A.settled}makeWorker(){const A=bA(this.wasmUrl),g={worker:A,ready:!1,remove:()=>{}};this.slot=g;const I=i=>{if(this.slot!==g)return;const D=i.data,N=this.active;if(D.type==="ready"){if(g.ready)return;g.ready=!0,N&&this.current(N)&&this.dispatch(N);return}if(!(!N||!this.current(N))){if(!g.ready&&D.type==="error"){this.finish(N,h(new Error(D.message)));return}if(!(D.operationId!==N.operationId||D.scopeEpoch!==N.scopeEpoch))try{if(D.type==="cpp_cache_eligibility"){if(this.options?.toolchainProfile!=="stock-certified-v1"||N.prepareOnly&&!N.validateCacheInputs)return;const K=S=>typeof S=="string"&&/^[0-9a-f]{64}$/.test(S),J=D.eligible===!0&&K(D.certificate_sha256)&&K(D.snapshot);this.cacheValidation={eligible:J,certificate:K(D.certificate_sha256)?D.certificate_sha256:void 0,snapshot:J?D.snapshot:void 0,operationId:N.operationId,reason:J?void 0:typeof D.reason=="string"?D.reason.slice(0,128):"stock-input-validation"}}else if(D.type==="stop")this.finish(N,{type:"completed",exitCode:D.exit_code,timing:{totalMs:performance.now()-N.startedAt,buildMs:D.build_ms,runMs:D.run_ms}});else if(D.type==="error")this.finish(N,h(new Error(D.message)));else if(D.type==="cpp_cache_object"&&D.generation===this.generation&&N.generation===this.generation)try{this.objects.stage(D)}catch{this.objects.abandonBatch()}else D.type==="cpp_cache_stats"&&D.generation===N.generation?N.stats.cache=D.stats:D.type==="cpp_cache_abandon"?this.objects.abandonBatch():D.type==="object_build_complete"?N.publication??=this.publishObjects(N,g):D.type==="compiler_module_stats"&&(N.stats.compilerModule=D)}catch(K){this.finish(N,h(K))}}},C=i=>{this.slot===g&&(this.clearCaches(),this.active?this.finish(this.active,h(i.error??new Error(i.message))):this.retireWorker())},B=()=>C({message:"Unreadable execution worker message"});this.debugger[Y].attach(A),A.addEventListener("message",I),A.addEventListener("error",C),A.addEventListener("messageerror",B),g.remove=()=>{A.removeEventListener("message",I),A.removeEventListener("error",C),A.removeEventListener("messageerror",B),this.debugger[Y].detach(A)}}async publishObjects(A,g){let I=!1;try{I=await this.objects.validateBatch()}catch{}if(!(!this.current(A)||this.slot!==g)){try{I&&A.cacheEpoch===this.generation?this.objects.commitBatch():(this.objects.abandonBatch(),this.cacheValidation?.operationId===A.operationId&&(this.cacheValidation={...this.cacheValidation,eligible:!1,snapshot:void 0,reason:"stock-publication-budget-or-validation"}))}catch{this.objects.clear(),this.cacheValidation?.operationId===A.operationId&&(this.cacheValidation={...this.cacheValidation,eligible:!1,snapshot:void 0,reason:"stock-publication-failure"})}this.current(A)&&g.worker.postMessage({type:"object_build_ack",scopeEpoch:A.scopeEpoch,operationId:A.operationId,cacheEpoch:A.cacheEpoch})}}ensureToolchain(){if(this.toolchain)return Promise.resolve(this.toolchain);if(this.toolchainLoading)return this.toolchainLoading;this.toolchainController=new AbortController;const A=X.load(iA("c"),this.cacheCompilerModule,this.toolchainController.signal,sA(),this.options?.toolchainProfile);return this.toolchainLoading=A,this.initializing.add(A),A.then(()=>this.initializing.delete(A),()=>{this.initializing.delete(A),this.toolchainLoading===A&&(this.toolchainLoading=void 0)}),A}async dispatch(A){const g=this.slot;if(!(!this.current(A)||!g))try{if(this.lang==="c"){const B=this.scopeEpoch,i=this.generation,D=this.ensureToolchain(),N=this.toolchain??await D;if(!this.current(A)||this.slot!==g||B!==this.scopeEpoch)return;const K=A.start.cpp_artifacts?.requiredToolchain;if(K&&!N.matchesExpectation(K)){this.finish(A,{type:"error",error:{type:"artifact-toolchain-integrity",message:"C++ artifacts require a different compiler, sysroot, or exception runtime"}});return}i===this.generation&&(this.toolchainIdentity&&this.toolchainIdentity!==N.identity&&(this.objects.clear(),A.start.cpp_cache=null),this.toolchain!==N&&(this.toolchainIngestions++,this.toolchainHashCount+=N.hashCount,this.toolchainHashMs+=N.hashMs),this.toolchainIdentity=N.identity,this.toolchain=N,this.toolchainLoading===D&&(this.toolchainLoading=void 0)),g.toolchain!==N&&(this.compilerModuleCloned=N.configure(g.worker,{type:"configure_cpp",cacheCompilerModule:this.cacheCompilerModule}),g.toolchain=N)}if(!this.current(A)||this.slot!==g)return;const I=g.worker;A.stats.workerReadyMs=performance.now()-A.startedAt;const C=B=>this.current(A)&&B.scopeEpoch===A.scopeEpoch&&B.operationId===A.operationId;if(this.stdout[Y].attach(I,C),this.stderr[Y].attach(I,C),A.prepareOnly||this.debugger[Y].beginRun(),A.opener){if(A.device=new rA(B=>this.finish(A,h(B))),A.device.attach(I),A.device.open(A.opener),!this.current(A))return;A.start.host_device=A.device.workerStart}this.current(A)&&(I.postMessage(A.start),A.start.fs={},A.start.binary_files={},A.start.cpp_artifacts=null,A.start.cpp_cache=null)}catch(I){this.current(A)&&(this.toolchainLoading=void 0,this.finish(A,h(I)))}}finish(A,g){if(!this.current(A))return;(g.type!=="completed"||g.exitCode!==0)&&(this.cacheValidation=void 0),A.settled=!0;const I=this.slot?.worker;I&&(this.stdout[Y].detach(I),this.stderr[Y].detach(I));const C=A.device?.close();C&&(g=h(C));const B=g.type==="completed"&&A.generation===this.generation&&!this.disposed,i=B&&g.type==="completed"&&g.exitCode===0;if(A.generation===this.generation)for(const D of A.stats.cache?.invalid_sources??[])this.objects.delete(D);if(i)for(const D of A.stats.cache?.hit_sources??[])this.objects.touch(D);this.objects.discardBatch(),this.latest=A.stats,this.stdin[Y].clear(),(!B||!this.retain)&&this.retireWorker(),!this.disposed&&A.cacheEpoch===this.generation&&(this.slot||this.toolchain&&this.cacheCompilerModule)&&this.options?.compilerLifetime!=="project"&&(this.idleTimer=setTimeout(()=>{this.retireWorker(),this.toolchain=void 0,this.toolchainLoading=void 0},this.idleTimeoutMs)),!this.retain&&!this.cacheCompilerModule&&(this.toolchain=void 0),A.cacheEpoch!==this.generation&&(this.toolchainController?.abort(),this.toolchainLoading=void 0),this.active=void 0,this.promise=void 0,this.flushReleases(),A.resolve(g)}retireWorker(){clearTimeout(this.idleTimer);const A=this.slot;A&&(this.slot=void 0,A.remove(),this.stdout[Y].detach(A.worker),this.stderr[Y].detach(A.worker),A.worker.onerror=g=>g.preventDefault(),A.worker.terminate(),this.retirements++)}}class BA extends wA{constructor(A){super(),this.mode=A,this.callback=(g=>{const I=g.data;if(this.accepts&&!this.accepts(I)||I.type!=="stdout"||I.mode!==this.mode)return;const C=I.data;this.emit("data",C)}).bind(this),this[Y]={attach:this.attach.bind(this),detach:this.detach.bind(this)}}callback;accepts;[Y];attach(A,g){this.accepts=g,A.addEventListener("message",this.callback)}detach(A){A.removeEventListener("message",this.callback)}}class H{static BUFFER_SIZE=2048;static HEADER_SIZE=8;static DATA_SIZE=H.BUFFER_SIZE-H.HEADER_SIZE;static READ_IDX=0;static WRITE_IDX=1;static encoder=new TextEncoder;buffer=new SharedArrayBuffer(H.BUFFER_SIZE);generation=0;indices;data;[Y];constructor(){this.indices=new Int32Array(this.buffer,0,2),this.data=new Int8Array(this.buffer,H.HEADER_SIZE);const A=()=>this.buffer;this[Y]={clear:this.clear.bind(this),get buffer(){return A()}}}clear(){this.generation++,Atomics.notify(this.indices,H.READ_IDX),this.buffer=new SharedArrayBuffer(H.BUFFER_SIZE),this.indices=new Int32Array(this.buffer,0,2),this.data=new Int8Array(this.buffer,H.HEADER_SIZE)}async write(A){const g=typeof A=="string"?H.encoder.encode(A):A;return this.writeBytes(g)}async writeBytes(A){const{DATA_SIZE:g,READ_IDX:I,WRITE_IDX:C}=H;let B=0;const i=this.generation;for(;B<A.length&&i===this.generation;){const D=Atomics.load(this.indices,I);let N=Atomics.load(this.indices,C);N===g-1&&D>0&&(N=0);const K=D<=N?g-N-1:D-N-1;if(K===0){await Atomics.waitAsync(this.indices,I,D).value;continue}const J=Math.min(A.length-B,K);this.data.set(A.subarray(B,B+J),N),Atomics.store(this.indices,C,(N+J)%g),Atomics.notify(this.indices,C),B+=J}}}a.Artifact=GA,a.Debugger=kA,a.Engine=QA,a.HOST_DEVICE_PATH=PA,a.Stdin=H,a.Stdout=BA,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(a,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(a=typeof globalThis<"u"?globalThis:a||self,x(a.engine={}))})(this,(function(a){"use strict";var x=typeof document<"u"?document.currentScript:null;function LA(Q){return Q&&Q.__esModule&&Object.prototype.hasOwnProperty.call(Q,"default")?Q.default:Q}var P={exports:{}},DA;function SA(){if(DA)return P.exports;DA=1;var Q=typeof Reflect=="object"?Reflect:null,A=Q&&typeof Q.apply=="function"?Q.apply:function(E,N,F){return Function.prototype.apply.call(E,N,F)},g;Q&&typeof Q.ownKeys=="function"?g=Q.ownKeys:Object.getOwnPropertySymbols?g=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:g=function(E){return Object.getOwnPropertyNames(E)};function I(w){console&&console.warn&&console.warn(w)}var C=Number.isNaN||function(E){return E!==E};function B(){B.init.call(this)}P.exports=B,P.exports.once=Z,B.EventEmitter=B,B.prototype._events=void 0,B.prototype._eventsCount=0,B.prototype._maxListeners=void 0;var i=10;function D(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(B,"defaultMaxListeners",{enumerable:!0,get:function(){return i},set:function(w){if(typeof w!="number"||w<0||C(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");i=w}}),B.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},B.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||C(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function o(w){return w._maxListeners===void 0?B.defaultMaxListeners:w._maxListeners}B.prototype.getMaxListeners=function(){return o(this)},B.prototype.emit=function(E){for(var N=[],F=1;F<arguments.length;F++)N.push(arguments[F]);var G=E==="error",R=this._events;if(R!==void 0)G=G&&R.error===void 0;else if(!G)return!1;if(G){var M;if(N.length>0&&(M=N[0]),M instanceof Error)throw M;var p=new Error("Unhandled error."+(M?" ("+M.message+")":""));throw p.context=M,p}var m=R[E];if(m===void 0)return!1;if(typeof m=="function")A(m,this,N);else for(var JA=m.length,vA=q(m,JA),F=0;F<JA;++F)A(vA[F],this,N);return!0};function K(w,E,N,F){var G,R,M;if(D(N),R=w._events,R===void 0?(R=w._events=Object.create(null),w._eventsCount=0):(R.newListener!==void 0&&(w.emit("newListener",E,N.listener?N.listener:N),R=w._events),M=R[E]),M===void 0)M=R[E]=N,++w._eventsCount;else if(typeof M=="function"?M=R[E]=F?[N,M]:[M,N]:F?M.unshift(N):M.push(N),G=o(w),G>0&&M.length>G&&!M.warned){M.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+M.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=w,p.type=E,p.count=M.length,I(p)}return w}B.prototype.addListener=function(E,N){return K(this,E,N,!1)},B.prototype.on=B.prototype.addListener,B.prototype.prependListener=function(E,N){return K(this,E,N,!0)};function J(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(w,E,N){var F={fired:!1,wrapFn:void 0,target:w,type:E,listener:N},G=J.bind(F);return G.listener=N,F.wrapFn=G,G}B.prototype.once=function(E,N){return D(N),this.on(E,h(this,E,N)),this},B.prototype.prependOnceListener=function(E,N){return D(N),this.prependListener(E,h(this,E,N)),this},B.prototype.removeListener=function(E,N){var F,G,R,M,p;if(D(N),G=this._events,G===void 0)return this;if(F=G[E],F===void 0)return this;if(F===N||F.listener===N)--this._eventsCount===0?this._events=Object.create(null):(delete G[E],G.removeListener&&this.emit("removeListener",E,F.listener||N));else if(typeof F!="function"){for(R=-1,M=F.length-1;M>=0;M--)if(F[M]===N||F[M].listener===N){p=F[M].listener,R=M;break}if(R<0)return this;R===0?F.shift():b(F,R),F.length===1&&(G[E]=F[0]),G.removeListener!==void 0&&this.emit("removeListener",E,p||N)}return this},B.prototype.off=B.prototype.removeListener,B.prototype.removeAllListeners=function(E){var N,F,G;if(F=this._events,F===void 0)return this;if(F.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):F[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete F[E]),this;if(arguments.length===0){var R=Object.keys(F),M;for(G=0;G<R.length;++G)M=R[G],M!=="removeListener"&&this.removeAllListeners(M);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(N=F[E],typeof N=="function")this.removeListener(E,N);else if(N!==void 0)for(G=N.length-1;G>=0;G--)this.removeListener(E,N[G]);return this};function Y(w,E,N){var F=w._events;if(F===void 0)return[];var G=F[E];return G===void 0?[]:typeof G=="function"?N?[G.listener||G]:[G]:N?EA(G):q(G,G.length)}B.prototype.listeners=function(E){return Y(this,E,!0)},B.prototype.rawListeners=function(E){return Y(this,E,!1)},B.listenerCount=function(w,E){return typeof w.listenerCount=="function"?w.listenerCount(E):s.call(w,E)},B.prototype.listenerCount=s;function s(w){var E=this._events;if(E!==void 0){var N=E[w];if(typeof N=="function")return 1;if(N!==void 0)return N.length}return 0}B.prototype.eventNames=function(){return this._eventsCount>0?g(this._events):[]};function q(w,E){for(var N=new Array(E),F=0;F<E;++F)N[F]=w[F];return N}function b(w,E){for(;E+1<w.length;E++)w[E]=w[E+1];w.pop()}function EA(w){for(var E=new Array(w.length),N=0;N<E.length;++N)E[N]=w[N].listener||w[N];return E}function Z(w,E){return new Promise(function(N,F){function G(M){w.removeListener(E,R),F(M)}function R(){typeof w.removeListener=="function"&&w.removeListener("error",G),N([].slice.call(arguments))}UA(w,E,R,{once:!0}),E!=="error"&&uA(w,G,{once:!0})})}function uA(w,E,N){typeof w.on=="function"&&UA(w,"error",E,N)}function UA(w,E,N,F){if(typeof w.on=="function")F.once?w.once(E,N):w.on(E,N);else if(typeof w.addEventListener=="function")w.addEventListener(E,function G(R){F.once&&w.removeEventListener(E,G),N(R)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return P.exports}var hA=SA();const wA=LA(hA);class _{__destroy_into_raw(){const A=this.__wbg_ptr;return this.__wbg_ptr=0,oA.unregister(this),A}free(){const A=this.__destroy_into_raw();k.__wbg_dapadapter_free(A,0)}attach(A){k.dapadapter_attach(this.__wbg_ptr,A)}detach(){k.dapadapter_detach(this.__wbg_ptr)}constructor(){const A=k.dapadapter_new();return this.__wbg_ptr=A>>>0,oA.register(this,this.__wbg_ptr,this),this}on(A){k.dapadapter_on(this.__wbg_ptr,A)}resetRun(){k.dapadapter_resetRun(this.__wbg_ptr)}sendMessage(A){return k.dapadapter_sendMessage(this.__wbg_ptr,A)}setFilterInternals(A){k.dapadapter_setFilterInternals(this.__wbg_ptr,A)}}Symbol.dispose&&(_.prototype[Symbol.dispose]=_.prototype.free);class O{static __wrap(A){A=A>>>0;const g=Object.create(O.prototype);return g.__wbg_ptr=A,kA.register(g,g.__wbg_ptr,g),g}__destroy_into_raw(){const A=this.__wbg_ptr;return this.__wbg_ptr=0,kA.unregister(this),A}free(){const A=this.__destroy_into_raw();k.__wbg_trap_free(A,0)}static __wbg_wasmer_trap(){k.trap___wbg_wasmer_trap()}}Symbol.dispose&&(O.prototype[Symbol.dispose]=O.prototype.free);function sA(){let Q,A;try{const g=k.cpp_exception_hash();return Q=g[0],A=g[1],c(g[0],g[1])}finally{k.__wbindgen_free(Q,A,1)}}function iA(Q){const A=W(Q,k.__wbindgen_malloc,k.__wbindgen_realloc),g=T,I=k.prefetch_urls(A,g);var C=FA(I[0],I[1]).slice();return k.__wbindgen_free(I[0],I[1]*4,4),C}function cA(){return{__proto__:null,"./engine_bg.js":{__proto__:null,__wbg_BigInt_b7bbccdff258c9f2:function(A){return BigInt(A)},__wbg_Error_8c4e43fe74559d73:function(A,g){return Error(c(A,g))},__wbg_Number_04624de7d0e8332d:function(A){return Number(A)},__wbg_String_8f0eb39a4a4c2f66:function(A,g){const I=String(g),C=W(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=T;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2:function(A,g){const I=g,C=typeof I=="bigint"?I:void 0;L().setBigInt64(A+8,V(C)?BigInt(0):C,!0),L().setInt32(A+0,!V(C),!0)},__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25:function(A){const g=A,I=typeof g=="boolean"?g:void 0;return V(I)?16777215:I?1:0},__wbg___wbindgen_debug_string_0bc8482c6e3508ae:function(A,g){const I=$(g),C=W(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=T;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg___wbindgen_function_table_5ae7216dfcbcc506:function(){return k.__wbindgen_export},__wbg___wbindgen_in_47fa6863be6f2f25:function(A,g){return A in g},__wbg___wbindgen_is_bigint_31b12575b56f32fc:function(A){return typeof A=="bigint"},__wbg___wbindgen_is_function_0095a73b8b156f76:function(A){return typeof A=="function"},__wbg___wbindgen_is_object_5ae8e5880f2c1fbd:function(A){const g=A;return typeof g=="object"&&g!==null},__wbg___wbindgen_is_string_cd444516edc5b180:function(A){return typeof A=="string"},__wbg___wbindgen_is_undefined_9e4d92534c42d778:function(A){return A===void 0},__wbg___wbindgen_jsval_eq_11888390b0186270:function(A,g){return A===g},__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811:function(A,g){return A==g},__wbg___wbindgen_lt_bb59cc3d23526e0d:function(A,g){return A<g},__wbg___wbindgen_neg_6b4d356dff49dcc6:function(A){return-A},__wbg___wbindgen_number_get_8ff4255516ccad3e:function(A,g){const I=g,C=typeof I=="number"?I:void 0;L().setFloat64(A+8,V(C)?0:C,!0),L().setInt32(A+0,!V(C),!0)},__wbg___wbindgen_rethrow_05525c567f154472:function(A){throw A},__wbg___wbindgen_shr_ef8e07cce709eb54:function(A,g){return A>>g},__wbg___wbindgen_string_get_72fb696202c56729:function(A,g){const I=g,C=typeof I=="string"?I:void 0;var B=V(C)?0:W(C,k.__wbindgen_malloc,k.__wbindgen_realloc),i=T;L().setInt32(A+4,i,!0),L().setInt32(A+0,B,!0)},__wbg___wbindgen_throw_be289d5034ed271b:function(A,g){throw new Error(c(A,g))},__wbg__wbg_cb_unref_d9b87ff7982e3b21:function(A){A._wbg_cb_unref()},__wbg_addEventListener_3acb0aad4483804c:function(){return y(function(A,g,I,C){A.addEventListener(c(g,I),C)},arguments)},__wbg_apply_2e22c45cb4f12415:function(){return y(function(A,g,I){return Reflect.apply(A,g,I)},arguments)},__wbg_apply_ada2ee1a60ac7b3c:function(){return y(function(A,g,I){return A.apply(g,I)},arguments)},__wbg_arrayBuffer_bb54076166006c39:function(){return y(function(A){return A.arrayBuffer()},arguments)},__wbg_bind_1dc37de2b9939128:function(A,g,I,C){return A.bind(g,I,C)},__wbg_bind_29ba380591735d8c:function(A,g,I){return A.bind(g,I)},__wbg_buffer_7b5f53e46557d8f1:function(A){return A.buffer},__wbg_byteLength_7b03c17ff1e4037f:function(A){return A.byteLength},__wbg_byteLength_b5d783d06792ed2c:function(A){return A.byteLength},__wbg_call_389efe28435a9388:function(){return y(function(A,g){return A.call(g)},arguments)},__wbg_call_4708e0c13bdc8e95:function(){return y(function(A,g,I){return A.call(g,I)},arguments)},__wbg_compareExchange_b578410c358e695e:function(){return y(function(A,g,I,C){return Atomics.compareExchange(A,g>>>0,I,C)},arguments)},__wbg_constructor_ad6c0ed428f55d34:function(A){return A.constructor},__wbg_crypto_86f2631e91b51511:function(A){return A.crypto},__wbg_customSections_193491b069139fb1:function(A,g,I){return WebAssembly.Module.customSections(A,c(g,I))},__wbg_data_5330da50312d0bc1:function(A){return A.data},__wbg_done_57b39ecd9addfe81:function(A){return A.done},__wbg_entries_58c7934c745daac7:function(A){return Object.entries(A)},__wbg_error_7534b8e9a36f1ab4:function(A,g){let I,C;try{I=A,C=g,console.error(c(A,g))}finally{k.__wbindgen_free(I,C,1)}},__wbg_exports_794a42000dacd046:function(A){return WebAssembly.Module.exports(A)},__wbg_exports_86b4926134c40288:function(A){return A.exports},__wbg_fetch_d1488f40cef1e210:function(A,g,I){return A.fetch(c(g,I))},__wbg_from_bddd64e7d5ff6941:function(A){return Array.from(A)},__wbg_getPrototypeOf_2653517f1dc884d5:function(){return y(function(A){return Reflect.getPrototypeOf(A)},arguments)},__wbg_getRandomValues_b3f15fcbfabb0f8b:function(){return y(function(A,g){A.getRandomValues(g)},arguments)},__wbg_getTime_1e3cd1391c5c3995:function(A){return A.getTime()},__wbg_getTimezoneOffset_81776d10a4ec18a8:function(A){return A.getTimezoneOffset()},__wbg_getUint32_bb6f5a401408e7fa:function(A,g,I){return A.getUint32(g>>>0,I!==0)},__wbg_get_7efbcc3819719b0f:function(){return y(function(A,g){return A.get(g>>>0)},arguments)},__wbg_get_9b94d73e6221f75c:function(A,g){return A[g>>>0]},__wbg_get_b3ed3ad4be2bc8ac:function(){return y(function(A,g){return Reflect.get(A,g)},arguments)},__wbg_get_index_253dd2a9e007656d:function(A,g){return A[g>>>0]},__wbg_get_index_9a5bfdd2ca49c65f:function(A,g){return A[g>>>0]},__wbg_get_with_ref_key_1dc361bd10053bfe:function(A,g){return A[g]},__wbg_grow_5d42bf28c2da22cb:function(){return y(function(A,g){return A.grow(g>>>0)},arguments)},__wbg_grow_d034989fce14cc8e:function(){return y(function(A,g){return A.grow(g>>>0)},arguments)},__wbg_imports_8333d40ab24779ad:function(A){return WebAssembly.Module.imports(A)},__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04:function(A){let g;try{g=A instanceof ArrayBuffer}catch{g=!1}return g},__wbg_instanceof_Error_8573fe0b0b480f46:function(A){let g;try{g=A instanceof Error}catch{g=!1}return g},__wbg_instanceof_Function_2a29eec978bb3b11:function(A){let g;try{g=A instanceof Function}catch{g=!1}return g},__wbg_instanceof_Global_2db767b6b2347f01:function(A){let g;try{g=A instanceof WebAssembly.Global}catch{g=!1}return g},__wbg_instanceof_Map_53af74335dec57f4:function(A){let g;try{g=A instanceof Map}catch{g=!1}return g},__wbg_instanceof_Memory_dc8c61e3f831ee37:function(A){let g;try{g=A instanceof WebAssembly.Memory}catch{g=!1}return g},__wbg_instanceof_Module_d0d412b14363ba9a:function(A){let g;try{g=A instanceof WebAssembly.Module}catch{g=!1}return g},__wbg_instanceof_Object_1c6af87502b733ed:function(A){let g;try{g=A instanceof Object}catch{g=!1}return g},__wbg_instanceof_RangeError_0b0dd056bc557b89:function(A){let g;try{g=A instanceof RangeError}catch{g=!1}return g},__wbg_instanceof_Response_ee1d54d79ae41977:function(A){let g;try{g=A instanceof Response}catch{g=!1}return g},__wbg_instanceof_SharedArrayBuffer_91d8a2fa16a2cc26:function(A){let g;try{g=A instanceof SharedArrayBuffer}catch{g=!1}return g},__wbg_instanceof_Table_127f216e592f4159:function(A){let g;try{g=A instanceof WebAssembly.Table}catch{g=!1}return g},__wbg_instanceof_Tag_f1d6b24a98b95210:function(A){let g;try{g=A instanceof WebAssembly.Tag}catch{g=!1}return g},__wbg_instanceof_Uint8Array_9b9075935c74707c:function(A){let g;try{g=A instanceof Uint8Array}catch{g=!1}return g},__wbg_isArray_d314bb98fcf08331:function(A){return Array.isArray(A)},__wbg_isSafeInteger_bfbc7332a9768d2a:function(A){return Number.isSafeInteger(A)},__wbg_is_f29129f676e5410c:function(A,g){return Object.is(A,g)},__wbg_iterator_6ff6560ca1568e55:function(){return Symbol.iterator},__wbg_length_32ed9a279acd054c:function(A){return A.length},__wbg_length_35a7bace40f36eac:function(A){return A.length},__wbg_length_aeb94ff17a8a8556:function(A){return A.length},__wbg_load_eff64ff5e429a422:function(){return y(function(A,g){return Atomics.load(A,g>>>0)},arguments)},__wbg_message_9ddc4b9a62a7c379:function(A){return A.message},__wbg_msCrypto_d562bbe83e0d4b91:function(A){return A.msCrypto},__wbg_new_0728bd2d4c5d41dd:function(){return y(function(A){return new WebAssembly.Tag(A)},arguments)},__wbg_new_0_73afc35eb544e539:function(){return new Date},__wbg_new_245cd5c49157e602:function(A){return new Date(A)},__wbg_new_2ac7fa8be584d280:function(A,g,I){return new DataView(A,g>>>0,I>>>0)},__wbg_new_361308b2356cecd0:function(){return new Object},__wbg_new_3eb36ae241fe6f44:function(){return new Array},__wbg_new_4a996a46a82782b6:function(){return y(function(A,g){return new WebAssembly.Global(A,g)},arguments)},__wbg_new_57c27ff3ddf5b62c:function(){return y(function(A){return new WebAssembly.Module(A)},arguments)},__wbg_new_67274f72d5abea37:function(){return y(function(A){return new WebAssembly.Table(A)},arguments)},__wbg_new_8a6f238a6ece86ea:function(){return new Error},__wbg_new_a4e3cab1cdd635ba:function(){return y(function(A,g){return new WebAssembly.Instance(A,g)},arguments)},__wbg_new_b061c0550d9f3281:function(){return y(function(A){return new WebAssembly.Memory(A)},arguments)},__wbg_new_b5d9e2fb389fef91:function(A,g){try{var I={a:A,b:g},C=(i,D)=>{const o=I.a;I.a=0;try{return VA(o,I.b,i,D)}finally{I.a=o}};return new Promise(C)}finally{I.a=I.b=0}},__wbg_new_ca409f861989e0c5:function(A){return new SharedArrayBuffer(A>>>0)},__wbg_new_dca287b076112a51:function(){return new Map},__wbg_new_dd2b680c8bf6ae29:function(A){return new Uint8Array(A)},__wbg_new_from_slice_a3d2629dc1826784:function(A,g){return new Uint8Array(n(A,g))},__wbg_new_no_args_1c7c842f08d00ebb:function(A,g){return new Function(c(A,g))},__wbg_new_with_args_7bba34e94b1cfa40:function(A,g,I,C){return new Function(c(A,g),c(I,C))},__wbg_new_with_byte_offset_9120ba79e057895b:function(A,g){return new Uint8Array(A,g>>>0)},__wbg_new_with_byte_offset_and_length_aa261d9c9da49eb1:function(A,g,I){return new Uint8Array(A,g>>>0,I>>>0)},__wbg_new_with_byte_offset_and_length_bc2e7b72cc96d1c1:function(A,g,I){return new Int32Array(A,g>>>0,I>>>0)},__wbg_new_with_length_1763c527b2923202:function(A){return new Array(A>>>0)},__wbg_new_with_length_a2c39cbe88fd8ff1:function(A){return new Uint8Array(A>>>0)},__wbg_next_3482f54c49e8af19:function(){return y(function(A){return A.next()},arguments)},__wbg_next_418f80d8f5303233:function(A){return A.next},__wbg_node_e1f24f89a7336c2e:function(A){return A.node},__wbg_notify_78a90977fab74963:function(){return y(function(A,g){return Atomics.notify(A,g>>>0)},arguments)},__wbg_now_a3af9a2f4bbaa4d1:function(){return Date.now()},__wbg_now_ebffdf7e580f210d:function(A){return A.now()},__wbg_ok_87f537440a0acf85:function(A){return A.ok},__wbg_postMessage_2041f4e90af61318:function(){return y(function(A,g){A.postMessage(g)},arguments)},__wbg_process_3975fd6c72f520aa:function(A){return A.process},__wbg_prototypesetcall_bdcdcc5842e4d77d:function(A,g,I){Uint8Array.prototype.set.call(n(A,g),I)},__wbg_push_8ffdcb2063340ba5:function(A,g){return A.push(g)},__wbg_queueMicrotask_0aa0a927f78f5d98:function(A){return A.queueMicrotask},__wbg_queueMicrotask_5bb536982f78a56f:function(A){queueMicrotask(A)},__wbg_randomFillSync_f8c153b79f285817:function(){return y(function(A,g){A.randomFillSync(g)},arguments)},__wbg_removeEventListener_e63328781a5b9af9:function(){return y(function(A,g,I,C){A.removeEventListener(c(g,I),C)},arguments)},__wbg_require_b74f47fc2d022fd6:function(){return y(function(){return module.require},arguments)},__wbg_resolve_002c4b7d9d8f6b64:function(A){return Promise.resolve(A)},__wbg_setTimeout_e0aacd5a637418a6:function(){return y(function(A,g,I){return A.setTimeout(g,I)},arguments)},__wbg_setUint32_d168af7751a8557e:function(A,g,I,C){A.setUint32(g>>>0,I>>>0,C!==0)},__wbg_set_0af2522656c2a71b:function(){return y(function(A,g,I){A.set(g>>>0,I)},arguments)},__wbg_set_1eb0999cf5d27fc8:function(A,g,I){return A.set(g,I)},__wbg_set_25cf9deff6bf0ea8:function(A,g,I){A.set(g,I>>>0)},__wbg_set_3f1d0b984ed272ed:function(A,g,I){A[g]=I},__wbg_set_6cb8631f80447a67:function(){return y(function(A,g,I){return Reflect.set(A,g,I)},arguments)},__wbg_set_cc56eefd2dd91957:function(A,g,I){A.set(n(g,I))},__wbg_set_f43e577aea94465b:function(A,g,I){A[g>>>0]=I},__wbg_set_index_b3244a6c458021e4:function(A,g,I){A[g>>>0]=I},__wbg_set_index_f259b54e97f7b177:function(A,g,I){A[g>>>0]=I},__wbg_set_onmessage_ea7cc2ba099021cd:function(A,g){A.onmessage=g},__wbg_set_value_fc06e541de098215:function(A,g){A.value=g},__wbg_slice_8bbd46adb2100583:function(A,g,I){return A.slice(g>>>0,I>>>0)},__wbg_stack_0ed75d68575b0f3c:function(A,g){const I=g.stack,C=W(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=T;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg_static_accessor_GLOBAL_12837167ad935116:function(){const A=typeof global>"u"?null:global;return V(A)?0:t(A)},__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f:function(){const A=typeof globalThis>"u"?null:globalThis;return V(A)?0:t(A)},__wbg_static_accessor_SELF_a621d3dfbb60d0ce:function(){const A=typeof self>"u"?null:self;return V(A)?0:t(A)},__wbg_static_accessor_WINDOW_f8727f0cf888e0bd:function(){const A=typeof window>"u"?null:window;return V(A)?0:t(A)},__wbg_store_d1d951c98d9bed41:function(){return y(function(A,g,I){return Atomics.store(A,g>>>0,I)},arguments)},__wbg_subarray_a96e1fef17ed23cb:function(A,g,I){return A.subarray(g>>>0,I>>>0)},__wbg_then_0d9fe2c7b1857d32:function(A,g,I){return A.then(g,I)},__wbg_then_b9e7b3b5f1a9e1b5:function(A,g){return A.then(g)},__wbg_toString_56d946daff83867b:function(A,g,I){const C=g.toString(I),B=W(C,k.__wbindgen_malloc,k.__wbindgen_realloc),i=T;L().setInt32(A+4,i,!0),L().setInt32(A+0,B,!0)},__wbg_toString_964ff7fe6eca8362:function(A){return A.toString()},__wbg_trap_new:function(A){return O.__wrap(A)},__wbg_validate_71c2d02a71bda62f:function(){return y(function(A){return WebAssembly.validate(A)},arguments)},__wbg_value_0546255b415e96c1:function(A){return A.value},__wbg_value_ce37a60e576310ff:function(A){return A.value},__wbg_versions_4e31226f5e8dc909:function(A){return A.versions},__wbg_wait_be5dae1e53f590f1:function(){return y(function(A,g,I){return Atomics.wait(A,g>>>0,I)},arguments)},__wbg_warn_81ab00e6e16e886d:function(A,g,I){console.warn(A,g,I)},__wbindgen_cast_0000000000000001:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,NA)},__wbindgen_cast_0000000000000002:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,NA)},__wbindgen_cast_0000000000000003:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,pA)},__wbindgen_cast_0000000000000004:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__FnMut__wasm_bindgen_36932265c58943ab___JsValue____Output_______,HA)},__wbindgen_cast_0000000000000005:function(A,g){return ZA(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__Fn__web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent____Output_______,aA)},__wbindgen_cast_0000000000000006:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__Fn__web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent____Output_______,qA)},__wbindgen_cast_0000000000000007:function(A){return A},__wbindgen_cast_0000000000000008:function(A){return A},__wbindgen_cast_0000000000000009:function(A,g){return n(A,g)},__wbindgen_cast_000000000000000a:function(A,g){return c(A,g)},__wbindgen_cast_000000000000000b:function(A,g){return BigInt.asUintN(64,A)|BigInt.asUintN(64,g)<<BigInt(64)},__wbindgen_cast_000000000000000c:function(A){return BigInt.asUintN(64,A)},__wbindgen_cast_000000000000000d:function(A,g){var I=FA(A,g).slice();return k.__wbindgen_free(A,g*4,4),I},__wbindgen_init_externref_table:function(){const A=k.__wbindgen_externrefs,g=A.grow(4);A.set(0,void 0),A.set(g+0,void 0),A.set(g+1,null),A.set(g+2,!0),A.set(g+3,!1)}}}}function HA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___wasm_bindgen_36932265c58943ab___JsValue_____(Q,A,g)}function aA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent_____(Q,A,g)}function qA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent______1_(Q,A,g)}function pA(Q,A,g){const I=k.wasm_bindgen_36932265c58943ab___convert__closures________invoke___js_sys_9eaf8169b8189500___Array__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_36932265c58943ab___JsValue__(Q,A,g);if(I[1])throw AA(I[0])}function NA(Q,A,g){const I=k.wasm_bindgen_36932265c58943ab___convert__closures________invoke___js_sys_9eaf8169b8189500___Array__core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue__(Q,A,g);if(I[2])throw AA(I[1]);return AA(I[0])}function VA(Q,A,g,I){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___wasm_bindgen_36932265c58943ab___JsValue__wasm_bindgen_36932265c58943ab___JsValue_____(Q,A,g,I)}const oA=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>k.__wbg_dapadapter_free(Q>>>0,1)),kA=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>k.__wbg_trap_free(Q>>>0,1));function t(Q){const A=k.__externref_table_alloc();return k.__wbindgen_externrefs.set(A,Q),A}const r=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>Q.dtor(Q.a,Q.b));function $(Q){const A=typeof Q;if(A=="number"||A=="boolean"||Q==null)return`${Q}`;if(A=="string")return`"${Q}"`;if(A=="symbol"){const C=Q.description;return C==null?"Symbol":`Symbol(${C})`}if(A=="function"){const C=Q.name;return typeof C=="string"&&C.length>0?`Function(${C})`:"Function"}if(Array.isArray(Q)){const C=Q.length;let B="[";C>0&&(B+=$(Q[0]));for(let i=1;i<C;i++)B+=", "+$(Q[i]);return B+="]",B}const g=/\[object ([^\]]+)\]/.exec(toString.call(Q));let I;if(g&&g.length>1)I=g[1];else return toString.call(Q);if(I=="Object")try{return"Object("+JSON.stringify(Q)+")"}catch{return"Object"}return Q instanceof Error?`${Q.name}: ${Q.message}
|
|
2
|
+
${Q.stack}`:I}function FA(Q,A){Q=Q>>>0;const g=L(),I=[];for(let C=Q;C<Q+4*A;C+=4)I.push(k.__wbindgen_externrefs.get(g.getUint32(C,!0)));return k.__externref_drop_slice(Q,A),I}function n(Q,A){return Q=Q>>>0,z().subarray(Q/1,Q/1+A)}let d=null;function L(){return(d===null||d.buffer.detached===!0||d.buffer.detached===void 0&&d.buffer!==k.memory.buffer)&&(d=new DataView(k.memory.buffer)),d}function c(Q,A){return Q=Q>>>0,xA(Q,A)}let j=null;function z(){return(j===null||j.byteLength===0)&&(j=new Uint8Array(k.memory.buffer)),j}function y(Q,A){try{return Q.apply(this,A)}catch(g){const I=t(g);k.__wbindgen_exn_store(I)}}function V(Q){return Q==null}function ZA(Q,A,g,I){const C={a:Q,b:A,cnt:1,dtor:g},B=(...i)=>{C.cnt++;try{return I(C.a,C.b,...i)}finally{B._wbg_cb_unref()}};return B._wbg_cb_unref=()=>{--C.cnt===0&&(C.dtor(C.a,C.b),C.a=0,r.unregister(C))},r.register(B,C,C),B}function f(Q,A,g,I){const C={a:Q,b:A,cnt:1,dtor:g},B=(...i)=>{C.cnt++;const D=C.a;C.a=0;try{return I(D,C.b,...i)}finally{C.a=D,B._wbg_cb_unref()}};return B._wbg_cb_unref=()=>{--C.cnt===0&&(C.dtor(C.a,C.b),C.a=0,r.unregister(C))},r.register(B,C,C),B}function W(Q,A,g){if(g===void 0){const D=l.encode(Q),o=A(D.length,1)>>>0;return z().subarray(o,o+D.length).set(D),T=D.length,o}let I=Q.length,C=A(I,1)>>>0;const B=z();let i=0;for(;i<I;i++){const D=Q.charCodeAt(i);if(D>127)break;B[C+i]=D}if(i!==I){i!==0&&(Q=Q.slice(i)),C=g(C,I,I=i+Q.length*3,1)>>>0;const D=z().subarray(C+i,C+I),o=l.encodeInto(Q,D);i+=o.written,C=g(C,I,i,1)>>>0}return T=i,C}function AA(Q){const A=k.__wbindgen_externrefs.get(Q);return k.__externref_table_dealloc(Q),A}let u=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});u.decode();const TA=2146435072;let gA=0;function xA(Q,A){return gA+=A,gA>=TA&&(u=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),u.decode(),gA=A),u.decode(z().subarray(Q,Q+A))}const l=new TextEncoder;"encodeInto"in l||(l.encodeInto=function(Q,A){const g=l.encode(Q);return A.set(g),{read:Q.length,written:g.length}});let T=0,k;function dA(Q,A){return k=Q.exports,d=null,j=null,k.__wbindgen_start(),k}async function WA(Q,A){if(typeof Response=="function"&&Q instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(Q,A)}catch(C){if(Q.ok&&g(Q.type)&&Q.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",C);else throw C}const I=await Q.arrayBuffer();return await WebAssembly.instantiate(I,A)}else{const I=await WebAssembly.instantiate(Q,A);return I instanceof WebAssembly.Instance?{instance:I,module:Q}:I}function g(I){switch(I){case"basic":case"cors":case"default":return!0}return!1}}async function OA(Q){if(k!==void 0)return k;Q!==void 0&&(Object.getPrototypeOf(Q)===Object.prototype?{module_or_path:Q}=Q:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),Q===void 0&&(Q=new URL("",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:x&&x.tagName.toUpperCase()==="SCRIPT"&&x.src||new URL("glassjar.umd.cjs",document.baseURI).href));const A=cA();(typeof Q=="string"||typeof Request=="function"&&Q instanceof Request||typeof URL=="function"&&Q instanceof URL)&&(Q=fetch(Q));const{instance:g,module:I}=await WA(await Q,A);return dA(g)}const tA=new URL("https://cdn.jsdelivr.net/npm/glassjar@0.6.0/dist/engine_bg.wasm"),jA=Object.freeze({maxObjectBytes:128*1024*1024,maxEntries:256,maxMetadataBytes:8*1024*1024,maxEntryMetadataBytes:1024*1024});class zA{records=new Map;staged=new Map;stagingFailed=!1;objectBytes=0;metadataBytes=0;evictions=0;oversized=0;limits;constructor(A={}){this.limits=Object.freeze({...jA,...A});for(const g of Object.values(this.limits))if(!Number.isSafeInteger(g)||g<0)throw new RangeError("C++ cache limits must be nonnegative safe integers")}beginBatch(){this.discardBatch(),this.stagingFailed=!1}stage(A){if(this.stagingFailed)return;const g=this.recordSize(A);if(g===void 0||this.staged.has(A.source)){this.failBatch();return}const I=this.limits;for(;this.records.size&&(this.records.size+this.staged.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes);)this.remove(this.records.keys().next().value),this.evictions++;if(this.records.size+this.staged.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes||g>I.maxEntryMetadataBytes){this.oversized++,this.failBatch();return}this.staged.set(A.source,{...A,object:new Uint8Array(A.object),metadataBytes:g}),this.objectBytes+=A.object.byteLength,this.metadataBytes+=g}abandonBatch(){this.failBatch()}failBatch(){this.discardBatch(),this.stagingFailed=!0}recordSize(A){if(!(typeof A.source!="string"||!A.source.startsWith("/")||A.source.split("/").slice(1).some(g=>!g||g==="."||g==="..")||typeof A.key!="string"||typeof A.object_hash!="string"||!/^[a-f0-9]{64}$/.test(A.key)||!/^[a-f0-9]{64}$/.test(A.object_hash)||A.receipt!=null&&typeof A.receipt!="string"||!(A.object instanceof Uint8Array)))return new TextEncoder().encode(JSON.stringify({source:A.source,key:A.key,object_hash:A.object_hash,...A.receipt==null?{}:{receipt:A.receipt}})).byteLength}async validateBatch(){if(this.stagingFailed)return!1;const A=[...this.staged.values()];for(const g of A){if(!fA(g.object))return!1;const I=await crypto.subtle.digest("SHA-256",g.object);if(Array.from(new Uint8Array(I),B=>B.toString(16).padStart(2,"0")).join("")!==g.object_hash)return!1}return!0}commitBatch(){for(const[A,g]of this.staged)this.remove(A),this.records.set(A,g);this.staged.clear(),this.stagingFailed=!1}discardBatch(){for(const A of this.staged.values())this.objectBytes-=A.object.byteLength,this.metadataBytes-=A.metadataBytes;this.staged.clear()}snapshot(){return[...this.records.values()].map(({source:A,key:g,object_hash:I,object:C,receipt:B})=>({source:A,key:g,object_hash:I,...B==null?{}:{receipt:B},object:C.slice()}))}touch(A){const g=this.records.get(A);g&&(this.records.delete(A),this.records.set(A,g))}put(A){if(typeof A.source!="string"||!A.source.startsWith("/")||A.source.split("/").slice(1).some(B=>!B||B==="."||B==="..")||typeof A.key!="string"||typeof A.object_hash!="string"||!/^[a-f0-9]{64}$/.test(A.object_hash)||!/^[a-f0-9]{64}$/.test(A.key)||!(A.object instanceof Uint8Array))return;const g=this.recordSize(A);if(g===void 0)return;const I=this.limits;if(this.remove(A.source),I.maxEntries===0||A.object.byteLength>I.maxObjectBytes||g>I.maxMetadataBytes||g>I.maxEntryMetadataBytes){this.oversized++;return}for(;this.records.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes;)this.remove(this.records.keys().next().value),this.evictions++;const C={...A,object:new Uint8Array(A.object),metadataBytes:g};this.records.set(A.source,C),this.objectBytes+=C.object.byteLength,this.metadataBytes+=g}delete(A){this.remove(A)}remove(A){const g=this.records.get(A);g&&(this.objectBytes-=g.object.byteLength,this.metadataBytes-=g.metadataBytes,this.records.delete(A))}clear(){this.records.clear(),this.staged.clear(),this.stagingFailed=!1,this.objectBytes=this.metadataBytes=0}stats(){return{objectBytes:this.objectBytes,metadataBytes:this.metadataBytes,entries:this.records.size,stagingEntries:this.staged.size,stagingObjectBytes:[...this.staged.values()].reduce((A,g)=>A+g.object.byteLength,0),stagingMetadataBytes:[...this.staged.values()].reduce((A,g)=>A+g.metadataBytes,0),evictions:this.evictions,oversized:this.oversized}}}function fA(Q){if(!WebAssembly.validate(Q)||Q.length<8)return!1;let A=8,g=!1;const I=()=>{let C=0,B=0;for(let i=0;i<5&&A<Q.length;i++,B+=7){const D=Q[A++];if(C+=(D&127)*2**B,!(D&128))return C}throw new Error("Malformed object section")};try{for(;A<Q.length;){const C=Q[A++],B=I(),i=A+B;if(i>Q.length||C===8)return!1;if(C===0){const D=I();if(A+D>i)return!1;const o=new TextDecoder().decode(Q.subarray(A,A+D));if(A+=D,o==="linking"){if(g||I()!==2)return!1;g=!0}}A=i}return g}catch{return!1}}const U=Symbol();function S(Q){return Q instanceof Error?{type:"error",error:{type:Q.constructor.name,message:Q.message}}:{type:"error",error:{type:typeof Q,message:String(Q)}}}class GA{name;data;constructor(A,g){this.name=A,this.data=g}download(){const A=new Uint8Array(this.data),g=new Blob([A]),I=URL.createObjectURL(g),C=document.createElement("a");C.href=I,C.download=this.name,document.body.appendChild(C),C.click(),document.body.removeChild(C),URL.revokeObjectURL(I)}}class MA extends wA{[U];dap;enabled=!0;set filterInternals(A){this.dap.setFilterInternals(A)}constructor(){super(),this[U]={attach:this.attach.bind(this),detach:this.detach.bind(this),beginRun:()=>this.dap.resetRun()},this.onMessage=this.onMessage.bind(this),this.dap=new _,this.dap.on(this.onMessage)}send(A){return this.dap.sendMessage(A)}artifactListener=A=>{if(A.data.type!=="artifact")return;const g=new GA(A.data.name,new Uint8Array(A.data.data));this.emit("artifact",g)};attach(A){A.addEventListener("message",this.artifactListener),this.dap.attach(A)}detach(A){A.removeEventListener("message",this.artifactListener),this.dap.detach()}onMessage(A){this.emit("event",A)}}const lA="glassjar-wasm:";function XA(Q,A){const g=new URL(String(Q),A);if(g.protocol!=="https:"&&g.protocol!=="http:")throw new TypeError(`Engine Wasm must be served over http(s), not ${g.protocol}`);return g.href}function bA(Q){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/worker-CxN69gQ2.js").href:new URL("assets/worker-CxN69gQ2.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),{type:"module",name:Q?.name})}function mA(Q){return new bA(Q?{name:lA+Q}:void 0)}const PA="/dev/debugger-sh-host";class yA{buffer=new SharedArrayBuffer(4+64*1024);length=new Int32Array(this.buffer,0,1);bytes=new Uint8Array(this.buffer,4);publish(A){Atomics.store(this.length,0,A),Atomics.notify(this.length,0)}}function IA(Q){try{return new Error(`Host device callback failed: ${Q instanceof Error?Q.message:String(Q)}`)}catch{return new Error("Host device callback failed")}}function KA(Q){try{const A=Q?.();if(A&&typeof A.then=="function")return Promise.resolve(A).catch(()=>{}),new TypeError("Host device cleanup must be synchronous")}catch(A){return IA(A)}}class rA{constructor(A){this.onFailure=A}incoming=new yA;outgoing=new yA;workerStart={guest_to_host:this.incoming.buffer,host_to_guest:this.outgoing.buffer};abort=new AbortController;listeners=new Set;cleanup;worker;writing=!1;open(A){let g;try{g=A({signal:this.abort.signal,onData:I=>{if(this.assertOpen(),typeof I!="function")throw new TypeError("Host device listener must be a function");return this.listeners.add(I),()=>{this.listeners.delete(I)}},write:I=>this.write(I)})}catch(I){throw IA(I)}if(g!==void 0&&typeof g!="function")throw Promise.resolve(g).catch(()=>{}),new TypeError("Host device opener must return a cleanup function or undefined");if(typeof g=="function")if(this.abort.signal.aborted){const I=KA(g);if(I)throw I}else this.cleanup=g}attach(A){this.assertOpen(),this.worker=A,A.addEventListener("message",this.onMessage)}assertOpen(){if(this.abort.signal.aborted)throw new Error("Host device is closed")}async write(A){if(this.assertOpen(),!(A instanceof Uint8Array))throw new TypeError("Host device writes require Uint8Array");if(this.writing)throw new Error("Await the previous host device write before writing again");this.writing=!0;try{const g=new Uint8Array(A),I=this.outgoing;let C=0;for(;C<g.length;){this.assertOpen();const B=Atomics.load(I.length,0);if(B!==0){await Atomics.waitAsync(I.length,0,B).value;continue}const i=g.subarray(C,C+I.bytes.length);I.bytes.set(i),I.publish(i.length),C+=i.length}}finally{this.writing=!1}}onMessage=A=>{if(!(this.abort.signal.aborted||A.data?.type!=="host_wake"))try{const g=Atomics.load(this.incoming.length,0);if(g<=0)return;const I=this.incoming.bytes.slice(0,g);this.incoming.publish(0);for(const C of this.listeners){if(this.abort.signal.aborted)break;Promise.resolve(C(I)).catch(B=>this.fail(B))}}catch(g){this.fail(g)}};fail(A){this.abort.signal.aborted||(this.close(),this.onFailure(IA(A)))}close(){if(this.abort.signal.aborted)return;this.worker?.removeEventListener("message",this.onMessage),this.worker=void 0,this.incoming.publish(-1),this.outgoing.publish(-1),this.abort.abort(),this.listeners.clear();const A=this.cleanup;return this.cleanup=void 0,KA(A)}}const nA=["4847c7cda81eb51b1cec18fe40b396605579fe84e17eca2760702b8a9666e4e1"],v=Object.freeze({compiler:"2d2c6ae498b27592a3cec7a270f274a08848a834e762cc08818c78626c32053a",sysroot:"8745c6af23fd841fa507d0c73f6b6b8e8da1b4ec216a6339739a28b38ff7227b",exceptions:"20986166552953de0e3ca5c1e9f341e7aec8b9ba54dcb244d0d2b2f9ca843ab4"});function RA(Q="legacy"){if(Q==="legacy")return{profile:Q,digests:v};if(Q==="stock-certified-v1"&&nA.length>0)return{profile:Q,digests:v};throw new Error(`The ${Q} toolchain is not available in this build`)}class X{#A;hashCount=3;hashMs;constructor(A,g){this.#A=A,this.hashMs=g}static async load(A,g,I,C=v.exceptions,B="legacy"){const i=RA(B);if(A.length!==2)throw new Error("Missing C++ toolchain assets");let D,o;const K=await Promise.allSettled(A.map(async(b,EA)=>{try{const Z=await fetch(b,{cache:"force-cache",signal:I});if(!Z.ok)throw new Error(`Cannot load C++ toolchain (${Z.status})`);return EA===0&&g&&typeof WebAssembly.compileStreaming=="function"&&typeof Z.clone=="function"&&(o=WebAssembly.compileStreaming(Z.clone()).catch(()=>{})),new Uint8Array(await Z.arrayBuffer())}catch(Z){throw D??={error:Z},Z}}));if(K[0].status==="rejected"||K[1].status==="rejected")throw D?.error;const[J,h]=[K[0].value,K[1].value],[Y,s]=await Promise.allSettled([X.ingestOwned(J,h,!1,C),g?(o??Promise.resolve(void 0)).then(b=>b??WebAssembly.compile(J)):Promise.resolve(void 0)]);if(Y.status==="rejected")throw Y.reason;const q=Y.value;if(q.#A.compilerHash!==i.digests.compiler||q.#A.sysrootHash!==i.digests.sysroot||q.#A.exceptionsHash!==i.digests.exceptions)throw new Error("C++ toolchain integrity mismatch");if(I?.aborted)throw new DOMException("Toolchain loading aborted","AbortError");if(s.status==="rejected")throw s.reason;return q.#A.stockProfile=i.profile==="stock-certified-v1",q.#A.module=s.value,q}static async fromBytes(A,g,I){const C=new Uint8Array(A),B=new Uint8Array(g);return X.ingestOwned(C,B,I,v.exceptions)}static async ingestOwned(A,g,I,C){const B=performance.now(),i=await Promise.allSettled([YA(A),YA(g)]);if(i[0].status==="rejected")throw i[0].reason;if(i[1].status==="rejected")throw i[1].reason;const[D,o]=[i[0].value,i[1].value],K=I?await WebAssembly.compile(A):void 0;return new X({compiler:A,sysroot:g,compilerHash:D,sysrootHash:o,exceptionsHash:C,module:K},performance.now()-B)}matchesExpectation(A){return A.compilerSha256===this.#A.compilerHash&&A.sysrootSha256===this.#A.sysrootHash&&A.exceptionsSha256===this.#A.exceptionsHash}get identity(){return`${this.#A.compilerHash}:${this.#A.sysrootHash}:${this.#A.exceptionsHash}`}get identityBytes(){return this.#A.compiler.byteLength+this.#A.sysroot.byteLength}get compilerBytes(){return this.#A.compiler.byteLength}configure(A,g){try{return A.postMessage({...g,toolchain:this.#A}),!!this.#A.module}catch(I){if(!(I instanceof DOMException)||I.name!=="DataCloneError"||!this.#A.module)throw I;return A.postMessage({...g,toolchain:{...this.#A,module:void 0}}),!1}}}async function YA(Q){const A=await crypto.subtle.digest("SHA-256",Q);return Array.from(new Uint8Array(A),g=>g.toString(16).padStart(2,"0")).join("")}let CA,e;class QA{stdout=new BA(1);stderr=new BA(2);stdin=new H;debugger;lang;scope;fs={};binaryFiles={};cppArtifacts;hostDevice;options;retain;idleTimeoutMs;wasmUrl;objects;generation=0;scopeEpoch=0;operationId=0;disposed=!1;active;promise;slot;idleTimer;toolchain;toolchainLoading;toolchainController;initializing=new Set;toolchainIdentity;toolchainIngestions=0;toolchainHashCount=0;toolchainHashMs=0;compilerModuleCloned=!1;disposal;cancellationDraining;releaseDrain;releases=new Set;retirements=0;latest;cacheValidation;static async create(A,g={}){const{wasmUrl:I,...C}=g,B=I===void 0?void 0:XA(I,globalThis.location?.href),i=structuredClone(C),D=B??null;if(e!==void 0&&e!==D)throw new Error("The engine Wasm is already loaded from a different wasmUrl");e=D,CA??=OA({module_or_path:B??tA}).catch(K=>{throw CA=void 0,e=void 0,K}),await CA;const o=new QA(A,i);if(o.wasmUrl=B,A!=="c"&&typeof window<"u"&&typeof fetch<"u")for(const K of iA(A))fetch(K,{cache:"force-cache"}).then(J=>J.arrayBuffer()).catch(()=>{});return o}constructor(A,g){const I=g.cpp;this.retain=g.retainWorker??I?.retainWorker??!0;const C=g.idleTimeoutMs??I?.idleTimeoutMs??3e4;if(!Number.isSafeInteger(C)||C<1||C>3e5)throw new RangeError("Worker idle timeout must be between 1 and 300000 milliseconds");if(this.idleTimeoutMs=C,I){if(A!=="c")throw new TypeError("C++ performance options require C/C++");if(!I.scope?.projectId||!I.scope.accountId)throw new TypeError("C++ performance options require project and account identity");if(I.compilerLifetime!==void 0&&!["idle","project"].includes(I.compilerLifetime))throw new TypeError("Invalid compiler lifetime");RA(I.toolchainProfile),this.scope=Object.freeze({...I.scope}),this.options=Object.freeze({...I,scope:this.scope,idleTimeoutMs:C})}this.objects=new zA(typeof I?.objectCache=="object"?I.objectCache:{}),this.debugger=new MA,this.lang=A}get cacheCompilerModule(){return this.options?.cacheCompilerModule??this.retain}get cacheStats(){return structuredClone({...this.objects.stats(),generation:this.generation,scopeEpoch:this.scopeEpoch,operationId:this.operationId,cacheEpoch:this.generation,toolchainProfile:this.options?.toolchainProfile??"legacy",cacheEligible:this.cacheValidation?.eligible??!1,stockCertificateSha256:this.cacheValidation?.certificate,cacheEligibilitySnapshot:this.cacheValidation?.snapshot,cacheEligibilityOperationId:this.cacheValidation?.operationId,cacheEligibilityReason:this.cacheValidation?.reason,toolchainIdentityBytes:this.toolchain?.identityBytes??0,toolchainIngestions:this.toolchainIngestions,toolchainHashCount:this.toolchainHashCount,toolchainHashMs:this.toolchainHashMs,compilerModuleCloned:this.compilerModuleCloned,workerRetained:!!this.slot&&!this.active,workerRetirements:this.retirements,compilerModuleIdentityBytes:this.cacheCompilerModule?this.toolchain?.compilerBytes??0:0,latest:this.active?.stats??this.latest})}clearCaches(){this.cacheValidation=void 0,this.generation++,this.objects.clear(),this.toolchain=void 0,this.active||(this.toolchainController?.abort(),this.toolchainLoading=void 0),this.active||this.retireWorker()}stop(){return this.clearCaches(),this.cancelCurrentOperation()}cancelCurrentOperation(){if(this.cancellationDraining)return this.cancellationDraining;this.operationId++;const A=this.promise,g=this.active?.publication;this.retireWorker(),this.objects.discardBatch(),this.active&&this.finish(this.active,{type:"stopped"});const I=Promise.allSettled([A,g]).then(()=>{this.cancellationDraining===I&&(this.cancellationDraining=void 0)});return this.cancellationDraining=I,I}releaseCompilerResources(A={}){const g=A.signal;return g?.aborted?Promise.resolve("cancelled"):this.disposed?Promise.resolve("released"):new Promise(I=>{const C={resolve:I,signal:g,abort:()=>this.settleRelease(C,"cancelled")};this.releases.add(C),g?.addEventListener("abort",C.abort,{once:!0}),this.flushReleases()})}settleRelease(A,g){this.releases.delete(A)&&(A.signal?.removeEventListener("abort",A.abort),A.resolve(g))}flushReleases(){if(!(this.active||!this.releases.size||this.releaseDrain)){if(this.initializing.size){this.toolchainController?.abort();const A=[...this.initializing];this.toolchainLoading=void 0,this.releaseDrain=Promise.allSettled(A).then(()=>{this.releaseDrain=void 0,this.flushReleases()});return}this.retireWorker(),this.toolchainController?.abort(),this.toolchain=void 0,this.toolchainLoading=void 0;for(const A of this.releases)this.settleRelease(A,"released")}}dispose(){if(this.disposal)return this.disposal;this.disposed=!0,this.scopeEpoch++,this.fs={},this.binaryFiles={},this.cppArtifacts=void 0,this.hostDevice=void 0,this.stdout.removeAllListeners(),this.stderr.removeAllListeners(),this.debugger.removeAllListeners();const A=[...this.initializing];return this.toolchainController?.abort(),this.disposal=Promise.allSettled([this.stop(),...A]).then(()=>{this.latest=void 0,this.flushReleases()}),this.disposal}prepareCompiler(A){if(A?.validateCacheInputs!==void 0&&typeof A.validateCacheInputs!="boolean")return Promise.resolve(S(new TypeError("Invalid compiler preparation options")));const g=A?.validateCacheInputs===!0&&this.options?.toolchainProfile==="stock-certified-v1"&&!!this.options?.objectCache&&this.objects.limits.maxEntries>0&&this.objects.limits.maxObjectBytes>0&&this.objects.limits.maxMetadataBytes>0&&this.objects.limits.maxEntryMetadataBytes>0;return this.submit(!0,!0,g)}run(){return this.submit(!1)}compile(){return this.submit(!0)}submit(A,g=!1,I=!1){if(this.disposed)return Promise.resolve(S(new Error("Engine is disposed")));if(this.active||this.cancellationDraining)return Promise.resolve(S(new Error("An engine job is already active")));if(A&&this.lang!=="c")return Promise.resolve(S(new Error("Compile-only is supported for C/C++")));this.cacheValidation=void 0;const C=g&&!I;let B;try{const Y=C||!this.cppArtifacts?null:{...this.cppArtifacts};if(Y?.cacheCertificate!==void 0){const s=Y.cacheCertificate;(typeof s!="string"||s.length>1024*1024||new TextEncoder().encode(s).byteLength>1024*1024)&&delete Y.cacheCertificate}B={fs:C?{}:structuredClone(this.fs),binary_files:Object.fromEntries(Object.entries(C?{}:this.binaryFiles).map(([s,q])=>[s,new Uint8Array(q)])),cpp_artifacts:structuredClone(Y)}}catch(Y){return Promise.resolve(S(Y))}const i=!A&&this.debugger.enabled,D=A?void 0:this.hostDevice;if(D!==void 0&&(typeof D!="function"||!["c","python"].includes(this.lang)))return Promise.resolve(S(new TypeError("Invalid host device configuration")));clearTimeout(this.idleTimer),this.stdin[U].clear();const o=!!this.slot;let K;const J=new Promise(Y=>{K=Y});this.promise=J;const h={generation:this.generation,scopeEpoch:this.scopeEpoch,operationId:++this.operationId,cacheEpoch:this.generation,prepareOnly:g,validateCacheInputs:I,settled:!1,buildOnly:A,debug:i,opener:D,startedAt:performance.now(),resolve:K,stats:{operation:g?"prepare_compiler":A?"compile":"run",workerReadyMs:0,workerReused:o},start:{...B,lang:this.lang,prepare_compiler:g,validate_cache_inputs:I,scope_epoch:this.scopeEpoch,operation_id:this.operationId,cache_epoch:this.generation,is_debug:i,build_only:A,stdin_buffer:this.stdin[U].buffer,cpp_cache:this.options?.objectCache&&!i&&!g?{generation:this.generation,entries:this.objects.snapshot(),max_entry_metadata_bytes:Math.min(this.objects.limits.maxEntryMetadataBytes,this.objects.limits.maxMetadataBytes,1024*1024)}:null}};this.objects.beginBatch(),this.active=h;try{if(this.slot||this.makeWorker(),!this.current(h))return J;const Y=this.slot;this.lang==="c"&&!this.toolchain&&this.ensureToolchain().catch(s=>{this.current(h)&&this.slot===Y&&this.finish(h,S(s))}),this.slot.ready&&this.dispatch(h)}catch(Y){this.finish(h,S(Y))}return J}current(A){return this.active===A&&!A.settled}makeWorker(){const A=mA(this.wasmUrl),g={worker:A,ready:!1,remove:()=>{}};this.slot=g;const I=i=>{if(this.slot!==g)return;const D=i.data,o=this.active;if(D.type==="ready"){if(g.ready)return;g.ready=!0,o&&this.current(o)&&this.dispatch(o);return}if(!(!o||!this.current(o))){if(!g.ready&&D.type==="error"){this.finish(o,S(new Error(D.message)));return}if(!(D.operationId!==o.operationId||D.scopeEpoch!==o.scopeEpoch))try{if(D.type==="cpp_cache_eligibility"){if(this.options?.toolchainProfile!=="stock-certified-v1"||o.prepareOnly&&!o.validateCacheInputs)return;const K=h=>typeof h=="string"&&/^[0-9a-f]{64}$/.test(h),J=D.eligible===!0&&K(D.certificate_sha256)&&K(D.snapshot);this.cacheValidation={eligible:J,certificate:K(D.certificate_sha256)?D.certificate_sha256:void 0,snapshot:J?D.snapshot:void 0,operationId:o.operationId,reason:J?void 0:typeof D.reason=="string"?D.reason.slice(0,128):"stock-input-validation"}}else if(D.type==="stop")this.finish(o,{type:"completed",exitCode:D.exit_code,timing:{totalMs:performance.now()-o.startedAt,buildMs:D.build_ms,runMs:D.run_ms}});else if(D.type==="error")this.finish(o,S(new Error(D.message)));else if(D.type==="cpp_cache_object"&&D.generation===this.generation&&o.generation===this.generation)try{this.objects.stage(D)}catch{this.objects.abandonBatch()}else D.type==="cpp_cache_stats"&&D.generation===o.generation?o.stats.cache=D.stats:D.type==="cpp_cache_abandon"?this.objects.abandonBatch():D.type==="object_build_complete"?o.publication??=this.publishObjects(o,g):D.type==="compiler_module_stats"&&(o.stats.compilerModule=D)}catch(K){this.finish(o,S(K))}}},C=i=>{this.slot===g&&(this.clearCaches(),this.active?this.finish(this.active,S(i.error??new Error(i.message))):this.retireWorker())},B=()=>C({message:"Unreadable execution worker message"});this.debugger[U].attach(A),A.addEventListener("message",I),A.addEventListener("error",C),A.addEventListener("messageerror",B),g.remove=()=>{A.removeEventListener("message",I),A.removeEventListener("error",C),A.removeEventListener("messageerror",B),this.debugger[U].detach(A)}}async publishObjects(A,g){let I=!1;try{I=await this.objects.validateBatch()}catch{}if(!(!this.current(A)||this.slot!==g)){try{I&&A.cacheEpoch===this.generation?this.objects.commitBatch():(this.objects.abandonBatch(),this.cacheValidation?.operationId===A.operationId&&(this.cacheValidation={...this.cacheValidation,eligible:!1,snapshot:void 0,reason:"stock-publication-budget-or-validation"}))}catch{this.objects.clear(),this.cacheValidation?.operationId===A.operationId&&(this.cacheValidation={...this.cacheValidation,eligible:!1,snapshot:void 0,reason:"stock-publication-failure"})}this.current(A)&&g.worker.postMessage({type:"object_build_ack",scopeEpoch:A.scopeEpoch,operationId:A.operationId,cacheEpoch:A.cacheEpoch})}}ensureToolchain(){if(this.toolchain)return Promise.resolve(this.toolchain);if(this.toolchainLoading)return this.toolchainLoading;this.toolchainController=new AbortController;const A=X.load(iA("c"),this.cacheCompilerModule,this.toolchainController.signal,sA(),this.options?.toolchainProfile);return this.toolchainLoading=A,this.initializing.add(A),A.then(()=>this.initializing.delete(A),()=>{this.initializing.delete(A),this.toolchainLoading===A&&(this.toolchainLoading=void 0)}),A}async dispatch(A){const g=this.slot;if(!(!this.current(A)||!g))try{if(this.lang==="c"){const B=this.scopeEpoch,i=this.generation,D=this.ensureToolchain(),o=this.toolchain??await D;if(!this.current(A)||this.slot!==g||B!==this.scopeEpoch)return;const K=A.start.cpp_artifacts?.requiredToolchain;if(K&&!o.matchesExpectation(K)){this.finish(A,{type:"error",error:{type:"artifact-toolchain-integrity",message:"C++ artifacts require a different compiler, sysroot, or exception runtime"}});return}i===this.generation&&(this.toolchainIdentity&&this.toolchainIdentity!==o.identity&&(this.objects.clear(),A.start.cpp_cache=null),this.toolchain!==o&&(this.toolchainIngestions++,this.toolchainHashCount+=o.hashCount,this.toolchainHashMs+=o.hashMs),this.toolchainIdentity=o.identity,this.toolchain=o,this.toolchainLoading===D&&(this.toolchainLoading=void 0)),g.toolchain!==o&&(this.compilerModuleCloned=o.configure(g.worker,{type:"configure_cpp",cacheCompilerModule:this.cacheCompilerModule}),g.toolchain=o)}if(!this.current(A)||this.slot!==g)return;const I=g.worker;A.stats.workerReadyMs=performance.now()-A.startedAt;const C=B=>this.current(A)&&B.scopeEpoch===A.scopeEpoch&&B.operationId===A.operationId;if(this.stdout[U].attach(I,C),this.stderr[U].attach(I,C),A.prepareOnly||this.debugger[U].beginRun(),A.opener){if(A.device=new rA(B=>this.finish(A,S(B))),A.device.attach(I),A.device.open(A.opener),!this.current(A))return;A.start.host_device=A.device.workerStart}this.current(A)&&(I.postMessage(A.start),A.start.fs={},A.start.binary_files={},A.start.cpp_artifacts=null,A.start.cpp_cache=null)}catch(I){this.current(A)&&(this.toolchainLoading=void 0,this.finish(A,S(I)))}}finish(A,g){if(!this.current(A))return;(g.type!=="completed"||g.exitCode!==0)&&(this.cacheValidation=void 0),A.settled=!0;const I=this.slot?.worker;I&&(this.stdout[U].detach(I),this.stderr[U].detach(I));const C=A.device?.close();C&&(g=S(C));const B=g.type==="completed"&&A.generation===this.generation&&!this.disposed,i=B&&g.type==="completed"&&g.exitCode===0;if(A.generation===this.generation)for(const D of A.stats.cache?.invalid_sources??[])this.objects.delete(D);if(i)for(const D of A.stats.cache?.hit_sources??[])this.objects.touch(D);this.objects.discardBatch(),this.latest=A.stats,this.stdin[U].clear(),(!B||!this.retain)&&this.retireWorker(),!this.disposed&&A.cacheEpoch===this.generation&&(this.slot||this.toolchain&&this.cacheCompilerModule)&&this.options?.compilerLifetime!=="project"&&(this.idleTimer=setTimeout(()=>{this.retireWorker(),this.toolchain=void 0,this.toolchainLoading=void 0},this.idleTimeoutMs)),!this.retain&&!this.cacheCompilerModule&&(this.toolchain=void 0),A.cacheEpoch!==this.generation&&(this.toolchainController?.abort(),this.toolchainLoading=void 0),this.active=void 0,this.promise=void 0,this.flushReleases(),A.resolve(g)}retireWorker(){clearTimeout(this.idleTimer);const A=this.slot;A&&(this.slot=void 0,A.remove(),this.stdout[U].detach(A.worker),this.stderr[U].detach(A.worker),A.worker.onerror=g=>g.preventDefault(),A.worker.terminate(),this.retirements++)}}class BA extends wA{constructor(A){super(),this.mode=A,this.callback=(g=>{const I=g.data;if(this.accepts&&!this.accepts(I)||I.type!=="stdout"||I.mode!==this.mode)return;const C=I.data;this.emit("data",C)}).bind(this),this[U]={attach:this.attach.bind(this),detach:this.detach.bind(this)}}callback;accepts;[U];attach(A,g){this.accepts=g,A.addEventListener("message",this.callback)}detach(A){A.removeEventListener("message",this.callback)}}class H{static BUFFER_SIZE=2048;static HEADER_SIZE=8;static DATA_SIZE=H.BUFFER_SIZE-H.HEADER_SIZE;static READ_IDX=0;static WRITE_IDX=1;static encoder=new TextEncoder;buffer=new SharedArrayBuffer(H.BUFFER_SIZE);generation=0;indices;data;[U];constructor(){this.indices=new Int32Array(this.buffer,0,2),this.data=new Int8Array(this.buffer,H.HEADER_SIZE);const A=()=>this.buffer;this[U]={clear:this.clear.bind(this),get buffer(){return A()}}}clear(){this.generation++,Atomics.notify(this.indices,H.READ_IDX),this.buffer=new SharedArrayBuffer(H.BUFFER_SIZE),this.indices=new Int32Array(this.buffer,0,2),this.data=new Int8Array(this.buffer,H.HEADER_SIZE)}async write(A){const g=typeof A=="string"?H.encoder.encode(A):A;return this.writeBytes(g)}async writeBytes(A){const{DATA_SIZE:g,READ_IDX:I,WRITE_IDX:C}=H;let B=0;const i=this.generation;for(;B<A.length&&i===this.generation;){const D=Atomics.load(this.indices,I);let o=Atomics.load(this.indices,C);o===g-1&&D>0&&(o=0);const K=D<=o?g-o-1:D-o-1;if(K===0){await Atomics.waitAsync(this.indices,I,D).value;continue}const J=Math.min(A.length-B,K);this.data.set(A.subarray(B,B+J),o),Atomics.store(this.indices,C,(o+J)%g),Atomics.notify(this.indices,C),B+=J}}}a.Artifact=GA,a.Debugger=MA,a.Engine=QA,a.HOST_DEVICE_PATH=PA,a.Stdin=H,a.Stdout=BA,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|