@lottiefiles/dotlottie-web 0.4.0 → 0.5.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/dotlottie.js CHANGED
@@ -1,5 +1,5 @@
1
- export { b as DotLottie } from './chunk-NPMXPAFK.js';
2
- import './chunk-VRCJABVO.js';
1
+ export { b as DotLottie } from './chunk-LVR6J6SH.js';
2
+ import './chunk-2ELNS7EO.js';
3
3
  import './chunk-6PRCY2FC.js';
4
4
  import './chunk-7Q3PPTBP.js';
5
5
  //# sourceMappingURL=out.js.map
@@ -84,6 +84,7 @@ declare class EventManager {
84
84
  addEventListener<T extends EventType>(type: T, listener: EventListener<T>): void;
85
85
  removeEventListener<T extends EventType>(type: T, listener?: EventListener<T>): void;
86
86
  dispatch<T extends EventType>(event: EventByType<T>): void;
87
+ removeAllEventListeners(): void;
87
88
  }
88
89
 
89
90
  export { BaseEvent, CompleteEvent, Event, EventListener, EventManager, EventType, FrameEvent, LoadErrorEvent, LoadEvent, LoopEvent, PauseEvent, PlayEvent, StopEvent };
@@ -1,4 +1,4 @@
1
- export { a as EventManager } from './chunk-VRCJABVO.js';
1
+ export { a as EventManager } from './chunk-2ELNS7EO.js';
2
2
  import './chunk-7Q3PPTBP.js';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=event-manager.js.map
package/dist/index.d.ts CHANGED
@@ -16,13 +16,35 @@ interface Renderer {
16
16
  totalFrames(): number;
17
17
  update(): boolean;
18
18
  }
19
+ interface Module {
20
+ Renderer: new () => Renderer;
21
+ }
22
+ /**
23
+ * WasmLoader is a utility class for loading WebAssembly modules.
24
+ * It provides methods to load modules with a primary URL and a backup URL.
25
+ */
19
26
  declare class WasmLoader {
20
- private static _Renderer;
27
+ private static _ModulePromise;
21
28
  private static _wasmURL;
22
29
  private constructor();
23
30
  private static _tryLoad;
31
+ /**
32
+ * Tries to load the WASM module from the primary URL, falling back to a backup URL if necessary.
33
+ * Throws an error if both URLs fail to load the module.
34
+ * @returns Promise<Module> - A promise that resolves to the loaded module.
35
+ */
24
36
  private static _loadWithBackup;
25
- static getInstance(): Promise<Renderer>;
37
+ /**
38
+ * Public method to load the WebAssembly module.
39
+ * Utilizes a primary and backup URL for robustness.
40
+ * @returns Promise<Module> - A promise that resolves to the loaded module.
41
+ */
42
+ static load(): Promise<Module>;
43
+ /**
44
+ * Sets a new URL for the WASM file and invalidates the current module promise.
45
+ *
46
+ * @param string - The new URL for the WASM file.
47
+ */
26
48
  static setWasmUrl(url: string): void;
27
49
  }
28
50
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { b as DotLottie, a as WasmLoader } from './chunk-NPMXPAFK.js';
2
- export { a as EventManager } from './chunk-VRCJABVO.js';
1
+ export { b as DotLottie, a as WasmLoader } from './chunk-LVR6J6SH.js';
2
+ export { a as EventManager } from './chunk-2ELNS7EO.js';
3
3
  export { a as getAnimationJSONFromDotLottie, b as loadAnimationJSONFromURL } from './chunk-6PRCY2FC.js';
4
4
  import './chunk-7Q3PPTBP.js';
5
5
  //# sourceMappingURL=out.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lottiefiles/dotlottie-web",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "Lottie and DotLottie player for the web",
6
6
  "repository": {
@@ -1,11 +0,0 @@
1
- import { a as a$1 } from './chunk-VRCJABVO.js';
2
- import { b, a as a$2 } from './chunk-6PRCY2FC.js';
3
- import { a } from './chunk-7Q3PPTBP.js';
4
-
5
- var fe={name:"@lottiefiles/dotlottie-web",version:"0.4.0",type:"module",description:"Lottie and DotLottie player for the web",repository:{type:"git",url:"git+https://github.com/LottieFiles/dotlottie-web.git",directory:"packages/web"},homepage:"https://github.com/LottieFiles/dotlottie-web#readme",bugs:"https://github.com/LottieFiles/dotlottie-web/issues",author:"LottieFiles",contributors:["Abdelrahman Ashraf <a.theashraf@gmail.com>"],license:"MIT",engines:{node:">=18"},main:"dist/index.js",module:"dist/index.js",types:"dist/index.d.ts",files:["dist"],keywords:["dotlottie","lottie","player","animation","web","canvas","javascript"],scripts:{build:"tsup","build:wasm":"./build_wasm.sh","build:wasm:docker":"./docker_build_wasm.sh",dev:"tsup --watch",lint:"eslint --fix .",size:"size-limit","size:why":"size-limit --why --clean-dir --save-bundle ./tmp","stats:eslint":"cross-env TIMING=1 eslint .","stats:ts":"tsc -p tsconfig.build.json --extendedDiagnostics","type-check":"tsc --noEmit"},dependencies:{"@dotlottie/dotlottie-js":"^0.6.0"},devDependencies:{"@size-limit/esbuild-why":"^10.0.2","@size-limit/preset-small-lib":"^10.0.2","cross-env":"7.0.3","size-limit":"^10.0.2",tsup:"7.2.0",typescript:"5.0.4"},publishConfig:{access:"public"}};var xn=(()=>{var ce=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(v={}){var a=v,D,N;a.ready=new Promise((e,r)=>{D=e,N=r;});var We=Object.assign({},a),Ue="./this.program",Ie=!0,M="";function Sr(e){return a.locateFile?a.locateFile(e,M):M+e}(typeof document<"u"&&document.currentScript&&(M=document.currentScript.src),ce&&(M=ce),M.indexOf("blob:")!==0?M=M.substr(0,M.replace(/[?#].*/,"").lastIndexOf("/")+1):M="",(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t();},n.onerror=t,n.send(null);});var Or=a.print||console.log.bind(console),G=a.printErr||console.error.bind(console);Object.assign(a,We),We=null,a.arguments&&(a.arguments),a.thisProgram&&(Ue=a.thisProgram),a.quit&&(a.quit);var ee;a.wasmBinary&&(ee=a.wasmBinary),typeof WebAssembly!="object"&&ne("no native wasm support detected");var ve,je=!1;function Wr(e,r){e||ne(r);}var q,E,re,pe,P,T,Le,He;function Ye(){var e=ve.buffer;a.HEAP8=q=new Int8Array(e),a.HEAP16=re=new Int16Array(e),a.HEAPU8=E=new Uint8Array(e),a.HEAPU16=pe=new Uint16Array(e),a.HEAP32=P=new Int32Array(e),a.HEAPU32=T=new Uint32Array(e),a.HEAPF32=Le=new Float32Array(e),a.HEAPF64=He=new Float64Array(e);}var xe=[],ze=[],Ve=[];function Ir(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)Hr(a.preRun.shift());Ae(xe);}function jr(){Ae(ze);}function Lr(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)xr(a.postRun.shift());Ae(Ve);}function Hr(e){xe.unshift(e);}function Yr(e){ze.unshift(e);}function xr(e){Ve.unshift(e);}var Y=0,te=null;function zr(e){Y++,a.monitorRunDependencies&&a.monitorRunDependencies(Y);}function Vr(e){if(Y--,a.monitorRunDependencies&&a.monitorRunDependencies(Y),Y==0&&(te)){var r=te;te=null,r();}}function ne(e){a.onAbort&&a.onAbort(e),e="Aborted("+e+")",G(e),je=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw N(r),r}var Br="data:application/octet-stream;base64,",Be=e=>e.startsWith(Br),X;X="renderer.wasm",Be(X)||(X=Sr(X));function Ne(e){if(e==X&&ee)return new Uint8Array(ee);throw "both async and sync fetching of the wasm failed"}function Nr(e){return !ee&&(Ie)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw "failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>Ne(e)):Promise.resolve().then(()=>Ne(e))}function Ge(e,r,t){return Nr(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{G(`failed to asynchronously prepare wasm: ${n}`),ne(n);})}function Gr(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!Be(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(i=>{var s=WebAssembly.instantiateStreaming(i,t);return s.then(n,function(l){return G(`wasm streaming compile failed: ${l}`),G("falling back to ArrayBuffer instantiation"),Ge(r,t,n)})}):Ge(r,t,n)}function qr(){var e={a:Cn};function r(n,i){return y=n.exports,ve=y.L,Ye(),sr=y.R,Yr(y.M),Vr(),y}zr();function t(n){r(n.instance);}if(a.instantiateWasm)try{return a.instantiateWasm(e,r)}catch(n){G(`Module.instantiateWasm callback failed with error: ${n}`),N(n);}return Gr(ee,X,e,t).catch(N),{}}var Ae=e=>{for(;e.length>0;)e.shift()(a);};a.noExitRuntime||!0;var qe=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Xe=(e,r,t)=>{for(var n=r+t,i=r;e[i]&&!(i>=n);)++i;if(i-r>16&&e.buffer&&qe)return qe.decode(e.subarray(r,i));for(var s="";r<i;){var l=e[r++];if(!(l&128)){s+=String.fromCharCode(l);continue}var o=e[r++]&63;if((l&224)==192){s+=String.fromCharCode((l&31)<<6|o);continue}var f=e[r++]&63;if((l&240)==224?l=(l&15)<<12|o<<6|f:l=(l&7)<<18|o<<12|f<<6|e[r++]&63,l<65536)s+=String.fromCharCode(l);else {var c=l-65536;s+=String.fromCharCode(55296|c>>10,56320|c&1023);}}return s},x=(e,r)=>e?Xe(E,e,r):"",Xr=(e,r,t,n)=>{ne(`Assertion failed: ${x(e)}, at: `+[r?x(r):"unknown filename",t,n?x(n):"unknown function"]);};function Jr(e,r,t){return 0}function Kr(e,r,t){return 0}function Zr(e,r,t,n){}var Qr=(e,r,t,n,i)=>{},et=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Je=e;},Je,R=e=>{for(var r="",t=e;E[t];)r+=Je[E[t++]];return r},K={},z={},he={},Z,m=e=>{throw new Z(e)},Ke,me=e=>{throw new Ke(e)},ie=(e,r,t)=>{e.forEach(function(o){he[o]=r;});function n(o){var f=t(o);f.length!==e.length&&me("Mismatched type converter count");for(var c=0;c<e.length;++c)k(e[c],f[c]);}var i=new Array(r.length),s=[],l=0;r.forEach((o,f)=>{z.hasOwnProperty(o)?i[f]=z[o]:(s.push(o),K.hasOwnProperty(o)||(K[o]=[]),K[o].push(()=>{i[f]=z[o],++l,l===s.length&&n(i);}));}),s.length===0&&n(i);};function rt(e,r,t={}){var n=r.name;if(e||m(`type "${n}" must have a positive integer typeid pointer`),z.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;m(`Cannot register type '${n}' twice`);}if(z[e]=r,delete he[e],K.hasOwnProperty(e)){var i=K[e];delete K[e],i.forEach(s=>s());}}function k(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return rt(e,r,t)}var U=8,tt=(e,r,t,n)=>{r=R(r),k(e,{name:r,fromWireType:function(i){return !!i},toWireType:function(i,s){return s?t:n},argPackAdvance:U,readValueFromPointer:function(i){return this.fromWireType(E[i])},destructorFunction:null});},nt=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Ee=e=>{function r(t){return t.$$.ptrType.registeredClass.name}m(r(e)+" instance already deleted");},Fe=!1,Ze=e=>{},it=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr);},Qe=e=>{e.count.value-=1;var r=e.count.value===0;r&&it(e);},er=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=er(e,r,t.baseClass);return n===null?null:t.downcast(n)},rr={},at=()=>Object.keys(oe).length,st=()=>{var e=[];for(var r in oe)oe.hasOwnProperty(r)&&e.push(oe[r]);return e},ae=[],Re=()=>{for(;ae.length;){var e=ae.pop();e.$$.deleteScheduled=!1,e.delete();}},se,ot=e=>{se=e,ae.length&&se&&se(Re);},lt=()=>{a.getInheritedInstanceCount=at,a.getLiveInheritedInstances=st,a.flushPendingDeletes=Re,a.setDelayFunction=ot;},oe={},ut=(e,r)=>{for(r===void 0&&m("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},ft=(e,r)=>(r=ut(e,r),oe[r]),_e=(e,r)=>{(!r.ptrType||!r.ptr)&&me("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&me("Both smartPtrType and smartPtr must be specified"),r.count={value:1},le(Object.create(e,{$$:{value:r}}))};function ct(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=ft(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?_e(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):_e(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var s=this.registeredClass.getActualType(r),l=rr[s];if(!l)return i.call(this);var o;this.isConst?o=l.constPointerType:o=l.pointerType;var f=er(r,this.registeredClass,o.registeredClass);return f===null?i.call(this):this.isSmartPointer?_e(o.registeredClass.instancePrototype,{ptrType:o,ptr:f,smartPtrType:this,smartPtr:e}):_e(o.registeredClass.instancePrototype,{ptrType:o,ptr:f})}var le=e=>typeof FinalizationRegistry>"u"?(le=r=>r,e):(Fe=new FinalizationRegistry(r=>{Qe(r.$$);}),le=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t};Fe.register(r,i,r);}return r},Ze=r=>Fe.unregister(r),le(e)),dt=()=>{Object.assign(ge.prototype,{isAliasOf(e){if(!(this instanceof ge)||!(e instanceof ge))return !1;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,i=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)i=n.upcast(i),n=n.baseClass;return r===n&&t===i},clone(){if(this.$$.ptr||Ee(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=le(Object.create(Object.getPrototypeOf(this),{$$:{value:nt(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},delete(){this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&m("Object already scheduled for deletion"),Ze(this),Qe(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0);},isDeleted(){return !this.$$.ptr},deleteLater(){return this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&m("Object already scheduled for deletion"),ae.push(this),ae.length===1&&se&&se(Re),this.$$.deleteScheduled=!0,this}});};function ge(){}var vt=48,pt=57,tr=e=>{if(e===void 0)return "_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=vt&&r<=pt?`_${e}`:e};function nr(e,r){return e=tr(e),{[e]:function(){return r.apply(this,arguments)}}[e]}var ir=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||m(`Function '${t}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[arguments.length].apply(this,arguments)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n;}},ht=(e,r,t)=>{a.hasOwnProperty(e)?((t===void 0||a[e].overloadTable!==void 0&&a[e].overloadTable[t]!==void 0)&&m(`Cannot register public name '${e}' twice`),ir(a,e,e),a.hasOwnProperty(t)&&m(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),a[e].overloadTable[t]=r):(a[e]=r,t!==void 0&&(a[e].numArguments=t));};function mt(e,r,t,n,i,s,l,o){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=s,this.upcast=l,this.downcast=o,this.pureVirtualFunctions=[];}var Se=(e,r,t)=>{for(;r!==t;)r.upcast||m(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function _t(e,r){if(r===null)return this.isReference&&m(`null is not a valid ${this.name}`),0;r.$$||m(`Cannot pass "${Me(r)}" as a ${this.name}`),r.$$.ptr||m(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Se(r.$$.ptr,t,this.registeredClass);return n}function gt(e,r){var t;if(r===null)return this.isReference&&m(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||m(`Cannot pass "${Me(r)}" as a ${this.name}`),r.$$.ptr||m(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&m(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=Se(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&m("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:m(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else {var i=r.clone();t=this.rawShare(t,be.toHandle(()=>i.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:m("Unsupporting sharing policy");}return t}function yt(e,r){if(r===null)return this.isReference&&m(`null is not a valid ${this.name}`),0;r.$$||m(`Cannot pass "${Me(r)}" as a ${this.name}`),r.$$.ptr||m(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&m(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Se(r.$$.ptr,t,this.registeredClass);return n}function ar(e){return this.fromWireType(T[e>>2])}var bt=()=>{Object.assign(ye.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor&&this.rawDestructor(e);},argPackAdvance:U,readValueFromPointer:ar,deleteObject(e){e!==null&&e.delete();},fromWireType:ct});};function ye(e,r,t,n,i,s,l,o,f,c,p){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=s,this.sharingPolicy=l,this.rawGetPointee=o,this.rawConstructor=f,this.rawShare=c,this.rawDestructor=p,!i&&r.baseClass===void 0?n?(this.toWireType=_t,this.destructorFunction=null):(this.toWireType=yt,this.destructorFunction=null):this.toWireType=gt;}var wt=(e,r,t)=>{a.hasOwnProperty(e)||me("Replacing nonexistant public symbol"),a[e].overloadTable!==void 0&&t!==void 0?a[e].overloadTable[t]=r:(a[e]=r,a[e].argCount=t);},$t=(e,r,t)=>{var n=a["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)},sr,I=e=>sr.get(e),Ct=(e,r,t)=>{if(e.includes("j"))return $t(e,r,t);var n=I(r).apply(null,t);return n},Tt=(e,r)=>{var t=[];return function(){return t.length=0,Object.assign(t,arguments),Ct(e,r,t)}},Q=(e,r)=>{e=R(e);function t(){return e.includes("j")?Tt(e,r):I(r)}var n=t();return typeof n!="function"&&m(`unknown function pointer with signature ${e}: ${r}`),n},Pt=(e,r)=>{var t=nr(r,function(n){this.name=r,this.message=n;var i=new Error(n).stack;i!==void 0&&(this.stack=this.toString()+`
6
- `+i.replace(/^Error(:[^\n]*)?\n/,""));});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},or,lr=e=>{var r=yr(e),t=R(r);return W(r),t},De=(e,r)=>{var t=[],n={};function i(s){if(!n[s]&&!z[s]){if(he[s]){he[s].forEach(i);return}t.push(s),n[s]=!0;}}throw r.forEach(i),new or(`${e}: `+t.map(lr).join([", "]))},At=(e,r,t,n,i,s,l,o,f,c,p,h,_)=>{p=R(p),s=Q(i,s),o&&(o=Q(l,o)),c&&(c=Q(f,c)),_=Q(h,_);var g=tr(p);ht(g,function(){De(`Cannot construct ${p} due to unbound types`,[n]);}),ie([e,r,t],n?[n]:[],function(w){w=w[0];var F,$;n?(F=w.registeredClass,$=F.instancePrototype):$=ge.prototype;var O=nr(g,function(){if(Object.getPrototypeOf(this)!==u)throw new Z("Use 'new' to construct "+p);if(d.constructor_body===void 0)throw new Z(p+" has no accessible constructor");var Ce=d.constructor_body[arguments.length];if(Ce===void 0)throw new Z(`Tried to invoke ctor of ${p} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(d.constructor_body).toString()}) parameters instead!`);return Ce.apply(this,arguments)}),u=Object.create($,{constructor:{value:O}});O.prototype=u;var d=new mt(p,O,u,_,F,s,o,c);d.baseClass&&(d.baseClass.__derivedClasses===void 0&&(d.baseClass.__derivedClasses=[]),d.baseClass.__derivedClasses.push(d));var b=new ye(p,d,!0,!1,!1),C=new ye(p+"*",d,!1,!1,!1),V=new ye(p+" const*",d,!1,!0,!1);return rr[e]={pointerType:C,constPointerType:V},wt(g,O),[b,C,V]});},ur=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(T[r+n*4>>2]);return t},Et=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r);}};function fr(e,r,t,n,i,s){var l=r.length;l<2&&m("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var o=r[1]!==null&&t!==null,f=!1,c=1;c<r.length;++c)if(r[c]!==null&&r[c].destructorFunction===void 0){f=!0;break}var p=r[0].name!=="void",h=l-2,_=new Array(h),g=[],w=[];return function(){arguments.length!==h&&m(`function ${e} called with ${arguments.length} arguments, expected ${h}`),w.length=0;var F;g.length=o?2:1,g[0]=i,o&&(F=r[1].toWireType(w,this),g[1]=F);for(var $=0;$<h;++$)_[$]=r[$+2].toWireType(w,arguments[$]),g.push(_[$]);var O=n.apply(null,g);function u(d){if(f)Et(w);else for(var b=o?1:2;b<r.length;b++){var C=b===1?F:_[b-2];r[b].destructorFunction!==null&&r[b].destructorFunction(C);}if(p)return r[0].fromWireType(d)}return u(O)}}var Ft=(e,r,t,n,i,s)=>{var l=ur(r,t);i=Q(n,i),ie([],[e],function(o){o=o[0];var f=`constructor ${o.name}`;if(o.registeredClass.constructor_body===void 0&&(o.registeredClass.constructor_body=[]),o.registeredClass.constructor_body[r-1]!==void 0)throw new Z(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${o.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return o.registeredClass.constructor_body[r-1]=()=>{De(`Cannot construct ${o.name} due to unbound types`,l);},ie([],l,c=>(c.splice(1,0,null),o.registeredClass.constructor_body[r-1]=fr(f,c,null,i,s),[])),[]});},Rt=e=>{e=e.trim();let r=e.indexOf("(");return r!==-1?(Wr(e[e.length-1]==")","Parentheses for argument names should match."),e.substr(0,r)):e},St=(e,r,t,n,i,s,l,o,f)=>{var c=ur(t,n);r=R(r),r=Rt(r),s=Q(i,s),ie([],[e],function(p){p=p[0];var h=`${p.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),o&&p.registeredClass.pureVirtualFunctions.push(r);function _(){De(`Cannot call ${h} due to unbound types`,c);}var g=p.registeredClass.instancePrototype,w=g[r];return w===void 0||w.overloadTable===void 0&&w.className!==p.name&&w.argCount===t-2?(_.argCount=t-2,_.className=p.name,g[r]=_):(ir(g,r,h),g[r].overloadTable[t-2]=_),ie([],c,function(F){var $=fr(h,F,p,s,l);return g[r].overloadTable===void 0?($.argCount=t-2,g[r]=$):g[r].overloadTable[t-2]=$,[]}),[]});};function Dt(){Object.assign(cr.prototype,{get(e){return this.allocated[e]},has(e){return this.allocated[e]!==void 0},allocate(e){var r=this.freelist.pop()||this.allocated.length;return this.allocated[r]=e,r},free(e){this.allocated[e]=void 0,this.freelist.push(e);}});}function cr(){this.allocated=[void 0],this.freelist=[];}var S=new cr,dr=e=>{e>=S.reserved&&--S.get(e).refcount===0&&S.free(e);},Mt=()=>{for(var e=0,r=S.reserved;r<S.allocated.length;++r)S.allocated[r]!==void 0&&++e;return e},Ot=()=>{S.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),S.reserved=S.allocated.length,a.count_emval_handles=Mt;},be={toValue:e=>(e||m("Cannot use deleted val. handle = "+e),S.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return S.allocate({refcount:1,value:e})}}};function vr(e){return this.fromWireType(P[e>>2])}var kt=(e,r)=>{r=R(r),k(e,{name:r,fromWireType:t=>{var n=be.toValue(t);return dr(t),n},toWireType:(t,n)=>be.toHandle(n),argPackAdvance:U,readValueFromPointer:vr,destructorFunction:null});},Me=e=>{if(e===null)return "null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},Wt=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(Le[t>>2])};case 8:return function(t){return this.fromWireType(He[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},Ut=(e,r,t)=>{r=R(r),k(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>i,argPackAdvance:U,readValueFromPointer:Wt(r,t),destructorFunction:null});},It=(e,r,t)=>{switch(r){case 1:return t?n=>q[n>>0]:n=>E[n>>0];case 2:return t?n=>re[n>>1]:n=>pe[n>>1];case 4:return t?n=>P[n>>2]:n=>T[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},jt=(e,r,t,n,i)=>{r=R(r);var s=p=>p;if(n===0){var l=32-8*t;s=p=>p<<l>>>l;}var o=r.includes("unsigned"),f=(p,h)=>{},c;o?c=function(p,h){return f(h,this.name),h>>>0}:c=function(p,h){return f(h,this.name),h},k(e,{name:r,fromWireType:s,toWireType:c,argPackAdvance:U,readValueFromPointer:It(r,t,n!==0),destructorFunction:null});},Lt=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],i=n[r];function s(l){var o=T[l>>2],f=T[l+4>>2];return new i(q.buffer,f,o)}t=R(t),k(e,{name:t,fromWireType:s,argPackAdvance:U,readValueFromPointer:s},{ignoreDuplicateRegistrations:!0});},pr=(e,r,t,n)=>{if(!(n>0))return 0;for(var i=t,s=t+n-1,l=0;l<e.length;++l){var o=e.charCodeAt(l);if(o>=55296&&o<=57343){var f=e.charCodeAt(++l);o=65536+((o&1023)<<10)|f&1023;}if(o<=127){if(t>=s)break;r[t++]=o;}else if(o<=2047){if(t+1>=s)break;r[t++]=192|o>>6,r[t++]=128|o&63;}else if(o<=65535){if(t+2>=s)break;r[t++]=224|o>>12,r[t++]=128|o>>6&63,r[t++]=128|o&63;}else {if(t+3>=s)break;r[t++]=240|o>>18,r[t++]=128|o>>12&63,r[t++]=128|o>>6&63,r[t++]=128|o&63;}}return r[t]=0,t-i},Ht=(e,r,t)=>pr(e,E,r,t),hr=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3;}return r},Yt=(e,r)=>{r=R(r);var t=r==="std::string";k(e,{name:r,fromWireType(n){var i=T[n>>2],s=n+4,l;if(t)for(var o=s,f=0;f<=i;++f){var c=s+f;if(f==i||E[c]==0){var p=c-o,h=x(o,p);l===void 0?l=h:(l+=String.fromCharCode(0),l+=h),o=c+1;}}else {for(var _=new Array(i),f=0;f<i;++f)_[f]=String.fromCharCode(E[s+f]);l=_.join("");}return W(n),l},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var s,l=typeof i=="string";l||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int8Array||m("Cannot pass non-string to std::string"),t&&l?s=hr(i):s=i.length;var o=ke(4+s+1),f=o+4;if(T[o>>2]=s,t&&l)Ht(i,f,s+1);else if(l)for(var c=0;c<s;++c){var p=i.charCodeAt(c);p>255&&(W(f),m("String has UTF-16 code units that do not fit in 8 bits")),E[f+c]=p;}else for(var c=0;c<s;++c)E[f+c]=i[c];return n!==null&&n.push(W,o),o},argPackAdvance:U,readValueFromPointer:ar,destructorFunction(n){W(n);}});},mr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,xt=(e,r)=>{for(var t=e,n=t>>1,i=n+r/2;!(n>=i)&&pe[n];)++n;if(t=n<<1,t-e>32&&mr)return mr.decode(E.subarray(e,t));for(var s="",l=0;!(l>=r/2);++l){var o=re[e+l*2>>1];if(o==0)break;s+=String.fromCharCode(o);}return s},zt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,s=0;s<i;++s){var l=e.charCodeAt(s);re[r>>1]=l,r+=2;}return re[r>>1]=0,r-n},Vt=e=>e.length*2,Bt=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var i=P[e+t*4>>2];if(i==0)break;if(++t,i>=65536){var s=i-65536;n+=String.fromCharCode(55296|s>>10,56320|s&1023);}else n+=String.fromCharCode(i);}return n},Nt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,i=n+t-4,s=0;s<e.length;++s){var l=e.charCodeAt(s);if(l>=55296&&l<=57343){var o=e.charCodeAt(++s);l=65536+((l&1023)<<10)|o&1023;}if(P[r>>2]=l,r+=4,r+4>i)break}return P[r>>2]=0,r-n},Gt=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4;}return r},qt=(e,r,t)=>{t=R(t);var n,i,s,l,o;r===2?(n=xt,i=zt,l=Vt,s=()=>pe,o=1):r===4&&(n=Bt,i=Nt,l=Gt,s=()=>T,o=2),k(e,{name:t,fromWireType:f=>{for(var c=T[f>>2],p=s(),h,_=f+4,g=0;g<=c;++g){var w=f+4+g*r;if(g==c||p[w>>o]==0){var F=w-_,$=n(_,F);h===void 0?h=$:(h+=String.fromCharCode(0),h+=$),_=w+r;}}return W(f),h},toWireType:(f,c)=>{typeof c!="string"&&m(`Cannot pass non-string to C++ string type ${t}`);var p=l(c),h=ke(4+p+r);return T[h>>2]=p>>o,i(c,h+4,p+r),f!==null&&f.push(W,h),h},argPackAdvance:U,readValueFromPointer:vr,destructorFunction(f){W(f);}});},Xt=(e,r)=>{r=R(r),k(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}});},Jt=()=>{throw 1/0},Kt=e=>{e>4&&(S.get(e).refcount+=1);},Zt=(e,r)=>{var t=z[e];return t===void 0&&m(r+" has unknown type "+lr(e)),t},Qt=(e,r)=>{e=Zt(e,"_emval_take_value");var t=e.readValueFromPointer(r);return be.toHandle(t)},en=()=>{ne("");},rn=(e,r,t)=>E.copyWithin(e,r,r+t),tn=()=>2147483648,nn=e=>{var r=ve.buffer,t=(e-r.byteLength+65535)/65536;try{return ve.grow(t),Ye(),1}catch{}},an=e=>{var r=E.length;e>>>=0;var t=tn();if(e>t)return !1;for(var n=(f,c)=>f+(c-f%c)%c,i=1;i<=4;i*=2){var s=r*(1+.2/i);s=Math.min(s,e+100663296);var l=Math.min(t,n(Math.max(e,s),65536)),o=nn(l);if(o)return !0}return !1},Oe={},sn=()=>Ue||"./this.program",ue=()=>{if(!ue.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:sn()};for(var t in Oe)Oe[t]===void 0?delete r[t]:r[t]=Oe[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);ue.strings=n;}return ue.strings},on=(e,r)=>{for(var t=0;t<e.length;++t)q[r++>>0]=e.charCodeAt(t);q[r>>0]=0;},ln=(e,r)=>{var t=0;return ue().forEach((n,i)=>{var s=r+t;T[e+i*4>>2]=s,on(n,s),t+=n.length+1;}),0},un=(e,r)=>{var t=ue();T[e>>2]=t.length;var n=0;return t.forEach(i=>n+=i.length+1),T[r>>2]=n,0},fn=e=>52,cn=(e,r,t,n)=>52;function vn(e,r,t,n,i){return 70}var pn=[null,[],[]],hn=(e,r)=>{var t=pn[e];r===0||r===10?((e===1?Or:G)(Xe(t,0)),t.length=0):t.push(r);},mn=(e,r,t,n)=>{for(var i=0,s=0;s<t;s++){var l=T[r>>2],o=T[r+4>>2];r+=8;for(var f=0;f<o;f++)hn(e,E[l+f]);i+=o;}return T[n>>2]=i,0},we=e=>e%4===0&&(e%100!==0||e%400===0),_n=(e,r)=>{for(var t=0,n=0;n<=r;t+=e[n++]);return t},_r=[31,29,31,30,31,30,31,31,30,31,30,31],gr=[31,28,31,30,31,30,31,31,30,31,30,31],gn=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var n=we(t.getFullYear()),i=t.getMonth(),s=(n?_r:gr)[i];if(r>s-t.getDate())r-=s-t.getDate()+1,t.setDate(1),i<11?t.setMonth(i+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t};function yn(e,r,t){var n=t>0?t:hr(e)+1,i=new Array(n),s=pr(e,i,0,i.length);return r&&(i.length=s),i}var bn=(e,r)=>{q.set(e,r);},wn=(e,r,t,n)=>{var i=T[n+40>>2],s={tm_sec:P[n>>2],tm_min:P[n+4>>2],tm_hour:P[n+8>>2],tm_mday:P[n+12>>2],tm_mon:P[n+16>>2],tm_year:P[n+20>>2],tm_wday:P[n+24>>2],tm_yday:P[n+28>>2],tm_isdst:P[n+32>>2],tm_gmtoff:P[n+36>>2],tm_zone:i?x(i):""},l=x(t),o={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var f in o)l=l.replace(new RegExp(f,"g"),o[f]);var c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p=["January","February","March","April","May","June","July","August","September","October","November","December"];function h(u,d,b){for(var C=typeof u=="number"?u.toString():u||"";C.length<d;)C=b[0]+C;return C}function _(u,d){return h(u,d,"0")}function g(u,d){function b(V){return V<0?-1:V>0?1:0}var C;return (C=b(u.getFullYear()-d.getFullYear()))===0&&(C=b(u.getMonth()-d.getMonth()))===0&&(C=b(u.getDate()-d.getDate())),C}function w(u){switch(u.getDay()){case 0:return new Date(u.getFullYear()-1,11,29);case 1:return u;case 2:return new Date(u.getFullYear(),0,3);case 3:return new Date(u.getFullYear(),0,2);case 4:return new Date(u.getFullYear(),0,1);case 5:return new Date(u.getFullYear()-1,11,31);case 6:return new Date(u.getFullYear()-1,11,30)}}function F(u){var d=gn(new Date(u.tm_year+1900,0,1),u.tm_yday),b=new Date(d.getFullYear(),0,4),C=new Date(d.getFullYear()+1,0,4),V=w(b),Ce=w(C);return g(V,d)<=0?g(Ce,d)<=0?d.getFullYear()+1:d.getFullYear():d.getFullYear()-1}var $={"%a":u=>c[u.tm_wday].substring(0,3),"%A":u=>c[u.tm_wday],"%b":u=>p[u.tm_mon].substring(0,3),"%B":u=>p[u.tm_mon],"%C":u=>{var d=u.tm_year+1900;return _(d/100|0,2)},"%d":u=>_(u.tm_mday,2),"%e":u=>h(u.tm_mday,2," "),"%g":u=>F(u).toString().substring(2),"%G":u=>F(u),"%H":u=>_(u.tm_hour,2),"%I":u=>{var d=u.tm_hour;return d==0?d=12:d>12&&(d-=12),_(d,2)},"%j":u=>_(u.tm_mday+_n(we(u.tm_year+1900)?_r:gr,u.tm_mon-1),3),"%m":u=>_(u.tm_mon+1,2),"%M":u=>_(u.tm_min,2),"%n":()=>`
7
- `,"%p":u=>u.tm_hour>=0&&u.tm_hour<12?"AM":"PM","%S":u=>_(u.tm_sec,2),"%t":()=>" ","%u":u=>u.tm_wday||7,"%U":u=>{var d=u.tm_yday+7-u.tm_wday;return _(Math.floor(d/7),2)},"%V":u=>{var d=Math.floor((u.tm_yday+7-(u.tm_wday+6)%7)/7);if((u.tm_wday+371-u.tm_yday-2)%7<=2&&d++,d){if(d==53){var C=(u.tm_wday+371-u.tm_yday)%7;C!=4&&(C!=3||!we(u.tm_year))&&(d=1);}}else {d=52;var b=(u.tm_wday+7-u.tm_yday-1)%7;(b==4||b==5&&we(u.tm_year%400-1))&&d++;}return _(d,2)},"%w":u=>u.tm_wday,"%W":u=>{var d=u.tm_yday+7-(u.tm_wday+6)%7;return _(Math.floor(d/7),2)},"%y":u=>(u.tm_year+1900).toString().substring(2),"%Y":u=>u.tm_year+1900,"%z":u=>{var d=u.tm_gmtoff,b=d>=0;return d=Math.abs(d)/60,d=d/60*100+d%60,(b?"+":"-")+("0000"+d).slice(-4)},"%Z":u=>u.tm_zone,"%%":()=>"%"};l=l.replace(/%%/g,"\0\0");for(var f in $)l.includes(f)&&(l=l.replace(new RegExp(f,"g"),$[f](s)));l=l.replace(/\0\0/g,"%");var O=yn(l,!1);return O.length>r?0:(bn(O,e),O.length-1)},$n=(e,r,t,n,i)=>wn(e,r,t,n);et(),Z=a.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Ke=a.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},dt(),lt(),bt(),or=a.UnboundTypeError=Pt(Error,"UnboundTypeError"),Dt(),Ot();var Cn={b:Xr,n:Jr,G:Kr,H:Zr,w:Qr,q:tt,K:At,J:Ft,e:St,I:kt,o:Ut,f:jt,d:Lt,p:Yt,k:qt,r:Xt,y:Jt,s:dr,t:Kt,g:Qt,j:en,D:rn,C:an,A:ln,B:un,m:fn,F:cn,v:vn,E:mn,i:Un,h:In,l:jn,a:kn,c:Wn,x:Ln,u:Hn,z:$n},y=qr(),W=e=>(W=y.N)(e),ke=e=>(ke=y.O)(e),yr=e=>(yr=y.P)(e);a.__embind_initialize_bindings=()=>(a.__embind_initialize_bindings=y.Q)();var j=(e,r)=>(j=y.S)(e,r),L=()=>(L=y.T)(),H=e=>(H=y.U)(e),br=a.dynCall_viiij=(e,r,t,n,i,s)=>(br=a.dynCall_viiij=y.V)(e,r,t,n,i,s);a.dynCall_jiji=(e,r,t,n,i)=>(a.dynCall_jiji=y.W)(e,r,t,n,i);a.dynCall_viijii=(e,r,t,n,i,s,l)=>(a.dynCall_viijii=y.X)(e,r,t,n,i,s,l);a.dynCall_iiiiij=(e,r,t,n,i,s,l)=>(a.dynCall_iiiiij=y.Y)(e,r,t,n,i,s,l);a.dynCall_iiiiijj=(e,r,t,n,i,s,l,o,f)=>(a.dynCall_iiiiijj=y.Z)(e,r,t,n,i,s,l,o,f);a.dynCall_iiiiiijj=(e,r,t,n,i,s,l,o,f,c)=>(a.dynCall_iiiiiijj=y._)(e,r,t,n,i,s,l,o,f,c);function kn(e,r){var t=L();try{I(e)(r);}catch(n){if(H(t),n!==n+0)throw n;j(1,0);}}function Wn(e,r,t){var n=L();try{I(e)(r,t);}catch(i){if(H(n),i!==i+0)throw i;j(1,0);}}function Un(e,r){var t=L();try{return I(e)(r)}catch(n){if(H(t),n!==n+0)throw n;j(1,0);}}function In(e,r,t,n){var i=L();try{return I(e)(r,t,n)}catch(s){if(H(i),s!==s+0)throw s;j(1,0);}}function jn(e,r,t,n,i,s){var l=L();try{return I(e)(r,t,n,i,s)}catch(o){if(H(l),o!==o+0)throw o;j(1,0);}}function Ln(e,r,t,n,i){var s=L();try{I(e)(r,t,n,i);}catch(l){if(H(s),l!==l+0)throw l;j(1,0);}}function Hn(e,r,t,n,i,s){var l=L();try{br(e,r,t,n,i,s);}catch(o){if(H(l),o!==o+0)throw o;j(1,0);}}var $e;te=function e(){$e||wr(),$e||(te=e);};function wr(){if(Y>0||(Ir(),Y>0))return;function e(){$e||($e=!0,a.calledRun=!0,!je&&(jr(),D(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),Lr()));}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("");},1),e();},1)):e();}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return wr(),v.ready}})(),Pr=xn;var B=class{constructor(){throw new Error("WasmLoader is a static class and cannot be instantiated.")}static async _tryLoad(v){try{return (await Pr({locateFile:()=>v})).Renderer}catch(a){throw console.warn(`Attempt to load WASM from ${v} failed. Error: ${a.message}`),a}}static async _loadWithBackup(){try{return await this._tryLoad(this._wasmURL)}catch(v){let a=`https://cdn.jsdelivr.net/npm/${fe.name}@${fe.version}/dist/renderer.wasm`;console.warn(`Trying backup URL for WASM loading: ${a}`);try{return await this._tryLoad(a)}catch(D){throw console.error(`Both primary and backup WASM URLs failed. Primary error: ${v.message}, Backup error: ${D.message}`),new Error("WASM loading failed from all sources.")}}}static async getInstance(){if(!this._Renderer)try{this._Renderer=await this._loadWithBackup();}catch(v){throw new Error(`WASM Renderer instantiation failed: ${v.message}`)}return new this._Renderer}static setWasmUrl(v){this._wasmURL=v;}};a(B,"_Renderer",null),a(B,"_wasmURL",`https://unpkg.com/${fe.name}@${fe.version}/dist/renderer.wasm`);var Ar=1e3,Er=class{constructor(v){a(this,"_canvas");a(this,"_context");a(this,"_eventManager",new a$1);a(this,"_renderer",null);a(this,"_playing",!1);a(this,"_beginTime",0);a(this,"_totalFrames",0);a(this,"_loop",!1);a(this,"_speed",1);a(this,"_currentFrame",0);a(this,"_duration",0);a(this,"_loopCount",0);a(this,"_autoplay",!1);this._animationLoop=this._animationLoop.bind(this),this._canvas=v.canvas,this._context=this._canvas.getContext("2d"),this._loop=v.loop??!1,this._speed=v.speed??1,this._autoplay=v.autoplay??!1,B.getInstance().then(a=>{this._renderer=a,v.src?this._loadAnimationFromURL(v.src):v.data&&this._initializeAnimationFromData(v.data);}).catch(a=>{this._eventManager.dispatch({type:"loadError",error:a});});}get currentFrame(){return this._currentFrame}get duration(){return this._duration}get totalFrames(){return this._totalFrames}get loop(){return this._loop}get speed(){return this._speed}get loopCount(){return this._loopCount}get playing(){return this._playing}_loadAnimationFromURL(v){b(v).then(a=>{this._initializeAnimationFromData(a);}).catch(a=>{this._eventManager.dispatch({type:"loadError",error:a});});}_initializeAnimationFromData(v){let a=D=>{try{this._renderer?.load(D,this._canvas.width,this._canvas.height)?(this._setupAnimationDetails(),this._eventManager.dispatch({type:"load"}),this._autoplay&&this.play()):this._eventManager.dispatch({type:"loadError",error:new Error("Error encountered while initializing animation from data.")});}catch(N){this._eventManager.dispatch({type:"loadError",error:N});}};typeof v=="string"?a(v):v instanceof ArrayBuffer&&a$2(v).then(a).catch(D=>{this._eventManager.dispatch({type:"loadError",error:D});});}_setupAnimationDetails(){this._renderer&&(this._totalFrames=this._renderer.totalFrames(),this._duration=this._renderer.duration());}_render(){if(this._context&&(this._renderer?.resize(this._canvas.width,this._canvas.height),this._renderer?.update())){let v=this._renderer.render(),a=Uint8ClampedArray.from(v);if(a.length===0)return;let D=new ImageData(a,this._canvas.width,this._canvas.height);this._context.putImageData(D,0,0);}}_update(){return this._playing?(this._currentFrame=(performance.now()/Ar-this._beginTime)*this._speed/this._duration*this._totalFrames,this._currentFrame>=this._totalFrames?this._loop?(this._currentFrame=0,this._beginTime=performance.now()/Ar,this._loopCount+=1,this._eventManager.dispatch({type:"loop",loopCount:this._loopCount}),!0):(this._playing=!1,this._eventManager.dispatch({type:"complete"}),!1):(this._currentFrame=Math.max(0,Math.min(this._currentFrame,this._totalFrames-1)),this._renderer?.frame(this._currentFrame)?(this._eventManager.dispatch({type:"frame",currentFrame:this._currentFrame}),!0):!1)):!1}_animationLoop(){this._update()&&(this._render(),window.requestAnimationFrame(this._animationLoop));}play(){if(this._totalFrames===0){this._eventManager.dispatch({type:"loadError",error:new Error("Unable to play animation.")});return}let v=this._currentFrame/this._totalFrames;this._beginTime=performance.now()/1e3-v*this._duration,this._playing||(this._playing=!0,this._animationLoop(),this._eventManager.dispatch({type:"play"}));}stop(){!this._playing&&this._currentFrame===0||(this._playing=!1,this.setFrame(0),this._eventManager.dispatch({type:"stop"}));}pause(){this._playing&&(this._playing=!1,this._eventManager.dispatch({type:"pause"}));}setSpeed(v){this._speed=v;}setLoop(v){this._loop=v;}setFrame(v){if(v<0||v>=this._totalFrames){console.error(`Invalid frame number provided: ${v}. Valid range is between 0 and ${this._totalFrames-1}.`);return}this._currentFrame=v,this._renderer?.frame(this._currentFrame),this._render(),this._eventManager.dispatch({type:"frame",currentFrame:this._currentFrame});}addEventListener(v,a){this._eventManager.addEventListener(v,a);}removeEventListener(v,a){this._eventManager.removeEventListener(v,a);}static setWasmUrl(v){B.setWasmUrl(v);}};
8
-
9
- export { B as a, Er as b };
10
- //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=chunk-NPMXPAFK.js.map