UNPKG

@rive-app/canvas-lite

Version:

A lite version of Rive's canvas based web api.

1,512 lines (1,493 loc) 304 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["rive"] = factory(); else root["rive"] = factory(); })(this, () => { return /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ([ /* 0 */, /* 1 */ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Animation: () => (/* reexport safe */ _Animation__WEBPACK_IMPORTED_MODULE_0__.Animation) /* harmony export */ }); /* harmony import */ var _Animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); /***/ }), /* 2 */ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Animation: () => (/* binding */ Animation) /* harmony export */ }); /** * Represents an animation that can be played on an Artboard. * Wraps animations and instances from the runtime and keeps track of playback state. * * The `Animation` class manages the state and behavior of a single animation instance, * including its current time, loop count, and ability to scrub to a specific time. * * The class provides methods to advance the animation, apply its interpolated keyframe * values to the Artboard, and clean up the underlying animation instance when the * animation is no longer needed. */ var Animation = /** @class */ (function () { /** * Constructs a new animation * @constructor * @param {any} animation: runtime animation object * @param {any} instance: runtime animation instance object */ function Animation(animation, artboard, runtime, playing) { this.animation = animation; this.artboard = artboard; this.playing = playing; this.loopCount = 0; /** * The time to which the animation should move to on the next render. * If not null, the animation will scrub to this time instead of advancing by the given time. */ this.scrubTo = null; this.instance = new runtime.LinearAnimationInstance(animation, artboard); } Object.defineProperty(Animation.prototype, "name", { /** * Returns the animation's name */ get: function () { return this.animation.name; }, enumerable: false, configurable: true }); Object.defineProperty(Animation.prototype, "time", { /** * Returns the animation's name */ get: function () { return this.instance.time; }, /** * Sets the animation's current time */ set: function (value) { this.instance.time = value; }, enumerable: false, configurable: true }); Object.defineProperty(Animation.prototype, "loopValue", { /** * Returns the animation's loop type */ get: function () { return this.animation.loopValue; }, enumerable: false, configurable: true }); Object.defineProperty(Animation.prototype, "needsScrub", { /** * Indicates whether the animation needs to be scrubbed. * @returns `true` if the animation needs to be scrubbed, `false` otherwise. */ get: function () { return this.scrubTo !== null; }, enumerable: false, configurable: true }); /** * Advances the animation by the give time. If the animation needs scrubbing, * time is ignored and the stored scrub value is used. * @param time the time to advance the animation by if no scrubbing required */ Animation.prototype.advance = function (time) { if (this.scrubTo === null) { this.instance.advance(time); } else { this.instance.time = 0; this.instance.advance(this.scrubTo); this.scrubTo = null; } }; /** * Apply interpolated keyframe values to the artboard. This should be called after calling * .advance() on an animation instance so that new values are applied to properties. * * Note: This does not advance the artboard, which updates all objects on the artboard * @param mix - Mix value for the animation from 0 to 1 */ Animation.prototype.apply = function (mix) { this.instance.apply(mix); }; /** * Deletes the backing Wasm animation instance; once this is called, this * animation is no more. */ Animation.prototype.cleanup = function () { this.instance.delete(); }; return Animation; }()); /***/ }), /* 3 */ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ RuntimeLoader: () => (/* binding */ RuntimeLoader) /* harmony export */ }); /* harmony import */ var _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4); /* harmony import */ var package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5); var __assign = (undefined && undefined.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; // Runtime singleton; use getInstance to provide a callback that returns the // Rive runtime var RuntimeLoader = /** @class */ (function () { // Class is never instantiated function RuntimeLoader() { } // Rejects all pending awaitInstance() promises and resets loading state so // the next call to getInstance() / awaitInstance() can retry with a new URL. RuntimeLoader.notifyError = function (error) { var _a; RuntimeLoader.isLoading = false; while (RuntimeLoader.errorCallbackQueue.length > 0) { (_a = RuntimeLoader.errorCallbackQueue.shift()) === null || _a === void 0 ? void 0 : _a(error); } RuntimeLoader.callBackQueue = []; }; // Loads the runtime RuntimeLoader.loadRuntime = function () { // Capture the URL at call time so the catch closure always refers to the // URL this particular attempt used, even if wasmURL is mutated for a retry. var attemptedUrl = RuntimeLoader.wasmURL; var wasmBinary = RuntimeLoader.wasmBinary; if (RuntimeLoader.enablePerfMarks) performance.mark('rive:wasm-init:start'); _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__["default"](__assign({ // Loads Wasm bundle locateFile: function () { return attemptedUrl; } }, (wasmBinary ? { wasmBinary: wasmBinary } : {}))) .then(function (rive) { var _a; if (RuntimeLoader.enablePerfMarks) { performance.mark('rive:wasm-init:end'); performance.measure('rive:wasm-init', 'rive:wasm-init:start', 'rive:wasm-init:end'); } RuntimeLoader.runtime = rive; RuntimeLoader.errorCallbackQueue = []; // Fire all the callbacks while (RuntimeLoader.callBackQueue.length > 0) { (_a = RuntimeLoader.callBackQueue.shift()) === null || _a === void 0 ? void 0 : _a(RuntimeLoader.runtime); } }) .catch(function (error) { // Capture specific error details var errorDetails = { message: (error === null || error === void 0 ? void 0 : error.message) || "Unknown error", type: (error === null || error === void 0 ? void 0 : error.name) || "Error", // Some browsers may provide additional WebAssembly-specific details wasmError: error instanceof WebAssembly.CompileError || error instanceof WebAssembly.RuntimeError, originalError: error, }; // Log detailed error for debugging console.debug("Rive WASM load error details:", errorDetails); // In case the primary URL fails, or the wasm was not supported, try the // fallback URL (a rive_fallback.wasm compiled for older architectures). // The fallback can be customised or disabled via setWasmFallbackUrl(). // TODO: (Gordon): preemptively test browser support and load the correct wasm file. Then use the fallback only if the primary fails. var fallbackUrl = RuntimeLoader.wasmFallbackURL; var alreadyOnFallback = fallbackUrl !== null && attemptedUrl.toLowerCase() === fallbackUrl.toLowerCase(); if (fallbackUrl !== null && !alreadyOnFallback) { console.warn("Failed to load WASM from ".concat(attemptedUrl, " (").concat(errorDetails.message, "), trying fallback URL: ").concat(fallbackUrl)); // Clear wasmBinary so the retry actually fetches via locateFile // instead of re-using the same (failing) in-memory binary. RuntimeLoader.wasmBinary = null; RuntimeLoader.setWasmUrl(fallbackUrl); RuntimeLoader.loadRuntime(); } else { // When alreadyOnFallback is true, wasmURL has already been overwritten // with the fallback URL, so we can no longer recover the original // primary URL here. The primary URL was logged in the earlier warning. var triedUrls = alreadyOnFallback ? "the configured WASM URL or its fallback (".concat(fallbackUrl, ")") : attemptedUrl; var errorMessage = [ "Could not load Rive WASM file from ".concat(triedUrls, "."), "Possible reasons:", "- Network connection is down", "- WebAssembly is not supported in this environment", "- The WASM file is corrupted or incompatible", "\nError details:", "- Type: ".concat(errorDetails.type), "- Message: ".concat(errorDetails.message), "- WebAssembly-specific error: ".concat(errorDetails.wasmError), "\nTo resolve, you may need to:", "1. Check your network connection", "2. Set a new WASM source via RuntimeLoader.setWasmUrl()", "3. Call RuntimeLoader.awaitInstance() again", ].join("\n"); console.error(errorMessage); RuntimeLoader.notifyError(new Error(errorMessage)); } }); }; // Provides a runtime instance via a callback RuntimeLoader.getInstance = function (callback, onError) { // If it's not loading, start loading runtime if (!RuntimeLoader.isLoading) { RuntimeLoader.isLoading = true; RuntimeLoader.loadRuntime(); } if (!RuntimeLoader.runtime) { RuntimeLoader.callBackQueue.push(callback); if (onError) { RuntimeLoader.errorCallbackQueue.push(onError); } } else { callback(RuntimeLoader.runtime); } }; // Provides a runtime instance via a promise; rejects if WASM fails to load. RuntimeLoader.awaitInstance = function () { return new Promise(function (resolve, reject) { return RuntimeLoader.getInstance(resolve, reject); }); }; // Manually sets the wasm url RuntimeLoader.setWasmUrl = function (url) { RuntimeLoader.wasmURL = url; }; // Gets the current wasm url RuntimeLoader.getWasmUrl = function () { return RuntimeLoader.wasmURL; }; /** * Sets the URL used as a fallback when the primary WASM URL fails to load. * Pass `null` to disable the fallback entirely. * * Defaults to pulling from the jsdelivr CDN. */ RuntimeLoader.setWasmFallbackUrl = function (url) { RuntimeLoader.wasmFallbackURL = url; }; // Gets the current fallback wasm url (null means fallback is disabled) RuntimeLoader.getWasmFallbackUrl = function () { return RuntimeLoader.wasmFallbackURL; }; // Manually sets the wasm binary or clears it with null RuntimeLoader.setWasmBinary = function (value) { if ((value instanceof ArrayBuffer) || value === null) { RuntimeLoader.wasmBinary = value; return; } console.error("setWasmBinary expects an ArrayBuffer or null"); }; // Gets the current wasm build as ArrayBuffer or null RuntimeLoader.getWasmBinary = function () { return RuntimeLoader.wasmBinary; }; // Flag to indicate that loading has started/completed RuntimeLoader.isLoading = false; // List of callbacks for the runtime that come in while loading RuntimeLoader.callBackQueue = []; // Path to the Wasm file; default path works for testing only; // if embedded wasm is used then this is never used. RuntimeLoader.wasmURL = "https://unpkg.com/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive.wasm"); // Fallback WASM URL tried when the primary URL fails. Set to null to disable // the fallback entirely. Defaults to pulling from the jsdelivr CDN. RuntimeLoader.wasmFallbackURL = "https://cdn.jsdelivr.net/npm/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive_fallback.wasm"); RuntimeLoader.wasmBinary = null; // Error callbacks enqueued from .getInstance() RuntimeLoader.errorCallbackQueue = []; /** * When true, performance.mark / performance.measure entries are emitted for * WASM initialization. */ RuntimeLoader.enablePerfMarks = false; return RuntimeLoader; }()); /***/ }), /* 4 */ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); var Rive = (() => { var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined; return ( function(moduleArg = {}) { var moduleRtn; var k = moduleArg, aa, ba, da = new Promise((b, a) => { aa = b; ba = a; }), ea = "object" == typeof window, fa = "function" == typeof importScripts; function ka() { function b(l) { const h = d; c = a = 0; d = new Map(); h.forEach(n => { try { n(l); } catch (m) { console.error(m); } }); this.va(); e && e.Pa(); } let a = 0, c = 0, d = new Map(), e = null, f = null; this.requestAnimationFrame = function(l) { a ||= requestAnimationFrame(b.bind(this)); const h = ++c; d.set(h, l); return h; }; this.cancelAnimationFrame = function(l) { d.delete(l); a && 0 == d.size && (cancelAnimationFrame(a), a = 0); }; this.Na = function(l) { f && (document.body.remove(f), f = null); l || (f = document.createElement("div"), f.style.backgroundColor = "black", f.style.position = "fixed", f.style.right = 0, f.style.top = 0, f.style.color = "white", f.style.padding = "4px", f.innerHTML = "RIVE FPS", l = function(h) { f.innerHTML = "RIVE FPS " + h.toFixed(1); }, document.body.appendChild(f)); e = new function() { let h = 0, n = 0; this.Pa = function() { var m = performance.now(); n ? (++h, m -= n, 1000 < m && (l(1000 * h / m), h = n = 0)) : (n = m, h = 0); }; }(); }; this.Ka = function() { f && (document.body.remove(f), f = null); e = null; }; this.va = function() { }; } function la(b) { console.assert(!0); const a = new Map(); let c = -Infinity; this.push = function(d) { d = d + ((1 << b) - 1) >> b; a.has(d) && clearTimeout(a.get(d)); a.set(d, setTimeout(function() { a.delete(d); 0 == a.length ? c = -Infinity : d == c && (c = Math.max(...a.keys()), console.assert(c < d)); }, 1000)); c = Math.max(d, c); return c << b; }; } const ma = k.onRuntimeInitialized; k.onRuntimeInitialized = function() { ma && ma(); let b = k.decodeAudio; k.decodeAudio = function(f, l) { f = b(f); l(f); }; let a = k.decodeFont; k.decodeFont = function(f, l) { f = a(f); l(f); }; let c = k.setFallbackFontCb; k.setFallbackFontCallback = "function" === typeof c ? function(f) { c(f); } : function() { console.warn("Module.setFallbackFontCallback called, but text support is not enabled in this build."); }; const d = k.FileAssetLoader; k.ptrToAsset = f => { let l = k.ptrToFileAsset(f); return l.isImage ? k.ptrToImageAsset(f) : l.isFont ? k.ptrToFontAsset(f) : l.isAudio ? k.ptrToAudioAsset(f) : l; }; k.CustomFileAssetLoader = d.extend("CustomFileAssetLoader", {__construct:function({loadContents:f}) { this.__parent.__construct.call(this); this.Ea = f; }, loadContents:function(f, l) { f = k.ptrToAsset(f); return this.Ea(f, l); },}); k.CDNFileAssetLoader = d.extend("CDNFileAssetLoader", {__construct:function() { this.__parent.__construct.call(this); }, loadContents:function(f) { let l = k.ptrToAsset(f); f = l.cdnUuid; if ("" === f) { return !1; } (function(h, n) { var m = new XMLHttpRequest(); m.responseType = "arraybuffer"; m.onreadystatechange = function() { 4 == m.readyState && 200 == m.status && n(m); }; m.open("GET", h, !0); m.send(null); })(l.cdnBaseUrl + "/" + f, h => { l.decode(new Uint8Array(h.response)); }); return !0; },}); k.FallbackFileAssetLoader = d.extend("FallbackFileAssetLoader", {__construct:function() { this.__parent.__construct.call(this); this.ua = []; }, addLoader:function(f) { this.ua.push(f); }, loadContents:function(f, l) { for (let h of this.ua) { if (h.loadContents(f, l)) { return !0; } } return !1; },}); let e = k.computeAlignment; k.computeAlignment = function(f, l, h, n, m = 1.0) { return e.call(this, f, l, h, n, m); }; }; const pa = "createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "), qa = new function() { function b() { if (!a) { var g = document.createElement("canvas"), t = {alpha:1, depth:0, stencil:0, antialias:0, premultipliedAlpha:1, preserveDrawingBuffer:0, powerPreference:"high-performance", failIfMajorPerformanceCaveat:0, enableExtensionsByDefault:1, explicitSwapControl:1, renderViaOffscreenBackBuffer:1,}; let q; if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { if (q = g.getContext("webgl", t), c = 1, !q) { return console.log("No WebGL support. Image mesh will not be drawn."), !1; } } else { if (q = g.getContext("webgl2", t)) { c = 2; } else { if (q = g.getContext("webgl", t)) { c = 1; } else { return console.log("No WebGL support. Image mesh will not be drawn."), !1; } } } q = new Proxy(q, {get(F, v) { if (F.isContextLost()) { if (n || (console.error("Cannot render the mesh because the GL Context was lost. Tried to invoke ", v), n = !0), "function" === typeof F[v]) { return function() { }; } } else { return "function" === typeof F[v] ? function(...H) { return F[v].apply(F, H); } : F[v]; } }, set(F, v, H) { if (F.isContextLost()) { n || (console.error("Cannot render the mesh because the GL Context was lost. Tried to set property " + v), n = !0); } else { return F[v] = H, !0; } },}); d = Math.min(q.getParameter(q.MAX_RENDERBUFFER_SIZE), q.getParameter(q.MAX_TEXTURE_SIZE)); function G(F, v, H) { v = q.createShader(v); q.shaderSource(v, H); q.compileShader(v); H = q.getShaderInfoLog(v); if (0 < (H || "").length) { throw H; } q.attachShader(F, v); } g = q.createProgram(); G(g, q.VERTEX_SHADER, "attribute vec2 vertex;\n attribute vec2 uv;\n uniform vec4 mat;\n uniform vec2 translate;\n varying vec2 st;\n void main() {\n st = uv;\n gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);\n }"); G(g, q.FRAGMENT_SHADER, "precision highp float;\n uniform sampler2D image;\n varying vec2 st;\n void main() {\n gl_FragColor = texture2D(image, st);\n }"); q.bindAttribLocation(g, 0, "vertex"); q.bindAttribLocation(g, 1, "uv"); q.linkProgram(g); t = q.getProgramInfoLog(g); if (0 < (t || "").trim().length) { throw t; } e = q.getUniformLocation(g, "mat"); f = q.getUniformLocation(g, "translate"); q.useProgram(g); q.bindBuffer(q.ARRAY_BUFFER, q.createBuffer()); q.enableVertexAttribArray(0); q.enableVertexAttribArray(1); q.bindBuffer(q.ELEMENT_ARRAY_BUFFER, q.createBuffer()); q.uniform1i(q.getUniformLocation(g, "image"), 0); q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0); a = q; } return !0; } let a = null, c = 0, d = 0, e = null, f = null, l = 0, h = 0, n = !1; b(); this.Xa = function() { b(); return d; }; this.Ja = function(g) { a.deleteTexture && a.deleteTexture(g); }; this.Ia = function(g) { if (!b()) { return null; } const t = a.createTexture(); if (!t) { return null; } a.bindTexture(a.TEXTURE_2D, t); a.texImage2D(a.TEXTURE_2D, 0, a.RGBA, a.RGBA, a.UNSIGNED_BYTE, g); a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE); a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE); a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR); 2 == c ? (a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR_MIPMAP_LINEAR), a.generateMipmap(a.TEXTURE_2D)) : a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR); return t; }; const m = new la(8), r = new la(8), w = new la(10), z = new la(10); this.Ma = function(g, t, q, G, F) { if (b()) { var v = m.push(g), H = r.push(t); if (a.canvas) { if (a.canvas.width != v || a.canvas.height != H) { a.canvas.width = v, a.canvas.height = H; } a.viewport(0, H - t, g, t); a.disable(a.SCISSOR_TEST); a.clearColor(0, 0, 0, 0); a.clear(a.COLOR_BUFFER_BIT); a.enable(a.SCISSOR_TEST); q.sort((E, V) => V.ya - E.ya); v = w.push(G); l != v && (a.bufferData(a.ARRAY_BUFFER, 8 * v, a.DYNAMIC_DRAW), l = v); v = 0; for (var L of q) { a.bufferSubData(a.ARRAY_BUFFER, v, L.ia), v += 4 * L.ia.length; } console.assert(v == 4 * G); for (var Q of q) { a.bufferSubData(a.ARRAY_BUFFER, v, Q.Ba), v += 4 * Q.Ba.length; } console.assert(v == 8 * G); v = z.push(F); h != v && (a.bufferData(a.ELEMENT_ARRAY_BUFFER, 2 * v, a.DYNAMIC_DRAW), h = v); L = 0; for (var ha of q) { a.bufferSubData(a.ELEMENT_ARRAY_BUFFER, L, ha.indices), L += 2 * ha.indices.length; } console.assert(L == 2 * F); ha = 0; Q = !0; v = L = 0; for (const E of q) { E.image.da != ha && (a.bindTexture(a.TEXTURE_2D, E.image.ca || null), ha = E.image.da); E.$a ? (a.scissor(E.na, H - E.oa - E.ta, E.lb, E.ta), Q = !0) : Q && (a.scissor(0, H - t, g, t), Q = !1); q = 2 / g; const V = -2 / t; a.uniform4f(e, E.N[0] * q * E.X, E.N[1] * V * E.Y, E.N[2] * q * E.X, E.N[3] * V * E.Y); a.uniform2f(f, E.N[4] * q * E.X + q * (E.na - E.Ya * E.X) - 1, E.N[5] * V * E.Y + V * (E.oa - E.Za * E.Y) + 1); a.vertexAttribPointer(0, 2, a.FLOAT, !1, 0, v); a.vertexAttribPointer(1, 2, a.FLOAT, !1, 0, v + 4 * G); a.drawElements(a.TRIANGLES, E.indices.length, a.UNSIGNED_SHORT, L); v += 4 * E.ia.length; L += 2 * E.indices.length; } console.assert(v == 4 * G); console.assert(L == 2 * F); } } }; this.canvas = function() { return b() && a.canvas; }; }(), ra = k.onRuntimeInitialized; k.onRuntimeInitialized = function() { function b(p) { switch(p) { case m.srcOver: return "source-over"; case m.screen: return "screen"; case m.overlay: return "overlay"; case m.darken: return "darken"; case m.lighten: return "lighten"; case m.colorDodge: return "color-dodge"; case m.colorBurn: return "color-burn"; case m.hardLight: return "hard-light"; case m.softLight: return "soft-light"; case m.difference: return "difference"; case m.exclusion: return "exclusion"; case m.multiply: return "multiply"; case m.hue: return "hue"; case m.saturation: return "saturation"; case m.color: return "color"; case m.luminosity: return "luminosity"; } } function a(p) { return "rgba(" + ((16711680 & p) >>> 16) + "," + ((65280 & p) >>> 8) + "," + ((255 & p) >>> 0) + "," + ((4278190080 & p) >>> 24) / 255 + ")"; } function c() { 0 < H.length && (qa.Ma(v.drawWidth(), v.drawHeight(), H, L, Q), H = [], Q = L = 0, v.reset(512, 512)); for (const p of F) { for (const u of p.v) { u(); } p.v = []; } F.clear(); } ra && ra(); var d = k.RenderPaintStyle; const e = k.RenderPath, f = k.RenderPaint, l = k.Renderer, h = k.StrokeCap, n = k.StrokeJoin, m = k.BlendMode, r = d.fill, w = d.stroke, z = k.FillRule.evenOdd; let g = 1; var t = k.RenderImage.extend("CanvasRenderImage", {__construct:function({R:p, W:u} = {}) { this.__parent.__construct.call(this); this.da = g; g = g + 1 & 2147483647 || 1; this.R = p; this.W = u; }, __destruct:function() { this.ca && (qa.Ja(this.ca), URL.revokeObjectURL(this.la)); this.__parent.__destruct.call(this); }, decode:function(p) { var u = this; u.W && u.W(u); var D = new Image(); u.la = URL.createObjectURL(new Blob([p], {type:"image/png",})); D.onload = function() { u.Da = D; u.ca = qa.Ia(D); u.size(D.width, D.height); u.R && u.R(u); }; D.src = u.la; },}), q = e.extend("CanvasRenderPath", {__construct:function() { this.__parent.__construct.call(this); this.H = new Path2D(); }, rewind:function() { this.H = new Path2D(); }, addPath:function(p, u, D, B, x, C, A) { var I = this.H, na = I.addPath; p = p.H; const P = new DOMMatrix(); P.a = u; P.b = D; P.c = B; P.d = x; P.e = C; P.f = A; na.call(I, p, P); }, fillRule:function(p) { this.ka = p; }, moveTo:function(p, u) { this.H.moveTo(p, u); }, lineTo:function(p, u) { this.H.lineTo(p, u); }, cubicTo:function(p, u, D, B, x, C) { this.H.bezierCurveTo(p, u, D, B, x, C); }, close:function() { this.H.closePath(); },}), G = f.extend("CanvasRenderPaint", {color:function(p) { this.ma = a(p); }, thickness:function(p) { this.Ga = p; }, join:function(p) { switch(p) { case n.miter: this.ba = "miter"; break; case n.round: this.ba = "round"; break; case n.bevel: this.ba = "bevel"; } }, cap:function(p) { switch(p) { case h.butt: this.aa = "butt"; break; case h.round: this.aa = "round"; break; case h.square: this.aa = "square"; } }, style:function(p) { this.Fa = p; }, blendMode:function(p) { this.Ca = b(p); }, clearGradient:function() { this.P = null; }, linearGradient:function(p, u, D, B) { this.P = {za:p, Aa:u, qa:D, ra:B, ga:[],}; }, radialGradient:function(p, u, D, B) { this.P = {za:p, Aa:u, qa:D, ra:B, ga:[], Wa:!0,}; }, addStop:function(p, u) { this.P.ga.push({color:p, stop:u,}); }, completeGradient:function() { }, draw:function(p, u, D, B) { let x = this.Fa; var C = this.ma, A = this.P; const I = p.globalCompositeOperation, na = p.globalAlpha; p.globalCompositeOperation = this.Ca; p.globalAlpha = B; if (null != A) { C = A.za; const T = A.Aa, ca = A.qa; var P = A.ra; B = A.ga; A.Wa ? (A = ca - C, P -= T, C = p.createRadialGradient(C, T, 0, C, T, Math.sqrt(A * A + P * P))) : C = p.createLinearGradient(C, T, ca, P); for (let U = 0, W = B.length; U < W; U++) { A = B[U], C.addColorStop(A.stop, a(A.color)); } this.ma = C; this.P = null; } switch(x) { case w: p.strokeStyle = C; p.lineWidth = this.Ga; p.lineCap = this.aa; p.lineJoin = this.ba; p.stroke(u); break; case r: p.fillStyle = C, p.fill(u, D); } p.globalCompositeOperation = I; p.globalAlpha = na; },}); const F = new Set(); let v = null, H = [], L = 0, Q = 0; var ha = k.CanvasRenderer = l.extend("Renderer", {__construct:function(p) { this.__parent.__construct.call(this); this.G = [1, 0, 0, 1, 0, 0]; this.u = [1.0]; this.m = p.getContext("2d"); this.ja = p; this.v = []; }, save:function() { this.G.push(...this.G.slice(this.G.length - 6)); this.u.push(this.u[this.u.length - 1]); this.v.push(this.m.save.bind(this.m)); }, restore:function() { const p = this.G.length - 6; if (6 > p) { throw "restore() called without matching save()."; } this.G.splice(p); this.u.pop(); this.v.push(this.m.restore.bind(this.m)); }, transform:function(p, u, D, B, x, C) { const A = this.G, I = A.length - 6; A.splice(I, 6, A[I] * p + A[I + 2] * u, A[I + 1] * p + A[I + 3] * u, A[I] * D + A[I + 2] * B, A[I + 1] * D + A[I + 3] * B, A[I] * x + A[I + 2] * C + A[I + 4], A[I + 1] * x + A[I + 3] * C + A[I + 5]); this.v.push(this.m.transform.bind(this.m, p, u, D, B, x, C)); }, rotate:function(p) { const u = Math.sin(p); p = Math.cos(p); this.transform(p, u, -u, p, 0, 0); }, modulateOpacity:function(p) { this.u[this.u.length - 1] *= p; }, _drawPath:function(p, u) { this.v.push(u.draw.bind(u, this.m, p.H, p.ka === z ? "evenodd" : "nonzero", Math.max(0, this.u[this.u.length - 1]))); }, _drawRiveImage:function(p, u, D, B) { var x = p.Da; if (x) { var C = this.m, A = b(D), I = Math.max(0, B * this.u[this.u.length - 1]); this.v.push(function() { C.globalCompositeOperation = A; C.globalAlpha = I; C.drawImage(x, 0, 0); C.globalAlpha = 1; }); } }, _getMatrix:function(p) { const u = this.G, D = u.length - 6; for (let B = 0; 6 > B; ++B) { p[B] = u[D + B]; } }, _drawImageMesh:function(p, u, D, B, x, C, A, I, na, P, T, ca, U, W) { let ub, vb, wb; try { ub = k.HEAPF32.slice(x >> 2, (x >> 2) + C), vb = k.HEAPF32.slice(A >> 2, (A >> 2) + I), wb = k.HEAPU16.slice(na >> 1, (na >> 1) + P); } catch (Ya) { console.error("[Rive] _drawImageMesh: failed to read mesh data from WASM heap. Mesh skipped for this frame."); return; } u = this.m.canvas.width; x = this.m.canvas.height; A = U - T; I = W - ca; T = Math.max(T, 0); ca = Math.max(ca, 0); U = Math.min(U, u); W = Math.min(W, x); const va = U - T, wa = W - ca; console.assert(va <= Math.min(A, u)); console.assert(wa <= Math.min(I, x)); if (!(0 >= va || 0 >= wa)) { U = va < A || wa < I; u = W = 1; var ia = Math.ceil(va * W), ja = Math.ceil(wa * u); x = qa.Xa(); ia > x && (W *= x / ia, ia = x); ja > x && (u *= x / ja, ja = x); v || (v = new k.DynamicRectanizer(x), v.reset(512, 512)); x = v.addRect(ia, ja); 0 > x && (c(), F.add(this), x = v.addRect(ia, ja), console.assert(0 <= x)); var xb = x & 65535, yb = x >> 16; H.push({N:this.G.slice(this.G.length - 6), image:p, na:xb, oa:yb, Ya:T, Za:ca, lb:ia, ta:ja, X:W, Y:u, ia:ub, Ba:vb, indices:wb, $a:U, ya:p.da << 1 | (U ? 1 : 0),}); L += C; Q += P; var oa = this.m, oc = b(D), pc = Math.max(0, B * this.u[this.u.length - 1]); this.v.push(function() { oa.save(); oa.resetTransform(); oa.globalCompositeOperation = oc; oa.globalAlpha = pc; const Ya = qa.canvas(); Ya && oa.drawImage(Ya, xb, yb, ia, ja, T, ca, va, wa); oa.restore(); }); } }, _clipPath:function(p) { this.v.push(this.m.clip.bind(this.m, p.H, p.ka === z ? "evenodd" : "nonzero")); }, clear:function() { F.add(this); this.v.push(this.m.clearRect.bind(this.m, 0, 0, this.ja.width, this.ja.height)); }, flush:function() { }, translate:function(p, u) { this.transform(1, 0, 0, 1, p, u); },}); k.makeRenderer = function(p) { const u = new ha(p), D = u.m; return new Proxy(u, {get(B, x) { if ("function" === typeof B[x]) { return function(...C) { return B[x].apply(B, C); }; } if ("function" === typeof D[x]) { if (-1 < pa.indexOf(x)) { throw Error("RiveException: Method call to '" + x + "()' is not allowed, as the renderer cannot immediately pass through the return values of any canvas 2d context methods."); } return function(...C) { u.v.push(D[x].bind(D, ...C)); }; } return B[x]; }, set(B, x, C) { if (x in D) { return u.v.push(() => { D[x] = C; }), !0; } },}); }; k.decodeImage = function(p, u) { (new t({R:u})).decode(p); }; k.renderFactory = {makeRenderPaint:function() { return new G(); }, makeRenderPath:function() { return new q(); }, makeRenderImage:function() { let p = V; return new t({W:() => { p.total++; }, R:() => { p.loaded++; if (p.loaded === p.total) { const u = p.ready; u && (u(), p.ready = null); } },}); },}; let E = k.load, V = null; k.load = function(p, u, D = !0) { const B = new k.FallbackFileAssetLoader(); void 0 !== u && B.addLoader(u); D && (u = new k.CDNFileAssetLoader(), B.addLoader(u)); return new Promise(function(x) { let C = null; V = {total:0, loaded:0, ready:function() { x(C); },}; C = E(p, B); 0 == V.total && x(C); }); }; let qc = k.RendererWrapper.prototype.align; k.RendererWrapper.prototype.align = function(p, u, D, B, x = 1.0) { qc.call(this, p, u, D, B, x); }; d = new ka(); k.requestAnimationFrame = d.requestAnimationFrame.bind(d); k.cancelAnimationFrame = d.cancelAnimationFrame.bind(d); k.enableFPSCounter = d.Na.bind(d); k.disableFPSCounter = d.Ka; d.va = c; k.resolveAnimationFrame = c; k.cleanup = function() { v && v.delete(); }; }; var sa = Object.assign({}, k), ta = "./this.program", y = "", ua, xa; if (ea || fa) { fa ? y = self.location.href : "undefined" != typeof document && document.currentScript && (y = document.currentScript.src), _scriptName && (y = _scriptName), y.startsWith("blob:") ? y = "" : y = y.substr(0, y.replace(/[?#].*/, "").lastIndexOf("/") + 1), fa && (xa = b => { var a = new XMLHttpRequest(); a.open("GET", b, !1); a.responseType = "arraybuffer"; a.send(null); return new Uint8Array(a.response); }), ua = (b, a, c) => { if (ya(b)) { var d = new XMLHttpRequest(); d.open("GET", b, !0); d.responseType = "arraybuffer"; d.onload = () => { 200 == d.status || 0 == d.status && d.response ? a(d.response) : c(); }; d.onerror = c; d.send(null); } else { fetch(b, {credentials:"same-origin"}).then(e => e.ok ? e.arrayBuffer() : Promise.reject(Error(e.status + " : " + e.url))).then(a, c); } }; } var za = k.print || console.log.bind(console), Aa = k.printErr || console.error.bind(console); Object.assign(k, sa); sa = null; k.thisProgram && (ta = k.thisProgram); var Ba; k.wasmBinary && (Ba = k.wasmBinary); var Ca, Da = !1, Ea, J, Fa, Ga, K, M, Ha, Ia; function Ja() { var b = Ca.buffer; k.HEAP8 = Ea = new Int8Array(b); k.HEAP16 = Fa = new Int16Array(b); k.HEAPU8 = J = new Uint8Array(b); k.HEAPU16 = Ga = new Uint16Array(b); k.HEAP32 = K = new Int32Array(b); k.HEAPU32 = M = new Uint32Array(b); k.HEAPF32 = Ha = new Float32Array(b); k.HEAPF64 = Ia = new Float64Array(b); } var Ka = [], La = [], Ma = []; function Na() { var b = k.preRun.shift(); Ka.unshift(b); } var Oa = 0, Pa = null, Qa = null; function Ra(b) { k.onAbort?.(b); b = "Aborted(" + b + ")"; Aa(b); Da = !0; b = new WebAssembly.RuntimeError(b + ". Build with -sASSERTIONS for more info."); ba(b); throw b; } var Sa = b => b.startsWith("data:application/octet-stream;base64,"), ya = b => b.startsWith("file://"), Ta; function Ua(b) { if (b == Ta && Ba) { return new Uint8Array(Ba); } if (xa) { return xa(b); } throw "both async and sync fetching of the wasm failed"; } function Va(b) { return Ba ? Promise.resolve().then(() => Ua(b)) : new Promise((a, c) => { ua(b, d => a(new Uint8Array(d)), () => { try { a(Ua(b)); } catch (d) { c(d); } }); }); } function Wa(b, a, c) { return Va(b).then(d => WebAssembly.instantiate(d, a)).then(c, d => { Aa(`failed to asynchronously prepare wasm: ${d}`); Ra(d); }); } function Xa(b, a) { var c = Ta; return Ba || "function" != typeof WebAssembly.instantiateStreaming || Sa(c) || ya(c) || "function" != typeof fetch ? Wa(c, b, a) : fetch(c, {credentials:"same-origin"}).then(d => WebAssembly.instantiateStreaming(d, b).then(a, function(e) { Aa(`wasm streaming compile failed: ${e}`); Aa("falling back to ArrayBuffer instantiation"); return Wa(c, b, a); })); } var Za = b => { for (; 0 < b.length;) { b.shift()(k); } }, $a = (b, a) => Object.defineProperty(a, "name", {value:b}), ab = [], N = [], O, R = b => { if (!b) { throw new O("Cannot use deleted val. handle = " + b); } return N[b]; }, bb = b => { switch(b) { case void 0: return 2; case null: return 4; case !0: return 6; case !1: return 8; default: const a = ab.pop() || N.length; N[a] = b; N[a + 1] = 1; return a; } }, cb = b => { var a = Error, c = $a(b, function(d) { this.name = b; this.message = d; d = Error(d).stack; void 0 !== d && (this.stack = this.toString() + "\n" + d.replace(/^Error(:[^\n]*)?\n/, "")); }); c.prototype = Object.create(a.prototype); c.prototype.constructor = c; c.prototype.toString = function() { return void 0 === this.message ? this.name : `${this.name}: ${this.message}`; }; return c; }, db, eb, S = b => { for (var a = ""; J[b];) { a += eb[J[b++]]; } return a; }, fb = [], gb = () => { for (; fb.length;) { var b = fb.pop(); b.g.M = !1; b["delete"](); } }, hb, ib = {}, jb = (b, a) => { if (void 0 === a) { throw new O("ptr should not be undefined"); } for (; b.o;) { a = b.S(a), b = b.o; } return a; }, kb = {}, nb = b => { b = lb(b); var a = S(b); mb(b); return a; }, ob = (b, a) => { var c = kb[b]; if (void 0 === c) { throw b = `${a} has unknown type ${nb(b)}`, new O(b); } return c; }, pb = () => { }, qb = !1, rb = (b, a, c) => { if (a === c) { return b; } if (void 0 === c.o) { return null; } b = rb(b, a, c.o); return null === b ? null : c.La(b); }, sb = {}, tb = (b, a) => { a = jb(b, a); return ib[a]; }, zb, Bb = (b, a) => { if (!a.j || !a.i) { throw new zb("makeClassHandle requires ptr and ptrType"); } if (!!a.A !== !!a.s) { throw new zb("Both smartPtrType and smartPtr must be specified"); } a.count = {value:1}; return Ab(Object.create(b, {g:{value:a, writable:!0,},})); }, Ab = b => { if ("undefined" === typeof FinalizationRegistry) { return Ab = a => a, b; } qb = new FinalizationRegistry(a => { a = a.g; --a.count.value; 0 === a.count.value && (a.s ? a.A.D(a.s) : a.j.h.D(a.i)); }); Ab = a => { var c = a.g; c.s && qb.register(a, {g:c}, a); return a; }; pb = a => { qb.unregister(a); }; return Ab(b); }, Cb = {}, Db = b => { for (; b.length;) { var a = b.pop(); b.pop()(a); } }; function Eb(b) { return this.fromWireType(M[b >> 2]); } var Fb = {}, Gb = {}, X = (b, a, c) => { function d(h) { h = c(h); if (h.length !== b.length) { throw new zb("Mismatched type converter count"); } for (var n = 0; n < b.length; ++n) { Hb(b[n], h[n]); } } b.forEach(function(h) { Gb[h] = a; }); var e = Array(a.length), f = [], l = 0; a.forEach((h, n) => { kb.hasOwnProperty(h) ? e[n] = kb[h] : (f.push(h), Fb.hasOwnProperty(h) || (Fb[h] = []), Fb[h].push(() => { e[n] = kb[h]; ++l; l === f.length && d(e); })); }); 0 === f.length && d(e); }; function Ib(b, a, c = {}) { var d = a.name; if (!b) { throw new O(`type "${d}" must have a positive integer typeid pointer`); } if (kb.hasOwnProperty(b)) { if (c.Va) { return; } throw new O(`Cannot register type '${d}' twice`); } kb[b] = a; delete Gb[b]; Fb.hasOwnProperty(b) && (a = Fb[b], delete Fb[b], a.forEach(e => e())); } function Hb(b, a, c = {}) { if (!("argPackAdvance" in a)) { throw new TypeError("registerType registeredInstance requires argPackAdvance"); } return Ib(b, a, c); } var Jb = b => { throw new O(b.g.j.h.name + " instance already deleted"); }; function Kb() { } var Lb = (b, a, c) => { if (void 0 === b[a].l) { var d = b[a]; b[a] = function(...e) { if (!b[a].l.hasOwnProperty(e.length)) { throw new O(`Function '${c}' called with an invalid number of arguments (${e.length}) - expects one of (${b[a].l})!`); } return b[a].l[e.length].apply(this, e); }; b[a].l = []; b[a].l[d.L] = d; } }, Mb = (b, a, c) => { if (k.hasOwnProperty(b)) { if (void 0 === c || void 0 !== k[b].l && void 0 !== k[b].l[c]) { throw new O(`Cannot register public name '${b}' twice`); } Lb(k, b, b); if (k.hasOwnProperty(c)) { throw new O(`Cannot register multiple overloads of a function with the same number of arguments (${c})!`); } k[b].l[c] = a; } else { k[b] = a, void 0 !== c && (k[b].nb = c); } }, Nb = b => { if (void 0 === b) { return "_unknown"; } b = b.replace(/[^a-zA-Z0-9_]/g, "$"); var a = b.charCodeAt(0); return 48 <= a && 57 >= a ? `_${b}` : b; }; function Ob(b, a, c, d, e, f, l, h) { this.name = b; this.constructor = a; this.C = c; this.D = d; this.o = e; this.Qa = f; this.S = l; this.La = h; this.wa = []; } var Pb = (b, a, c) => { for (; a !== c;) { if (!a.S) { throw new O(`Expected null or instance of ${c.name}, got an instance of ${a.name}`); } b = a.S(b); a = a.o; } return b; }; function Qb(b, a) { if (null === a) { if (this.ea) { throw new O(`null is not a valid ${this.name}`); } return 0; } if (!a.g) { throw new O(`Cannot pass "${Rb(a)}" as a ${this.name}`); } if (!a.g.i) { throw new O(`Cannot pass deleted object as a pointer of type ${this.name}`); } return Pb(a.g.i, a.g.j.h, this.h); } function Sb(b, a) { if (null === a) { if (this.ea) { throw new O(`null is not a valid ${this.name}`); } if (this.V) { var c = this.fa(); null !== b && b.push(this.D, c); return c; } return 0; } if (!a || !a.g) { throw new O(`Cannot pass "${Rb(a)}" as a ${this.name}`); } if (!a.g.i) { throw new O(`Cannot pass deleted object as a pointer of type ${this.name}`); } if (!this.U && a.g.j.U) { throw new O(`Cannot convert argument of type ${a.g.A ? a.g.A.name : a.g.j.name} to parameter type ${this.name}`); } c = Pb(a.g.i, a.g.j.h, this.h); if (this.V) { if (void 0 === a.g.s) { throw new O("Passing raw pointer to smart pointer is illegal"); } switch(this.gb) { case 0: if (a.g.A === this) { c = a.g.s; } else { throw new O(`Cannot convert argument of type ${a.g.A ? a.g.A.name : a.g.j.name} to parameter type ${this.name}`); } break; case 1: c = a.g.s; break; case 2: if (a.g.A === this) { c = a.g.s; } else { var d = a.clone(); c = this.bb(c, bb(() => d["delete"]())); null !== b && b.push(this.D, c); } break; default: throw new O("Unsupporting sharing policy"); } } return c; } function Tb(b, a) { if (null === a) { if (this.ea) { throw new O(`null is not a valid ${this.name}`); } return 0; } if (!a.g) { throw new O(`Cannot pass "${Rb(a)}" as a ${this.name}`); } if (!a.g.i) { throw new O(`Cannot pass deleted object as a pointer of type ${this.name}`); } if (a.g.j.U) { throw new O(`Cannot convert argument of type ${a.g.j.name} to parameter type ${this.name}`); } return Pb(a.g.i, a.g.j.h, this.h); } function Ub(b, a, c, d, e, f, l, h, n, m, r) { this.name = b; this.h = a; this.ea = c; this.U = d; this.V = e; this.ab = f; this.gb = l; this.xa = h; this.fa = n; this.bb = m; this.D = r; e || void 0 !== a.o ? this.toWireType = Sb : (this.toWireType = d ? Qb : Tb, this.B = null); } var Vb = (b, a, c) => { if (!k.hasOwnProperty(b)) { throw new zb("Replacing nonexistent public symbol"); } void 0 !== k[b].l && void 0 !== c ? k[b].l[c] = a : (k[b] = a, k[b].L = c); }, Wb = [], Xb, Yb = b => { var a = Wb[b]; a || (b >= Wb.length && (Wb.length = b + 1), Wb[b] = a = Xb.get(b)); return a; }, Zb = (b, a, c = []) => { b.includes("j") ? (b = b.replace(/p/g, "i"), a = (0,k["dynCall_" + b])(a, ...c)) : a = Yb(a)(...c); return a; }, $b = (b, a) => (...c) => Zb(b, a, c), Y = (b, a) => { b = S(b); var c = b.includes("j") ? $b(b, a) : Yb(a); if ("function" != typeof c) { throw new O(`unknown function pointer with signature ${b}: ${a}`); } return c; }, ac, bc = (b, a) => { function c(f) { e[f] || kb[f] || (Gb[f] ? Gb[f].forEach(c) : (d.push(f), e[f] = !0)); } var d = [], e = {}; a.forEach(c); throw new ac(`${b}: ` + d.map(nb).join([", "])); }; function cc(b) { for (var a = 1; a < b.length; ++a) { if (null !== b[a] && void 0 === b[a].B) { return !0; } } return !1; } function dc(b, a, c, d, e) { var f = a.length; if (2 > f) { throw new O("argTypes array size mismatch! Must at least get return value and 'this' types!"); } var l = null !== a[1] && null !== c, h = cc(a), n = "void" !== a[0].name, m = f - 2, r = Array(m), w = [], z = []; return $a(b, function(...g) { if (g.length !== m) { throw new O(`function ${b} called with ${g.length} arguments, expected ${m}`); } z.length = 0; w.length = l ? 2 : 1; w[0] = e; if (l) { var t = a[1].toWireType(z, this); w[1] = t; } for (var q = 0; q < m; ++q) { r[q] = a[q + 2].toWireType(z, g[q]), w.push(r[q]); } g = d(...w); if (h) { Db(z); } else { for (q = l ? 1 : 2; q < a.length; q++) { var G = 1 === q ? t : r[q - 2]; null !== a[q].B && a[q].B(G); } } t = n ? a[0].fromWireType(g) : void 0; return t; }); } var ec = (b, a) => { for (var c = [], d = 0; d < b; d++) { c.push(M[a + 4 * d >> 2]); } return c; }, fc = b => { b = b.trim(); const a = b.indexOf("("); return -1 !== a ? b.substr(0, a) : b; }, gc = (b, a, c) => { if (!(b instanceof Object)) { throw new O(`${c} with invalid "this": ${b}`); } if (!(b instanceof a.h.constructor)) { throw new O(`${c} incompatible with "this" of type ${b.constructor.name}`); } if (!b.g.i) { throw new O(`cannot call emscripten binding method ${c} on deleted object`); } return Pb(b.g.i, b.g.j.h, a.h); }, hc = b => { 9 < b && 0 === --N[b + 1] && (N[b] = void 0, ab.push(b)); }, ic = {name:"emscripten::val", fromWireType:b => { var a = R(b); hc(b); return a; }, toWireType:(b, a) => bb(a), argPackAdvance:8, readValueFromPointer:Eb, B:null,}, jc = (b, a, c) => { switch(a) { case 1: return c ? function(d) { return this.fromWireType(Ea[d]); } : function(d) { return this.fromWireType(J[d]); }; case 2: return c ? function(d) { return this.fromWireType(Fa[d >> 1]); } : function(d) {