@rive-app/webgl 1.0.2

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.
Files changed (3) hide show
  1. package/package.json +30 -0
  2. package/rive.js +1765 -0
  3. package/rive.wasm +0 -0
package/rive.js ADDED
@@ -0,0 +1,1765 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["rive"] = factory();
8
+ else
9
+ root["rive"] = factory();
10
+ })(this, function() {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ([
14
+ /* 0 */,
15
+ /* 1 */
16
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
17
+
18
+ __webpack_require__.r(__webpack_exports__);
19
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
20
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
21
+ /* harmony export */ });
22
+
23
+ var Rive = (function() {
24
+ var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
25
+ if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
26
+ return (
27
+ function(Rive) {
28
+ Rive = Rive || {};
29
+
30
+
31
+ null;var g;g||(g=typeof Rive !== 'undefined' ? Rive : {});var aa,ba;g.ready=new Promise(function(a,b){aa=a;ba=b});g.onRuntimeInitialized=function(){const a=g.makeRenderer;g.makeRenderer=function(b){var c=ca(b);da=ea[c];g.xe=k=da&&da.Pd;return a(b.width,b.height)}};var fa={},r;for(r in g)g.hasOwnProperty(r)&&(fa[r]=g[r]);
32
+ var ha="./this.program",ia="object"===typeof window,ja="function"===typeof importScripts,ka="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node,v="",la,ma,na,oa,pa;
33
+ if(ka)v=ja?require("path").dirname(v)+"/":__dirname+"/",la=function(a,b){oa||(oa=require("fs"));pa||(pa=require("path"));a=pa.normalize(a);return oa.readFileSync(a,b?null:"utf8")},na=function(a){a=la(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||qa("Assertion failed: undefined");return a},ma=function(a,b,c){oa||(oa=require("fs"));pa||(pa=require("path"));a=pa.normalize(a);oa.readFile(a,function(d,e){d?c(d):b(e.buffer)})},1<process.argv.length&&(ha=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),
34
+ process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",function(a){throw a;}),g.inspect=function(){return"[Emscripten Module object]"};else if(ia||ja)ja?v=self.location.href:"undefined"!==typeof document&&document.currentScript&&(v=document.currentScript.src),_scriptDir&&(v=_scriptDir),0!==v.indexOf("blob:")?v=v.substr(0,v.replace(/[?#].*/,"").lastIndexOf("/")+1):v="",la=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},ja&&
35
+ (na=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),ma=function(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=function(){200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)};var ra=g.print||console.log.bind(console),y=g.printErr||console.warn.bind(console);for(r in fa)fa.hasOwnProperty(r)&&(g[r]=fa[r]);fa=null;g.thisProgram&&(ha=g.thisProgram);
36
+ var sa=0,ta;g.wasmBinary&&(ta=g.wasmBinary);var noExitRuntime=g.noExitRuntime||!0;"object"!==typeof WebAssembly&&qa("no native wasm support detected");var ua,va=!1,wa="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
37
+ function xa(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&wa)return wa.decode(a.subarray(b,c));for(d="";b<c;){var e=a[b++];if(e&128){var f=a[b++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|f);else{var l=a[b++]&63;e=224==(e&240)?(e&15)<<12|f<<6|l:(e&7)<<18|f<<12|l<<6|a[b++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d}function ya(a,b){return a?xa(z,a,b):""}
38
+ function za(a,b,c,d){if(!(0<d))return 0;var e=c;d=c+d-1;for(var f=0;f<a.length;++f){var l=a.charCodeAt(f);if(55296<=l&&57343>=l){var h=a.charCodeAt(++f);l=65536+((l&1023)<<10)|h&1023}if(127>=l){if(c>=d)break;b[c++]=l}else{if(2047>=l){if(c+1>=d)break;b[c++]=192|l>>6}else{if(65535>=l){if(c+2>=d)break;b[c++]=224|l>>12}else{if(c+3>=d)break;b[c++]=240|l>>18;b[c++]=128|l>>12&63}b[c++]=128|l>>6&63}b[c++]=128|l&63}}b[c]=0;return c-e}
39
+ function Aa(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}var Ba="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function Ca(a,b){var c=a>>1;for(var d=c+b/2;!(c>=d)&&Da[c];)++c;c<<=1;if(32<c-a&&Ba)return Ba.decode(z.subarray(a,c));c="";for(d=0;!(d>=b/2);++d){var e=A[a+2*d>>1];if(0==e)break;c+=String.fromCharCode(e)}return c}
40
+ function Ea(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var e=0;e<c;++e)A[b>>1]=a.charCodeAt(e),b+=2;A[b>>1]=0;return b-d}function Fa(a){return 2*a.length}function Ga(a,b){for(var c=0,d="";!(c>=b/4);){var e=B[a+4*c>>2];if(0==e)break;++c;65536<=e?(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023)):d+=String.fromCharCode(e)}return d}
41
+ function Ha(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var e=0;e<a.length;++e){var f=a.charCodeAt(e);if(55296<=f&&57343>=f){var l=a.charCodeAt(++e);f=65536+((f&1023)<<10)|l&1023}B[b>>2]=f;b+=4;if(b+4>c)break}B[b>>2]=0;return b-d}function Ja(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&++c;b+=4}return b}var Ka,C,z,A,Da,B,E,F,La;
42
+ function Ma(){var a=ua.buffer;Ka=a;g.HEAP8=C=new Int8Array(a);g.HEAP16=A=new Int16Array(a);g.HEAP32=B=new Int32Array(a);g.HEAPU8=z=new Uint8Array(a);g.HEAPU16=Da=new Uint16Array(a);g.HEAPU32=E=new Uint32Array(a);g.HEAPF32=F=new Float32Array(a);g.HEAPF64=La=new Float64Array(a)}var Na,Oa=[],Pa=[],Qa=[];function Ra(){var a=g.preRun.shift();Oa.unshift(a)}var Sa=0,Ta=null,Ua=null;g.preloadedImages={};g.preloadedAudios={};
43
+ function qa(a){if(g.onAbort)g.onAbort(a);a="Aborted("+a+")";y(a);va=!0;a=new WebAssembly.RuntimeError(a+". Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Va(){return G.startsWith("data:application/octet-stream;base64,")}var G;G="webgl_advanced.wasm";if(!Va()){var Wa=G;G=g.locateFile?g.locateFile(Wa,v):v+Wa}function Xa(){var a=G;try{if(a==G&&ta)return new Uint8Array(ta);if(na)return na(a);throw"both async and sync fetching of the wasm failed";}catch(b){qa(b)}}
44
+ function Ya(){if(!ta&&(ia||ja)){if("function"===typeof fetch&&!G.startsWith("file://"))return fetch(G,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+G+"'";return a.arrayBuffer()}).catch(function(){return Xa()});if(ma)return new Promise(function(a,b){ma(G,function(c){a(new Uint8Array(c))},b)})}return Promise.resolve().then(function(){return Xa()})}
45
+ function Za(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(g);else{var c=b.ye;"number"===typeof c?void 0===b.Jd?H(c)():H(c)(b.Jd):c(void 0===b.Jd?null:b.Jd)}}}function H(a){return Na.get(a)}var $a={};function ab(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function bb(a){return this.fromWireType(E[a>>2])}var cb={},db={},eb={};function fb(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
46
+ function gb(a,b){a=fb(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function hb(a){var b=Error,c=gb(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
47
+ var ib=void 0;function jb(a){throw new ib(a);}function I(a,b,c){function d(h){h=c(h);h.length!==a.length&&jb("Mismatched type converter count");for(var n=0;n<a.length;++n)J(a[n],h[n])}a.forEach(function(h){eb[h]=b});var e=Array(b.length),f=[],l=0;b.forEach(function(h,n){db.hasOwnProperty(h)?e[n]=db[h]:(f.push(h),cb.hasOwnProperty(h)||(cb[h]=[]),cb[h].push(function(){e[n]=db[h];++l;l===f.length&&d(e)}))});0===f.length&&d(e)}
48
+ function kb(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var lb=void 0;function K(a){for(var b="";z[a];)b+=lb[z[a++]];return b}var mb=void 0;function L(a){throw new mb(a);}
49
+ function J(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||L('type "'+d+'" must have a positive integer typeid pointer');if(db.hasOwnProperty(a)){if(c.ie)return;L("Cannot register type '"+d+"' twice")}db[a]=b;delete eb[a];cb.hasOwnProperty(a)&&(b=cb[a],delete cb[a],b.forEach(function(e){e()}))}function nb(a){L(a.ed.jd.gd.name+" instance already deleted")}var ob=!1;function pb(){}
50
+ function qb(a){--a.count.value;0===a.count.value&&(a.md?a.od.qd(a.md):a.jd.gd.qd(a.hd))}function rb(a){if("undefined"===typeof FinalizationGroup)return rb=function(b){return b},a;ob=new FinalizationGroup(function(b){for(var c=b.next();!c.done;c=b.next())c=c.value,c.hd?qb(c):console.warn("object already deleted: "+c.hd)});rb=function(b){ob.register(b,b.ed,b.ed);return b};pb=function(b){ob.unregister(b.ed)};return rb(a)}var sb=void 0,tb=[];
51
+ function ub(){for(;tb.length;){var a=tb.pop();a.ed.ud=!1;a["delete"]()}}function M(){}var vb={};function wb(a,b,c){if(void 0===a[b].kd){var d=a[b];a[b]=function(){a[b].kd.hasOwnProperty(arguments.length)||L("Function '"+c+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+a[b].kd+")!");return a[b].kd[arguments.length].apply(this,arguments)};a[b].kd=[];a[b].kd[d.Ad]=d}}
52
+ function xb(a,b,c){g.hasOwnProperty(a)?((void 0===c||void 0!==g[a].kd&&void 0!==g[a].kd[c])&&L("Cannot register public name '"+a+"' twice"),wb(g,a,a),g.hasOwnProperty(c)&&L("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),g[a].kd[c]=b):(g[a]=b,void 0!==c&&(g[a].Ce=c))}function yb(a,b,c,d,e,f,l,h){this.name=a;this.constructor=b;this.rd=c;this.qd=d;this.pd=e;this.de=f;this.zd=l;this.ae=h;this.me=[]}
53
+ function zb(a,b,c){for(;b!==c;)b.zd||L("Expected null or instance of "+c.name+", got an instance of "+b.name),a=b.zd(a),b=b.pd;return a}function Ab(a,b){if(null===b)return this.Ld&&L("null is not a valid "+this.name),0;b.ed||L('Cannot pass "'+Bb(b)+'" as a '+this.name);b.ed.hd||L("Cannot pass deleted object as a pointer of type "+this.name);return zb(b.ed.hd,b.ed.jd.gd,this.gd)}
54
+ function Cb(a,b){if(null===b){this.Ld&&L("null is not a valid "+this.name);if(this.Cd){var c=this.Md();null!==a&&a.push(this.qd,c);return c}return 0}b.ed||L('Cannot pass "'+Bb(b)+'" as a '+this.name);b.ed.hd||L("Cannot pass deleted object as a pointer of type "+this.name);!this.Bd&&b.ed.jd.Bd&&L("Cannot convert argument of type "+(b.ed.od?b.ed.od.name:b.ed.jd.name)+" to parameter type "+this.name);c=zb(b.ed.hd,b.ed.jd.gd,this.gd);if(this.Cd)switch(void 0===b.ed.md&&L("Passing raw pointer to smart pointer is illegal"),
55
+ this.re){case 0:b.ed.od===this?c=b.ed.md:L("Cannot convert argument of type "+(b.ed.od?b.ed.od.name:b.ed.jd.name)+" to parameter type "+this.name);break;case 1:c=b.ed.md;break;case 2:if(b.ed.od===this)c=b.ed.md;else{var d=b.clone();c=this.ne(c,Db(function(){d["delete"]()}));null!==a&&a.push(this.qd,c)}break;default:L("Unsupporting sharing policy")}return c}
56
+ function Eb(a,b){if(null===b)return this.Ld&&L("null is not a valid "+this.name),0;b.ed||L('Cannot pass "'+Bb(b)+'" as a '+this.name);b.ed.hd||L("Cannot pass deleted object as a pointer of type "+this.name);b.ed.jd.Bd&&L("Cannot convert argument of type "+b.ed.jd.name+" to parameter type "+this.name);return zb(b.ed.hd,b.ed.jd.gd,this.gd)}function Fb(a,b,c){if(b===c)return a;if(void 0===c.pd)return null;a=Fb(a,b,c.pd);return null===a?null:c.ae(a)}var Gb={};
57
+ function Hb(a,b){for(void 0===b&&L("ptr should not be undefined");a.pd;)b=a.zd(b),a=a.pd;return Gb[b]}function Ib(a,b){b.jd&&b.hd||jb("makeClassHandle requires ptr and ptrType");!!b.od!==!!b.md&&jb("Both smartPtrType and smartPtr must be specified");b.count={value:1};return rb(Object.create(a,{ed:{value:b}}))}
58
+ function O(a,b,c,d){this.name=a;this.gd=b;this.Ld=c;this.Bd=d;this.Cd=!1;this.qd=this.ne=this.Md=this.Wd=this.re=this.le=void 0;void 0!==b.pd?this.toWireType=Cb:(this.toWireType=d?Ab:Eb,this.nd=null)}function Jb(a,b,c){g.hasOwnProperty(a)||jb("Replacing nonexistant public symbol");void 0!==g[a].kd&&void 0!==c?g[a].kd[c]=b:(g[a]=b,g[a].Ad=c)}
59
+ function Kb(a,b){var c=[];return function(){c.length=arguments.length;for(var d=0;d<arguments.length;d++)c[d]=arguments[d];a.includes("j")?(d=g["dynCall_"+a],d=c&&c.length?d.apply(null,[b].concat(c)):d.call(null,b)):d=H(b).apply(null,c);return d}}function P(a,b){a=K(a);var c=a.includes("j")?Kb(a,b):H(b);"function"!==typeof c&&L("unknown function pointer with signature "+a+": "+b);return c}var Lb=void 0;function Mb(a){a=Nb(a);var b=K(a);Q(a);return b}
60
+ function Ob(a,b){function c(f){e[f]||db[f]||(eb[f]?eb[f].forEach(c):(d.push(f),e[f]=!0))}var d=[],e={};b.forEach(c);throw new Lb(a+": "+d.map(Mb).join([", "]));}function Pb(a,b,c){a instanceof Object||L(c+' with invalid "this": '+a);a instanceof b.gd.constructor||L(c+' incompatible with "this" of type '+a.constructor.name);a.ed.hd||L("cannot call emscripten binding method "+c+" on deleted object");return zb(a.ed.hd,a.ed.jd.gd,b.gd)}
61
+ function Qb(a,b){for(var c=[],d=0;d<a;d++)c.push(B[(b>>2)+d]);return c}function Rb(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=gb(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
62
+ function Sb(a,b,c,d,e){var f=b.length;2>f&&L("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=null!==b[1]&&null!==c,h=!1;for(c=1;c<b.length;++c)if(null!==b[c]&&void 0===b[c].nd){h=!0;break}var n="void"!==b[0].name,p="",q="";for(c=0;c<f-2;++c)p+=(0!==c?", ":"")+"arg"+c,q+=(0!==c?", ":"")+"arg"+c+"Wired";a="return function "+fb(a)+"("+p+") {\nif (arguments.length !== "+(f-2)+") {\nthrowBindingError('function "+a+" called with ' + arguments.length + ' arguments, expected "+
63
+ (f-2)+" args!');\n}\n";h&&(a+="var destructors = [];\n");var u=h?"destructors":"null";p="throwBindingError invoker fn runDestructors retType classParam".split(" ");d=[L,d,e,ab,b[0],b[1]];l&&(a+="var thisWired = classParam.toWireType("+u+", this);\n");for(c=0;c<f-2;++c)a+="var arg"+c+"Wired = argType"+c+".toWireType("+u+", arg"+c+"); // "+b[c+2].name+"\n",p.push("argType"+c),d.push(b[c+2]);l&&(q="thisWired"+(0<q.length?", ":"")+q);a+=(n?"var rv = ":"")+"invoker(fn"+(0<q.length?", ":"")+q+");\n";if(h)a+=
64
+ "runDestructors(destructors);\n";else for(c=l?1:2;c<b.length;++c)f=1===c?"thisWired":"arg"+(c-2)+"Wired",null!==b[c].nd&&(a+=f+"_dtor("+f+"); // "+b[c].name+"\n",p.push(f+"_dtor"),d.push(b[c].nd));n&&(a+="var ret = retType.fromWireType(rv);\nreturn ret;\n");p.push(a+"}\n");return Rb(p).apply(null,d)}var Tb=[],S=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Ub(a){4<a&&0===--S[a].Nd&&(S[a]=void 0,Tb.push(a))}
65
+ function Vb(a){a||L("Cannot use deleted val. handle = "+a);return S[a].value}function Db(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Tb.length?Tb.pop():S.length;S[b]={Nd:1,value:a};return b}}
66
+ function Wb(a,b,c){switch(b){case 0:return function(d){return this.fromWireType((c?C:z)[d])};case 1:return function(d){return this.fromWireType((c?A:Da)[d>>1])};case 2:return function(d){return this.fromWireType((c?B:E)[d>>2])};default:throw new TypeError("Unknown integer type: "+a);}}function Xb(a,b){var c=db[a];void 0===c&&L(b+" has unknown type "+Mb(a));return c}function Bb(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
67
+ function Yb(a,b){switch(b){case 2:return function(c){return this.fromWireType(F[c>>2])};case 3:return function(c){return this.fromWireType(La[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}
68
+ function Zb(a,b,c){switch(b){case 0:return c?function(d){return C[d]}:function(d){return z[d]};case 1:return c?function(d){return A[d>>1]}:function(d){return Da[d>>1]};case 2:return c?function(d){return B[d>>2]}:function(d){return E[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var $b={};function ac(a){var b=$b[a];return void 0===b?K(a):b}var bc=[];function cc(a){var b=bc.length;bc.push(a);return b}
69
+ function dc(a,b){for(var c=Array(a),d=0;d<a;++d)c[d]=Xb(B[(b>>2)+d],"parameter "+d);return c}var ec=[],fc;fc=ka?function(){var a=process.hrtime();return 1E3*a[0]+a[1]/1E6}:function(){return performance.now()};var gc=1,hc=[],T=[],ic=[],jc=[],kc=[],U=[],lc=[],ea=[],mc=[],nc=[],oc={},pc={};function V(a){rc||(rc=a)}function sc(a){for(var b=gc++,c=a.length;c<b;c++)a[c]=null;return b}
70
+ function ca(a){var b={alpha:1,depth:1,stencil:8,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,preferLowPowerToHighPerformance:0,failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:0,renderViaOffscreenBackBuffer:0};a.Ud||(a.Ud=a.getContext,a.getContext=function(d,e){e=a.Ud(d,e);return"webgl"==d==e instanceof WebGLRenderingContext?e:null});var c=a.getContext("webgl2",b);return c?tc(c,b):0}
71
+ function tc(a,b){var c=sc(ea),d={ze:c,attributes:b,version:b.Ae,Pd:a};a.canvas&&(a.canvas.we=d);ea[c]=d;("undefined"===typeof b.be||b.be)&&uc(d);return c}
72
+ function uc(a){a||(a=da);if(!a.je){a.je=!0;var b=a.Pd;b.Rd=b.getExtension("WEBGL_draw_instanced_base_vertex_base_instance");b.Vd=b.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance");2<=a.version&&(b.Sd=b.getExtension("EXT_disjoint_timer_query_webgl2"));if(2>a.version||!b.Sd)b.Sd=b.getExtension("EXT_disjoint_timer_query");b.Be=b.getExtension("WEBGL_multi_draw");(b.getSupportedExtensions()||[]).forEach(function(c){c.includes("lose_context")||c.includes("debug")||b.getExtension(c)})}}
73
+ var rc,da,vc=[];function wc(a,b,c,d){for(var e=0;e<a;e++){var f=k[c](),l=f&&sc(d);f?(f.name=l,d[l]=f):V(1282);B[b+4*e>>2]=l}}
74
+ function xc(a,b){if(b){var c=void 0;switch(a){case 36346:c=1;break;case 36344:return;case 34814:case 36345:c=0;break;case 34466:var d=k.getParameter(34467);c=d?d.length:0;break;case 33309:if(2>da.version){V(1282);return}c=2*(k.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>da.version){V(1280);return}c=33307==a?3:0}if(void 0===c)switch(d=k.getParameter(a),typeof d){case "number":c=d;break;case "boolean":c=d?1:0;break;case "string":V(1280);return;case "object":if(null===d)switch(a){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:c=
75
+ 0;break;default:V(1280);return}else{if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(a=0;a<d.length;++a)B[b+4*a>>2]=d[a];return}try{c=d.name|0}catch(e){V(1280);y("GL_INVALID_ENUM in glGet0v: Unknown object returned from WebGL getParameter("+a+")! (error: "+e+")");return}}break;default:V(1280);y("GL_INVALID_ENUM in glGet0v: Native code calling glGet0v("+a+") and it returns "+d+" of type "+typeof d+"!");return}B[b>>2]=c}else V(1281)}
76
+ function yc(a){var b=Aa(a)+1,c=zc(b);za(a,z,c,b);return c}function Ac(a){return"]"==a.slice(-1)&&a.lastIndexOf("[")}function Bc(a){a-=5120;return 0==a?C:1==a?z:2==a?A:4==a?B:6==a?F:5==a||28922==a||28520==a||30779==a||30782==a?E:Da}function W(a){var b=k.$d;if(b){var c=b.yd[a];"number"===typeof c&&(b.yd[a]=c=k.getUniformLocation(b,b.Xd[a]+(0<c?"["+c+"]":"")));return c}V(1282)}var Cc={};
77
+ function Dc(){if(!Ec){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"===typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:ha||"./this.program"},b;for(b in Cc)void 0===Cc[b]?delete a[b]:a[b]=Cc[b];var c=[];for(b in a)c.push(b+"="+a[b]);Ec=c}return Ec}var Ec,Fc=[null,[],[]];function Gc(a){return 0===a%4&&(0!==a%100||0===a%400)}function Hc(a,b){for(var c=0,d=0;d<=b;c+=a[d++]);return c}
78
+ var Ic=[31,29,31,30,31,30,31,31,30,31,30,31],Jc=[31,28,31,30,31,30,31,31,30,31,30,31];function Kc(a,b){for(a=new Date(a.getTime());0<b;){var c=a.getMonth(),d=(Gc(a.getFullYear())?Ic:Jc)[c];if(b>d-a.getDate())b-=d-a.getDate()+1,a.setDate(1),11>c?a.setMonth(c+1):(a.setMonth(0),a.setFullYear(a.getFullYear()+1));else{a.setDate(a.getDate()+b);break}}return a}
79
+ function Lc(a,b,c,d){function e(m,t,w){for(m="number"===typeof m?m.toString():m||"";m.length<t;)m=w[0]+m;return m}function f(m,t){return e(m,t,"0")}function l(m,t){function w(N){return 0>N?-1:0<N?1:0}var D;0===(D=w(m.getFullYear()-t.getFullYear()))&&0===(D=w(m.getMonth()-t.getMonth()))&&(D=w(m.getDate()-t.getDate()));return D}function h(m){switch(m.getDay()){case 0:return new Date(m.getFullYear()-1,11,29);case 1:return m;case 2:return new Date(m.getFullYear(),0,3);case 3:return new Date(m.getFullYear(),
80
+ 0,2);case 4:return new Date(m.getFullYear(),0,1);case 5:return new Date(m.getFullYear()-1,11,31);case 6:return new Date(m.getFullYear()-1,11,30)}}function n(m){m=Kc(new Date(m.ld+1900,0,1),m.Id);var t=new Date(m.getFullYear()+1,0,4),w=h(new Date(m.getFullYear(),0,4));t=h(t);return 0>=l(w,m)?0>=l(t,m)?m.getFullYear()+1:m.getFullYear():m.getFullYear()-1}var p=B[d+40>>2];d={ue:B[d>>2],te:B[d+4>>2],Gd:B[d+8>>2],xd:B[d+12>>2],vd:B[d+16>>2],ld:B[d+20>>2],Hd:B[d+24>>2],Id:B[d+28>>2],De:B[d+32>>2],se:B[d+
81
+ 36>>2],ve:p?ya(p):""};c=ya(c);p={"%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 q in p)c=c.replace(new RegExp(q,"g"),p[q]);var u="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),
82
+ x="January February March April May June July August September October November December".split(" ");p={"%a":function(m){return u[m.Hd].substring(0,3)},"%A":function(m){return u[m.Hd]},"%b":function(m){return x[m.vd].substring(0,3)},"%B":function(m){return x[m.vd]},"%C":function(m){return f((m.ld+1900)/100|0,2)},"%d":function(m){return f(m.xd,2)},"%e":function(m){return e(m.xd,2," ")},"%g":function(m){return n(m).toString().substring(2)},"%G":function(m){return n(m)},"%H":function(m){return f(m.Gd,
83
+ 2)},"%I":function(m){m=m.Gd;0==m?m=12:12<m&&(m-=12);return f(m,2)},"%j":function(m){return f(m.xd+Hc(Gc(m.ld+1900)?Ic:Jc,m.vd-1),3)},"%m":function(m){return f(m.vd+1,2)},"%M":function(m){return f(m.te,2)},"%n":function(){return"\n"},"%p":function(m){return 0<=m.Gd&&12>m.Gd?"AM":"PM"},"%S":function(m){return f(m.ue,2)},"%t":function(){return"\t"},"%u":function(m){return m.Hd||7},"%U":function(m){var t=new Date(m.ld+1900,0,1),w=0===t.getDay()?t:Kc(t,7-t.getDay());m=new Date(m.ld+1900,m.vd,m.xd);return 0>
84
+ l(w,m)?f(Math.ceil((31-w.getDate()+(Hc(Gc(m.getFullYear())?Ic:Jc,m.getMonth()-1)-31)+m.getDate())/7),2):0===l(w,t)?"01":"00"},"%V":function(m){var t=new Date(m.ld+1901,0,4),w=h(new Date(m.ld+1900,0,4));t=h(t);var D=Kc(new Date(m.ld+1900,0,1),m.Id);return 0>l(D,w)?"53":0>=l(t,D)?"01":f(Math.ceil((w.getFullYear()<m.ld+1900?m.Id+32-w.getDate():m.Id+1-w.getDate())/7),2)},"%w":function(m){return m.Hd},"%W":function(m){var t=new Date(m.ld,0,1),w=1===t.getDay()?t:Kc(t,0===t.getDay()?1:7-t.getDay()+1);m=
85
+ new Date(m.ld+1900,m.vd,m.xd);return 0>l(w,m)?f(Math.ceil((31-w.getDate()+(Hc(Gc(m.getFullYear())?Ic:Jc,m.getMonth()-1)-31)+m.getDate())/7),2):0===l(w,t)?"01":"00"},"%y":function(m){return(m.ld+1900).toString().substring(2)},"%Y":function(m){return m.ld+1900},"%z":function(m){m=m.se;var t=0<=m;m=Math.abs(m)/60;return(t?"+":"-")+String("0000"+(m/60*100+m%60)).slice(-4)},"%Z":function(m){return m.ve},"%%":function(){return"%"}};for(q in p)c.includes(q)&&(c=c.replace(new RegExp(q,"g"),p[q](d)));q=Mc(c);
86
+ if(q.length>b)return 0;C.set(q,a);return q.length-1}ib=g.InternalError=hb("InternalError");for(var Nc=Array(256),Oc=0;256>Oc;++Oc)Nc[Oc]=String.fromCharCode(Oc);lb=Nc;mb=g.BindingError=hb("BindingError");M.prototype.isAliasOf=function(a){if(!(this instanceof M&&a instanceof M))return!1;var b=this.ed.jd.gd,c=this.ed.hd,d=a.ed.jd.gd;for(a=a.ed.hd;b.pd;)c=b.zd(c),b=b.pd;for(;d.pd;)a=d.zd(a),d=d.pd;return b===d&&c===a};
87
+ M.prototype.clone=function(){this.ed.hd||nb(this);if(this.ed.wd)return this.ed.count.value+=1,this;var a=rb,b=Object,c=b.create,d=Object.getPrototypeOf(this),e=this.ed;a=a(c.call(b,d,{ed:{value:{count:e.count,ud:e.ud,wd:e.wd,hd:e.hd,jd:e.jd,md:e.md,od:e.od}}}));a.ed.count.value+=1;a.ed.ud=!1;return a};M.prototype["delete"]=function(){this.ed.hd||nb(this);this.ed.ud&&!this.ed.wd&&L("Object already scheduled for deletion");pb(this);qb(this.ed);this.ed.wd||(this.ed.md=void 0,this.ed.hd=void 0)};
88
+ M.prototype.isDeleted=function(){return!this.ed.hd};M.prototype.deleteLater=function(){this.ed.hd||nb(this);this.ed.ud&&!this.ed.wd&&L("Object already scheduled for deletion");tb.push(this);1===tb.length&&sb&&sb(ub);this.ed.ud=!0;return this};O.prototype.ee=function(a){this.Wd&&(a=this.Wd(a));return a};O.prototype.Qd=function(a){this.qd&&this.qd(a)};O.prototype.argPackAdvance=8;O.prototype.readValueFromPointer=bb;O.prototype.deleteObject=function(a){if(null!==a)a["delete"]()};
89
+ O.prototype.fromWireType=function(a){function b(){return this.Cd?Ib(this.gd.rd,{jd:this.le,hd:c,od:this,md:a}):Ib(this.gd.rd,{jd:this,hd:a})}var c=this.ee(a);if(!c)return this.Qd(a),null;var d=Hb(this.gd,c);if(void 0!==d){if(0===d.ed.count.value)return d.ed.hd=c,d.ed.md=a,d.clone();d=d.clone();this.Qd(a);return d}d=this.gd.de(c);d=vb[d];if(!d)return b.call(this);d=this.Bd?d.Zd:d.pointerType;var e=Fb(c,this.gd,d.gd);return null===e?b.call(this):this.Cd?Ib(d.gd.rd,{jd:d,hd:e,od:this,md:a}):Ib(d.gd.rd,
90
+ {jd:d,hd:e})};g.getInheritedInstanceCount=function(){return Object.keys(Gb).length};g.getLiveInheritedInstances=function(){var a=[],b;for(b in Gb)Gb.hasOwnProperty(b)&&a.push(Gb[b]);return a};g.flushPendingDeletes=ub;g.setDelayFunction=function(a){sb=a;tb.length&&sb&&sb(ub)};Lb=g.UnboundTypeError=hb("UnboundTypeError");g.count_emval_handles=function(){for(var a=0,b=5;b<S.length;++b)void 0!==S[b]&&++a;return a};g.get_first_emval=function(){for(var a=5;a<S.length;++a)if(void 0!==S[a])return S[a];return null};
91
+ for(var k,Pc=0;32>Pc;++Pc)vc.push(Array(Pc));function Mc(a){var b=Array(Aa(a)+1);za(a,b,0,b.length);return b}
92
+ var ed={cb:function(a){var b=$a[a];delete $a[a];var c=b.Md,d=b.qd,e=b.Td,f=e.map(function(l){return l.he}).concat(e.map(function(l){return l.pe}));I([a],f,function(l){var h={};e.forEach(function(n,p){var q=l[p],u=n.fe,x=n.ge,m=l[p+e.length],t=n.oe,w=n.qe;h[n.ce]={read:function(D){return q.fromWireType(u(x,D))},write:function(D,N){var R=[];t(w,D,m.toWireType(R,N));ab(R)}}});return[{name:b.name,fromWireType:function(n){var p={},q;for(q in h)p[q]=h[q].read(n);d(n);return p},toWireType:function(n,p){for(var q in h)if(!(q in
93
+ p))throw new TypeError('Missing field: "'+q+'"');var u=c();for(q in h)h[q].write(u,p[q]);null!==n&&n.push(d,u);return u},argPackAdvance:8,readValueFromPointer:bb,nd:d}]})},fb:function(){},wb:function(a,b,c,d,e){var f=kb(c);b=K(b);J(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,h){return h?d:e},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var h=C;else if(2===c)h=A;else if(4===c)h=B;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(h[l>>
94
+ f])},nd:null})},g:function(a,b,c,d,e,f,l,h,n,p,q,u,x){q=K(q);f=P(e,f);h&&(h=P(l,h));p&&(p=P(n,p));x=P(u,x);var m=fb(q);xb(m,function(){Ob("Cannot construct "+q+" due to unbound types",[d])});I([a,b,c],d?[d]:[],function(t){t=t[0];if(d){var w=t.gd;var D=w.rd}else D=M.prototype;t=gb(m,function(){if(Object.getPrototypeOf(this)!==N)throw new mb("Use 'new' to construct "+q);if(void 0===R.sd)throw new mb(q+" has no accessible constructor");var qc=R.sd[arguments.length];if(void 0===qc)throw new mb("Tried to invoke ctor of "+
95
+ q+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(R.sd).toString()+") parameters instead!");return qc.apply(this,arguments)});var N=Object.create(D,{constructor:{value:t}});t.prototype=N;var R=new yb(q,t,N,x,w,f,h,p);w=new O(q,R,!0,!1);D=new O(q+"*",R,!1,!1);var Ia=new O(q+" const*",R,!1,!0);vb[a]={pointerType:D,Zd:Ia};Jb(m,t);return[w,D,Ia]})},k:function(a,b,c,d,e,f,l,h){b=K(b);f=P(e,f);I([],[a],function(n){n=n[0];var p=n.name+"."+b,q={get:function(){Ob("Cannot access "+
96
+ p+" due to unbound types",[c])},enumerable:!0,configurable:!0};q.set=h?function(){Ob("Cannot access "+p+" due to unbound types",[c])}:function(){L(p+" is a read-only property")};Object.defineProperty(n.gd.constructor,b,q);I([],[c],function(u){u=u[0];var x={get:function(){return u.fromWireType(f(d))},enumerable:!0};h&&(h=P(l,h),x.set=function(m){var t=[];h(d,u.toWireType(t,m));ab(t)});Object.defineProperty(n.gd.constructor,b,x);return[]});return[]})},v:function(a,b,c,d,e,f){0<b||qa("Assertion failed: undefined");
97
+ var l=Qb(b,c);e=P(d,e);I([],[a],function(h){h=h[0];var n="constructor "+h.name;void 0===h.gd.sd&&(h.gd.sd=[]);if(void 0!==h.gd.sd[b-1])throw new mb("Cannot register multiple constructors with identical number of parameters ("+(b-1)+") for class '"+h.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");h.gd.sd[b-1]=function(){Ob("Cannot construct "+h.name+" due to unbound types",l)};I([],l,function(p){p.splice(1,0,null);h.gd.sd[b-1]=Sb(n,p,null,
98
+ e,f);return[]});return[]})},e:function(a,b,c,d,e,f,l,h){var n=Qb(c,d);b=K(b);f=P(e,f);I([],[a],function(p){function q(){Ob("Cannot call "+u+" due to unbound types",n)}p=p[0];var u=p.name+"."+b;b.startsWith("@@")&&(b=Symbol[b.substring(2)]);h&&p.gd.me.push(b);var x=p.gd.rd,m=x[b];void 0===m||void 0===m.kd&&m.className!==p.name&&m.Ad===c-2?(q.Ad=c-2,q.className=p.name,x[b]=q):(wb(x,b,u),x[b].kd[c-2]=q);I([],n,function(t){t=Sb(u,t,p,f,l);void 0===x[b].kd?(t.Ad=c-2,x[b]=t):x[b].kd[c-2]=t;return[]});return[]})},
99
+ f:function(a,b,c,d,e,f,l,h,n,p){b=K(b);e=P(d,e);I([],[a],function(q){q=q[0];var u=q.name+"."+b,x={get:function(){Ob("Cannot access "+u+" due to unbound types",[c,l])},enumerable:!0,configurable:!0};x.set=n?function(){Ob("Cannot access "+u+" due to unbound types",[c,l])}:function(){L(u+" is a read-only property")};Object.defineProperty(q.gd.rd,b,x);I([],n?[c,l]:[c],function(m){var t=m[0],w={get:function(){var N=Pb(this,q,u+" getter");return t.fromWireType(e(f,N))},enumerable:!0};if(n){n=P(h,n);var D=
100
+ m[1];w.set=function(N){var R=Pb(this,q,u+" setter"),Ia=[];n(p,R,D.toWireType(Ia,N));ab(Ia)}}Object.defineProperty(q.gd.rd,b,w);return[]});return[]})},vb:function(a,b){b=K(b);J(a,{name:b,fromWireType:function(c){var d=Vb(c);Ub(c);return d},toWireType:function(c,d){return Db(d)},argPackAdvance:8,readValueFromPointer:bb,nd:null})},sb:function(a,b,c,d){function e(){}c=kb(c);b=K(b);e.values={};J(a,{name:b,constructor:e,fromWireType:function(f){return this.constructor.values[f]},toWireType:function(f,l){return l.value},
101
+ argPackAdvance:8,readValueFromPointer:Wb(b,c,d),nd:null});xb(b,e)},mb:function(a,b,c){var d=Xb(a,"enum");b=K(b);a=d.constructor;d=Object.create(d.constructor.prototype,{value:{value:c},constructor:{value:gb(d.name+"_"+b,function(){})}});a.values[c]=d;a[b]=d},w:function(a,b,c){c=kb(c);b=K(b);J(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,e){return e},argPackAdvance:8,readValueFromPointer:Yb(b,c),nd:null})},y:function(a,b,c,d,e,f){var l=Qb(b,c);a=K(a);e=P(d,e);xb(a,function(){Ob("Cannot call "+
102
+ a+" due to unbound types",l)},b-1);I([],l,function(h){h=[h[0],null].concat(h.slice(1));Jb(a,Sb(a,h,null,e,f),b-1);return[]})},m:function(a,b,c,d,e){function f(p){return p}b=K(b);-1===e&&(e=4294967295);var l=kb(c);if(0===d){var h=32-8*c;f=function(p){return p<<h>>>h}}var n=b.includes("unsigned");J(a,{name:b,fromWireType:f,toWireType:function(p,q){if("number"!==typeof q&&"boolean"!==typeof q)throw new TypeError('Cannot convert "'+Bb(q)+'" to '+this.name);if(q<d||q>e)throw new TypeError('Passing a number "'+
103
+ Bb(q)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+e+"]!");return n?q>>>0:q|0},argPackAdvance:8,readValueFromPointer:Zb(b,l,0!==d),nd:null})},l:function(a,b,c){function d(f){f>>=2;var l=E;return new e(Ka,l[f+1],l[f])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=K(c);J(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{ie:!0})},x:function(a,b){b=K(b);var c="std::string"===
104
+ b;J(a,{name:b,fromWireType:function(d){var e=E[d>>2];if(c)for(var f=d+4,l=0;l<=e;++l){var h=d+4+l;if(l==e||0==z[h]){f=ya(f,h-f);if(void 0===n)var n=f;else n+=String.fromCharCode(0),n+=f;f=h+1}}else{n=Array(e);for(l=0;l<e;++l)n[l]=String.fromCharCode(z[d+4+l]);n=n.join("")}Q(d);return n},toWireType:function(d,e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));var f="string"===typeof e;f||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||L("Cannot pass non-string to std::string");
105
+ var l=(c&&f?function(){return Aa(e)}:function(){return e.length})(),h=zc(4+l+1);E[h>>2]=l;if(c&&f)za(e,z,h+4,l+1);else if(f)for(f=0;f<l;++f){var n=e.charCodeAt(f);255<n&&(Q(h),L("String has UTF-16 code units that do not fit in 8 bits"));z[h+4+f]=n}else for(f=0;f<l;++f)z[h+4+f]=e[f];null!==d&&d.push(Q,h);return h},argPackAdvance:8,readValueFromPointer:bb,nd:function(d){Q(d)}})},u:function(a,b,c){c=K(c);if(2===b){var d=Ca;var e=Ea;var f=Fa;var l=function(){return Da};var h=1}else 4===b&&(d=Ga,e=Ha,
106
+ f=Ja,l=function(){return E},h=2);J(a,{name:c,fromWireType:function(n){for(var p=E[n>>2],q=l(),u,x=n+4,m=0;m<=p;++m){var t=n+4+m*b;if(m==p||0==q[t>>h])x=d(x,t-x),void 0===u?u=x:(u+=String.fromCharCode(0),u+=x),x=t+b}Q(n);return u},toWireType:function(n,p){"string"!==typeof p&&L("Cannot pass non-string to C++ string type "+c);var q=f(p),u=zc(4+q+b);E[u>>2]=q>>h;e(p,u+4,q+b);null!==n&&n.push(Q,u);return u},argPackAdvance:8,readValueFromPointer:bb,nd:function(n){Q(n)}})},ib:function(a,b,c,d,e,f){$a[a]=
107
+ {name:K(b),Md:P(c,d),qd:P(e,f),Td:[]}},bb:function(a,b,c,d,e,f,l,h,n,p){$a[a].Td.push({ce:K(b),he:c,fe:P(d,e),ge:f,pe:l,oe:P(h,n),qe:p})},xb:function(a,b){b=K(b);J(a,{ke:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},nb:function(){throw"longjmp";},oa:function(a,b,c){a=Vb(a);b=Xb(b,"emval::as");var d=[],e=Db(d);B[c>>2]=e;return b.toWireType(d,a)},U:function(a,b,c,d){a=bc[a];b=Vb(b);c=ac(c);a(b,c,null,d)},Fc:Ub,J:function(a,b){var c=dc(a,b),d=c[0];b=d.name+"_$"+c.slice(1).map(function(q){return q.name}).join("_")+
108
+ "$";var e=ec[b];if(void 0!==e)return e;e=["retType"];for(var f=[d],l="",h=0;h<a-1;++h)l+=(0!==h?", ":"")+"arg"+h,e.push("argType"+h),f.push(c[1+h]);var n="return function "+fb("methodCaller_"+b)+"(handle, name, destructors, args) {\n",p=0;for(h=0;h<a-1;++h)n+=" var arg"+h+" = argType"+h+".readValueFromPointer(args"+(p?"+"+p:"")+");\n",p+=c[h+1].argPackAdvance;n+=" var rv = handle[name]("+l+");\n";for(h=0;h<a-1;++h)c[h+1].deleteObject&&(n+=" argType"+h+".deleteObject(arg"+h+");\n");d.ke||
109
+ (n+=" return retType.toWireType(destructors, rv);\n");e.push(n+"};\n");a=Rb(e).apply(null,f);e=cc(a);return ec[b]=e},Ka:function(a,b){a=Vb(a);b=Vb(b);return Db(a[b])},Ec:function(a){4<a&&(S[a].Nd+=1)},za:function(a){return Db(ac(a))},da:function(a){var b=Vb(a);ab(b);Ub(a)},Va:function(a,b){a=Xb(a,"_emval_take_value");a=a.readValueFromPointer(b);return Db(a)},a:function(){qa("")},ob:function(a,b){if(0===a)a=Date.now();else if(1===a||4===a)a=fc();else return B[Qc()>>2]=28,-1;B[b>>2]=a/1E3|0;B[b+
110
+ 4>>2]=a%1E3*1E6|0;return 0},Ya:function(a){k.activeTexture(a)},Xa:function(a,b){k.attachShader(T[a],U[b])},Wa:function(a,b,c){k.bindAttribLocation(T[a],b,ya(c))},Ua:function(a,b){35051==a?k.Kd=b:35052==a&&(k.td=b);k.bindBuffer(a,hc[b])},Xb:function(a,b){k.bindFramebuffer(a,ic[b])},Wb:function(a,b){k.bindRenderbuffer(a,jc[b])},Fb:function(a,b){k.bindSampler(a,mc[b])},Ta:function(a,b){k.bindTexture(a,kc[b])},nc:function(a){k.bindVertexArray(lc[a])},kc:function(a){k.bindVertexArray(lc[a])},Sa:function(a,
111
+ b,c,d){k.blendColor(a,b,c,d)},Ra:function(a){k.blendEquation(a)},Qa:function(a,b){k.blendFunc(a,b)},Kb:function(a,b,c,d,e,f,l,h,n,p){k.blitFramebuffer(a,b,c,d,e,f,l,h,n,p)},Pa:function(a,b,c,d){c?k.bufferData(a,z,d,c,b):k.bufferData(a,b,d)},Oa:function(a,b,c,d){k.bufferSubData(a,b,z,d,c)},Vb:function(a){return k.checkFramebufferStatus(a)},Na:function(a){k.clear(a)},Ma:function(a,b,c,d){k.clearColor(a,b,c,d)},La:function(a){k.clearStencil(a)},$a:function(a,b,c,d){return k.clientWaitSync(nc[a],b,(c>>>
112
+ 0)+4294967296*d)},Ja:function(a,b,c,d){k.colorMask(!!a,!!b,!!c,!!d)},Ia:function(a){k.compileShader(U[a])},Ha:function(a,b,c,d,e,f,l,h){k.td?k.compressedTexImage2D(a,b,c,d,e,f,l,h):k.compressedTexImage2D(a,b,c,d,e,f,z,h,l)},Ga:function(a,b,c,d,e,f,l,h,n){k.td?k.compressedTexSubImage2D(a,b,c,d,e,f,l,h,n):k.compressedTexSubImage2D(a,b,c,d,e,f,l,z,n,h)},Fa:function(a,b,c,d,e,f,l,h){k.copyTexSubImage2D(a,b,c,d,e,f,l,h)},Ea:function(){var a=sc(T),b=k.createProgram();b.name=a;b.Fd=b.Dd=b.Ed=0;b.Od=1;T[a]=
113
+ b;return a},Da:function(a){var b=sc(U);U[b]=k.createShader(a);return b},Ca:function(a){k.cullFace(a)},Ba:function(a,b){for(var c=0;c<a;c++){var d=B[b+4*c>>2],e=hc[d];e&&(k.deleteBuffer(e),e.name=0,hc[d]=null,d==k.Kd&&(k.Kd=0),d==k.td&&(k.td=0))}},Ub:function(a,b){for(var c=0;c<a;++c){var d=B[b+4*c>>2],e=ic[d];e&&(k.deleteFramebuffer(e),e.name=0,ic[d]=null)}},Aa:function(a){if(a){var b=T[a];b?(k.deleteProgram(b),b.name=0,T[a]=null):V(1281)}},Tb:function(a,b){for(var c=0;c<a;c++){var d=B[b+4*c>>2],
114
+ e=jc[d];e&&(k.deleteRenderbuffer(e),e.name=0,jc[d]=null)}},Eb:function(a,b){for(var c=0;c<a;c++){var d=B[b+4*c>>2],e=mc[d];e&&(k.deleteSampler(e),e.name=0,mc[d]=null)}},ya:function(a){if(a){var b=U[a];b?(k.deleteShader(b),U[a]=null):V(1281)}},Ib:function(a){if(a){var b=nc[a];b?(k.deleteSync(b),b.name=0,nc[a]=null):V(1281)}},xa:function(a,b){for(var c=0;c<a;c++){var d=B[b+4*c>>2],e=kc[d];e&&(k.deleteTexture(e),e.name=0,kc[d]=null)}},mc:function(a,b){for(var c=0;c<a;c++){var d=B[b+4*c>>2];k.deleteVertexArray(lc[d]);
115
+ lc[d]=null}},jc:function(a,b){for(var c=0;c<a;c++){var d=B[b+4*c>>2];k.deleteVertexArray(lc[d]);lc[d]=null}},wa:function(a){k.depthMask(!!a)},va:function(a){k.disable(a)},ua:function(a){k.disableVertexAttribArray(a)},ta:function(a,b,c){k.drawArrays(a,b,c)},hc:function(a,b,c,d){k.drawArraysInstanced(a,b,c,d)},fc:function(a,b,c,d,e){k.Rd.drawArraysInstancedBaseInstanceWEBGL(a,b,c,d,e)},dc:function(a,b){for(var c=vc[a],d=0;d<a;d++)c[d]=B[b+4*d>>2];k.drawBuffers(c)},sa:function(a,b,c,d){k.drawElements(a,
116
+ b,c,d)},gc:function(a,b,c,d,e){k.drawElementsInstanced(a,b,c,d,e)},ec:function(a,b,c,d,e,f,l){k.Rd.drawElementsInstancedBaseVertexBaseInstanceWEBGL(a,b,c,d,e,f,l)},$b:function(a,b,c,d,e,f){k.drawElements(a,d,e,f)},ra:function(a){k.enable(a)},qa:function(a){k.enableVertexAttribArray(a)},Hb:function(a,b){return(a=k.fenceSync(a,b))?(b=sc(nc),a.name=b,nc[b]=a,b):0},pa:function(){k.finish()},na:function(){k.flush()},Sb:function(a,b,c,d){k.framebufferRenderbuffer(a,b,c,jc[d])},Rb:function(a,b,c,d,e){k.framebufferTexture2D(a,
117
+ b,c,kc[d],e)},ma:function(a){k.frontFace(a)},la:function(a,b){wc(a,b,"createBuffer",hc)},Qb:function(a,b){wc(a,b,"createFramebuffer",ic)},Pb:function(a,b){wc(a,b,"createRenderbuffer",jc)},Db:function(a,b){wc(a,b,"createSampler",mc)},ka:function(a,b){wc(a,b,"createTexture",kc)},lc:function(a,b){wc(a,b,"createVertexArray",lc)},ic:function(a,b){wc(a,b,"createVertexArray",lc)},Ob:function(a){k.generateMipmap(a)},ja:function(a,b,c){c?B[c>>2]=k.getBufferParameter(a,b):V(1281)},ia:function(){var a=k.getError()||
118
+ rc;rc=0;return a},Nb:function(a,b,c,d){a=k.getFramebufferAttachmentParameter(a,b,c);if(a instanceof WebGLRenderbuffer||a instanceof WebGLTexture)a=a.name|0;B[d>>2]=a},Za:function(a,b){xc(a,b)},ha:function(a,b,c,d){a=k.getProgramInfoLog(T[a]);null===a&&(a="(unknown error)");b=0<b&&d?za(a,z,d,b):0;c&&(B[c>>2]=b)},ga:function(a,b,c){if(c)if(a>=gc)V(1281);else if(a=T[a],35716==b)a=k.getProgramInfoLog(a),null===a&&(a="(unknown error)"),B[c>>2]=a.length+1;else if(35719==b){if(!a.Fd)for(b=0;b<k.getProgramParameter(a,
119
+ 35718);++b)a.Fd=Math.max(a.Fd,k.getActiveUniform(a,b).name.length+1);B[c>>2]=a.Fd}else if(35722==b){if(!a.Dd)for(b=0;b<k.getProgramParameter(a,35721);++b)a.Dd=Math.max(a.Dd,k.getActiveAttrib(a,b).name.length+1);B[c>>2]=a.Dd}else if(35381==b){if(!a.Ed)for(b=0;b<k.getProgramParameter(a,35382);++b)a.Ed=Math.max(a.Ed,k.getActiveUniformBlockName(a,b).length+1);B[c>>2]=a.Ed}else B[c>>2]=k.getProgramParameter(a,b);else V(1281)},Mb:function(a,b,c){c?B[c>>2]=k.getRenderbufferParameter(a,b):V(1281)},fa:function(a,
120
+ b,c,d){a=k.getShaderInfoLog(U[a]);null===a&&(a="(unknown error)");b=0<b&&d?za(a,z,d,b):0;c&&(B[c>>2]=b)},yb:function(a,b,c,d){a=k.getShaderPrecisionFormat(a,b);B[c>>2]=a.rangeMin;B[c+4>>2]=a.rangeMax;B[d>>2]=a.precision},ea:function(a,b,c){c?35716==b?(a=k.getShaderInfoLog(U[a]),null===a&&(a="(unknown error)"),B[c>>2]=a?a.length+1:0):35720==b?(a=k.getShaderSource(U[a]),B[c>>2]=a?a.length+1:0):B[c>>2]=k.getShaderParameter(U[a],b):V(1281)},s:function(a){var b=oc[a];if(!b){switch(a){case 7939:b=k.getSupportedExtensions()||
121
+ [];b=b.concat(b.map(function(d){return"GL_"+d}));b=yc(b.join(" "));break;case 7936:case 7937:case 37445:case 37446:(b=k.getParameter(a))||V(1280);b=b&&yc(b);break;case 7938:b=yc("OpenGL ES 3.0 ("+k.getParameter(7938)+")");break;case 35724:b=k.getParameter(35724);var c=b.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==c&&(3==c[1].length&&(c[1]+="0"),b="OpenGL ES GLSL ES "+c[1]+" ("+b+")");b=yc(b);break;default:V(1280)}oc[a]=b}return b},_a:function(a,b){if(2>da.version)return V(1282),0;
122
+ var c=pc[a];if(c)return 0>b||b>=c.length?(V(1281),0):c[b];switch(a){case 7939:return c=k.getSupportedExtensions()||[],c=c.concat(c.map(function(d){return"GL_"+d})),c=c.map(function(d){return yc(d)}),c=pc[a]=c,0>b||b>=c.length?(V(1281),0):c[b];default:return V(1280),0}},ca:function(a,b){b=ya(b);if(a=T[a]){var c=a,d=c.yd,e=c.Yd,f;if(!d)for(c.yd=d={},c.Xd={},f=0;f<k.getProgramParameter(c,35718);++f){var l=k.getActiveUniform(c,f);var h=l.name;l=l.size;var n=Ac(h);n=0<n?h.slice(0,n):h;var p=c.Od;c.Od+=
123
+ l;e[n]=[l,p];for(h=0;h<l;++h)d[p]=h,c.Xd[p++]=n}c=a.yd;d=0;e=b;f=Ac(b);0<f&&(d=parseInt(b.slice(f+1))>>>0,e=b.slice(0,f));if((e=a.Yd[e])&&d<e[0]&&(d+=e[1],c[d]=c[d]||k.getUniformLocation(a,b)))return d}else V(1281);return-1},Ab:function(a,b,c){for(var d=vc[b],e=0;e<b;e++)d[e]=B[c+4*e>>2];k.invalidateFramebuffer(a,d)},zb:function(a,b,c,d,e,f,l){for(var h=vc[b],n=0;n<b;n++)h[n]=B[c+4*n>>2];k.invalidateSubFramebuffer(a,h,d,e,f,l)},Gb:function(a){return k.isSync(nc[a])},ba:function(a){return(a=kc[a])?
124
+ k.isTexture(a):0},aa:function(a){k.lineWidth(a)},$:function(a){a=T[a];k.linkProgram(a);a.yd=0;a.Yd={}},bc:function(a,b,c,d,e,f){k.Vd.multiDrawArraysInstancedBaseInstanceWEBGL(a,B,b>>2,B,c>>2,B,d>>2,E,e>>2,f)},ac:function(a,b,c,d,e,f,l,h){k.Vd.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(a,B,b>>2,c,B,d>>2,B,e>>2,B,f>>2,E,l>>2,h)},_:function(a,b){k.pixelStorei(a,b)},cc:function(a){k.readBuffer(a)},Z:function(a,b,c,d,e,f,l){if(k.Kd)k.readPixels(a,b,c,d,e,f,l);else{var h=Bc(f);k.readPixels(a,
125
+ b,c,d,e,f,h,l>>31-Math.clz32(h.BYTES_PER_ELEMENT))}},Lb:function(a,b,c,d){k.renderbufferStorage(a,b,c,d)},Jb:function(a,b,c,d,e){k.renderbufferStorageMultisample(a,b,c,d,e)},Cb:function(a,b,c){k.samplerParameteri(mc[a],b,c)},Bb:function(a,b,c){k.samplerParameteri(mc[a],b,B[c>>2])},Y:function(a,b,c,d){k.scissor(a,b,c,d)},X:function(a,b,c,d){for(var e="",f=0;f<b;++f){var l=d?B[d+4*f>>2]:-1;e+=ya(B[c+4*f>>2],0>l?void 0:l)}k.shaderSource(U[a],e)},W:function(a,b,c){k.stencilFunc(a,b,c)},V:function(a,b,
126
+ c,d){k.stencilFuncSeparate(a,b,c,d)},T:function(a){k.stencilMask(a)},S:function(a,b){k.stencilMaskSeparate(a,b)},R:function(a,b,c){k.stencilOp(a,b,c)},Q:function(a,b,c,d){k.stencilOpSeparate(a,b,c,d)},P:function(a,b,c,d,e,f,l,h,n){if(k.td)k.texImage2D(a,b,c,d,e,f,l,h,n);else if(n){var p=Bc(h);k.texImage2D(a,b,c,d,e,f,l,h,p,n>>31-Math.clz32(p.BYTES_PER_ELEMENT))}else k.texImage2D(a,b,c,d,e,f,l,h,null)},O:function(a,b,c){k.texParameterf(a,b,c)},N:function(a,b,c){k.texParameterf(a,b,F[c>>2])},M:function(a,
127
+ b,c){k.texParameteri(a,b,c)},L:function(a,b,c){k.texParameteri(a,b,B[c>>2])},_b:function(a,b,c,d,e){k.texStorage2D(a,b,c,d,e)},K:function(a,b,c,d,e,f,l,h,n){if(k.td)k.texSubImage2D(a,b,c,d,e,f,l,h,n);else if(n){var p=Bc(h);k.texSubImage2D(a,b,c,d,e,f,l,h,p,n>>31-Math.clz32(p.BYTES_PER_ELEMENT))}else k.texSubImage2D(a,b,c,d,e,f,l,h,null)},I:function(a,b){k.uniform1f(W(a),b)},H:function(a,b,c){k.uniform1fv(W(a),F,c>>2,b)},G:function(a,b){k.uniform1i(W(a),b)},F:function(a,b,c){k.uniform1iv(W(a),B,c>>
128
+ 2,b)},E:function(a,b,c){k.uniform2f(W(a),b,c)},D:function(a,b,c){k.uniform2fv(W(a),F,c>>2,2*b)},C:function(a,b,c){k.uniform2i(W(a),b,c)},B:function(a,b,c){k.uniform2iv(W(a),B,c>>2,2*b)},A:function(a,b,c,d){k.uniform3f(W(a),b,c,d)},z:function(a,b,c){k.uniform3fv(W(a),F,c>>2,3*b)},Dc:function(a,b,c,d){k.uniform3i(W(a),b,c,d)},Cc:function(a,b,c){k.uniform3iv(W(a),B,c>>2,3*b)},Bc:function(a,b,c,d,e){k.uniform4f(W(a),b,c,d,e)},Ac:function(a,b,c){k.uniform4fv(W(a),F,c>>2,4*b)},zc:function(a,b,c,d,e){k.uniform4i(W(a),
129
+ b,c,d,e)},yc:function(a,b,c){k.uniform4iv(W(a),B,c>>2,4*b)},xc:function(a,b,c,d){k.uniformMatrix2fv(W(a),!!c,F,d>>2,4*b)},wc:function(a,b,c,d){k.uniformMatrix3fv(W(a),!!c,F,d>>2,9*b)},vc:function(a,b,c,d){k.uniformMatrix4fv(W(a),!!c,F,d>>2,16*b)},uc:function(a){a=T[a];k.useProgram(a);k.$d=a},tc:function(a,b){k.vertexAttrib1f(a,b)},sc:function(a,b){k.vertexAttrib2f(a,F[b>>2],F[b+4>>2])},rc:function(a,b){k.vertexAttrib3f(a,F[b>>2],F[b+4>>2],F[b+8>>2])},qc:function(a,b){k.vertexAttrib4f(a,F[b>>2],F[b+
130
+ 4>>2],F[b+8>>2],F[b+12>>2])},Zb:function(a,b){k.vertexAttribDivisor(a,b)},Yb:function(a,b,c,d,e){k.vertexAttribIPointer(a,b,c,d,e)},pc:function(a,b,c,d,e,f){k.vertexAttribPointer(a,b,c,!!d,e,f)},oc:function(a,b,c,d){k.viewport(a,b,c,d)},ab:function(a,b,c,d){k.waitSync(nc[a],b,(c>>>0)+4294967296*d)},t:function(a){var b=z.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(a,d);0<d%65536&&(d+=65536-d%65536);a:{try{ua.grow(Math.min(2147483648,
131
+ d)-Ka.byteLength+65535>>>16);Ma();var e=1;break a}catch(f){}e=void 0}if(e)return!0}return!1},qb:function(a,b){var c=0;Dc().forEach(function(d,e){var f=b+c;e=B[a+4*e>>2]=f;for(f=0;f<d.length;++f)C[e++>>0]=d.charCodeAt(f);C[e>>0]=0;c+=d.length+1});return 0},rb:function(a,b){var c=Dc();B[a>>2]=c.length;var d=0;c.forEach(function(e){d+=e.length+1});B[b>>2]=d;return 0},ub:function(){return 0},eb:function(){},tb:function(a,b,c,d){for(var e=0,f=0;f<c;f++){var l=B[b>>2],h=B[b+4>>2];b+=8;for(var n=0;n<h;n++){var p=
132
+ z[l+n],q=Fc[a];0===p||10===p?((1===a?ra:y)(xa(q,0)),q.length=0):q.push(p)}e+=h}B[d>>2]=e;return 0},b:function(){return sa},db:function(a,b){xc(a,b)},n:Rc,h:Sc,o:Tc,r:Uc,hb:Vc,jb:Wc,q:Xc,j:Yc,d:Zc,p:$c,i:ad,kb:bd,gb:cd,lb:dd,c:function(a){sa=a},pb:function(a,b,c,d){return Lc(a,b,c,d)}};
133
+ (function(){function a(e){g.asm=e.exports;ua=g.asm.Gc;Ma();Na=g.asm.Qc;Pa.unshift(g.asm.Hc);Sa--;g.monitorRunDependencies&&g.monitorRunDependencies(Sa);0==Sa&&(null!==Ta&&(clearInterval(Ta),Ta=null),Ua&&(e=Ua,Ua=null,e()))}function b(e){a(e.instance)}function c(e){return Ya().then(function(f){return WebAssembly.instantiate(f,d)}).then(function(f){return f}).then(e,function(f){y("failed to asynchronously prepare wasm: "+f);qa(f)})}var d={a:ed};Sa++;g.monitorRunDependencies&&g.monitorRunDependencies(Sa);
134
+ if(g.instantiateWasm)try{return g.instantiateWasm(d,a)}catch(e){return y("Module.instantiateWasm callback failed with error: "+e),!1}(function(){return ta||"function"!==typeof WebAssembly.instantiateStreaming||Va()||G.startsWith("file://")||"function"!==typeof fetch?c(b):fetch(G,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,d).then(b,function(f){y("wasm streaming compile failed: "+f);y("falling back to ArrayBuffer instantiation");return c(b)})})})().catch(ba);
135
+ return{}})();g.___wasm_call_ctors=function(){return(g.___wasm_call_ctors=g.asm.Hc).apply(null,arguments)};var zc=g._malloc=function(){return(zc=g._malloc=g.asm.Ic).apply(null,arguments)},Qc=g.___errno_location=function(){return(Qc=g.___errno_location=g.asm.Jc).apply(null,arguments)},Q=g._free=function(){return(Q=g._free=g.asm.Kc).apply(null,arguments)},Nb=g.___getTypeName=function(){return(Nb=g.___getTypeName=g.asm.Lc).apply(null,arguments)};
136
+ g.___embind_register_native_and_builtin_types=function(){return(g.___embind_register_native_and_builtin_types=g.asm.Mc).apply(null,arguments)};var X=g.stackSave=function(){return(X=g.stackSave=g.asm.Nc).apply(null,arguments)},Y=g.stackRestore=function(){return(Y=g.stackRestore=g.asm.Oc).apply(null,arguments)},Z=g._setThrew=function(){return(Z=g._setThrew=g.asm.Pc).apply(null,arguments)};g.dynCall_iiiij=function(){return(g.dynCall_iiiij=g.asm.Rc).apply(null,arguments)};
137
+ g.dynCall_viiij=function(){return(g.dynCall_viiij=g.asm.Sc).apply(null,arguments)};g.dynCall_iiij=function(){return(g.dynCall_iiij=g.asm.Tc).apply(null,arguments)};g.dynCall_viij=function(){return(g.dynCall_viij=g.asm.Uc).apply(null,arguments)};g.dynCall_viiiiij=function(){return(g.dynCall_viiiiij=g.asm.Vc).apply(null,arguments)};g.dynCall_jii=function(){return(g.dynCall_jii=g.asm.Wc).apply(null,arguments)};g.dynCall_viji=function(){return(g.dynCall_viji=g.asm.Xc).apply(null,arguments)};
138
+ g.dynCall_ji=function(){return(g.dynCall_ji=g.asm.Yc).apply(null,arguments)};g.dynCall_iij=function(){return(g.dynCall_iij=g.asm.Zc).apply(null,arguments)};g.dynCall_vij=function(){return(g.dynCall_vij=g.asm._c).apply(null,arguments)};g.dynCall_jiji=function(){return(g.dynCall_jiji=g.asm.$c).apply(null,arguments)};g.dynCall_iiiiij=function(){return(g.dynCall_iiiiij=g.asm.ad).apply(null,arguments)};g.dynCall_iiiiijj=function(){return(g.dynCall_iiiiijj=g.asm.bd).apply(null,arguments)};
139
+ g.dynCall_iiiiiijj=function(){return(g.dynCall_iiiiiijj=g.asm.cd).apply(null,arguments)};g.dynCall_viijii=function(){return(g.dynCall_viijii=g.asm.dd).apply(null,arguments)};function Zc(a,b,c){var d=X();try{H(a)(b,c)}catch(e){Y(d);if(e!==e+0&&"longjmp"!==e)throw e;Z(1,0)}}function Tc(a,b,c,d){var e=X();try{return H(a)(b,c,d)}catch(f){Y(e);if(f!==f+0&&"longjmp"!==f)throw f;Z(1,0)}}function ad(a,b,c,d,e){var f=X();try{H(a)(b,c,d,e)}catch(l){Y(f);if(l!==l+0&&"longjmp"!==l)throw l;Z(1,0)}}
140
+ function Yc(a,b){var c=X();try{H(a)(b)}catch(d){Y(c);if(d!==d+0&&"longjmp"!==d)throw d;Z(1,0)}}function Sc(a,b,c){var d=X();try{return H(a)(b,c)}catch(e){Y(d);if(e!==e+0&&"longjmp"!==e)throw e;Z(1,0)}}function Uc(a,b,c,d,e){var f=X();try{return H(a)(b,c,d,e)}catch(l){Y(f);if(l!==l+0&&"longjmp"!==l)throw l;Z(1,0)}}function Rc(a,b){var c=X();try{return H(a)(b)}catch(d){Y(c);if(d!==d+0&&"longjmp"!==d)throw d;Z(1,0)}}
141
+ function Xc(a){var b=X();try{H(a)()}catch(c){Y(b);if(c!==c+0&&"longjmp"!==c)throw c;Z(1,0)}}function dd(a,b,c,d,e,f,l,h,n){var p=X();try{H(a)(b,c,d,e,f,l,h,n)}catch(q){Y(p);if(q!==q+0&&"longjmp"!==q)throw q;Z(1,0)}}function $c(a,b,c,d){var e=X();try{H(a)(b,c,d)}catch(f){Y(e);if(f!==f+0&&"longjmp"!==f)throw f;Z(1,0)}}function bd(a,b,c,d,e,f){var l=X();try{H(a)(b,c,d,e,f)}catch(h){Y(l);if(h!==h+0&&"longjmp"!==h)throw h;Z(1,0)}}
142
+ function Wc(a,b,c,d,e,f,l){var h=X();try{return H(a)(b,c,d,e,f,l)}catch(n){Y(h);if(n!==n+0&&"longjmp"!==n)throw n;Z(1,0)}}function Vc(a,b,c,d,e,f){var l=X();try{return H(a)(b,c,d,e,f)}catch(h){Y(l);if(h!==h+0&&"longjmp"!==h)throw h;Z(1,0)}}function cd(a,b,c,d,e,f,l){var h=X();try{H(a)(b,c,d,e,f,l)}catch(n){Y(h);if(n!==n+0&&"longjmp"!==n)throw n;Z(1,0)}}var fd;Ua=function gd(){fd||hd();fd||(Ua=gd)};
143
+ function hd(){function a(){if(!fd&&(fd=!0,g.calledRun=!0,!va)){Za(Pa);aa(g);if(g.onRuntimeInitialized)g.onRuntimeInitialized();if(g.postRun)for("function"==typeof g.postRun&&(g.postRun=[g.postRun]);g.postRun.length;){var b=g.postRun.shift();Qa.unshift(b)}Za(Qa)}}if(!(0<Sa)){if(g.preRun)for("function"==typeof g.preRun&&(g.preRun=[g.preRun]);g.preRun.length;)Ra();Za(Oa);0<Sa||(g.setStatus?(g.setStatus("Running..."),setTimeout(function(){setTimeout(function(){g.setStatus("")},1);a()},1)):a())}}
144
+ g.run=hd;if(g.preInit)for("function"==typeof g.preInit&&(g.preInit=[g.preInit]);0<g.preInit.length;)g.preInit.pop()();hd();
145
+
146
+
147
+ return Rive.ready
148
+ }
149
+ );
150
+ })();
151
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Rive);
152
+
153
+ /***/ }),
154
+ /* 2 */
155
+ /***/ ((module) => {
156
+
157
+ module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"1.0.2","description":"Rive\'s webgl based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.wasm"],"typings":"rive.d.ts","dependencies":{}}');
158
+
159
+ /***/ })
160
+ /******/ ]);
161
+ /************************************************************************/
162
+ /******/ // The module cache
163
+ /******/ var __webpack_module_cache__ = {};
164
+ /******/
165
+ /******/ // The require function
166
+ /******/ function __webpack_require__(moduleId) {
167
+ /******/ // Check if module is in cache
168
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
169
+ /******/ if (cachedModule !== undefined) {
170
+ /******/ return cachedModule.exports;
171
+ /******/ }
172
+ /******/ // Create a new module (and put it into the cache)
173
+ /******/ var module = __webpack_module_cache__[moduleId] = {
174
+ /******/ // no module.id needed
175
+ /******/ // no module.loaded needed
176
+ /******/ exports: {}
177
+ /******/ };
178
+ /******/
179
+ /******/ // Execute the module function
180
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
181
+ /******/
182
+ /******/ // Return the exports of the module
183
+ /******/ return module.exports;
184
+ /******/ }
185
+ /******/
186
+ /************************************************************************/
187
+ /******/ /* webpack/runtime/define property getters */
188
+ /******/ (() => {
189
+ /******/ // define getter functions for harmony exports
190
+ /******/ __webpack_require__.d = (exports, definition) => {
191
+ /******/ for(var key in definition) {
192
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
193
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
194
+ /******/ }
195
+ /******/ }
196
+ /******/ };
197
+ /******/ })();
198
+ /******/
199
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
200
+ /******/ (() => {
201
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
202
+ /******/ })();
203
+ /******/
204
+ /******/ /* webpack/runtime/make namespace object */
205
+ /******/ (() => {
206
+ /******/ // define __esModule on exports
207
+ /******/ __webpack_require__.r = (exports) => {
208
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
209
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
210
+ /******/ }
211
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
212
+ /******/ };
213
+ /******/ })();
214
+ /******/
215
+ /************************************************************************/
216
+ var __webpack_exports__ = {};
217
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
218
+ (() => {
219
+ __webpack_require__.r(__webpack_exports__);
220
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
221
+ /* harmony export */ "Fit": () => (/* binding */ Fit),
222
+ /* harmony export */ "Alignment": () => (/* binding */ Alignment),
223
+ /* harmony export */ "Layout": () => (/* binding */ Layout),
224
+ /* harmony export */ "RuntimeLoader": () => (/* binding */ RuntimeLoader),
225
+ /* harmony export */ "StateMachineInputType": () => (/* binding */ StateMachineInputType),
226
+ /* harmony export */ "StateMachineInput": () => (/* binding */ StateMachineInput),
227
+ /* harmony export */ "EventType": () => (/* binding */ EventType),
228
+ /* harmony export */ "LoopType": () => (/* binding */ LoopType),
229
+ /* harmony export */ "Rive": () => (/* binding */ Rive),
230
+ /* harmony export */ "Testing": () => (/* binding */ Testing)
231
+ /* harmony export */ });
232
+ /* harmony import */ var _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
233
+ /* harmony import */ var package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
234
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
235
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
236
+ return new (P || (P = Promise))(function (resolve, reject) {
237
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
238
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
239
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
240
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
241
+ });
242
+ };
243
+ var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
244
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
245
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
246
+ function verb(n) { return function (v) { return step([n, v]); }; }
247
+ function step(op) {
248
+ if (f) throw new TypeError("Generator is already executing.");
249
+ while (_) try {
250
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
251
+ if (y = 0, t) op = [op[0] & 2, t.value];
252
+ switch (op[0]) {
253
+ case 0: case 1: t = op; break;
254
+ case 4: _.label++; return { value: op[1], done: false };
255
+ case 5: _.label++; y = op[1]; op = [0]; continue;
256
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
257
+ default:
258
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
259
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
260
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
261
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
262
+ if (t[2]) _.ops.pop();
263
+ _.trys.pop(); continue;
264
+ }
265
+ op = body.call(thisArg, _);
266
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
267
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
268
+ }
269
+ };
270
+
271
+
272
+ // Tracks playback states; numbers map to the runtime's numerical values
273
+ // i.e. play: 0, pause: 1, stop: 2
274
+ var PlaybackState;
275
+ (function (PlaybackState) {
276
+ PlaybackState[PlaybackState["Play"] = 0] = "Play";
277
+ PlaybackState[PlaybackState["Pause"] = 1] = "Pause";
278
+ PlaybackState[PlaybackState["Stop"] = 2] = "Stop";
279
+ })(PlaybackState || (PlaybackState = {}));
280
+ // #region layout
281
+ // Fit options for the canvas
282
+ var Fit;
283
+ (function (Fit) {
284
+ Fit["Cover"] = "cover";
285
+ Fit["Contain"] = "contain";
286
+ Fit["Fill"] = "fill";
287
+ Fit["FitWidth"] = "fitWidth";
288
+ Fit["FitHeight"] = "fitHeight";
289
+ Fit["None"] = "none";
290
+ Fit["ScaleDown"] = "scaleDown";
291
+ })(Fit || (Fit = {}));
292
+ // Alignment options for the canvas
293
+ var Alignment;
294
+ (function (Alignment) {
295
+ Alignment["Center"] = "center";
296
+ Alignment["TopLeft"] = "topLeft";
297
+ Alignment["TopCenter"] = "topCenter";
298
+ Alignment["TopRight"] = "topRight";
299
+ Alignment["CenterLeft"] = "centerLeft";
300
+ Alignment["CenterRight"] = "centerRight";
301
+ Alignment["BottomLeft"] = "bottomLeft";
302
+ Alignment["BottomCenter"] = "bottomCenter";
303
+ Alignment["BottomRight"] = "bottomRight";
304
+ })(Alignment || (Alignment = {}));
305
+ // Alignment options for Rive animations in a HTML canvas
306
+ var Layout = /** @class */ (function () {
307
+ function Layout(params) {
308
+ var _a, _b, _c, _d, _e, _f;
309
+ this.fit = (_a = params === null || params === void 0 ? void 0 : params.fit) !== null && _a !== void 0 ? _a : Fit.Contain;
310
+ this.alignment = (_b = params === null || params === void 0 ? void 0 : params.alignment) !== null && _b !== void 0 ? _b : Alignment.Center;
311
+ this.minX = (_c = params === null || params === void 0 ? void 0 : params.minX) !== null && _c !== void 0 ? _c : 0;
312
+ this.minY = (_d = params === null || params === void 0 ? void 0 : params.minY) !== null && _d !== void 0 ? _d : 0;
313
+ this.maxX = (_e = params === null || params === void 0 ? void 0 : params.maxX) !== null && _e !== void 0 ? _e : 0;
314
+ this.maxY = (_f = params === null || params === void 0 ? void 0 : params.maxY) !== null && _f !== void 0 ? _f : 0;
315
+ }
316
+ // Alternative constructor to build a Layout from an interface/object
317
+ Layout.new = function (_a) {
318
+ var fit = _a.fit, alignment = _a.alignment, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
319
+ console.warn('This function is deprecated: please use `new Layout({})` instead');
320
+ return new Layout({ fit: fit, alignment: alignment, minX: minX, minY: minY, maxX: maxX, maxY: maxY });
321
+ };
322
+ /**
323
+ * Makes a copy of the layout, replacing any specified parameters
324
+ */
325
+ Layout.prototype.copyWith = function (_a) {
326
+ var fit = _a.fit, alignment = _a.alignment, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
327
+ return new Layout({
328
+ fit: fit !== null && fit !== void 0 ? fit : this.fit,
329
+ alignment: alignment !== null && alignment !== void 0 ? alignment : this.alignment,
330
+ minX: minX !== null && minX !== void 0 ? minX : this.minX,
331
+ minY: minY !== null && minY !== void 0 ? minY : this.minY,
332
+ maxX: maxX !== null && maxX !== void 0 ? maxX : this.maxX,
333
+ maxY: maxY !== null && maxY !== void 0 ? maxY : this.maxY
334
+ });
335
+ };
336
+ // Returns fit for the Wasm runtime format
337
+ Layout.prototype.runtimeFit = function (rive) {
338
+ if (this.cachedRuntimeFit)
339
+ return this.cachedRuntimeFit;
340
+ var fit;
341
+ if (this.fit === Fit.Cover)
342
+ fit = rive.Fit.cover;
343
+ else if (this.fit === Fit.Contain)
344
+ fit = rive.Fit.contain;
345
+ else if (this.fit === Fit.Fill)
346
+ fit = rive.Fit.fill;
347
+ else if (this.fit === Fit.FitWidth)
348
+ fit = rive.Fit.fitWidth;
349
+ else if (this.fit === Fit.FitHeight)
350
+ fit = rive.Fit.fitHeight;
351
+ else if (this.fit === Fit.ScaleDown)
352
+ fit = rive.Fit.scaleDown;
353
+ else
354
+ fit = rive.Fit.none;
355
+ this.cachedRuntimeFit = fit;
356
+ return fit;
357
+ };
358
+ // Returns alignment for the Wasm runtime format
359
+ Layout.prototype.runtimeAlignment = function (rive) {
360
+ if (this.cachedRuntimeAlignment)
361
+ return this.cachedRuntimeAlignment;
362
+ var alignment;
363
+ if (this.alignment === Alignment.TopLeft)
364
+ alignment = rive.Alignment.topLeft;
365
+ else if (this.alignment === Alignment.TopCenter)
366
+ alignment = rive.Alignment.topCenter;
367
+ else if (this.alignment === Alignment.TopRight)
368
+ alignment = rive.Alignment.topRight;
369
+ else if (this.alignment === Alignment.CenterLeft)
370
+ alignment = rive.Alignment.centerLeft;
371
+ else if (this.alignment === Alignment.CenterRight)
372
+ alignment = rive.Alignment.centerRight;
373
+ else if (this.alignment === Alignment.BottomLeft)
374
+ alignment = rive.Alignment.bottomLeft;
375
+ else if (this.alignment === Alignment.BottomCenter)
376
+ alignment = rive.Alignment.bottomCenter;
377
+ else if (this.alignment === Alignment.BottomRight)
378
+ alignment = rive.Alignment.bottomRight;
379
+ else
380
+ alignment = rive.Alignment.center;
381
+ this.cachedRuntimeAlignment = alignment;
382
+ return alignment;
383
+ };
384
+ return Layout;
385
+ }());
386
+
387
+ // Runtime singleton; use getInstance to provide a callback that returns the
388
+ // Rive runtime
389
+ var RuntimeLoader = /** @class */ (function () {
390
+ // Class is never instantiated
391
+ function RuntimeLoader() {
392
+ }
393
+ // Loads the runtime
394
+ RuntimeLoader.loadRuntime = function () {
395
+ _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__.default({
396
+ // Loads Wasm bundle
397
+ locateFile: function (_) { return RuntimeLoader.wasmURL; }
398
+ }).then(function (rive) {
399
+ var _a;
400
+ RuntimeLoader.runtime = rive;
401
+ // Fire all the callbacks
402
+ while (RuntimeLoader.callBackQueue.length > 0) {
403
+ (_a = RuntimeLoader.callBackQueue.shift()) === null || _a === void 0 ? void 0 : _a(RuntimeLoader.runtime);
404
+ }
405
+ });
406
+ };
407
+ // Provides a runtime instance via a callback
408
+ RuntimeLoader.getInstance = function (callback) {
409
+ // If it's not loading, start loading runtime
410
+ if (!RuntimeLoader.isLoading) {
411
+ RuntimeLoader.isLoading = true;
412
+ RuntimeLoader.loadRuntime();
413
+ }
414
+ if (!RuntimeLoader.runtime) {
415
+ RuntimeLoader.callBackQueue.push(callback);
416
+ }
417
+ else {
418
+ callback(RuntimeLoader.runtime);
419
+ }
420
+ };
421
+ // Provides a runtime instance via a promise
422
+ RuntimeLoader.awaitInstance = function () {
423
+ return new Promise(function (resolve, reject) {
424
+ return RuntimeLoader.getInstance(function (rive) { return resolve(rive); });
425
+ });
426
+ };
427
+ // Manually sets the wasm url
428
+ RuntimeLoader.setWasmUrl = function (url) {
429
+ RuntimeLoader.wasmURL = url;
430
+ };
431
+ // Flag to indicate that loading has started/completed
432
+ RuntimeLoader.isLoading = false;
433
+ // List of callbacks for the runtime that come in while loading
434
+ RuntimeLoader.callBackQueue = [];
435
+ // Path to the Wasm file; default path works for testing only;
436
+ // if embedded wasm is used then this is never used.
437
+ RuntimeLoader.wasmURL = "https://unpkg.com/" + package_json__WEBPACK_IMPORTED_MODULE_1__.name + "@" + package_json__WEBPACK_IMPORTED_MODULE_1__.version + "/rive.wasm";
438
+ return RuntimeLoader;
439
+ }());
440
+
441
+ // #endregion
442
+ // #region animations
443
+ // Wraps animations and instances from the runtime and keeps track of playback
444
+ // state
445
+ var Animation = /** @class */ (function () {
446
+ /**
447
+ * Constructs a new animation
448
+ * @constructor
449
+ * @param {any} animation: runtime animation object
450
+ * @param {any} instance: runtime animation instance object
451
+ */
452
+ function Animation(animation, runtime, playing) {
453
+ this.animation = animation;
454
+ this.playing = playing;
455
+ this.loopCount = 0;
456
+ // Time to which the animation should move to on the next render
457
+ this.scrubTo = null;
458
+ this.instance = new runtime.LinearAnimationInstance(animation);
459
+ }
460
+ Object.defineProperty(Animation.prototype, "name", {
461
+ // Returns the animation's name
462
+ get: function () {
463
+ return this.animation.name;
464
+ },
465
+ enumerable: false,
466
+ configurable: true
467
+ });
468
+ Object.defineProperty(Animation.prototype, "time", {
469
+ // Returns the animation's current time
470
+ get: function () {
471
+ return this.instance.time;
472
+ },
473
+ // Sets the animation's current time
474
+ set: function (value) {
475
+ this.instance.time = value;
476
+ },
477
+ enumerable: false,
478
+ configurable: true
479
+ });
480
+ Object.defineProperty(Animation.prototype, "loopValue", {
481
+ // Returns the animation's loop type
482
+ get: function () {
483
+ return this.animation.loopValue;
484
+ },
485
+ enumerable: false,
486
+ configurable: true
487
+ });
488
+ /**
489
+ * Advances the animation by the give time. If the animation needs scrubbing,
490
+ * time is ignored and the stored scrub value is used.
491
+ * @param time the time to advance the animation by if no scrubbing required
492
+ */
493
+ Animation.prototype.advance = function (time) {
494
+ if (this.scrubTo === null) {
495
+ this.instance.advance(time);
496
+ }
497
+ else {
498
+ this.instance.time = 0;
499
+ this.instance.advance(this.scrubTo);
500
+ this.scrubTo = null;
501
+ }
502
+ };
503
+ Object.defineProperty(Animation.prototype, "needsScrub", {
504
+ get: function () {
505
+ return this.scrubTo !== null;
506
+ },
507
+ enumerable: false,
508
+ configurable: true
509
+ });
510
+ /**
511
+ * Deletes the backing Wasm animation instance; once this is called, this
512
+ * animation is no more.
513
+ */
514
+ Animation.prototype.cleanup = function () {
515
+ this.instance.delete();
516
+ };
517
+ return Animation;
518
+ }());
519
+ // #endregion
520
+ // #region state machines
521
+ var StateMachineInputType;
522
+ (function (StateMachineInputType) {
523
+ StateMachineInputType[StateMachineInputType["Number"] = 56] = "Number";
524
+ StateMachineInputType[StateMachineInputType["Trigger"] = 58] = "Trigger";
525
+ StateMachineInputType[StateMachineInputType["Boolean"] = 59] = "Boolean";
526
+ })(StateMachineInputType || (StateMachineInputType = {}));
527
+ /**
528
+ * An input for a state machine
529
+ */
530
+ var StateMachineInput = /** @class */ (function () {
531
+ function StateMachineInput(type, runtimeInput) {
532
+ this.type = type;
533
+ this.runtimeInput = runtimeInput;
534
+ }
535
+ Object.defineProperty(StateMachineInput.prototype, "name", {
536
+ /**
537
+ * Returns the name of the input
538
+ */
539
+ get: function () {
540
+ return this.runtimeInput.name;
541
+ },
542
+ enumerable: false,
543
+ configurable: true
544
+ });
545
+ Object.defineProperty(StateMachineInput.prototype, "value", {
546
+ /**
547
+ * Returns the current value of the input
548
+ */
549
+ get: function () {
550
+ return this.runtimeInput.value;
551
+ },
552
+ /**
553
+ * Sets the value of the input
554
+ */
555
+ set: function (value) {
556
+ this.runtimeInput.value = value;
557
+ },
558
+ enumerable: false,
559
+ configurable: true
560
+ });
561
+ /**
562
+ * Fires a trigger; does nothing on Number or Boolean input types
563
+ */
564
+ StateMachineInput.prototype.fire = function () {
565
+ if (this.type === StateMachineInputType.Trigger) {
566
+ this.runtimeInput.fire();
567
+ }
568
+ };
569
+ return StateMachineInput;
570
+ }());
571
+
572
+ var StateMachine = /** @class */ (function () {
573
+ /**
574
+ * @constructor
575
+ * @param stateMachine runtime state machine object
576
+ * @param instance runtime state machine instance object
577
+ */
578
+ function StateMachine(stateMachine, runtime, playing) {
579
+ this.stateMachine = stateMachine;
580
+ this.playing = playing;
581
+ /**
582
+ * Caches the inputs from the runtime
583
+ */
584
+ this.inputs = [];
585
+ this.instance = new runtime.StateMachineInstance(stateMachine);
586
+ this.initInputs(runtime);
587
+ }
588
+ Object.defineProperty(StateMachine.prototype, "name", {
589
+ get: function () {
590
+ return this.stateMachine.name;
591
+ },
592
+ enumerable: false,
593
+ configurable: true
594
+ });
595
+ Object.defineProperty(StateMachine.prototype, "statesChanged", {
596
+ /**
597
+ * Returns a list of state names that have changed on this frame
598
+ */
599
+ get: function () {
600
+ var names = [];
601
+ for (var i = 0; i < this.instance.stateChangedCount(); i++) {
602
+ names.push(this.instance.stateChangedNameByIndex(i));
603
+ }
604
+ return names;
605
+ },
606
+ enumerable: false,
607
+ configurable: true
608
+ });
609
+ /**
610
+ * Fetches references to the state machine's inputs and caches them
611
+ * @param runtime an instance of the runtime; needed for the SMIInput types
612
+ */
613
+ StateMachine.prototype.initInputs = function (runtime) {
614
+ // Fetch the inputs from the runtime if we don't have them
615
+ for (var i = 0; i < this.instance.inputCount(); i++) {
616
+ var input = this.instance.input(i);
617
+ this.inputs.push(this.mapRuntimeInput(input, runtime));
618
+ }
619
+ };
620
+ /**
621
+ * Maps a runtime input to it's appropriate type
622
+ * @param input
623
+ */
624
+ StateMachine.prototype.mapRuntimeInput = function (input, runtime) {
625
+ if (input.type === runtime.SMIInput.bool) {
626
+ return new StateMachineInput(StateMachineInputType.Boolean, input.asBool());
627
+ }
628
+ else if (input.type === runtime.SMIInput.number) {
629
+ return new StateMachineInput(StateMachineInputType.Number, input.asNumber());
630
+ }
631
+ else if (input.type === runtime.SMIInput.trigger) {
632
+ return new StateMachineInput(StateMachineInputType.Trigger, input.asTrigger());
633
+ }
634
+ };
635
+ /**
636
+ * Deletes the backing Wasm state machine instance; once this is called, this
637
+ * state machine is no more.
638
+ */
639
+ StateMachine.prototype.cleanup = function () {
640
+ this.instance.delete();
641
+ };
642
+ return StateMachine;
643
+ }());
644
+ // #endregion
645
+ // #region animator
646
+ /**
647
+ * Manages animation
648
+ */
649
+ var Animator = /** @class */ (function () {
650
+ /**
651
+ * Constructs a new animator
652
+ * @constructor
653
+ * @param runtime Rive runtime; needed to instance animations & state machines
654
+ * @param artboard the artboard that holds all animations and state machines
655
+ * @param animations optional list of animations
656
+ * @param stateMachines optional list of state machines
657
+ */
658
+ function Animator(runtime, artboard, eventManager, animations, stateMachines) {
659
+ if (animations === void 0) { animations = []; }
660
+ if (stateMachines === void 0) { stateMachines = []; }
661
+ this.runtime = runtime;
662
+ this.artboard = artboard;
663
+ this.eventManager = eventManager;
664
+ this.animations = animations;
665
+ this.stateMachines = stateMachines;
666
+ }
667
+ /**
668
+ * Adds animations and state machines by their names. If names are shared
669
+ * between animations & state machines, then the first one found will be
670
+ * created. Best not to use the same names for these in your Rive file.
671
+ * @param animatable the name(s) of animations and state machines to add
672
+ * @returns a list of names of the playing animations and state machines
673
+ */
674
+ Animator.prototype.add = function (animatables, playing, fireEvent) {
675
+ if (fireEvent === void 0) { fireEvent = true; }
676
+ animatables = mapToStringArray(animatables);
677
+ // If animatables is empty, play or pause everything
678
+ if (animatables.length === 0) {
679
+ this.animations.forEach(function (a) { return a.playing = playing; });
680
+ this.stateMachines.forEach(function (m) { return m.playing = playing; });
681
+ }
682
+ else {
683
+ // Play/pause already instanced items, or create new instances
684
+ var instancedAnimationNames = this.animations.map(function (a) { return a.name; });
685
+ var instancedMachineNames = this.stateMachines.map(function (m) { return m.name; });
686
+ for (var i in animatables) {
687
+ var aIndex = instancedAnimationNames.indexOf(animatables[i]);
688
+ var mIndex = instancedMachineNames.indexOf(animatables[i]);
689
+ if (aIndex >= 0 || mIndex >= 0) {
690
+ if (aIndex >= 0) {
691
+ // Animation is instanced, play/pause it
692
+ this.animations[aIndex].playing = playing;
693
+ }
694
+ else {
695
+ // State machine is instanced, play/pause it
696
+ this.stateMachines[mIndex].playing = playing;
697
+ }
698
+ }
699
+ else {
700
+ // Try to create a new animation instance
701
+ var anim = this.artboard.animationByName(animatables[i]);
702
+ if (anim) {
703
+ this.animations.push(new Animation(anim, this.runtime, playing));
704
+ }
705
+ else {
706
+ // Try to create a new state machine instance
707
+ var sm = this.artboard.stateMachineByName(animatables[i]);
708
+ if (sm) {
709
+ this.stateMachines.push(new StateMachine(sm, this.runtime, playing));
710
+ }
711
+ }
712
+ }
713
+ }
714
+ }
715
+ // Fire play/paused events for animations
716
+ if (fireEvent) {
717
+ if (playing) {
718
+ this.eventManager.fire({
719
+ type: EventType.Play,
720
+ data: this.playing,
721
+ });
722
+ }
723
+ else {
724
+ this.eventManager.fire({
725
+ type: EventType.Pause,
726
+ data: this.paused,
727
+ });
728
+ }
729
+ }
730
+ return playing ? this.playing : this.paused;
731
+ };
732
+ /**
733
+ * Play the named animations/state machines
734
+ * @param animatables the names of the animations/machines to play; plays all if empty
735
+ * @returns a list of the playing items
736
+ */
737
+ Animator.prototype.play = function (animatables) {
738
+ return this.add(animatables, true);
739
+ };
740
+ /**
741
+ * Pauses named animations and state machines, or everything if nothing is
742
+ * specified
743
+ * @param animatables names of the animations and state machines to pause
744
+ * @returns a list of names of the animations and state machines paused
745
+ */
746
+ Animator.prototype.pause = function (animatables) {
747
+ return this.add(animatables, false);
748
+ };
749
+ /**
750
+ * Set time of named animations
751
+ * @param animations names of the animations to scrub
752
+ * @param value time scrub value, a floating point number to which the playhead is jumped
753
+ * @returns a list of names of the animations that were scrubbed
754
+ */
755
+ Animator.prototype.scrub = function (animatables, value) {
756
+ var forScrubbing = this.animations.filter(function (a) { return animatables.includes(a.name); });
757
+ forScrubbing.forEach(function (a) { return a.scrubTo = value; });
758
+ return forScrubbing.map(function (a) { return a.name; });
759
+ };
760
+ Object.defineProperty(Animator.prototype, "playing", {
761
+ /**
762
+ * Returns a list of names of all animations and state machines currently
763
+ * playing
764
+ */
765
+ get: function () {
766
+ return this.animations.filter(function (a) { return a.playing; }).map(function (a) { return a.name; }).concat(this.stateMachines.filter(function (m) { return m.playing; }).map(function (m) { return m.name; }));
767
+ },
768
+ enumerable: false,
769
+ configurable: true
770
+ });
771
+ Object.defineProperty(Animator.prototype, "paused", {
772
+ /**
773
+ * Returns a list of names of all animations and state machines currently
774
+ * paused
775
+ */
776
+ get: function () {
777
+ return this.animations.filter(function (a) { return !a.playing; }).map(function (a) { return a.name; }).concat(this.stateMachines.filter(function (m) { return !m.playing; }).map(function (m) { return m.name; }));
778
+ },
779
+ enumerable: false,
780
+ configurable: true
781
+ });
782
+ /**
783
+ * Stops and removes all named animations and state machines
784
+ * @param animatables animations and state machines to remove
785
+ * @returns a list of names of removed items
786
+ */
787
+ Animator.prototype.stop = function (animatables) {
788
+ var _this = this;
789
+ animatables = mapToStringArray(animatables);
790
+ // If nothing's specified, wipe them out, all of them
791
+ var removedNames = [];
792
+ // Stop everything
793
+ if (animatables.length === 0) {
794
+ removedNames = this.animations.map(function (a) { return a.name; }).concat(this.stateMachines.map(function (m) { return m.name; }));
795
+ // Clean up before emptying the arrays
796
+ this.animations.forEach(function (a) { return a.cleanup(); });
797
+ this.stateMachines.forEach(function (m) { return m.cleanup(); });
798
+ // Empty out the arrays
799
+ this.animations.splice(0, this.animations.length);
800
+ this.stateMachines.splice(0, this.stateMachines.length);
801
+ }
802
+ else {
803
+ // Remove only the named animations/state machines
804
+ var animationsToRemove = this.animations.filter(function (a) { return animatables.includes(a.name); });
805
+ animationsToRemove.forEach(function (a) {
806
+ a.cleanup();
807
+ _this.animations.splice(_this.animations.indexOf(a), 1);
808
+ });
809
+ var machinesToRemove = this.stateMachines.filter(function (m) { return animatables.includes(m.name); });
810
+ machinesToRemove.forEach(function (m) {
811
+ m.cleanup();
812
+ _this.stateMachines.splice(_this.stateMachines.indexOf(m), 1);
813
+ });
814
+ removedNames = animationsToRemove.map(function (a) { return a.name; }).concat(machinesToRemove.map(function (m) { return m.name; }));
815
+ }
816
+ this.eventManager.fire({
817
+ type: EventType.Stop,
818
+ data: removedNames,
819
+ });
820
+ // Return the list of animations removed
821
+ return removedNames;
822
+ };
823
+ Object.defineProperty(Animator.prototype, "isPlaying", {
824
+ /**
825
+ * Returns true if at least one animation is active
826
+ */
827
+ get: function () {
828
+ return this.animations.reduce(function (acc, curr) { return acc || curr.playing; }, false)
829
+ || this.stateMachines.reduce(function (acc, curr) { return acc || curr.playing; }, false);
830
+ },
831
+ enumerable: false,
832
+ configurable: true
833
+ });
834
+ Object.defineProperty(Animator.prototype, "isPaused", {
835
+ /**
836
+ * Returns true if all animations are paused and there's at least one animation
837
+ */
838
+ get: function () {
839
+ return !this.isPlaying &&
840
+ (this.animations.length > 0 || this.stateMachines.length > 0);
841
+ },
842
+ enumerable: false,
843
+ configurable: true
844
+ });
845
+ Object.defineProperty(Animator.prototype, "isStopped", {
846
+ /**
847
+ * Returns true if there are no playing or paused animations/state machines
848
+ */
849
+ get: function () {
850
+ return this.animations.length === 0 && this.stateMachines.length === 0;
851
+ },
852
+ enumerable: false,
853
+ configurable: true
854
+ });
855
+ /**
856
+ * If there are no animations or state machines, add the first one found
857
+ * @returns the name of the animation or state machine instanced
858
+ */
859
+ Animator.prototype.atLeastOne = function (playing, fireEvent) {
860
+ if (fireEvent === void 0) { fireEvent = true; }
861
+ var instancedName;
862
+ if (this.animations.length === 0 && this.stateMachines.length === 0) {
863
+ if (this.artboard.animationCount() > 0) {
864
+ // Add the first animation
865
+ this.add([instancedName = this.artboard.animationByIndex(0).name], playing, fireEvent);
866
+ }
867
+ else if (this.artboard.stateMachineCount() > 0) {
868
+ // Add the first state machine
869
+ this.add([instancedName = this.artboard.stateMachineByIndex(0).name], playing, fireEvent);
870
+ }
871
+ }
872
+ return instancedName;
873
+ };
874
+ /**
875
+ * Checks if any animations have looped and if so, fire the appropriate event
876
+ */
877
+ Animator.prototype.handleLooping = function () {
878
+ for (var _i = 0, _a = this.animations.filter(function (a) { return a.playing; }); _i < _a.length; _i++) {
879
+ var animation = _a[_i];
880
+ // Emit if the animation looped
881
+ if (animation.loopValue === 0 && animation.loopCount) {
882
+ animation.loopCount = 0;
883
+ // This is a one-shot; if it has ended, delete the instance
884
+ this.stop(animation.name);
885
+ }
886
+ else if (animation.loopValue === 1 && animation.loopCount) {
887
+ this.eventManager.fire({
888
+ type: EventType.Loop,
889
+ data: { animation: animation.name, type: LoopType.Loop }
890
+ });
891
+ animation.loopCount = 0;
892
+ }
893
+ // Wasm indicates a loop at each time the animation
894
+ // changes direction, so a full loop/lap occurs every
895
+ // two loop counts
896
+ else if (animation.loopValue === 2 && animation.loopCount > 1) {
897
+ this.eventManager.fire({
898
+ type: EventType.Loop,
899
+ data: { animation: animation.name, type: LoopType.PingPong }
900
+ });
901
+ animation.loopCount = 0;
902
+ }
903
+ }
904
+ };
905
+ /**
906
+ * Checks if states have changed in state machines and fires a statechange
907
+ * event
908
+ */
909
+ Animator.prototype.handleStateChanges = function () {
910
+ var statesChanged = [];
911
+ for (var _i = 0, _a = this.stateMachines.filter(function (sm) { return sm.playing; }); _i < _a.length; _i++) {
912
+ var stateMachine = _a[_i];
913
+ statesChanged.push.apply(statesChanged, stateMachine.statesChanged);
914
+ }
915
+ if (statesChanged.length > 0) {
916
+ this.eventManager.fire({
917
+ type: EventType.StateChange,
918
+ data: statesChanged,
919
+ });
920
+ }
921
+ };
922
+ return Animator;
923
+ }());
924
+ // #endregion
925
+ // #region events
926
+ /**
927
+ * Supported event types triggered in Rive
928
+ */
929
+ var EventType;
930
+ (function (EventType) {
931
+ EventType["Load"] = "load";
932
+ EventType["LoadError"] = "loaderror";
933
+ EventType["Play"] = "play";
934
+ EventType["Pause"] = "pause";
935
+ EventType["Stop"] = "stop";
936
+ EventType["Loop"] = "loop";
937
+ EventType["Draw"] = "draw";
938
+ EventType["StateChange"] = "statechange";
939
+ })(EventType || (EventType = {}));
940
+ /**
941
+ * Looping types: one-shot, loop, and ping-pong
942
+ */
943
+ var LoopType;
944
+ (function (LoopType) {
945
+ LoopType["OneShot"] = "oneshot";
946
+ LoopType["Loop"] = "loop";
947
+ LoopType["PingPong"] = "pingpong"; // has value 2 in runtime
948
+ })(LoopType || (LoopType = {}));
949
+ // Manages Rive events and listeners
950
+ var EventManager = /** @class */ (function () {
951
+ function EventManager(listeners) {
952
+ if (listeners === void 0) { listeners = []; }
953
+ this.listeners = listeners;
954
+ }
955
+ // Gets listeners of specified type
956
+ EventManager.prototype.getListeners = function (type) {
957
+ return this.listeners.filter(function (e) { return e.type === type; });
958
+ };
959
+ // Adds a listener
960
+ EventManager.prototype.add = function (listener) {
961
+ if (!this.listeners.includes(listener)) {
962
+ this.listeners.push(listener);
963
+ }
964
+ };
965
+ /**
966
+ * Removes a listener
967
+ * @param listener the listener with the callback to be removed
968
+ */
969
+ EventManager.prototype.remove = function (listener) {
970
+ // We can't simply look for the listener as it'll be a different instance to
971
+ // one originally subscribed. Find all the listeners of the right type and
972
+ // then check their callbacks which should match.
973
+ for (var i = 0; i < this.listeners.length; i++) {
974
+ var currentListener = this.listeners[i];
975
+ if (currentListener.type === listener.type) {
976
+ if (currentListener.callback === listener.callback) {
977
+ this.listeners.splice(i, 1);
978
+ break;
979
+ }
980
+ }
981
+ }
982
+ };
983
+ /**
984
+ * Clears all listeners of specified type, or every listener if no type is
985
+ * specified
986
+ * @param type the type of listeners to clear, or all listeners if not
987
+ * specified
988
+ */
989
+ EventManager.prototype.removeAll = function (type) {
990
+ var _this = this;
991
+ if (!type) {
992
+ this.listeners.splice(0, this.listeners.length);
993
+ }
994
+ else {
995
+ this.listeners
996
+ .filter(function (l) { return l.type === type; })
997
+ .forEach(function (l) { return _this.remove(l); });
998
+ }
999
+ };
1000
+ // Fires an event
1001
+ EventManager.prototype.fire = function (event) {
1002
+ var eventListeners = this.getListeners(event.type);
1003
+ eventListeners.forEach(function (listener) { return listener.callback(event); });
1004
+ };
1005
+ return EventManager;
1006
+ }());
1007
+ // Manages a queue of tasks
1008
+ var TaskQueueManager = /** @class */ (function () {
1009
+ function TaskQueueManager(eventManager) {
1010
+ this.eventManager = eventManager;
1011
+ this.queue = [];
1012
+ }
1013
+ // Adds a task top the queue
1014
+ TaskQueueManager.prototype.add = function (task) {
1015
+ this.queue.push(task);
1016
+ };
1017
+ // Processes all tasks in the queue
1018
+ TaskQueueManager.prototype.process = function () {
1019
+ while (this.queue.length > 0) {
1020
+ var task = this.queue.shift();
1021
+ task === null || task === void 0 ? void 0 : task.action();
1022
+ if (task === null || task === void 0 ? void 0 : task.event) {
1023
+ this.eventManager.fire(task.event);
1024
+ }
1025
+ }
1026
+ };
1027
+ return TaskQueueManager;
1028
+ }());
1029
+ var Rive = /** @class */ (function () {
1030
+ function Rive(params) {
1031
+ var _a;
1032
+ // Flag to indicate if the layout has changed; used by the renderer to know
1033
+ // when to align
1034
+ this._updateLayout = true;
1035
+ /**
1036
+ * Flag to active/deactivate renderer
1037
+ */
1038
+ this.isRendererActive = true;
1039
+ // Tracks if a Rive file is loaded
1040
+ this.loaded = false;
1041
+ /**
1042
+ * Tracks if a Rive file is loaded; we need this in addition to loaded as some
1043
+ * commands (e.g. contents) can be called as soon as the file is loaded.
1044
+ * However, playback commands need to be queued and run in order once initial
1045
+ * animations and autoplay has been sorted out. This applies to play, pause,
1046
+ * and start.
1047
+ */
1048
+ this.readyForPlaying = false;
1049
+ // Runtime artboard
1050
+ this.artboard = null;
1051
+ /**
1052
+ * Used be draw to track when a second of active rendering time has passed. Used for debugging purposes
1053
+ */
1054
+ this.renderSecondTimer = 0;
1055
+ this.canvas = params.canvas;
1056
+ this.src = params.src;
1057
+ this.buffer = params.buffer;
1058
+ this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
1059
+ // New event management system
1060
+ this.eventManager = new EventManager();
1061
+ if (params.onLoad)
1062
+ this.on(EventType.Load, params.onLoad);
1063
+ if (params.onLoadError)
1064
+ this.on(EventType.LoadError, params.onLoadError);
1065
+ if (params.onPlay)
1066
+ this.on(EventType.Play, params.onPlay);
1067
+ if (params.onPause)
1068
+ this.on(EventType.Pause, params.onPause);
1069
+ if (params.onStop)
1070
+ this.on(EventType.Stop, params.onStop);
1071
+ if (params.onLoop)
1072
+ this.on(EventType.Loop, params.onLoop);
1073
+ if (params.onStateChange)
1074
+ this.on(EventType.StateChange, params.onStateChange);
1075
+ /**
1076
+ * @deprecated Use camelCase'd versions instead.
1077
+ */
1078
+ if (params.onload && !params.onLoad)
1079
+ this.on(EventType.Load, params.onload);
1080
+ if (params.onloaderror && !params.onLoadError)
1081
+ this.on(EventType.LoadError, params.onloaderror);
1082
+ if (params.onplay && !params.onPlay)
1083
+ this.on(EventType.Play, params.onplay);
1084
+ if (params.onpause && !params.onPause)
1085
+ this.on(EventType.Pause, params.onpause);
1086
+ if (params.onstop && !params.onStop)
1087
+ this.on(EventType.Stop, params.onstop);
1088
+ if (params.onloop && !params.onLoop)
1089
+ this.on(EventType.Loop, params.onloop);
1090
+ if (params.onstatechange && !params.onStateChange)
1091
+ this.on(EventType.StateChange, params.onstatechange);
1092
+ // Hook up the task queue
1093
+ this.taskQueue = new TaskQueueManager(this.eventManager);
1094
+ this.init({
1095
+ src: this.src,
1096
+ buffer: this.buffer,
1097
+ autoplay: params.autoplay,
1098
+ animations: params.animations,
1099
+ stateMachines: params.stateMachines,
1100
+ artboard: params.artboard
1101
+ });
1102
+ }
1103
+ // Alternative constructor to build a Rive instance from an interface/object
1104
+ Rive.new = function (params) {
1105
+ console.warn('This function is deprecated: please use `new Rive({})` instead');
1106
+ return new Rive(params);
1107
+ };
1108
+ // Initializes the Rive object either from constructor or load()
1109
+ Rive.prototype.init = function (_a) {
1110
+ var _this = this;
1111
+ var src = _a.src, buffer = _a.buffer, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b;
1112
+ this.src = src;
1113
+ this.buffer = buffer;
1114
+ // If no source file url specified, it's a bust
1115
+ if (!this.src && !this.buffer) {
1116
+ throw new Error(Rive.missingErrorMessage);
1117
+ }
1118
+ // List of animations that should be initialized.
1119
+ var startingAnimationNames = mapToStringArray(animations);
1120
+ // List of state machines that should be initialized
1121
+ var startingStateMachineNames = mapToStringArray(stateMachines);
1122
+ // Ensure loaded is marked as false if loading new file
1123
+ this.loaded = false;
1124
+ this.readyForPlaying = false;
1125
+ // Ensure the runtime is loaded
1126
+ RuntimeLoader.awaitInstance().then(function (runtime) {
1127
+ _this.runtime = runtime;
1128
+ // Load Rive data from a source uri or a data buffer
1129
+ _this.initData(artboard, startingAnimationNames, startingStateMachineNames, autoplay).catch(function (e) {
1130
+ console.error(e);
1131
+ });
1132
+ }).catch(function (e) {
1133
+ console.error(e);
1134
+ });
1135
+ };
1136
+ // Initializes runtime with Rive data and preps for playing
1137
+ Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
1138
+ var _a;
1139
+ return __awaiter(this, void 0, void 0, function () {
1140
+ var _b, _c, msg;
1141
+ return __generator(this, function (_d) {
1142
+ switch (_d.label) {
1143
+ case 0:
1144
+ if (!this.src) return [3 /*break*/, 2];
1145
+ _b = this;
1146
+ return [4 /*yield*/, loadRiveFile(this.src)];
1147
+ case 1:
1148
+ _b.buffer = _d.sent();
1149
+ _d.label = 2;
1150
+ case 2:
1151
+ // Load the Rive file
1152
+ _c = this;
1153
+ return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer))];
1154
+ case 3:
1155
+ // Load the Rive file
1156
+ _c.file = _d.sent();
1157
+ if (this.file) {
1158
+ // Initialize and draw frame
1159
+ this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay);
1160
+ // Everything's set up, emit a load event
1161
+ this.loaded = true;
1162
+ this.eventManager.fire({
1163
+ type: EventType.Load,
1164
+ data: (_a = this.src) !== null && _a !== void 0 ? _a : 'buffer'
1165
+ });
1166
+ // Flag ready for playback commands and clear the task queue; this order
1167
+ // is important or it may infinitely recurse
1168
+ this.readyForPlaying = true;
1169
+ this.taskQueue.process();
1170
+ this.drawFrame();
1171
+ return [2 /*return*/, Promise.resolve()];
1172
+ }
1173
+ else {
1174
+ msg = 'Problem loading file; may be corrupt!';
1175
+ console.warn(msg);
1176
+ this.eventManager.fire({ type: EventType.LoadError, data: msg });
1177
+ return [2 /*return*/, Promise.reject(msg)];
1178
+ }
1179
+ return [2 /*return*/];
1180
+ }
1181
+ });
1182
+ });
1183
+ };
1184
+ // Initialize for playback
1185
+ Rive.prototype.initArtboard = function (artboardName, animationNames, stateMachineNames, autoplay) {
1186
+ // Fetch the artboard
1187
+ var rootArtboard = artboardName ?
1188
+ this.file.artboardByName(artboardName) :
1189
+ this.file.defaultArtboard();
1190
+ // Check we have a working artboard
1191
+ if (!rootArtboard) {
1192
+ var msg = 'Invalid artboard name or no default artboard';
1193
+ console.warn(msg);
1194
+ this.eventManager.fire({ type: EventType.LoadError, data: msg });
1195
+ return;
1196
+ }
1197
+ // Instance the artboard
1198
+ this.artboard = rootArtboard.instance();
1199
+ // Check that the artboard has at least 1 animation
1200
+ if (this.artboard.animationCount() < 1) {
1201
+ var msg = 'Artboard has no animations';
1202
+ this.eventManager.fire({ type: EventType.LoadError, data: msg });
1203
+ throw msg;
1204
+ }
1205
+ // Initialize the animator
1206
+ this.animator = new Animator(this.runtime, this.artboard, this.eventManager);
1207
+ // Get the canvas where you want to render the animation and create a renderer
1208
+ this.renderer = this.runtime.makeRenderer(this.canvas);
1209
+ // Initialize the animations; as loaded hasn't happened yet, we need to
1210
+ // suppress firing the play/pause events until the load event has fired. To
1211
+ // do this we tell the animator to suppress firing events, and add event
1212
+ // firing to the task queue.
1213
+ var instanceNames;
1214
+ if (animationNames.length > 0 || stateMachineNames.length > 0) {
1215
+ instanceNames = animationNames.concat(stateMachineNames);
1216
+ this.animator.add(instanceNames, autoplay, false);
1217
+ }
1218
+ else {
1219
+ instanceNames = [this.animator.atLeastOne(autoplay, false)];
1220
+ }
1221
+ // Queue up firing the playback events
1222
+ this.taskQueue.add({
1223
+ action: function () { },
1224
+ event: {
1225
+ type: autoplay ? EventType.Play : EventType.Pause,
1226
+ data: instanceNames,
1227
+ }
1228
+ });
1229
+ };
1230
+ // Draws the current artboard frame
1231
+ Rive.prototype.drawFrame = function () {
1232
+ this.startRendering();
1233
+ };
1234
+ /**
1235
+ * Draw rendering loop; renders animation frames at the correct time interval.
1236
+ * @param time the time at which to render a frame
1237
+ */
1238
+ Rive.prototype.draw = function (time, onSecond) {
1239
+ // Clear the frameRequestId, as we're now rendering a fresh frame
1240
+ this.frameRequestId = null;
1241
+ // On the first pass, make sure lastTime has a valid value
1242
+ if (!this.lastRenderTime) {
1243
+ this.lastRenderTime = time;
1244
+ }
1245
+ // Handle the onSecond callback
1246
+ this.renderSecondTimer += (time - this.lastRenderTime);
1247
+ if (this.renderSecondTimer > 5000) {
1248
+ this.renderSecondTimer = 0;
1249
+ onSecond === null || onSecond === void 0 ? void 0 : onSecond();
1250
+ }
1251
+ // Calculate the elapsed time between frames in seconds
1252
+ var elapsedTime = (time - this.lastRenderTime) / 1000;
1253
+ this.lastRenderTime = time;
1254
+ // Advance non-paused animations by the elapsed number of seconds
1255
+ // Also advance any animations that require scrubbing
1256
+ var activeAnimations = this.animator.animations.filter(function (a) { return a.playing || a.needsScrub; })
1257
+ // The scrubbed animations must be applied first to prevent weird artifacts
1258
+ // if the playing animations conflict with the scrubbed animating attribuates.
1259
+ .sort(function (first, second) { return first.needsScrub ? -1 : 1; });
1260
+ for (var _i = 0, activeAnimations_1 = activeAnimations; _i < activeAnimations_1.length; _i++) {
1261
+ var animation = activeAnimations_1[_i];
1262
+ animation.advance(elapsedTime);
1263
+ if (animation.instance.didLoop) {
1264
+ animation.loopCount += 1;
1265
+ }
1266
+ animation.instance.apply(this.artboard, 1.0);
1267
+ }
1268
+ // Advance non-paused state machines by the elapsed number of seconds
1269
+ var activeStateMachines = this.animator.stateMachines.filter(function (a) { return a.playing; });
1270
+ for (var _a = 0, activeStateMachines_1 = activeStateMachines; _a < activeStateMachines_1.length; _a++) {
1271
+ var stateMachine = activeStateMachines_1[_a];
1272
+ stateMachine.instance.advance(this.artboard, elapsedTime);
1273
+ // stateMachine.instance.apply(this.artboard);
1274
+ }
1275
+ // Once the animations have been applied to the artboard, advance it
1276
+ // by the elapsed time.
1277
+ this.artboard.advance(elapsedTime);
1278
+ var renderer = this.renderer;
1279
+ renderer.save();
1280
+ // Update the renderer alignment if necessary
1281
+ this.alignRenderer();
1282
+ this.artboard.draw(renderer);
1283
+ renderer.restore();
1284
+ renderer.flush();
1285
+ // Check for any animations that looped
1286
+ this.animator.handleLooping();
1287
+ // Check for any state machines that had a state change
1288
+ this.animator.handleStateChanges();
1289
+ // Calling requestAnimationFrame will rerun draw() at the correct rate:
1290
+ // https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations
1291
+ if (this.animator.isPlaying) {
1292
+ // Request a new rendering frame
1293
+ this.startRendering();
1294
+ }
1295
+ else if (this.animator.isPaused) {
1296
+ // Reset the end time so on playback it starts at the correct frame
1297
+ this.lastRenderTime = 0;
1298
+ }
1299
+ else if (this.animator.isStopped) {
1300
+ // Reset animation instances, artboard and time
1301
+ // TODO: implement this properly when we have instancing
1302
+ // this.initArtboard();
1303
+ // this.drawFrame();
1304
+ this.lastRenderTime = 0;
1305
+ }
1306
+ };
1307
+ /**
1308
+ * Align the renderer
1309
+ */
1310
+ Rive.prototype.alignRenderer = function () {
1311
+ var _a = this, renderer = _a.renderer, runtime = _a.runtime, _layout = _a._layout, artboard = _a.artboard;
1312
+ // Canvas must be wiped to prevent artifacts
1313
+ renderer.clear();
1314
+ // Now save so that future changes to align can restore
1315
+ renderer.save();
1316
+ // Align things up safe in the knowledge we can restore if changed
1317
+ renderer.align(_layout.runtimeFit(runtime), _layout.runtimeAlignment(runtime), {
1318
+ minX: _layout.minX,
1319
+ minY: _layout.minY,
1320
+ maxX: _layout.maxX,
1321
+ maxY: _layout.maxY
1322
+ }, artboard.bounds);
1323
+ };
1324
+ /**
1325
+ * Cleans up any Wasm-generated objects that need to be manually destroyed:
1326
+ * artboard instances, animation instances, state machine instances.
1327
+ *
1328
+ * Once this is called, things will need to be reinitialized or bad things
1329
+ * might happen.
1330
+ */
1331
+ Rive.prototype.cleanup = function () {
1332
+ this.artboard.delete();
1333
+ // TODO: delete animation and state machine instances
1334
+ };
1335
+ // Plays specified animations; if none specified, it unpauses everything.
1336
+ Rive.prototype.play = function (animationNames, autoplay) {
1337
+ var _this = this;
1338
+ animationNames = mapToStringArray(animationNames);
1339
+ // If the file's not loaded, queue up the play
1340
+ if (!this.readyForPlaying) {
1341
+ this.taskQueue.add({
1342
+ action: function () { return _this.play(animationNames, autoplay); },
1343
+ });
1344
+ return;
1345
+ }
1346
+ this.animator.play(animationNames);
1347
+ this.startRendering();
1348
+ };
1349
+ // Pauses specified animations; if none specified, pauses all.
1350
+ Rive.prototype.pause = function (animationNames) {
1351
+ var _this = this;
1352
+ animationNames = mapToStringArray(animationNames);
1353
+ // If the file's not loaded, early out, nothing to pause
1354
+ if (!this.readyForPlaying) {
1355
+ this.taskQueue.add({
1356
+ action: function () { return _this.pause(animationNames); },
1357
+ });
1358
+ return;
1359
+ }
1360
+ this.animator.pause(animationNames);
1361
+ };
1362
+ Rive.prototype.scrub = function (animationNames, value) {
1363
+ var _this = this;
1364
+ animationNames = mapToStringArray(animationNames);
1365
+ // If the file's not loaded, early out, nothing to pause
1366
+ if (!this.readyForPlaying) {
1367
+ this.taskQueue.add({
1368
+ action: function () { return _this.scrub(animationNames, value); },
1369
+ });
1370
+ return;
1371
+ }
1372
+ // Scrub the animation time; we draw a single frame here so that if
1373
+ // nothing's currently playing, the scrubbed animation is still rendered/
1374
+ this.animator.scrub(animationNames, value || 0);
1375
+ this.drawFrame();
1376
+ };
1377
+ // Stops specified animations; if none specifies, stops them all.
1378
+ Rive.prototype.stop = function (animationNames) {
1379
+ var _this = this;
1380
+ animationNames = mapToStringArray(animationNames);
1381
+ // If the file's not loaded, early out, nothing to pause
1382
+ if (!this.readyForPlaying) {
1383
+ this.taskQueue.add({
1384
+ action: function () { return _this.stop(animationNames); },
1385
+ });
1386
+ return;
1387
+ }
1388
+ this.animator.stop(animationNames);
1389
+ };
1390
+ /**
1391
+ * Resets the animation
1392
+ * @param artboard the name of the artboard, or default if none given
1393
+ * @param animations the names of animations for playback
1394
+ * @param stateMachines the names of state machines for playback
1395
+ * @param autoplay whether to autoplay when reset, defaults to false
1396
+ *
1397
+ */
1398
+ Rive.prototype.reset = function (params) {
1399
+ var _a;
1400
+ // Get the current artboard, animations, state machines, and playback states
1401
+ var artBoardName = params === null || params === void 0 ? void 0 : params.artboard;
1402
+ var animationNames = mapToStringArray(params === null || params === void 0 ? void 0 : params.animations);
1403
+ var stateMachineNames = mapToStringArray(params === null || params === void 0 ? void 0 : params.stateMachines);
1404
+ var autoplay = (_a = params === null || params === void 0 ? void 0 : params.autoplay) !== null && _a !== void 0 ? _a : false;
1405
+ // Stop everything and clean up
1406
+ this.stop();
1407
+ this.cleanup();
1408
+ // Reinitialize an artboard instance with the state
1409
+ this.initArtboard(artBoardName, animationNames, stateMachineNames, autoplay);
1410
+ };
1411
+ // Loads a new Rive file, keeping listeners in place
1412
+ Rive.prototype.load = function (params) {
1413
+ // Stop all animations
1414
+ this.stop();
1415
+ // Reinitialize
1416
+ this.init(params);
1417
+ };
1418
+ Object.defineProperty(Rive.prototype, "layout", {
1419
+ /**
1420
+ * Returns the current layout. Note that layout should be treated as
1421
+ * immutable. If you want to change the layout, create a new one use the
1422
+ * layout setter
1423
+ */
1424
+ get: function () {
1425
+ return this._layout;
1426
+ },
1427
+ // Sets a new layout
1428
+ set: function (layout) {
1429
+ this._layout = layout;
1430
+ // If the maxX or maxY are 0, then set them to the canvas width and height
1431
+ if (!layout.maxX || !layout.maxY) {
1432
+ this.resizeToCanvas();
1433
+ }
1434
+ if (this.loaded && !this.animator.isPlaying) {
1435
+ this.drawFrame();
1436
+ }
1437
+ },
1438
+ enumerable: false,
1439
+ configurable: true
1440
+ });
1441
+ /**
1442
+ * Sets the layout bounds to the current canvas size; this is typically called
1443
+ * when the canvas is resized
1444
+ */
1445
+ Rive.prototype.resizeToCanvas = function () {
1446
+ this._layout = this.layout.copyWith({
1447
+ minX: 0,
1448
+ minY: 0,
1449
+ maxX: this.canvas.width,
1450
+ maxY: this.canvas.height
1451
+ });
1452
+ };
1453
+ Object.defineProperty(Rive.prototype, "source", {
1454
+ // Returns the animation source, which may be undefined
1455
+ get: function () {
1456
+ return this.src;
1457
+ },
1458
+ enumerable: false,
1459
+ configurable: true
1460
+ });
1461
+ Object.defineProperty(Rive.prototype, "activeArtboard", {
1462
+ /**
1463
+ * Returns the name of the active artboard
1464
+ */
1465
+ get: function () {
1466
+ return this.artboard.name;
1467
+ },
1468
+ enumerable: false,
1469
+ configurable: true
1470
+ });
1471
+ Object.defineProperty(Rive.prototype, "animationNames", {
1472
+ // Returns a list of animation names on the chosen artboard
1473
+ get: function () {
1474
+ // If the file's not loaded, we got nothing to return
1475
+ if (!this.loaded) {
1476
+ return [];
1477
+ }
1478
+ var animationNames = [];
1479
+ for (var i = 0; i < this.artboard.animationCount(); i++) {
1480
+ animationNames.push(this.artboard.animationByIndex(i).name);
1481
+ }
1482
+ return animationNames;
1483
+ },
1484
+ enumerable: false,
1485
+ configurable: true
1486
+ });
1487
+ Object.defineProperty(Rive.prototype, "stateMachineNames", {
1488
+ /**
1489
+ * Returns a list of state machine names from the current artboard
1490
+ */
1491
+ get: function () {
1492
+ // If the file's not loaded, we got nothing to return
1493
+ if (!this.loaded) {
1494
+ return [];
1495
+ }
1496
+ var stateMachineNames = [];
1497
+ for (var i = 0; i < this.artboard.stateMachineCount(); i++) {
1498
+ stateMachineNames.push(this.artboard.stateMachineByIndex(i).name);
1499
+ }
1500
+ return stateMachineNames;
1501
+ },
1502
+ enumerable: false,
1503
+ configurable: true
1504
+ });
1505
+ /**
1506
+ * Returns the inputs for the specified instanced state machine, or an empty
1507
+ * list if the name is invalid or the state machine is not instanced
1508
+ * @param name the state machine name
1509
+ * @returns the inputs for the named state machine
1510
+ */
1511
+ Rive.prototype.stateMachineInputs = function (name) {
1512
+ // If the file's not loaded, early out, nothing to pause
1513
+ if (!this.loaded) {
1514
+ return;
1515
+ }
1516
+ var stateMachine = this.animator.stateMachines.find(function (m) { return m.name === name; });
1517
+ return stateMachine === null || stateMachine === void 0 ? void 0 : stateMachine.inputs;
1518
+ };
1519
+ Object.defineProperty(Rive.prototype, "playingStateMachineNames", {
1520
+ // Returns a list of playing machine names
1521
+ get: function () {
1522
+ // If the file's not loaded, we got nothing to return
1523
+ if (!this.loaded) {
1524
+ return [];
1525
+ }
1526
+ return this.animator.stateMachines
1527
+ .filter(function (m) { return m.playing; })
1528
+ .map(function (m) { return m.name; });
1529
+ },
1530
+ enumerable: false,
1531
+ configurable: true
1532
+ });
1533
+ Object.defineProperty(Rive.prototype, "playingAnimationNames", {
1534
+ // Returns a list of playing animation names
1535
+ get: function () {
1536
+ // If the file's not loaded, we got nothing to return
1537
+ if (!this.loaded) {
1538
+ return [];
1539
+ }
1540
+ return this.animator.animations
1541
+ .filter(function (a) { return a.playing; })
1542
+ .map(function (a) { return a.name; });
1543
+ },
1544
+ enumerable: false,
1545
+ configurable: true
1546
+ });
1547
+ Object.defineProperty(Rive.prototype, "pausedAnimationNames", {
1548
+ // Returns a list of paused animation names
1549
+ get: function () {
1550
+ // If the file's not loaded, we got nothing to return
1551
+ if (!this.loaded) {
1552
+ return [];
1553
+ }
1554
+ return this.animator.animations
1555
+ .filter(function (a) { return !a.playing; })
1556
+ .map(function (a) { return a.name; });
1557
+ },
1558
+ enumerable: false,
1559
+ configurable: true
1560
+ });
1561
+ Object.defineProperty(Rive.prototype, "pausedStateMachineNames", {
1562
+ /**
1563
+ * Returns a list of paused machine names
1564
+ * @returns a list of state machine names that are paused
1565
+ */
1566
+ get: function () {
1567
+ // If the file's not loaded, we got nothing to return
1568
+ if (!this.loaded) {
1569
+ return [];
1570
+ }
1571
+ return this.animator.stateMachines
1572
+ .filter(function (m) { return !m.playing; })
1573
+ .map(function (m) { return m.name; });
1574
+ },
1575
+ enumerable: false,
1576
+ configurable: true
1577
+ });
1578
+ Object.defineProperty(Rive.prototype, "isPlaying", {
1579
+ /**
1580
+ * @returns true if any animation is playing
1581
+ */
1582
+ get: function () {
1583
+ return this.animator.isPlaying;
1584
+ },
1585
+ enumerable: false,
1586
+ configurable: true
1587
+ });
1588
+ Object.defineProperty(Rive.prototype, "isPaused", {
1589
+ /**
1590
+ * @returns true if all instanced animations are paused
1591
+ */
1592
+ get: function () {
1593
+ return this.animator.isPaused;
1594
+ },
1595
+ enumerable: false,
1596
+ configurable: true
1597
+ });
1598
+ Object.defineProperty(Rive.prototype, "isStopped", {
1599
+ /**
1600
+ * @returns true if no animations are playing or paused
1601
+ */
1602
+ get: function () {
1603
+ return this.animator.isStopped;
1604
+ },
1605
+ enumerable: false,
1606
+ configurable: true
1607
+ });
1608
+ Object.defineProperty(Rive.prototype, "bounds", {
1609
+ /**
1610
+ * @returns the bounds of the current artboard, or undefined if the artboard
1611
+ * isn't loaded yet.
1612
+ */
1613
+ get: function () {
1614
+ return this.artboard ? this.artboard.bounds : undefined;
1615
+ },
1616
+ enumerable: false,
1617
+ configurable: true
1618
+ });
1619
+ /**
1620
+ * Subscribe to Rive-generated events
1621
+ * @param type the type of event to subscribe to
1622
+ * @param callback callback to fire when the event occurs
1623
+ */
1624
+ Rive.prototype.on = function (type, callback) {
1625
+ this.eventManager.add({
1626
+ type: type,
1627
+ callback: callback,
1628
+ });
1629
+ };
1630
+ /**
1631
+ * Unsubscribes from a Rive-generated event
1632
+ * @param callback the callback to unsubscribe from
1633
+ */
1634
+ Rive.prototype.unsubscribe = function (type, callback) {
1635
+ this.eventManager.remove({
1636
+ type: type,
1637
+ callback: callback,
1638
+ });
1639
+ };
1640
+ /**
1641
+ * Unsubscribes all listeners from an event type, or everything if no type is
1642
+ * given
1643
+ * @param type the type of event to unsubscribe from, or all types if
1644
+ * undefined
1645
+ */
1646
+ Rive.prototype.unsubscribeAll = function (type) {
1647
+ this.eventManager.removeAll(type);
1648
+ };
1649
+ /**
1650
+ * Stops the rendering loop; this is different from pausing in that it doesn't
1651
+ * change the state of any animation. It stops rendering from occurring. This
1652
+ * is designed for situations such as when Rive isn't visible.
1653
+ *
1654
+ * The only way to start rendering again is to call `startRendering`.
1655
+ * Animations that are marked as playing will start from the position that
1656
+ * they would have been at if rendering had not been stopped.
1657
+ */
1658
+ Rive.prototype.stopRendering = function () {
1659
+ if (this.loaded && this.frameRequestId) {
1660
+ cancelAnimationFrame(this.frameRequestId);
1661
+ this.frameRequestId = null;
1662
+ }
1663
+ };
1664
+ /**
1665
+ * Starts the rendering loop if it has been previously stopped. If the
1666
+ * renderer is already active, then this will have zero effect.
1667
+ */
1668
+ Rive.prototype.startRendering = function () {
1669
+ if (this.loaded && !this.frameRequestId) {
1670
+ this.frameRequestId = requestAnimationFrame(this.draw.bind(this));
1671
+ }
1672
+ };
1673
+ Object.defineProperty(Rive.prototype, "contents", {
1674
+ /**
1675
+ * Returns the contents of a Rive file: the artboards, animations, and state machines
1676
+ */
1677
+ get: function () {
1678
+ if (!this.loaded) {
1679
+ return undefined;
1680
+ }
1681
+ var riveContents = {
1682
+ artboards: [],
1683
+ };
1684
+ for (var i = 0; i < this.file.artboardCount(); i++) {
1685
+ var artboard = this.file.artboardByIndex(i);
1686
+ var artboardContents = {
1687
+ name: artboard.name,
1688
+ animations: [],
1689
+ stateMachines: [],
1690
+ };
1691
+ for (var j = 0; j < artboard.animationCount(); j++) {
1692
+ var animation = artboard.animationByIndex(j);
1693
+ artboardContents.animations.push(animation.name);
1694
+ }
1695
+ for (var k = 0; k < artboard.stateMachineCount(); k++) {
1696
+ var stateMachine = artboard.stateMachineByIndex(k);
1697
+ var name_1 = stateMachine.name;
1698
+ var instance = new this.runtime.StateMachineInstance(stateMachine);
1699
+ var inputContents = [];
1700
+ for (var l = 0; l < instance.inputCount(); l++) {
1701
+ var input = instance.input(l);
1702
+ inputContents.push({ name: input.name, type: input.type });
1703
+ }
1704
+ artboardContents.stateMachines.push({ name: name_1, inputs: inputContents });
1705
+ }
1706
+ riveContents.artboards.push(artboardContents);
1707
+ }
1708
+ return riveContents;
1709
+ },
1710
+ enumerable: false,
1711
+ configurable: true
1712
+ });
1713
+ // Error message for missing source or buffer
1714
+ Rive.missingErrorMessage = 'Rive source file or data buffer required';
1715
+ return Rive;
1716
+ }());
1717
+
1718
+ // Loads Rive data from a URI via fetch.
1719
+ var loadRiveFile = function (src) { return __awaiter(void 0, void 0, void 0, function () {
1720
+ var req, res, buffer;
1721
+ return __generator(this, function (_a) {
1722
+ switch (_a.label) {
1723
+ case 0:
1724
+ req = new Request(src);
1725
+ return [4 /*yield*/, fetch(req)];
1726
+ case 1:
1727
+ res = _a.sent();
1728
+ return [4 /*yield*/, res.arrayBuffer()];
1729
+ case 2:
1730
+ buffer = _a.sent();
1731
+ return [2 /*return*/, buffer];
1732
+ }
1733
+ });
1734
+ }); };
1735
+ // #endregion
1736
+ // #region utility functions
1737
+ /*
1738
+ * Utility function to ensure an object is a string array
1739
+ */
1740
+ var mapToStringArray = function (obj) {
1741
+ if (typeof obj === 'string') {
1742
+ return [obj];
1743
+ }
1744
+ else if (obj instanceof Array) {
1745
+ return obj;
1746
+ }
1747
+ // If obj is undefined, return empty array
1748
+ return [];
1749
+ };
1750
+ // #endregion
1751
+ // #region testing utilities
1752
+ // Exports to only be used for tests
1753
+ var Testing = {
1754
+ EventManager: EventManager,
1755
+ TaskQueueManager: TaskQueueManager,
1756
+ };
1757
+ // #endregion
1758
+
1759
+ })();
1760
+
1761
+ /******/ return __webpack_exports__;
1762
+ /******/ })()
1763
+ ;
1764
+ });
1765
+ //# sourceMappingURL=rive.js.map