<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/**
 * @license
 * PlayCanvas Engine v1.31.0 revision ba9d6341
 * Copyright 2011-2020 PlayCanvas Ltd. All rights reserved.
 */
! function(e, t) {
    "object" == typeof exports &amp;&amp; "undefined" != typeof module ? t(exports) : "function" == typeof define &amp;&amp; define.amd ? define(["exports"], t) : t((e = e || self).pcx = {})
}(this, (function(e) {
    "use strict";

    function CpuTimer(e) {
        this._frameIndex = 0, this._frameTimings = [], this._timings = [], this._prevTimings = [], this.enabled = !0, e.on("frameupdate", this.begin.bind(this, "update")), e.on("framerender", this.mark.bind(this, "render")), e.on("frameend", this.mark.bind(this, "other"))
    }

    function GpuTimer(e) {
        this._gl = e.graphicsDevice.gl, this._ext = e.graphicsDevice.extDisjointTimerQuery, this._freeQueries = [], this._frameQueries = [], this._frames = [], this._timings = [], this._prevTimings = [], this.enabled = !0, e.on("frameupdate", this.begin.bind(this, "update")), e.on("framerender", this.mark.bind(this, "render")), e.on("frameend", this.end.bind(this))
    }

    function Render2d(e, t) {
        t = t || 128;
        for (var i = new pc.VertexFormat(e, [{
                semantic: pc.SEMANTIC_POSITION,
                components: 2,
                type: pc.TYPE_FLOAT32
            }, {
                semantic: pc.SEMANTIC_TEXCOORD0,
                components: 4,
                type: pc.TYPE_FLOAT32
            }]), s = new Uint32Array(6 * t), r = 0; r &lt; t; ++r) s[6 * r + 0] = 4 * r, s[6 * r + 1] = 4 * r + 1, s[6 * r + 2] = 4 * r + 2, s[6 * r + 3] = 4 * r, s[6 * r + 4] = 4 * r + 2, s[6 * r + 5] = 4 * r + 3;
        this.device = e, this.shader = pc.shaderChunks.createShaderFromCode(e, "attribute vec2 vertex_position;\nattribute vec4 vertex_texCoord0;\nuniform vec4 screenAndTextureSize;\nvarying vec4 uv0;\nvoid main(void) {\n\tvec2 pos = vertex_position.xy / screenAndTextureSize.xy;\n\tgl_Position = vec4(pos * 2.0 - 1.0, 0.5, 1.0);\n\tuv0 = vec4(vertex_texCoord0.xy / screenAndTextureSize.zw, vertex_texCoord0.zw);\n}\n", "varying vec4 uv0;\nuniform vec4 clr;\nuniform sampler2D source;\nvoid main (void) {\n\tvec4 tex = texture2D(source, uv0.xy);\n\tif (tex.rgb != vec3(1, 1, 1)) {\n\t   if (uv0.w &lt; tex.r)\n\t\t   tex = vec4(1.0, 0.3, 0.3, 1.0);\n\t   else if (uv0.w &lt; tex.g)\n\t\t   tex = vec4(0.3, 1.0, 0.3, 1.0);\n\t   else\n\t\t   tex = vec4(0.0, 0.0, 0.0, 1.0);\n\t}\n\tgl_FragColor = tex * clr;\n}\n", "mini-stats"), this.buffer = new pc.VertexBuffer(e, i, 4 * t, pc.BUFFER_STREAM), this.data = new Float32Array(this.buffer.numBytes / 4), this.indexBuffer = new pc.IndexBuffer(e, pc.INDEXFORMAT_UINT32, 6 * t, pc.BUFFER_STATIC, s), this.prims = [], this.prim = null, this.primIndex = -1, this.quads = 0, this.clrId = e.scope.resolve("clr"), this.clr = new Float32Array(4), this.screenTextureSizeId = e.scope.resolve("screenAndTextureSize"), this.screenTextureSize = new Float32Array(4)
    }

    function WordAtlas(e, t) {
        var i = document.createElement("canvas");
        i.width = e.width, i.height = e.height;
        var s = i.getContext("2d", {
            alpha: !0
        });
        s.font = '10px "Lucida Console", Monaco, monospace', s.textAlign = "left", s.textBaseline = "alphabetic", s.fillStyle = "rgb(255, 255, 255)";
        var r, n = 5,
            h = 5,
            a = [];
        for (r = 0; r &lt; t.length; ++r) {
            var o = s.measureText(t[r]),
                u = Math.ceil(-o.actualBoundingBoxLeft),
                d = Math.ceil(o.actualBoundingBoxRight),
                c = Math.ceil(o.actualBoundingBoxAscent),
                m = Math.ceil(o.actualBoundingBoxDescent),
                p = u + d,
                f = c + m;
            n + p &gt;= i.width &amp;&amp; (n = 5, h += 16), s.fillText(t[r], n - u, h + c), a.push({
                l: u,
                r: d,
                a: c,
                d: m,
                x: n,
                y: h,
                w: p,
                h: f
            }), n += p + 5
        }
        var g = {};
        t.forEach((function(e, t) {
            g[e] = t
        })), this.words = t, this.wordMap = g, this.placements = a, this.texture = e;
        var l = s.getImageData(0, 0, i.width, i.height),
            _ = e.lock();
        for (h = 0; h &lt; l.height; ++h)
            for (n = 0; n &lt; l.width; ++n) {
                var v = 4 * (n + h * e.width);
                _[v] = 255, _[v + 1] = 255, _[v + 2] = 255, _[v + 3] = l.data[4 * (n + (l.height - 1 - h) * l.width) + 3]
            }
    }

    function Graph(e, t, i, s, r) {
        this.name = e, this.device = t.graphicsDevice, this.timer = i, this.enabled = !1, this.avgTotal = 0, this.avgTimer = 0, this.avgCount = 0, this.timingText = "", this.texture = s, this.yOffset = r, this.cursor = 0, this.sample = new Uint8Array(4), this.sample.set([0, 0, 0, 255]), t.on("frameupdate", this.update.bind(this)), this.counter = 0
    }
    Object.assign(CpuTimer.prototype, {
        begin: function(e) {
            if (this.enabled) {
                this._frameIndex &lt; this._frameTimings.length &amp;&amp; this._frameTimings.splice(this._frameIndex);
                var t = this._prevTimings;
                this._prevTimings = this._timings, this._timings = this._frameTimings, this._frameTimings = t, this._frameIndex = 0, this.mark(e)
            }
        },
        mark: function(e) {
            if (this.enabled) {
                var t, i = pc.now();
                if (this._frameIndex &gt; 0 ? (t = this._frameTimings[this._frameIndex - 1])[1] = i - t[1] : this._timings.length &gt; 0 &amp;&amp; ((t = this._timings[this._timings.length - 1])[1] = i - t[1]), this._frameIndex &gt;= this._frameTimings.length) this._frameTimings.push([e, i]);
                else {
                    var s = this._frameTimings[this._frameIndex];
                    s[0] = e, s[1] = i
                }
                this._frameIndex++
            }
        }
    }), Object.defineProperty(CpuTimer.prototype, "timings", {
        get: function() {
            return this._timings.slice(0, -1).map((function(e) {
                return e[1]
            }))
        }
    }), Object.assign(GpuTimer.prototype, {
        begin: function(e) {
            if (this.enabled) {
                if (this._frameQueries.length &gt; 0 &amp;&amp; this.end(), this._checkDisjoint(), this._frames.length &gt; 0 &amp;&amp; this._resolveFrameTimings(this._frames[0], this._prevTimings)) {
                    var t = this._prevTimings;
                    this._prevTimings = this._timings, this._timings = t, this._freeQueries = this._freeQueries.concat(this._frames.splice(0, 1)[0])
                }
                this.mark(e)
            }
        },
        mark: function(e) {
            if (this.enabled) {
                this._frameQueries.length &gt; 0 &amp;&amp; this._gl.endQuery(this._ext.TIME_ELAPSED_EXT);
                var t = this._allocateQuery();
                t[0] = e, this._gl.beginQuery(this._ext.TIME_ELAPSED_EXT, t[1]), this._frameQueries.push(t)
            }
        },
        end: function() {
            this.enabled &amp;&amp; (this._gl.endQuery(this._ext.TIME_ELAPSED_EXT), this._frames.push(this._frameQueries), this._frameQueries = [])
        },
        _checkDisjoint: function() {
            this._gl.getParameter(this._ext.GPU_DISJOINT_EXT) &amp;&amp; (this._freeQueries = [this._frames, [this._frameQueries],
                [this._freeQueries]
            ].flat(2), this._frameQueries = [], this._frames = [])
        },
        _allocateQuery: function() {
            return this._freeQueries.length &gt; 0 ? this._freeQueries.splice(-1, 1)[0] : ["", this._gl.createQuery()]
        },
        _resolveFrameTimings: function(e, t) {
            if (!this._gl.getQueryParameter(e[e.length - 1][1], this._gl.QUERY_RESULT_AVAILABLE)) return !1;
            for (var i = 0; i &lt; e.length; ++i) t[i] = [e[i][0], 1e-6 * this._gl.getQueryParameter(e[i][1], this._gl.QUERY_RESULT)];
            return !0
        }
    }), Object.defineProperty(GpuTimer.prototype, "timings", {
        get: function() {
            return this._timings.map((function(e) {
                return e[1]
            }))
        }
    }), Object.assign(Render2d.prototype, {
        quad: function(e, t, i, s, r, n, h, a, o) {
            var u = this.quads++,
                d = this.prim;
            d &amp;&amp; d.texture === e ? d.count += 6 : (this.primIndex++, this.primIndex === this.prims.length ? (d = {
                type: pc.PRIMITIVE_TRIANGLES,
                indexed: !0,
                base: 6 * u,
                count: 6,
                texture: e
            }, this.prims.push(d)) : ((d = this.prims[this.primIndex]).base = 6 * u, d.count = 6, d.texture = e), this.prim = d);
            var c = t + s,
                m = i + r,
                p = n + (void 0 === a ? s : a),
                f = h + (void 0 === o ? r : o);
            this.data.set([t, i, n, h, 0, 0, c, i, p, h, 1, 0, c, m, p, f, 1, 1, t, m, n, f, 0, 1], 24 * u)
        },
        render: function(e) {
            var t = this.device,
                i = this.buffer;
            i.setData(this.data.buffer), t.updateBegin(), t.setDepthTest(!1), t.setDepthWrite(!1), t.setCullMode(pc.CULLFACE_NONE), t.setBlending(!0), t.setBlendFunctionSeparate(pc.BLENDMODE_SRC_ALPHA, pc.BLENDMODE_ONE_MINUS_SRC_ALPHA, pc.BLENDMODE_ONE, pc.BLENDMODE_ONE), t.setBlendEquationSeparate(pc.BLENDEQUATION_ADD, pc.BLENDEQUATION_ADD), t.setVertexBuffer(i, 0), t.setIndexBuffer(this.indexBuffer), t.setShader(this.shader);
            var s = Math.min(t.maxPixelRatio, window.devicePixelRatio);
            this.clr.set(e, 0), this.clrId.setValue(this.clr), this.screenTextureSize[0] = t.width / s, this.screenTextureSize[1] = t.height / s;
            for (var r = 0; r &lt;= this.primIndex; ++r) {
                var n = this.prims[r];
                this.screenTextureSize[2] = n.texture.width, this.screenTextureSize[3] = n.texture.height, this.screenTextureSizeId.setValue(this.screenTextureSize), t.constantTexSource.setValue(n.texture), t.draw(n)
            }
            t.updateEnd(), this.prim = null, this.primIndex = -1, this.quads = 0
        }
    }), Object.assign(WordAtlas.prototype, {
        render: function(e, t, i, s) {
            var r = this.placements[this.wordMap[t]];
            if (r) {
                return e.quad(this.texture, i + r.l - 1, s - r.d + 1, r.w + 2, r.h + 2, r.x - 1, 64 - r.y - r.h - 1), r.w
            }
            return 0
        }
    }), Object.assign(Graph.prototype, {
        update: function(e) {
            var t = this.timer.timings,
                i = t.reduce((function(e, t) {
                    return e + t
                }), 0);
            if (this.avgTotal += i, this.avgTimer += e, this.avgCount++, this.avgTimer &gt; 1e3 &amp;&amp; (this.timingText = (this.avgTotal / this.avgCount).toFixed(1), this.avgTimer = 0, this.avgTotal = 0, this.avgCount = 0), this.enabled) {
                for (var s = 0, r = 0; r &lt; t.length; ++r) s = Math.min(255, s + Math.floor(5.3125 * t[r])), this.sample[r] = s;
                var n = this.device.gl;
                this.device.bindTexture(this.texture), n.texSubImage2D(n.TEXTURE_2D, 0, this.cursor, this.yOffset, 1, 1, n.RGBA, n.UNSIGNED_BYTE, this.sample), this.cursor++, this.cursor === this.texture.width &amp;&amp; (this.cursor = 0)
            }
        },
        render: function(e, t, i, s, r) {
            this.enabled &amp;&amp; e.quad(this.texture, t + s, i, -s, r, this.cursor, .5 + this.yOffset, -s, 0)
        }
    });
    var FrameTimer = function(e) {
        this.ms = 0;
        var t = this;
        e.on("frameupdate", (function(e) {
            t.ms = e
        }))
    };

    function MiniStats(e) {
        for (var t = e.graphicsDevice, i = new pc.Texture(t, {
                name: "mini-stats",
                width: 256,
                height: 32,
                mipmaps: !1,
                minFilter: pc.FILTER_NEAREST,
                magFilter: pc.FILTER_NEAREST
            }), s = new WordAtlas(i, ["Frame", "CPU", "GPU", "ms", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."]), r = i.lock(), n = 0; n &lt; 4 * i.width; ++n) r.set([0, 0, 0, 255], 4 * n);
        i.unlock();
        var h = [new Graph("Frame", e, new FrameTimer(e), i, 1), new Graph("CPU", e, new CpuTimer(e), i, 2)];
        t.extDisjointTimerQuery &amp;&amp; h.push(new Graph("GPU", e, new GpuTimer(e), i, 3));
        var a = [{
                width: 100,
                height: 16,
                graphs: !1
            }, {
                width: 128,
                height: 32,
                graphs: !0
            }, {
                width: 256,
                height: 64,
                graphs: !0
            }],
            o = 0,
            u = this,
            d = document.createElement("div");
        d.style.cssText = "position:fixed;bottom:0;left:0;background:transparent;", document.body.appendChild(d), d.addEventListener("mouseenter", (function(e) {
            u.opacity = 1
        })), d.addEventListener("mouseleave", (function(e) {
            u.opacity = .5
        })), d.addEventListener("click", (function(e) {
            e.preventDefault(), u._enabled &amp;&amp; (o = (o + 1) % a.length, u.resize(a[o].width, a[o].height, a[o].graphs))
        })), t.on("resizecanvas", (function() {
            u.updateDiv()
        })), e.on("postrender", (function() {
            u._enabled &amp;&amp; u.render()
        })), this.device = t, this.texture = i, this.wordAtlas = s, this.render2d = new Render2d(t), this.graphs = h, this.div = d, this.width = 0, this.height = 0, this.gspacing = 2, this.clr = [1, 1, 1, .5], this._enabled = !0, this.resize(a[o].width, a[o].height, a[o].graphs)
    }
    Object.defineProperty(FrameTimer.prototype, "timings", {
        get: function() {
            return [this.ms]
        }
    }), Object.defineProperties(MiniStats.prototype, {
        opacity: {
            get: function() {
                return this.clr[3]
            },
            set: function(e) {
                this.clr[3] = e
            }
        },
        overallHeight: {
            get: function() {
                var e = this.graphs;
                return this.height * e.length + this.gspacing * (e.length - 1)
            }
        },
        enabled: {
            get: function() {
                return this._enabled
            },
            set: function(e) {
                if (e !== this._enabled) {
                    this._enabled = e;
                    for (var t = 0; t &lt; this.graphs.length; ++t) this.graphs[t].enabled = e, this.graphs[t].timer.enabled = e
                }
            }
        }
    }), Object.assign(MiniStats.prototype, {
        render: function() {
            var e, t, i, s, r, n = this.graphs,
                h = this.wordAtlas,
                a = this.render2d,
                o = this.width,
                u = this.height,
                d = this.gspacing;
            for (e = 0; e &lt; n.length; ++e) {
                s = e * (u + d), (r = n[e]).render(a, 0, s, o, u), i = 1, s += u - 13, i += h.render(a, r.name, i, s) + 10;
                var c = r.timingText;
                for (t = 0; t &lt; c.length; ++t) i += h.render(a, c[t], i, s);
                h.render(a, "ms", i, s)
            }
            a.render(this.clr)
        },
        resize: function(e, t, i) {
            for (var s = this.graphs, r = 0; r &lt; s.length; ++r) s[r].enabled = i;
            this.width = e, this.height = t, this.updateDiv()
        },
        updateDiv: function() {
            var e = this.device.canvas.getBoundingClientRect();
            this.div.style.left = e.left + "px", this.div.style.bottom = window.innerHeight - e.bottom + "px", this.div.style.width = this.width + "px", this.div.style.height = this.overallHeight + "px"
        }
    }), e.MiniStats = MiniStats, Object.defineProperty(e, "__esModule", {
        value: !0
    })
}));
"undefined" != typeof document &amp;&amp; (
    /*! FPSMeter 0.3.1 - 9th May 2013 | https://github.com/Darsain/fpsmeter */
    function(t, e) {
        function s(t, e) {
            for (var n in e) try {
                t.style[n] = e[n]
            } catch (t) {}
            return t
        }

        function H(t) {
            return null == t ? String(t) : "object" == typeof t || "function" == typeof t ? Object.prototype.toString.call(t).match(/\s([a-z]+)/i)[1].toLowerCase() || "object" : typeof t
        }

        function R(t, e) {
            if ("array" !== H(e)) return -1;
            if (e.indexOf) return e.indexOf(t);
            for (var n = 0, o = e.length; n &lt; o; n++)
                if (e[n] === t) return n;
            return -1
        }

        function I() {
            var t, e = arguments;
            for (t in e[1])
                if (e[1].hasOwnProperty(t)) switch (H(e[1][t])) {
                    case "object":
                        e[0][t] = I({}, e[0][t], e[1][t]);
                        break;
                    case "array":
                        e[0][t] = e[1][t].slice(0);
                        break;
                    default:
                        e[0][t] = e[1][t]
                }
            return 2 &lt; e.length ? I.apply(null, [e[0]].concat(Array.prototype.slice.call(e, 2))) : e[0]
        }

        function N(t) {
            return 1 === (t = Math.round(255 * t).toString(16)).length ? "0" + t : t
        }

        function S(t, e, n, o) {
            t.addEventListener ? t[o ? "removeEventListener" : "addEventListener"](e, n, !1) : t.attachEvent &amp;&amp; t[o ? "detachEvent" : "attachEvent"]("on" + e, n)
        }

        function D(t, e) {
            function g(t, e, n, o) {
                return h[0 | t][Math.round(Math.min((e - n) / (o - n) * M, M))]
            }

            function r() {
                F.legend.fps !== q &amp;&amp; (F.legend.fps = q, F.legend[c] = q ? "FPS" : "ms"), b = q ? v.fps : v.duration, F.count[c] = 999 &lt; b ? "999+" : b.toFixed(99 &lt; b ? 0 : O.decimals)
            }

            function m() {
                for (l = n(), P &lt; l - O.threshold &amp;&amp; (v.fps -= v.fps / Math.max(1, 60 * O.smoothing / O.interval), v.duration = 1e3 / v.fps), w = O.history; w--;) T[w] = 0 === w ? v.fps : T[w - 1], j[w] = 0 === w ? v.duration : j[w - 1];
                if (r(), O.heat) {
                    if (z.length)
                        for (w = z.length; w--;) z[w].el.style[o[z[w].name].heatOn] = q ? g(o[z[w].name].heatmap, v.fps, 0, O.maxFps) : g(o[z[w].name].heatmap, v.duration, O.threshold, 0);
                    if (F.graph &amp;&amp; o.column.heatOn)
                        for (w = C.length; w--;) C[w].style[o.column.heatOn] = q ? g(o.column.heatmap, T[w], 0, O.maxFps) : g(o.column.heatmap, j[w], O.threshold, 0)
                }
                if (F.graph)
                    for (y = 0; y &lt; O.history; y++) C[y].style.height = (q ? T[y] ? Math.round(x / O.maxFps * Math.min(T[y], O.maxFps)) : 0 : j[y] ? Math.round(x / O.threshold * Math.min(j[y], O.threshold)) : 0) + "px"
            }

            function k() {
                20 &gt; O.interval ? (p = i(k), m()) : (p = setTimeout(k, O.interval), f = i(m))
            }

            function G(t) {
                (t = t || window.event).preventDefault ? (t.preventDefault(), t.stopPropagation()) : (t.returnValue = !1, t.cancelBubble = !0), v.toggle()
            }

            function U() {
                O.toggleOn &amp;&amp; S(F.container, O.toggleOn, G, 1), t.removeChild(F.container)
            }

            function V() {
                if (F.container &amp;&amp; U(), o = D.theme[O.theme], !(h = o.compiledHeatmaps || []).length &amp;&amp; o.heatmaps.length) {
                    for (y = 0; y &lt; o.heatmaps.length; y++)
                        for (h[y] = [], w = 0; w &lt;= M; w++) {
                            var e, n = h[y],
                                a = w;
                            e = .33 / M * w;
                            var i = o.heatmaps[y].saturation,
                                l = o.heatmaps[y].lightness,
                                p = void 0,
                                c = void 0,
                                u = void 0,
                                d = u = void 0,
                                f = p = c = void 0;
                            f = void 0;
                            0 === (u = .5 &gt;= l ? l * (1 + i) : l + i - l * i) ? e = "#000" : (c = (u - (d = 2 * l - u)) / u, f = (e *= 6) - (p = Math.floor(e)), f *= u * c, 0 === p || 6 === p ? (p = u, c = d + f, u = d) : 1 === p ? (p = u - f, c = u, u = d) : 2 === p ? (p = d, c = u, u = d + f) : 3 === p ? (p = d, c = u - f) : 4 === p ? (p = d + f, c = d) : (p = u, c = d, u -= f), e = "#" + N(p) + N(c) + N(u)), n[a] = e
                        }
                    o.compiledHeatmaps = h
                }
                for (var b in F.container = s(document.createElement("div"), o.container), F.count = F.container.appendChild(s(document.createElement("div"), o.count)), F.legend = F.container.appendChild(s(document.createElement("div"), o.legend)), F.graph = O.graph ? F.container.appendChild(s(document.createElement("div"), o.graph)) : 0, z.length = 0, F) F[b] &amp;&amp; o[b].heatOn &amp;&amp; z.push({
                    name: b,
                    el: F[b]
                });
                if (C.length = 0, F.graph)
                    for (F.graph.style.width = O.history * o.column.width + (O.history - 1) * o.column.spacing + "px", w = 0; w &lt; O.history; w++) C[w] = F.graph.appendChild(s(document.createElement("div"), o.column)), C[w].style.position = "absolute", C[w].style.bottom = 0, C[w].style.right = w * o.column.width + w * o.column.spacing + "px", C[w].style.width = o.column.width + "px", C[w].style.height = "0px";
                s(F.container, O), r(), t.appendChild(F.container), F.graph &amp;&amp; (x = F.graph.clientHeight), O.toggleOn &amp;&amp; ("click" === O.toggleOn &amp;&amp; (F.container.style.cursor = "pointer"), S(F.container, O.toggleOn, G))
            }
            "object" === H(t) &amp;&amp; undefined === t.nodeType &amp;&amp; (e = t, t = document.body), t || (t = document.body);
            var o, h, l, p, f, x, b, w, y, v = this,
                O = I({}, D.defaults, e || {}),
                F = {},
                C = [],
                M = 100,
                z = [],
                E = O.threshold,
                A = 0,
                P = n() - E,
                T = [],
                j = [],
                q = "fps" === O.show;
            v.options = O, v.fps = 0, v.duration = 0, v.isPaused = 0, v.tickStart = function() {
                A = n()
            }, v.tick = function() {
                l = n(), E += (l - P - E) / O.smoothing, v.fps = 1e3 / E, v.duration = A &lt; P ? E : l - A, P = l
            }, v.pause = function() {
                return p &amp;&amp; (v.isPaused = 1, clearTimeout(p), a(p), a(f), p = f = 0), v
            }, v.resume = function() {
                return p || (v.isPaused = 0, k()), v
            }, v.set = function(t, e) {
                return O[t] = e, q = "fps" === O.show, -1 !== R(t, u) &amp;&amp; V(), -1 !== R(t, d) &amp;&amp; s(F.container, O), v
            }, v.showDuration = function() {
                return v.set("show", "ms"), v
            }, v.showFps = function() {
                return v.set("show", "fps"), v
            }, v.toggle = function() {
                return v.set("show", q ? "ms" : "fps"), v
            }, v.hide = function() {
                return v.pause(), F.container.style.display = "none", v
            }, v.show = function() {
                return v.resume(), F.container.style.display = "block", v
            }, v.destroy = function() {
                v.pause(), U(), v.tick = v.tickStart = function() {}
            }, V(), k()
        }
        var n, o = t.performance;
        n = o &amp;&amp; (o.now || o.webkitNow) ? o[o.now ? "now" : "webkitNow"].bind(o) : function() {
            return +new Date
        };
        for (var a = t.cancelAnimationFrame || t.cancelRequestAnimationFrame, i = t.requestAnimationFrame, h = 0, l = 0, p = (o = ["moz", "webkit", "o"]).length; l &lt; p &amp;&amp; !a; ++l) i = (a = t[o[l] + "CancelAnimationFrame"] || t[o[l] + "CancelRequestAnimationFrame"]) &amp;&amp; t[o[l] + "RequestAnimationFrame"];
        a || (i = function(e) {
            var o = n(),
                a = Math.max(0, 16 - (o - h));
            return h = o + a, t.setTimeout((function() {
                e(o + a)
            }), a)
        }, a = function(t) {
            clearTimeout(t)
        });
        var c = "string" === H(document.createElement("div").textContent) ? "textContent" : "innerText";
        D.extend = I, window.FPSMeter = D, D.defaults = {
            interval: 100,
            smoothing: 10,
            show: "fps",
            toggleOn: "click",
            decimals: 1,
            maxFps: 60,
            threshold: 100,
            position: "absolute",
            zIndex: 10,
            left: "5px",
            top: "95%",
            right: "auto",
            bottom: "auto",
            margin: "0 0 0 0",
            theme: "dark",
            heat: 0,
            graph: 0,
            history: 20
        };
        var u = ["toggleOn", "theme", "heat", "graph", "history"],
            d = "position zIndex left top right bottom margin".split(" ")
    }(window),
    function(t, e) {
        e.theme = {};
        var n = e.theme.base = {
            heatmaps: [],
            container: {
                heatOn: null,
                heatmap: null,
                padding: "5px",
                minWidth: "95px",
                height: "30px",
                lineHeight: "30px",
                textAlign: "right",
                textShadow: "none"
            },
            count: {
                heatOn: null,
                heatmap: null,
                position: "absolute",
                top: 0,
                right: 0,
                padding: "5px 10px",
                height: "30px",
                fontSize: "24px",
                fontFamily: "Consolas, Andale Mono, monospace",
                zIndex: 2
            },
            legend: {
                heatOn: null,
                heatmap: null,
                position: "absolute",
                top: 0,
                left: 0,
                padding: "5px 10px",
                height: "30px",
                fontSize: "12px",
                lineHeight: "32px",
                fontFamily: "sans-serif",
                textAlign: "left",
                zIndex: 2
            },
            graph: {
                heatOn: null,
                heatmap: null,
                position: "relative",
                boxSizing: "padding-box",
                MozBoxSizing: "padding-box",
                height: "100%",
                zIndex: 1
            },
            column: {
                width: 4,
                spacing: 1,
                heatOn: null,
                heatmap: null
            }
        };
        e.theme.dark = e.extend({}, n, {
            heatmaps: [{
                saturation: .8,
                lightness: .8
            }],
            container: {
                background: "#222",
                color: "#fff",
                border: "1px solid #1a1a1a",
                textShadow: "1px 1px 0 #222"
            },
            count: {
                heatOn: "color"
            },
            column: {
                background: "#3f3f3f"
            }
        }), e.theme.light = e.extend({}, n, {
            heatmaps: [{
                saturation: .5,
                lightness: .5
            }],
            container: {
                color: "#666",
                background: "#fff",
                textShadow: "1px 1px 0 rgba(255,255,255,.5), -1px -1px 0 rgba(255,255,255,.5)",
                boxShadow: "0 0 0 1px rgba(0,0,0,.1)"
            },
            count: {
                heatOn: "color"
            },
            column: {
                background: "#eaeaea"
            }
        }), e.theme.colorful = e.extend({}, n, {
            heatmaps: [{
                saturation: .5,
                lightness: .6
            }],
            container: {
                heatOn: "backgroundColor",
                background: "#888",
                color: "#fff",
                textShadow: "1px 1px 0 rgba(0,0,0,.2)",
                boxShadow: "0 0 0 1px rgba(0,0,0,.1)"
            },
            column: {
                background: "#777",
                backgroundColor: "rgba(0,0,0,.2)"
            }
        }), e.theme.transparent = e.extend({}, n, {
            heatmaps: [{
                saturation: .8,
                lightness: .5
            }],
            container: {
                padding: 0,
                color: "#fff",
                textShadow: "1px 1px 0 rgba(0,0,0,.5)"
            },
            count: {
                padding: "0 5px",
                height: "40px",
                lineHeight: "40px"
            },
            legend: {
                padding: "0 5px",
                height: "40px",
                lineHeight: "42px"
            },
            graph: {
                height: "40px"
            },
            column: {
                width: 5,
                background: "#999",
                heatOn: "backgroundColor",
                opacity: .5
            }
        })
    }(window, FPSMeter));
var Fps = pc.createScript("fps");
Fps.prototype.initialize = function() {
    this.fps = new FPSMeter({
        heat: !0,
        graph: !0
    })
}, Fps.prototype.update = function(t) {
    this.fps.tick()
};
var FamobiApi = pc.createScript("famobiApi");
FamobiApi.attributes.add("overlay", {
    type: "entity"
}), FamobiApi.attributes.add("cooldown", {
    type: "number",
    default: 6e4
}), pc.extend(FamobiApi.prototype, {
    initialize: function() {
        this._rewardedAdCooldown = !1, this.overlay.enabled = !1, window.famobi = window.famobi || {}, window.famobi.localStorage = window.famobi.localStorage || window.localStorage, window.famobi.sessionStorage = window.famobi.sessionStorage || window.sessionStorage, FamobiApi.instance = this
    },
    getBrandingButtonImage: function() {
        return window.famobi.getBrandingButtonImage()
    },
    openBrandingLink: function() {
        window.famobi.openBrandingLink()
    },
    showInterstitialAd: function() {
        return window.famobi.showInterstitialAd()
    },
    hasRewardedAd: function() {
        return window.famobi.hasRewardedAd() &amp;&amp; !this._rewardedAdCooldown
    },
    rewardedAd: function(e, o) {
        this.overlay.enabled = !0, window.famobi.rewardedAd(function(o) {
            o.rewardGranted &amp;&amp; FamobiApi.instance.activateCooldown(), e(o), FamobiApi.instance.overlay.enabled = !1
        }.bind(o))
    },
    activateCooldown: function() {
        this._timeout ? console.log("something went wrong", this._timeout) : (this._rewardedAdCooldown = !0, this.app.fire("FamobiAPI:cooldown", !0), this._timeout = setTimeout(function() {
            this._rewardedAdCooldown = !1, this._timeout = null
        }.bind(this), this.cooldown))
    },
    setOnPauseRequested: function(e, o) {
        window.famobi_onPauseRequested = e.bind(o || this)
    },
    setOnResumeRequested: function(e, o) {
        window.famobi_onResumeRequested = e.bind(o || this)
    },
    get: function(e) {
        return window.famobi.__(e) || e
    },
    getCurrentLanguage: function() {
        return window.famobi.getCurrentLanguage()
    },
    setLocalStorageItem: function(e, o) {
        window.famobi.localStorage.setItem(e, o)
    },
    getLocalStorageItem: function(e) {
        return window.famobi.localStorage.getItem(e)
    },
    removeLocalStorageItem: function(e) {
        window.famobi.localStorage.removeItem(e)
    },
    clearLocalStorage: function() {
        window.famobi.localStorage.clear()
    },
    setSessionStorageItem: function(e, o) {
        window.famobi.sessionStorage.setItem(e, o)
    },
    getSessionStorageItem: function(e) {
        window.famobi.sessionStorage.getItem(e)
    },
    removeSessionStorageItem: function(e) {
        window.famobi.sessionStorage.removeItem(e)
    },
    clearSessionStorage: function() {
        window.famobi.sessionStorage.clear()
    },
    getOrientation: function() {
        return window.famobi.getOrientation()
    },
    setOnOrientationChange: function(e, o) {
        window.famobi.onOrientationChange(e.bind(o))
    }
}), pc.extend(FamobiApi.prototype, {
    getMoreGamesButtonImage: function() {
        console.warn("GetMoreGamesButtonImage is deprecated, use getBrandingButtonImage instead"), this.getBrandingButtonImage()
    },
    moreGamesLink: function() {
        console.warn("moreGamesLink is deprecated, use openBrandingLink instead"), this.openBrandingLink()
    },
    submitHighscore: function() {
        console.warn("submitHighscore is deprecated, use window.famobi_analytics.trackEvent instead")
    },
    levelUp: function() {
        console.warn("levelUp is deprecated, use window.famobi_analytics.trackEvent instead")
    },
    gameOver: function() {
        console.warn("gameOver is deprecated, use window.famobi_analytics.trackEvent instead")
    },
    showAd: function() {
        console.warn("showAd is deprecated, use showInterstitalAd instead")
    }
});
var FakeFamobiApi = pc.createScript("fakeFamobiApi"),
    templateName = "BOILERPLATE_FAMOBI";
FakeFamobiApi.attributes.add("templateName", {
    type: "string",
    default: templateName,
    title: "Template Name",
    description: "This value is used for saving in the localStorage. Make sure to make it unique, so it doesn't override any other storages."
}), FakeFamobiApi.attributes.add("hasRewardedAd", {
    type: "boolean",
    default: !1,
    title: "Has Rewarded Ad",
    description: "You can change this value for testing purposes. This will not affect the real famobi API"
}), FakeFamobiApi.attributes.add("interstitialDuration", {
    type: "number",
    default: 3e3,
    title: "Interstitial Duration"
}), FakeFamobiApi.attributes.add("rewardedDuration", {
    type: "number",
    default: 3e3,
    title: "Rewarded Ad Duration"
}), FakeFamobiApi.attributes.add("eventDuration", {
    type: "number",
    default: 50,
    title: "Event tracking duration"
}), FakeFamobiApi.attributes.add("currentLanguage", {
    type: "string",
    default: "en",
    title: "Default Language",
    enum: [{
        German: "de"
    }, {
        English: "en"
    }, {
        Turkish: "tr"
    }, {
        Polish: "pl"
    }, {
        Russian: "ru"
    }, {
        Dutch: "nl"
    }, {
        Spanish: "es"
    }, {
        Portuguese: "pt"
    }, {
        French: "fr"
    }]
}), FakeFamobiApi.attributes.add("trackingLog", {
    type: "boolean"
}), FakeFamobiApi.attributes.add("debug", {
    type: "boolean",
    default: !1
}), pc.extend(FakeFamobiApi.prototype, {
    initialize: function() {
        this.on("attr:hasRewardedAd", (function(e) {
            window.famobi_hasRewardedAd = e
        })), this.on("attr:interstitialDuration", (function(e) {
            window.famobi_interstitialDuration = e
        })), this.on("attr:rewardedDuration", (function(e) {
            window.famobi_rewardedDuration = e
        })), this.on("attr:currentLanguage", (function(e) {
            window.famobi_currentLanguage = e
        })), this.on("attr:debug", (function(e) {
            window.famobi_debug = e
        })), window.famobi ? console.log("Famobi api found") : (console.log("No window.famobi found, creating a fake one."), window.famobi_currentLanguage = this.currentLanguage, window.famobi_interstitialDuration = this.interstitialDuration, window.famobi_hasRewardedAd = this.hasRewardedAd, window.famobi_rewardedDuration = this.rewardedDuration, window.famobi_gameID = this.templateName, window.famobi_eventDuration = this.eventDuration, window.famobi_debug = this.debug, window.famobi_gameID === templateName &amp;&amp; console.warn("Set a different Famobi Game ID in FakeFamobiAPI"), window.famobi = {
            getBrandingButtonImage: function() {
                return pc.Application.getApplication().assets.find("placeholder_famobi_branding_button.png").getFileUrl().replace("/api/", "")
            },
            openBrandingLink: function() {
                window.open("https://html5games.com/")
            },
            showInterstitialAd: function() {
                return console.log("[Show Interstitital Ad] Waiting for " + window.famobi_interstitialDuration / 1e3 + " seconds"), "function" == typeof window.famobi_onPauseRequested &amp;&amp; window.famobi_onPauseRequested(), new Promise((function(e, t) {
                    setTimeout((function() {
                        "function" == typeof window.famobi_onResumeRequested &amp;&amp; window.famobi_onResumeRequested(), e()
                    }), window.famobi_interstitialDuration)
                }))
            },
            hasRewardedAd: function() {
                return window.famobi_hasRewardedAd
            },
            rewardedAd: function(e) {
                console.log("[Show Rewarded Ad] Waiting for " + window.famobi_rewardedDuration / 1e3 + " seconds"), "function" == typeof window.famobi_onPauseRequested &amp;&amp; window.famobi_onPauseRequested(), window.famobi_hasRewardedAd = !1, setTimeout((function() {
                    window.famobi_hasRewardedAd = !0
                }), 3e3), setTimeout((function() {
                    "function" == typeof window.famobi_onPauseRequested &amp;&amp; window.famobi_onResumeRequested(), e({
                        rewardGranted: !0
                    })
                }), window.famobi_rewardedDuration)
            },
            __: function(e) {
                return console.log("need a smart solution for this."), e
            },
            getCurrentLanguage: function() {
                return window.famobi_currentLangauge
            },
            localStorage: {
                setItem: function(e, t) {
                    window.localStorage.setItem(window.famobi_gameID + ":" + e, t)
                },
                getItem: function(e) {
                    return window.localStorage.getItem(window.famobi_gameID + ":" + e)
                },
                removeItem: function(e) {
                    window.localStorage.removeItem(e)
                },
                clear: function() {
                    for (var e in window.localStorage) e.startsWith(window.famobi_gameID + ":") &amp;&amp; window.localStorage.removeItem(e)
                }
            },
            getOrientation: function() {
                var e = window.innerWidth,
                    t = window.innerHeight;
                return e &gt; t ? "landscape" : e &lt; t ? "portrait" : ""
            },
            onOrientationChange: function(e) {
                window.addEventListener("resize", e)
            }
        }), window.famobi_analytics ? console.log("Famobi api analytics found") : (console.log("No window.famobi_analytics found, creating a fake one."), window.famobi_analytics = {
            EVENT_LEVELSUCCESS: "EVENT_LEVELSUCCESS",
            EVENT_LEVELFAIL: "EVENT_LEVELFAIL",
            EVENT_LEVELSTART: "EVENT_LEVELSTART",
            EVENT_LEVELRESTART: "EVENT_LEVELRESTART",
            EVENT_TOTALSCORE: "EVENT_TOTALSCORE",
            EVENT_LEVELSCORE: "EVENT_LEVELSCORE",
            EVENT_VOLUMECHANGE: "EVENT_VOLUMECHANGE",
            EVENT_PAUSE: "EVENT_PAUSE",
            EVENT_RESUME: "EVENT_RESUME",
            EVENT_CUSTOM: "EVENT_CUSTOM",
            trackEvent: function(e, t) {
                return this._validateParameters(e, t), new Promise((function(e, t) {
                    setTimeout((function() {
                        e()
                    }), window.famobi_eventDuration)
                }))
            },
            trackStats: function(e, t) {
                return window.famobi_debug &amp;&amp; console.warn("Track stats", e, t), new Promise((function(n, a) {
                    var o = {};
                    "string" == typeof e &amp;&amp; (o[e] = t);
                    if (! function() {
                            for (var t in o) {
                                if (!("string" == typeof e &amp;&amp; e.length &amp;&amp; e.length &lt;= 42 &amp;&amp; e.match(/^[a-z\_0-9]+$/))) return console.warn("trackStats(): key '" + e + "' contains not only lowercase letters, numbers and underscore ([a-z_0-9]), maximum length: 42 characters"), !1
                            }
                            return !0
                        }()) return a("trackStats(): invalid params " + JSON.stringify(e, t)), !1;
                    n({})
                }))
            },
            _validateParameters: function(e, t) {
                switch (e) {
                    case this.EVENT_LEVELSUCCESS:
                        t &amp;&amp; "string" == typeof t.levelName || console.log("Object with the key levelName has a wrong value", t);
                        break;
                    case this.EVENT_LEVELFAIL:
                        t &amp;&amp; "string" == typeof t.levelName || console.log("Object with the key levelName has a wrong value", t), t &amp;&amp; "string" == typeof t.reason || console.log('Object with the key reason has a wrong value. It should be either "timeout" | "dead" | "wrong_answer" | "draw"', t);
                        break;
                    case this.EVENT_LEVELSTART:
                    case this.EVENT_LEVELRESTART:
                        t &amp;&amp; "string" == typeof t.levelName || console.log("Object with the key levelName has a wrong value", t);
                        break;
                    case this.EVENT_TOTALSCORE:
                        t &amp;&amp; "number" == typeof t.totalScore || console.log("Object with the key totalScore has a wrong value", t);
                        break;
                    case this.EVENT_LEVELSCORE:
                        t &amp;&amp; "string" == typeof t.levelName || console.log("Object with the key levelName has a wrong value", t), t &amp;&amp; "number" == typeof t.levelScore || console.log("Object with the key levelScore has a wrong value", t);
                        break;
                    case this.EVENT_VOLUMECHANGE:
                        (!t || "number" != typeof t.bgmVolume &amp;&amp; "number" != typeof t.sfxVolume) &amp;&amp; console.log("Object has no bgmVolume and sfxVolume value", t);
                        break;
                    case this.EVENT_PAUSE:
                    case this.EVENT_RESUME:
                        break;
                    case this.EVENT_CUSTOM:
                        0 === Object.keys(t).length &amp;&amp; console.log("Object should have atleast one key value pair", t);
                        break;
                    default:
                        console.warn("Event name", e, "is not recognized!")
                }
            }
        }), window.famobi_tracking || (window.famobi_tracking = {
            trackingLog: this.trackingLog,
            tracking: {
                queue: [],
                currentPromise: Promise.resolve()
            },
            EVENTS: {
                LEVEL_START: "event/level/start",
                LEVEL_END: "event/level/end",
                LEVEL_UPDATE: "event/level/update",
                AD: "event/ad"
            },
            EVENT_PARAMS: {
                level: "number",
                score: "number",
                stars: "number",
                movesAvailable: "number",
                movesLeft: "number",
                success: "boolean",
                revives: "number",
                powerups: "object",
                jumpStarters: "object",
                data: "object"
            },
            init: function(e, t, n, a, o) {
                console.log(e, t, n, a, o)
            },
            trackEvent: function(e, t) {
                if (window.famobi_debug &amp;&amp; console.warn("Track Event", e, t), e in this.EVENTS &amp;&amp; (e = this.EVENTS[e]), this.trackingLog &amp;&amp; console.log("queuing event", e, "with data", t), "string" == typeof e &amp;&amp; "object" == typeof t &amp;&amp; null !== t) {
                    for (var n = Object.keys(t), a = 0; a &lt; n.length; a++) {
                        var o = n[a];
                        o in this.EVENT_PARAMS &amp;&amp; typeof t[o] === this.EVENT_PARAMS[o] || console.log("tracking event cancelled - wrong key or type", "event", e, "data", t, "key", o)
                    }
                    this.tracking.queue.push({
                        event: e,
                        data: t
                    }), this.processQueue()
                } else console.log("tracking event cancelled - wrong/missing parameters", "event", e, "data", t)
            },
            sendRequest: function(e, t) {
                return this.trackingLog &amp;&amp; console.log("tracking event", e, "with data", t), new Promise((function(e, t) {
                    setTimeout(e, 1e3)
                }))
            },
            processQueue: function() {
                this.tracking.queue.forEach(function(e) {
                    this.tracking.currentPromise = this.tracking.currentPromise.then(function() {
                        return this.sendRequest(e.event, e.data)
                    }.bind(this), function() {
                        return this.sendRequest(e.event, e.data)
                    }.bind(this))
                }.bind(this)), this.tracking.queue.length = 0
            }
        })
    }
});
var AudioManager = pc.createScript("audioManager");
AudioManager.attributes.add("bgmVolume", {
    type: "number",
    default: .25,
    min: 0,
    max: 1
}), AudioManager.attributes.add("maxBGMVolume", {
    type: "number",
    default: 1,
    min: 0,
    max: 1
}), AudioManager.attributes.add("sfxVolume", {
    type: "number",
    default: 1,
    min: 0,
    max: 1
}), AudioManager.attributes.add("maxSFXVolume", {
    type: "number",
    default: 1,
    min: 0,
    max: 1
}), AudioManager.attributes.add("autoPlayBGMIndex", {
    type: "number",
    default: 0
}), AudioManager.attributes.add("bgmSettingKey", {
    type: "string",
    default: "music",
    description: "This key must be the same as in the default_save_data.json"
}), AudioManager.attributes.add("sfxSettingKey", {
    type: "string",
    default: "",
    description: "Leave this empty if there is only one setting for all sounds"
}), pc.extend(AudioManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (AudioManager.instance = this), this.sfx = this.app.assets.findByTag("sfx"), this.bgm = this.app.assets.findByTag("bgm"), this.soundPlayer = this.entity.addComponent("sound"), this.soundPlayer.positional = !1, this.activeMusicSlot = null, this.activeMusicName = null, this.natureSoundSlot = null, this.natureSoundName = null, this.useBGM = !0, this.useSFX = !0, this._bgmSlots = {}, this._sfxSlots = {}, this._bgmVolume = this.bgmVolume, this._sfxVolume = this.sfxVolume, this.app.on("Audio:sfx", this._playSFX, this), this.app.on("Audio:bgm", this._playBGM, this), this.on("attr:bgmVolume", this._setBGMVolume, this), this.on("attr:sfxVolume", this._setSFXVolume, this), this.on("attr:maxBGMVolume", (function() {
            this._setBGMVolume(this.bgmVolume)
        }), this), this.on("attr:maxSFXVolume", (function() {
            this._setSFXVolume(this.sfxVolume)
        }), this), this.app.context._soundManager.context &amp;&amp; "suspended" === this.app.context._soundManager.context.state &amp;&amp; this.app.on("InputManager:input", this._onResumeContext, this), this.app.on("AudioManager:stopBgm", this._stopMusic, this), this.app.on("UIManager:opened", this._onUIOpen, this)
    },
    postInitialize: function() {
        Wrapper.instance.setOnPauseRequested(this.mute, this), Wrapper.instance.setOnResumeRequested(this.unmute, this), this.setBGMSetting(StorageManager.instance.get(this.bgmSettingKey), !0), this.sfxSettingKey &amp;&amp; this.setSFXSetting(StorageManager.instance.get(this.sfxSettingKey), !0), this._loadSounds(), this._playNatureSoundSlot("nature_sounds.mp3")
    },
    _loadSounds: function() {
        for (var t = 0; t &lt; this.bgm.length; t += 1)
            if (this.bgm[t] instanceof pc.Asset)
                if (this._bgmSlots[this.bgm[t].name] = 0, this.bgm[t].resource) {
                    var e = this._createBGMSlot(this.bgm[t]);
                    this.activeMusicName = this.bgm[t].name, t === this.autoPlayBGMIndex &amp;&amp; this._playBGMSlot(e)
                } else t === this.autoPlayBGMIndex ? (this.activeMusicName = this.bgm[t].name, LazyLoader.instance.lazyLoad(this.bgm[t], (function(t) {
                    this._onBGMLoadComplete(t, !0)
                }), this)) : LazyLoader.instance.lazyLoad(this.bgm[t], (function(t) {
                    this._onBGMLoadComplete(t, !1)
                }), this);
        else console.warn("BGM with index " + t + " is not an asset!");
        for (var s = 0; s &lt; this.sfx.length; s += 1) this.sfx[s] instanceof pc.Asset ? 0 !== this._sfxSlots[this.sfx[s].name] ? (this._sfxSlots[this.sfx[s].name] = 0, this.sfx[s].resource ? this._createSFXSlot(this.sfx[s]) : LazyLoader.instance.lazyLoad(this.sfx[s], this._onSFXLoadComplete, this)) : console.warn(this.sfx[s].name, " is already loading. Ignoring", this.sfx[s]) : console.warn("SFX with index " + s + " is not an asset!")
    },
    _onBGMLoadComplete: function(t, e) {
        var s = this._createBGMSlot(t);
        e &amp;&amp; this._playBGMSlot(s)
    },
    _onSFXLoadComplete: function(t) {
        this._createSFXSlot(t)
    },
    _createBGMSlot: function(t) {
        var e = this.soundPlayer.addSlot(t.name, {
            asset: t.id,
            volume: ("number" == typeof this._bgmVolume ? this._bgmVolume : 1) * this.maxBGMVolume,
            pitch: 1,
            loop: !0,
            overlap: !1
        });
        return this._bgmSlots[t.name] = e, e
    },
    _createSFXSlot: function(t) {
        var e = this.soundPlayer.addSlot(t.name, {
            asset: t.id,
            volume: ("number" == typeof this._sfxVolume ? this._sfxVolume : 1) * this.maxSFXVolume,
            pitch: 1,
            loop: !1,
            overlap: !0
        });
        return this._sfxSlots[t.name] = e, e
    },
    _onResumeContext: function() {
        this.app.context._soundManager.context.resume(), setTimeout(function() {
            "suspended" !== this.app.context._soundManager.context.state &amp;&amp; this.app.off("InputManager:input", this._onResumeContext, this)
        }.bind(this), 100)
    },
    _playSFX: function(t) {
        var e = this._sfxSlots[t];
        if (e) return this._playSFXSlot(e);
        switch (e) {
            case void 0:
                console.warn("Sound slot with the name [" + t + "] is not found");
                break;
            case 0:
                console.warn("Sound slot with the name " + t + " is still loading");
                break;
            default:
                console.warn("Something went wrong with the sound. Value is " + e)
        }
    },
    _playBGM: function(t) {
        var e = this._bgmSlots[t];
        if (this.activeMusicName = t, e) return this._playBGMSlot(e);
        switch (e) {
            case void 0:
                console.warn("Sound slot with the name [" + t + "] is not found");
                break;
            case 0:
                console.warn("Sound slot with the name " + t + " is still loading");
                break;
            default:
                console.warn("Something went wrong with the sound. Value is " + e)
        }
    },
    _playBGMSlot: function(t) {
        if (this.activeMusicSlot === t &amp;&amp; this.activeMusicSlot.isPlaying) console.warn("Can't play the same bgm twice");
        else if (this.activeMusicName === t.name &amp;&amp; (this.app.context._soundManager.context &amp;&amp; "suspended" === this.app.context._soundManager.context.state &amp;&amp; this._onResumeContext(), this._stopMusic(), this.useBGM)) return this.activeMusicSlot = t, this.activeMusicSlot.volume = this._bgmVolume * this.maxBGMVolume, this.activeMusicSlot.play(), this.activeMusicSlot
    },
    playBGM: function(t) {
        return this._playBGM(t)
    },
    playSFX: function(t) {
        return this._playSFX(t)
    },
    getActiveMusicSlot: function() {
        return this.activeMusicSlot
    },
    fadeOutMusicSlot: function(t, e) {
        return this.activeMusicSlot ? this.entity.tween(this.activeMusicSlot).to({
            volume: 0
        }, t, pc.Linear, e || 0).start() : (console.warn("No active music slot"), null)
    },
    _playSFXSlot: function(t) {
        if (this.useSFX) return t.play(), t
    },
    _stopMusic: function() {
        this.activeMusicSlot &amp;&amp; (this.activeMusicSlot.stop(), this.activeMusicSlot = null)
    },
    _setBGMVolume: function(t) {
        var e = Object.keys(this._bgmSlots);
        this._bgmVolume = t;
        for (var s = 0; s &lt; e.length; s += 1) "object" == typeof this._bgmSlots[e[s]] &amp;&amp; (this._bgmSlots[e[s]].volume = t * this.maxBGMVolume)
    },
    _setSFXVolume: function(t) {
        var e = Object.keys(this._sfxSlots);
        this._sfxVolume = t;
        for (var s = 0; s &lt; e.length; s += 1) "object" == typeof this._sfxSlots[e[s]] &amp;&amp; (this._sfxSlots[e[s]].volume = t * this.maxSFXVolume)
    },
    _playNatureSoundSlot: function(t) {
        var e = this._bgmSlots[t];
        if (this.natureSoundName = t, e) this.natureSoundSlot === e &amp;&amp; this.natureSoundSlot.isPlaying ? console.warn("Can't play the same bgm twice") : this.natureSoundName === e.name &amp;&amp; (this.app.context._soundManager.context &amp;&amp; "suspended" === this.app.context._soundManager.context.state &amp;&amp; this._onResumeContext(), this.useBGM &amp;&amp; (this.natureSoundSlot = e, this.natureSoundSlot.play()));
        else switch (e) {
            case void 0:
                console.warn("Sound slot with the name [" + t + "] is not found");
                break;
            case 0:
                console.warn("Sound slot with the name " + t + " is still loading");
                break;
            default:
                console.warn("Something went wrong with the sound. Value is " + e)
        }
    },
    setBGMSetting: function(t, e) {
        if (t = Number(t), !isNaN(t)) return t = pc.math.clamp(t, 0, 1), e || StorageManager.instance.set(this.bgmSettingKey, t), this._setBGMVolume(t), this.bgmSettingKey &amp;&amp; !this.sfxSettingKey &amp;&amp; this.setSFXSetting(t), this.useBGM;
        console.warn("Volume is NaN!", t)
    },
    setSFXSetting: function(t, e) {
        if (t = Number(t), !isNaN(t)) return t = pc.math.clamp(t, 0, 1), this.sfxSettingKey &amp;&amp; !e &amp;&amp; StorageManager.instance.set(this.sfxSettingKey, t), this.useSFX = !!t, this._setSFXVolume(t), this.useSFX;
        console.warn("Volume is NaN!", t)
    },
    startBGM: function() {
        this._playBGM("main_ost.mp3")
    },
    mute: function(t) {
        this.app.systems.sound.volume = 0
    },
    unmute: function(t) {
        this.app.systems.sound.volume = 1
    },
    getSFXVolume: function() {
        return this._sfxVolume
    },
    getBGMVolume: function() {
        return this._bgmVolume
    }
});
var GameManager = pc.createScript("gameManager");
GameManager.attributes.add("levelSelectionEntities", {
    type: "entity"
}), pc.extend(GameManager, {
    startUp: function() {
        GameManager.instance.goToGarden()
    }
}), pc.extend(GameManager.prototype, {
    initialize: function() {
        GameManager.instance = this, this._currentSceneController = null, this.levelString = "level_"
    },
    postInitialize: function() {
        LevelLoader.instance.loadLevel(1)
    },
    goToGarden: function() {
        this.lastPlayedWorld = "World", LoadScreenController.load(this.lastPlayedWorld, !0, "Loading", null)
    },
    onSelect: function(e) {
        this.entity.script.swapMode.onSelect(e, e.colorID)
    },
    getLevelName: function() {
        return this.levelString + LevelManager.instance.getCurrentLevelNumber()
    },
    loadScreenDone: function() {
        Application.loadedLevelName.includes("World") &amp;&amp; (this.app.fire("UIManager:showUI", "Menu"), this.app.fire("UIManager:showUI", "Settings"), this.app.fire("GameManager:ready"), LevelLoader.instance.lazyLoadLevels())
    },
    trackEventLevelStart: function(e) {
        var a = window.famobi_analytics.trackEvent(e ? window.famobi_analytics.EVENT_LEVELRESTART : window.famobi_analytics.EVENT_LEVELSTART, {
            levelName: this.getLevelName()
        });
        return Promise.all([a])
    },
    trackEventLevelSuccess: function(e) {
        StatisticsManager.instance.incrementStatistic("levels_completed", 1);
        LevelManager.instance.getCurrentLevelNumber();
        var a = [],
            t = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_LEVELSUCCESS, {
                levelName: this.getLevelName()
            }),
            n = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_LEVELSCORE, {
                levelName: this.getLevelName(),
                levelScore: ScoreManager.instance.getCurrentLevelScore()
            }),
            i = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_TOTALSCORE, {
                totalScore: ScoreManager.instance.getScore()
            });
        return a.push(t, n, i), e &amp;&amp; a.push(FamobiApi.instance.showInterstitialAd()), Promise.all(a)
    },
    trackEventLevelFail: function(e) {
        StatisticsManager.instance.incrementStatistic("attempts_failed", 1);
        LevelManager.instance.getCurrentLevelNumber();
        var a = [],
            t = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_LEVELFAIL, {
                levelName: this.getLevelName(),
                reason: "dead"
            }),
            n = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_LEVELSCORE, {
                levelName: this.getLevelName(),
                levelScore: ScoreManager.instance.getCurrentLevelScore()
            }),
            i = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_TOTALSCORE, {
                totalScore: ScoreManager.instance.getScore()
            });
        return a.push(t, n, i), e &amp;&amp; a.push(FamobiApi.instance.showInterstitialAd()), Promise.all(a)
    },
    trackEventLevelQuit: function() {
        var e = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_LEVELFAIL, {
            levelName: this.getLevelName(),
            reason: "quit"
        });
        return this.app.fire("GameManager:quit"), Promise.all([e])
    },
    trackEventPause: function() {
        var e = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_PAUSE);
        return Promise.all([e])
    },
    trackEventResume: function() {
        var e = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_RESUME);
        return Promise.all([e])
    },
    trackEventVolumeChange: function() {
        var e = window.famobi_analytics.trackEvent(window.famobi_analytics.EVENT_VOLUMECHANGE, {
            bgmVolume: AudioManager.instance.getBGMVolume(),
            sfxVolume: AudioManager.instance.getSFXVolume()
        });
        return Promise.all([e])
    }
});
var LocalizationManager = pc.createScript("localizationManager");
pc.extend(LocalizationManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (LocalizationManager.instance = this), this.textInstances = {}
    },
    setLocale: function(t) {
        this.app.i18n.locale = t, this._replaceTextInstances()
    },
    setText: function(t, e, n) {
        this._logText(t, e, n), this._displayText(t, e, n)
    },
    _getTextByKey: function(t) {
        return this.app.i18n.getText(t)
    },
    _parseText: function(t, e) {
        if (!Array.isArray(e) || 0 === e.length) {
            if (!e) return t;
            e = [e]
        }
        for (var n = t, i = 0; i &lt; e.length; i += 1) n = n.replace("{" + i + "}", e[i]);
        return n
    },
    _displayText: function(t, e, n) {
        t.element.text = this._parseText(this.app.i18n.getText(e), n)
    },
    _logText: function(t, e, n) {
        this.textInstances[t._guid] || (this.textInstances[t._guid] = {}, this.textInstances[t._guid].textEntity = t, this.textInstances[t._guid].key = e), this.textInstances[t._guid].variables = n
    },
    _replaceTextInstances: function() {
        for (var t in this.textInstances) void 0 === this.textInstances[t].textEntity.element ? delete this.textInstances[t] : this._displayText(this.textInstances[t].textEntity, this.textInstances[t].key, this.textInstances[t].variables)
    },
    get: function(t, e) {
        return this._parseText(this._getTextByKey(t), e)
    }
});
var TweenAlpha = pc.createScript("tweenAlpha");
TweenAlpha.attributes.add("initFrom", {
    type: "number",
    default: 1,
    title: "From"
}), TweenAlpha.attributes.add("initTo", {
    type: "number",
    default: 0,
    title: "To"
}), TweenAlpha.attributes.add("playStyle", {
    type: "number",
    enum: [{
        Once: 0
    }, {
        Loop: 1
    }, {
        PingPong: 2
    }],
    title: "Play Style"
}), TweenAlpha.attributes.add("duration", {
    type: "number",
    default: 1,
    title: "duration"
}), TweenAlpha.attributes.add("curve", {
    type: "curve",
    title: "Animation Curve"
}), TweenAlpha.attributes.add("ignoreTimeScale", {
    type: "boolean",
    default: !0,
    title: "Ignore Time Scale"
}), TweenAlpha.attributes.add("startDelay", {
    type: "number",
    default: 0,
    title: "Start Delay"
}), TweenAlpha.attributes.add("debug", {
    type: "boolean",
    default: !1,
    title: "Show Debug"
}), TweenAlpha.attributes.add("startOnEnable", {
    type: "boolean",
    default: !0,
    title: "Start on Enable"
}), TweenAlpha.attributes.add("startOnInitialize", {
    type: "boolean",
    default: !0,
    title: "Start on Initialize"
}), pc.extend(TweenAlpha.prototype, {
    initialize: function() {
        this._time = this.startOnInitialize ? 0 : this.duration + this.startDelay, this._oldTime = this.app._time || 0, this._from = this.initFrom, this._to = this.initTo, this._elements = this._elements || []
    },
    postInitialize: function() {
        this._getAllElementComponents(this.entity), this.startOnInitialize &amp;&amp; this.startTween(), this.on("state", (function(t) {
            t &amp;&amp; this.startOnEnable &amp;&amp; this.startTween()
        }))
    },
    update: function(t) {
        if (this.isActive()) {
            if (this.updateTime(t), this._time &gt; this.startDelay) {
                var e = this._from - this.curve.value((this._time - this.startDelay) / this.duration) * (this._from - this._to);
                this.setAllElementOpacity(e), this.debug &amp;&amp; console.log(this.entity.name, this._time, e)
            }
            this._oldTime = this.app._time
        }
        if (this._time &gt;= this.duration + this.startDelay) switch (this.playStyle) {
            case 0:
                break;
            case 1:
                this._time = 0;
                break;
            case 2:
                this._time = 0;
                var i = this._from;
                this._from = this._to, this._to = i
        }
    },
    updateTime: function() {
        this._time += this.ignoreTimeScale ? (this.app._time - this._oldTime) / 1e3 : dt
    },
    _getAllElementComponents: function(t) {
        var e = t.element;
        void 0 !== e &amp;&amp; null !== e.opacity &amp;&amp; void 0 !== e.opacity &amp;&amp; this._elements.push(t.element);
        var i = this;
        t.children.forEach((function(t) {
            i._getAllElementComponents(t)
        }))
    },
    startTween: function() {
        this._time = 0, this._from = this.initFrom, this._to = this.initTo, this.setAllElementOpacity(this._from), this._oldTime = this.app._time
    },
    setAllElementOpacity: function(t) {
        this._elements || (this._elements = [], this._getAllElementComponents(this.entity)), this._elements.forEach((function(e) {
            e.opacity = t
        }))
    },
    isActive: function() {
        return this._time &gt;= 0 &amp;&amp; this._time &lt;= this.duration + this.startDelay
    }
});
var TweenPosition = pc.createScript("tweenPosition");
TweenPosition.attributes.add("initFrom", {
    type: "vec3",
    default: [0, 0, 0],
    title: "From"
}), TweenPosition.attributes.add("initTo", {
    type: "vec3",
    default: [0, 0, 0],
    title: "To"
}), TweenPosition.attributes.add("playStyle", {
    type: "number",
    enum: [{
        Once: 0
    }, {
        Loop: 1
    }, {
        PingPong: 2
    }],
    title: "Play Style"
}), TweenPosition.attributes.add("duration", {
    type: "number",
    default: 1,
    title: "duration"
}), TweenPosition.attributes.add("curve", {
    type: "curve",
    title: "Animation Curve"
}), TweenPosition.attributes.add("ignoreTimeScale", {
    type: "boolean",
    default: !0,
    title: "Ignore Time Scale"
}), TweenPosition.attributes.add("startDelay", {
    type: "number",
    default: 0,
    title: "Start Delay"
}), TweenPosition.attributes.add("debug", {
    type: "boolean",
    default: !1,
    title: "Show Debug"
}), TweenPosition.attributes.add("startAtEnable", {
    type: "boolean",
    default: !0,
    title: "Start on Initialize"
}), TweenPosition.attributes.add("startOnEnable", {
    type: "boolean",
    default: !0,
    title: "Start on Enable"
}), pc.extend(TweenPosition.prototype, {
    initialize: function() {
        this._time = this.startAtEnable ? 0 : this.duration + this.startDelay + 1, this._oldTime = this.app._time || 0, this._from = this.initFrom.clone(), this._to = this.initTo.clone(), this._initPosition = this.entity.getLocalPosition().clone(), this._newPosition = new pc.Vec3(0, 0, 0)
    },
    postInitialize: function() {
        this.on("state", (function(t) {
            t &amp;&amp; this.startOnEnable &amp;&amp; this.startTween()
        })), this.startAtEnable &amp;&amp; this.startTween()
    },
    update: function(t) {
        if (this._time &gt;= 0 &amp;&amp; this._time &lt;= this.duration + this.startDelay &amp;&amp; (this.updateTime(t), this._time &gt; this.startDelay &amp;&amp; (this._newPosition.set(this._from.x, this._from.y, this._from.z).sub(this._to).scale(this.curve.value((this._time - this.startDelay) / this.duration)).sub2(this._from, this._newPosition).add(this._initPosition), this.entity.setLocalPosition(this._newPosition)), this._oldTime = this.app._time), this._time &gt;= this.duration + this.startDelay || this._time &lt;= 0) switch (this.playStyle) {
            case 0:
                break;
            case 1:
                this._time = 0;
                break;
            case 2:
                this._time = 0;
                var i = this._from;
                this._from = this._to, this._to = i
        }
    },
    updateTime: function(t) {
        this._time += this.ignoreTimeScale ? (this.app._time - this._oldTime) / 1e3 : t
    },
    moveTo: function(t, i) {
        this._time = 0, this._from.set(0, 0, 0), this._to.set(0, 0, 0), this._to.sub(t), this._initPosition.set(t.x, t.y, t.z), this.oldTime = this.app._time
    },
    startTween: function() {
        try {
            this._time = 0, this._from.set(this.initFrom.x, this.initFrom.y, this.initFrom.z), this._to.set(this.initTo.x, this.initTo.y, this.initTo.z), this.entity.setLocalPosition(this._from.x + this._initPosition.x, this._from.y + this._initPosition.y, this._from.z + this._initPosition.z), this.oldTime = this.app._time
        } catch (t) {
            console.log(t), setTimeout(this.startTween)
        }
    }
});
var TweenRotation = pc.createScript("tweenRotation");
TweenRotation.attributes.add("initFrom", {
    type: "vec3",
    default: [0, 0, 0],
    title: "From"
}), TweenRotation.attributes.add("initTo", {
    type: "vec3",
    default: [0, 0, 0],
    title: "To"
}), TweenRotation.attributes.add("playStyle", {
    type: "number",
    enum: [{
        Once: 0
    }, {
        Loop: 1
    }, {
        PingPong: 2
    }],
    title: "Play Style"
}), TweenRotation.attributes.add("duration", {
    type: "number",
    default: 1,
    title: "duration"
}), TweenRotation.attributes.add("curve", {
    type: "curve",
    title: "Animation Curve"
}), TweenRotation.attributes.add("ignoreTimeScale", {
    type: "boolean",
    default: !0,
    title: "Ignore Time Scale"
}), TweenRotation.attributes.add("startDelay", {
    type: "number",
    default: 0,
    title: "Start Delay"
}), TweenRotation.attributes.add("debug", {
    type: "boolean",
    default: !1,
    title: "Show Debug"
}), TweenRotation.attributes.add("startOnEnable", {
    type: "boolean",
    default: !0,
    title: "Start on Enable"
}), TweenRotation.attributes.add("startOnInit", {
    type: "boolean",
    default: !0,
    title: "Start on Initialize"
}), pc.extend(TweenRotation.prototype, {
    initialize: function() {
        this.on("attr:initFrom", (function() {
            this.stopTween(), this.startTween()
        }), this), this.on("attr:initTo", (function() {
            this.stopTween(), this.startTween()
        }), this), this._time = this.startOnInit ? 0 : this.duration + this.startDelay + 1, this._oldTime = this.app._time || 0, this._from = this.initFrom.clone(), this._to = this.initTo.clone()
    },
    postInitialize: function() {
        this._initRotation = this.entity.getLocalEulerAngles(), this._newRotation = new pc.Vec3(0, 0, 0), this.on("state", (function(t) {
            t &amp;&amp; this.startOnEnable &amp;&amp; this.startTween()
        })), this.startOnInit &amp;&amp; this.startTween()
    },
    update: function(t) {
        if (this._time &gt;= 0 &amp;&amp; this._time &lt;= this.duration + this.startDelay &amp;&amp; (this._updateTime(t), this._time &gt; this.startDelay &amp;&amp; (this._newRotation.set(this._from.x, this._from.y, this._from.z).sub(this._to).scale(this.curve.value((this._time - this.startDelay) / this.duration)).sub2(this._from, this._newRotation).add(this._initRotation), this.debug &amp;&amp; console.log(this.time, newRotation.toString()), this.entity.setLocalEulerAngles(this._newRotation.x, this._newRotation.y, this._newRotation.z)), this._oldTime = this.app._time), this._time &gt;= this.duration + this.startDelay || this._time &lt;= 0) switch (this.playStyle) {
            case 0:
                break;
            case 1:
                this._time = 0;
                break;
            case 2:
                this._time = 0;
                var i = this._from;
                this._from = this._to, this._to = i
        }
    },
    _updateTime: function(t) {
        this._time += this.ignoreTimeScale ? (this.app._time - this._oldTime) / 1e3 : t
    },
    setInitRotation: function(t, i, e) {
        this.entity.setLocalEulerAngles(t, i, e), this._initRotation.set(this.entity.getLocalEulerAngles().x, this.entity.getLocalEulerAngles().y, this.entity.getLocalEulerAngles().z)
    },
    startTween: function() {
        this._time = 0, this._from.set(this.initFrom.x, this.initFrom.y, this.initFrom.z), this._to.set(this.initTo.x, this.initTo.y, this.initTo.z), this.entity.setLocalEulerAngles(this._from.x, this._from.y, this._from.z), this._oldTime = this.app._time
    },
    stopTween: function() {
        this.entity.setLocalEulerAngles(this.initFrom.x, this.initFrom.y, this.initFrom.z), this._time = this.duration + this.startDelay + 1
    }
});
var TweenScale = pc.createScript("tweenScale");
TweenScale.attributes.add("initFrom", {
    type: "vec3",
    default: [0, 0, 0],
    title: "From"
}), TweenScale.attributes.add("initTo", {
    type: "vec3",
    default: [0, 0, 0],
    title: "To"
}), TweenScale.attributes.add("playStyle", {
    type: "number",
    enum: [{
        Once: 0
    }, {
        Loop: 1
    }, {
        PingPong: 2
    }],
    title: "Play Style"
}), TweenScale.attributes.add("duration", {
    type: "number",
    default: 1,
    title: "duration"
}), TweenScale.attributes.add("curve", {
    type: "curve",
    title: "Animation Curve"
}), TweenScale.attributes.add("ignoreTimeScale", {
    type: "boolean",
    default: !0,
    title: "Ignore Time Scale"
}), TweenScale.attributes.add("startDelay", {
    type: "number",
    default: 0,
    title: "Start Delay"
}), TweenScale.attributes.add("debug", {
    type: "boolean",
    default: !1,
    title: "Show Debug"
}), TweenScale.attributes.add("startOnEnable", {
    type: "boolean",
    default: !0,
    title: "Start on Enable"
}), TweenScale.attributes.add("startOnInit", {
    type: "boolean",
    default: !0,
    title: "Start on Initialize"
}), pc.extend(TweenScale.prototype, {
    initialize: function() {
        this._time = this.startAtEnable ? 0 : this.duration + this.startDelay + 1, this._oldTime = this.app._time || 0, this._from = this.initFrom, this._to = this.initTo, this._temp = new pc.Vec3(0, 0, 0), this._newScale = new pc.Vec3(0, 0, 0), this._initScale = this.entity.getLocalScale().clone()
    },
    postInitialize: function() {
        this._initScale = this.entity.getLocalScale().clone(), this.on("state", (function(t) {
            t &amp;&amp; this.startOnEnable &amp;&amp; this.startTween()
        })), this.startOnInit &amp;&amp; this.startTween()
    },
    update: function(t) {
        if (this._time &gt;= 0 &amp;&amp; this._time &lt;= this.duration + this.startDelay &amp;&amp; (this._updateTime(t), this._time &gt; this.startDelay &amp;&amp; (this._newScale.set(this._from.x, this._from.y, this._from.z).sub(this._to).scale(this.curve.value((this._time - this.startDelay) / this.duration)).sub2(this._from, this._newScale).mul(this._initScale), this.debug &amp;&amp; console.log(this._time, newScale.toString()), this.entity.setLocalScale(this._newScale.x, this._newScale.y, this._newScale.z)), this._oldTime = this.app._time), this._time &gt;= this.duration + this.startDelay || this._time &lt;= 0) switch (this.playStyle) {
            case 0:
                break;
            case 1:
                this._time = 0;
                break;
            case 2:
                this._time = 0, this._temp.set(this._from.x, this._from.y, this._from.z), this._from.set(this._to.x, this._to.y, this._to.z), this._to.set(this._temp.x, this._temp.y, this._temp.z)
        }
    },
    _updateTime: function(t) {
        this._time += this.ignoreTimeScale ? (this.app._time - this._oldTime) / 1e3 : t
    },
    startTween: function() {
        this._from &amp;&amp; (this._time = 0, this._from.set(this.initFrom.x, this.initFrom.y, this.initFrom.z), this._to.set(this.initTo.x, this.initTo.y, this.initTo.z), this.entity.setLocalScale(this._from.x * this._initScale.x, this._from.y * this._initScale.y, this._from.z * this._initScale.z), this._oldTime = this.app._time)
    },
    stopTween: function() {
        this._active = !1
    },
    reset: function() {
        this.entity.setLocalScale(this.initFrom)
    },
    isTweening: function() {
        return this._time &gt;= 0 &amp;&amp; this._time &lt; this.duration + this.startDelay
    }
});
var LevelLoader = pc.createScript("levelLoader");
LevelLoader.attributes.add("levelKey", {
    type: "string",
    default: "level"
}), pc.extend(LevelLoader.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (LevelLoader.instance = this)
    },
    loadLevel: function(e, l, a, t) {
        var i = this.padLevelNumber(e),
            o = this.app.assets.find("level_" + i + ".json");
        LazyLoader.instance.lazyLoad(o, l, a, t)
    },
    padLevelNumber: function(e) {
        return String(e).padStart(4, "0")
    },
    lazyLoadLevels: function() {
        window.levelDataExporter ? this._lazyLoadLevelsSimultaneously() : this._lazyLoadLevel();
        for (var e = 0; e &lt; this.times; e++) this._lazyLoadLevel(), this.level++
    },
    _lazyLoadLevel() {
        this.loadLevel(this.level, (function() {
            this.level++, this._lazyLoadLevel()
        }), this, !0)
    },
    _lazyLoadLevelsSimultaneously: function() {
        for (var e = this.app.assets.findByTag("level"), l = 0, a = e.length, t = this, onAssetLoad = function() {
                (l += 1) === a &amp;&amp; (console.log("All levels loaded."), t.app.fire("LevelLoader:levelsLoaded"))
            }, i = 0; i &lt; e.length; i += 1) e[i].resource ? onAssetLoad() : LazyLoader.instance.lazyLoad(e[i], onAssetLoad, this)
    }
});
var VibrationManager = pc.createScript("vibrationManager");
pc.extend(VibrationManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (VibrationManager.instance = this), navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate, this._isSupported = !!navigator.vibrate, this._defaultVibration = [100, 10, 100]
    },
    postInitialize: function() {
        this._vibration = StorageManager.instance.get("vibrate"), navigator.vibrate ? this.app.on("vibrate", this._vibrate, this) : this.enabled = !1
    },
    _vibrate: function(i) {
        navigator.vibrate || console.warn("Vibration not supported"), this._vibration &amp;&amp; navigator.vibrate(i || this._defaultVibration)
    },
    _save: function() {
        StorageManager.instance.set("vibrate", this._vibration)
    },
    get: function() {
        return this._vibration
    },
    set: function(i) {
        this._vibration = i, this._save()
    },
    toggle: function() {
        return this._vibration = !this._vibration, this.save(), this._vibration
    },
    isVibrationSupported: function() {
        return this._isSupported &amp;&amp; pc.platform.mobile
    }
});
var LazyLoader = pc.createScript("lazyLoader");
pc.extend(LazyLoader.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (LazyLoader.instance = this), this.app.loader.getHandler("texture").crossOrigin = "anonymous"
    },
    lazyLoad: function(e, a, n, t) {
        if (e)
            if (e.resource) a &amp;&amp; a.call(n, e);
            else {
                e.once("load", (function() {
                    setTimeout((function() {
                        a &amp;&amp; a.call(n, e)
                    }))
                })), this.app.assets.load(e)
            }
        else t ? this.app.fire("LevelLoader:levelsLoaded") : console.warn("Asset is undefined", a, n)
    }
});
var UIManager = pc.createScript("uiManager");
UIManager.SCREEN_LOADING_OVERLAY = "Loading Overlay", UIManager.SCREEN_INTRO = "Intro", UIManager.SCREEN_MENU = "Menu", UIManager.SCREEN_GAME = "Game", UIManager.SCREEN_PAUSE = "Pause", UIManager.SCREEN_END = "End", UIManager.SCREEN_DIALOG = "Dialog", UIManager.SCREEN_TUTORIAL_DIALOG = "Tutorial", UIManager.SCREEN_VIGNETTE = "Viginette", UIManager.attributes.add("loadingOverlay", {
    type: "entity"
}), UIManager.attributes.add("screenPrefabs", {
    type: "entity"
}), pc.extend(UIManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (UIManager.instance = this), this._screenScripts = this.screenPrefabs.findScripts("uiEntity"), this._stackScreen = [], this._stackOverlay = [], this._stackPopup = [], this._uiTypes = ["Screen", "Overlay", "Popup"], this._uis = {}, this.app.on("GameManager:ready", this._removeLoadingOverlay, this), this.app.on("UIManager:showUI", this._showUI, this), this.app.on("UIManager:hideUI", this._hideUI, this), this.app.on("UIManager:hideAll", this._hideAll, this)
    },
    postInitialize: function() {
        this.enableChildrens()
    },
    enableChildrens: function() {
        for (var e = 0; e &lt; this.entity.children.length; e += 1) {
            var t = this.entity.children[e];
            t instanceof pc.Entity &amp;&amp; (t.script.uiEntity ? t.enabled || (t.enabled = !0) : console.log(t.name, "has no uiEntity script", t))
        }
    },
    getScreen: function(e) {
        for (var t = 0; t &lt; this._screenScripts.length; t++)
            if (this._screenScripts[t].name === e) return this._screenScripts[t].entity
    },
    addUIEntity: function(e, t, i, n) {
        -1 !== this._uiTypes.indexOf(t) ? ("string" == typeof e &amp;&amp; e || console.warn("Name is invalid", e), this._uis[e] ? console.warn("This ui name is already occupied.", e) : (this._uis[e] = {
            entity: i,
            type: t
        }, n ? this._showUI(e, null, !0) : this._hideUI(e, null, !0))) : console.warn("Type is not recognize", t)
    },
    _removeLoadingOverlay: function() {
        this.loadingOverlay instanceof pc.Entity &amp;&amp; this.loadingOverlay.destroy()
    },
    _showUI: function(e, t, i) {
        var n = this.getScreen(e);
        n ? !n.enabled || i ? (n.script.uiEntity.onOpen(t), this._addToStack(n, n.script.uiEntity.type, i), this.app.fire("UIManager:opened", e), FirstTimeUserManager.instance.checkDisappear()) : console.warn("UI is already enabled", e) : console.warn("No ui is found with the name", e)
    },
    _hideUI: function(e, t, i) {
        var n = this.getScreen(e);
        n ? (n.enabled || i) &amp;&amp; n.script &amp;&amp; (n.script.uiEntity.onClose(t), this._removeFromStack(n, n.script.uiEntity.type, i)) : console.warn("No ui is found with the name", e)
    },
    _addToStack: function(e, t, i) {
        var n = this._getStack(t),
            a = n.indexOf(e); - 1 !== a &amp;&amp; (console.log("Entity is already in the stack, pushed to the top", e), n.splice(a, 1)), n.push(e)
    },
    _removeFromStack: function(e, t, i) {
        if (!i) {
            var n = this._getStack(t),
                a = n.indexOf(e); - 1 !== a ? n.splice(a, 1) : console.warn("Entity doesn't exist in the stack", n, e)
        }
    },
    _getStack: function(e) {
        return this["_stack" + e]
    },
    getTopStack: function(e) {
        var t = this["_stack" + e].length;
        return this["_stack" + e][t - 1]
    },
    getReferenceResolution: function() {
        return this.entity.screen.referenceResolution
    },
    getScale: function() {
        return this.entity.screen.scale
    },
    _hideAll: function() {
        for (var e = Object.keys(this._uis), t = 0; t &lt; e.length; t += 1) this._hideUI(e[t])
    }
});
var StatisticsManager = pc.createScript("statisticsManager");
StatisticsManager.STATISTICS = ["matches_made", "three_flower_matches_made", "four_flower_matches_made", "five_flower_matches_made", "power_tiles_activated", "bees_activated", "ladybugs_activated", "butterflies_activated", "flowers_destroyed", "blue_flowers_destroyed", "yellow_flowers_destroyed", "red_flowers_destroyed", "purple_flowers_destroyed", "green_flowers_destroyed", "orange_flowers_destroyed", "boosters_used", "free_swap_booster_used", "breaker_booster_used", "crossbomb_booster_used", "pre_boosters_used", "bees_pre_booster_used", "ladybugs_pre_booster_used", "butterflies_pre_booster_used", "droppers_collected", "flowerparts_collected", "flowers_collected", "tiles_coated", "orders_completed", "flower_orders_completed", "blue_flower_orders_completed", "yellow_flower_orders_completed", "red_flower_orders_completed", "purple_flower_orders_completed", "green_flower_orders_completed", "orange_flower_orders_completed", "panels_orders_completed", "blocker_orders_completed", "locker_orders_completed", "virus_orders_completed", "sinker_orders_completed", "switcher_orders_completed", "sticker_orders_completed", "popper_orders_completed", "coins_redeemed", "coins_used", "total_bought", "free_swap_booster_bought", "breaker_booster_bought", "crossbomb_booster_bought", "bees_pre_booster_bought", "ladybugs_pre_booster_bought", "butterflies_pre_booster_bought", "levels_completed", "attempts_failed", "revive_amount", "player_amount"], pc.extend(StatisticsManager.prototype, {
    initialize: function() {
        StatisticsManager.instance = this, this._dirty = !1, this._data = this._getData(), this._statsToBeUpdated = {}
    },
    _getData: function() {
        var e = StorageManager.instance.get("statistics");
        ("object" != typeof e || Array.isArray(e)) &amp;&amp; (e = {});
        for (var t = Object.keys(e), s = 0; s &lt; t.length; s++) {
            var r = t[s]; - 1 === StatisticsManager.STATISTICS.indexOf(r) &amp;&amp; delete e[r]
        }
        for (var o = 0; o &lt; StatisticsManager.STATISTICS.length; o++) {
            "number" != typeof e[r = StatisticsManager.STATISTICS[o]] &amp;&amp; (e[r] = 0)
        }
        return e
    },
    saveStatistics: function() {
        this._dirty &amp;&amp; (this._updateStatistics(), StorageManager.instance.set("statistics", this._data), this._dirty = !1)
    },
    _updateStatistics: function() {
        for (var e = Object.keys(this._statsToBeUpdated), t = 0; t &lt; e.length; t++) {
            var s = e[t],
                r = this._statsToBeUpdated[s];
            0 === r || isNaN(r) || (window.famobi_analytics.trackStats(s, r), this._statsToBeUpdated[s] = 0)
        }
    },
    incrementStatistic: function(e, t) {
        if (this._isKeyValid(e)) {
            var s = t || 1;
            this._data[e] += s, this._setStatsToBeUpdated(e, s), this._dirty = !0
        }
    },
    setStatistic: function(e, t, s) {
        if (this._isKeyValid(e)) {
            var r = this._data[e];
            r !== t &amp;&amp; (s &amp;&amp; r &gt; t || (this._data[e] = t, this._setStatsToBeUpdated(e, t - r), this._dirty = !0))
        }
    },
    _isKeyValid: function(e) {
        var t = StatisticsManager.STATISTICS.indexOf(e);
        return -1 === t &amp;&amp; console.warn("No statistic found with the key", e), -1 !== t
    },
    _setStatsToBeUpdated: function(e, t) {
        "number" != typeof this._statsToBeUpdated[e] &amp;&amp; (this._statsToBeUpdated[e] = 0), this._statsToBeUpdated[e] += t
    }
});
var UIEntity = pc.createScript("uiEntity");
UIEntity.attributes.add("name", {
    type: "string",
    default: ""
}), UIEntity.attributes.add("type", {
    type: "string",
    enum: [{
        Screen: "Screen"
    }, {
        Overlay: "Overlay"
    }, {
        Popup: "Popup"
    }]
}), UIEntity.attributes.add("scriptName", {
    type: "string",
    default: ""
}), UIEntity.attributes.add("showOnStartUp", {
    type: "boolean",
    default: !1
}), pc.extend(UIEntity.prototype, {
    postInitialize: function() {
        UIManager.instance.addUIEntity(this.name, this.type, this.entity, this.showOnStartUp), this.entity.element || console.warn(this.entity.name, "doesn't have a group element, please add it!"), this.entity.script || this.entity.script.dynamicScreen || console.warn(this.entity.name, "doesn't have a dynamicScreen script, please add it!")
    },
    onClose: function() {
        return this.entity.enabled = !1, !!this.scriptName &amp;&amp; (this.entity.script[this.scriptName] instanceof Object.getPrototypeOf(pc.script).constructor ? "function" == typeof this.entity.script[this.scriptName].onUIEntityClose &amp;&amp; (this.entity.script[this.scriptName].onUIEntityClose(), !0) : (console.warn(this.scriptName, "is not a valid script."), !1))
    },
    onOpen: function(t) {
        this.entity.enabled = !0, this.scriptName &amp;&amp; (this.entity.script[this.scriptName] instanceof Object.getPrototypeOf(pc.script).constructor ? "function" == typeof this.entity.script[this.scriptName].onUIEntityOpen &amp;&amp; this.entity.script[this.scriptName].onUIEntityOpen(t) : console.warn(this.scriptName, "is not a valid script."))
    }
});
/*! deePool
    v2.2.0 (c) Kyle Simpson
    MIT License: http://getify.mit-license.org
    Source: https://github.com/getify/deePool
*/
var ObjectPool = pc.createScript("objectPool");
ObjectPool.attributes.add("templateEntity", {
    type: "entity",
    title: "Template Entity"
}), ObjectPool.attributes.add("initialLength", {
    type: "number",
    default: 16
}), ObjectPool.attributes.add("growCount", {
    type: "number",
    default: 5
}), ObjectPool.attributes.add("disableOnInit", {
    type: "boolean",
    default: !0,
    title: "Disable on Init"
}), ObjectPool.attributes.add("disable", {
    type: "boolean",
    default: !0
}), ObjectPool.attributes.add("debug", {
    type: "boolean",
    default: !1
}), pc.extend(ObjectPool.prototype, {
    initialize: function() {
        this._pool = [], this._nextFreeSlot = null, this.templateEntity ? this._grow(this.initialLength, !0) : console.warn("ObjectPool: template is null (aborting initialization...)")
    },
    _grow: function(t, e) {
        if (t &gt; 0 &amp;&amp; null === this._nextFreeSlot &amp;&amp; (this._nextFreeSlot = 0), t &gt; 0) {
            var o = this._pool.length;
            this._pool.length += Number(t);
            for (var l = o; l &lt; this._pool.length; l += 1) {
                var i = this.templateEntity.clone();
                i.enabled = !0, i.reparent(this.entity), i.objectPool = this, this._pool[l] = i, i.setPosition(0, -1e12, 0), this.disableOnInit &amp;&amp; (this._pool[l].enabled = !1, this._pool[l].reparent(null))
            }
        }
        return this._pool.length
    },
    use: function() {
        null !== this._nextFreeSlot &amp;&amp; this._nextFreeSlot !== this._pool.length || this._grow(this.growCount);
        var t = this._pool[this._nextFreeSlot];
        return this._pool[this._nextFreeSlot] = null, this._nextFreeSlot += 1, t
    },
    recycle: function(t) {
        this.debug &amp;&amp; console.warn(t), t.enabled &amp;&amp; this.disable, t.name !== this.templateEntity.name &amp;&amp; console.warn("Something went wrong", t, this.templateEntity), -1 === this._pool.indexOf(t) ? (null === this._nextFreeSlot || -1 === this._nextFreeSlot ? this._pool[this._pool.length] = t : this._pool[this._nextFreeSlot -= 1] = t, t.setPosition(0, -1e12, 0)) : console.log("already in the object pool", t)
    },
    size: function() {
        return this._pool.length
    }
});
var SwitchUibutton = pc.createScript("switchUibutton");
SwitchUibutton.attributes.add("openUIEntity", {
    type: "entity",
    array: !0,
    title: "Open UI Entities"
}), SwitchUibutton.attributes.add("closeItself", {
    type: "boolean",
    default: !1,
    title: "Close current UI Entity"
}), SwitchUibutton.attributes.add("closeUIEntity", {
    type: "entity",
    array: !0,
    title: "Close other UI Entities"
}), SwitchUibutton.attributes.add("clickSFX", {
    type: "string",
    default: "button_click.mp3"
}), pc.extend(SwitchUibutton.prototype, {
    initialize: function() {
        this._elementInput = null, this._waitForEvent = !1, this._createInputEvent(), this._setCloseItself()
    },
    _createInputEvent: function() {
        this._elementInput = this.entity.script.elementInput, this._elementInput || (this._elementInput = this.entity.script.create("elementInput"), console.warn("Add the script elementInput to this entity:", this.entity.name)), this._elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _setCloseItself: function() {
        if (this.closeItself) {
            var t = this._getUIEntity(this.entity, 4);
            t instanceof pc.Entity ? this.closeUIEntity.push(t) : console.warn("Couldn't find a UI Entity")
        }
    },
    _getUIEntity: function(t, i) {
        return i &lt;= 0 &amp;&amp; !(t instanceof pc.Entity) ? null : t.script &amp;&amp; t.script.uiEntity instanceof Object.getPrototypeOf(pc.script).constructor ? t : this._getUIEntity(t.parent, i -= 1)
    },
    _onClick: function(t) {
        this._waitForEvent ? console.log("Wait for event to finish") : (this._waitForEvent = this.doEvent(), this.app.fire("Audio:sfx", this.clickSFX), this._waitForEvent || (this.fire("click"), this._openEntities(), this._closeEntities()))
    },
    doEvent: function() {
        switch (this.entity.name) {
            case "Exit Button":
                return GameManager.instance.trackEventPause().then(this._onEventDone.bind(this)), !0;
            case "Continue":
                return GameManager.instance.trackEventResume().then(this._onEventDone.bind(this)), !0;
            case "Quit":
                return GameManager.instance.trackEventLevelQuit().then(this._onEventDone.bind(this)), !0
        }
        return !1
    },
    _onEventDone: function() {
        this._waitForEvent = !1, this.fire("click"), this._openEntities(), this._closeEntities()
    },
    _openEntities: function() {
        for (var t = 0; t &lt; this.openUIEntity.length; t += 1) this.openUIEntity[t] instanceof pc.Entity ? this.app.fire("UIManager:showUI", this.openUIEntity[t].script.uiEntity.name) : console.warn(this.entity.parent.name, "has in invalid parameter in the array openUIEntity with index", t)
    },
    _closeEntities: function() {
        for (var t = 0; t &lt; this.closeUIEntity.length; t += 1) this.closeUIEntity[t] instanceof pc.Entity ? this.app.fire("UIManager:hideUI", this.closeUIEntity[t].script.uiEntity.name) : console.warn(this.entity.parent.name, "has in invalid parameter in the array closeUIEntity with index", t)
    }
}); // dat.gui.min.js
! function(e, t) {
    "object" == typeof exports &amp;&amp; "object" == typeof module ? module.exports = t() : "function" == typeof define &amp;&amp; define.amd ? define([], t) : "object" == typeof exports ? exports.dat = t() : e.dat = t()
}(this, function() {
    return function(e) {
        function t(o) {
            if (n[o]) return n[o].exports;
            var i = n[o] = {
                exports: {},
                id: o,
                loaded: !1
            };
            return e[o].call(i.exports, i, i.exports, t), i.loaded = !0, i.exports
        }
        var n = {};
        return t.m = e, t.c = n, t.p = "", t(0)
    }([function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }
        var i = n(1),
            r = o(i);
        e.exports = r["default"]
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }
        t.__esModule = !0;
        var i = n(2),
            r = o(i),
            a = n(6),
            l = o(a),
            s = n(3),
            u = o(s),
            d = n(7),
            c = o(d),
            f = n(8),
            _ = o(f),
            p = n(10),
            h = o(p),
            m = n(11),
            b = o(m),
            g = n(12),
            v = o(g),
            y = n(13),
            w = o(y),
            x = n(14),
            E = o(x),
            C = n(15),
            A = o(C),
            S = n(16),
            k = o(S),
            O = n(9),
            T = o(O),
            R = n(17),
            L = o(R);
        t["default"] = {
            color: {
                Color: r["default"],
                math: l["default"],
                interpret: u["default"]
            },
            controllers: {
                Controller: c["default"],
                BooleanController: _["default"],
                OptionController: h["default"],
                StringController: b["default"],
                NumberController: v["default"],
                NumberControllerBox: w["default"],
                NumberControllerSlider: E["default"],
                FunctionController: A["default"],
                ColorController: k["default"]
            },
            dom: {
                dom: T["default"]
            },
            gui: {
                GUI: L["default"]
            },
            GUI: L["default"]
        }
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t, n) {
            Object.defineProperty(e, t, {
                get: function() {
                    return "RGB" === this.__state.space ? this.__state[t] : (h.recalculateRGB(this, t, n), this.__state[t])
                },
                set: function(e) {
                    "RGB" !== this.__state.space &amp;&amp; (h.recalculateRGB(this, t, n), this.__state.space = "RGB"), this.__state[t] = e
                }
            })
        }

        function a(e, t) {
            Object.defineProperty(e, t, {
                get: function() {
                    return "HSV" === this.__state.space ? this.__state[t] : (h.recalculateHSV(this), this.__state[t])
                },
                set: function(e) {
                    "HSV" !== this.__state.space &amp;&amp; (h.recalculateHSV(this), this.__state.space = "HSV"), this.__state[t] = e
                }
            })
        }
        t.__esModule = !0;
        var l = n(3),
            s = o(l),
            u = n(6),
            d = o(u),
            c = n(4),
            f = o(c),
            _ = n(5),
            p = o(_),
            h = function() {
                function e() {
                    if (i(this, e), this.__state = s["default"].apply(this, arguments), this.__state === !1) throw new Error("Failed to interpret color arguments");
                    this.__state.a = this.__state.a || 1
                }
                return e.prototype.toString = function() {
                    return (0, f["default"])(this)
                }, e.prototype.toHexString = function() {
                    return (0, f["default"])(this, !0)
                }, e.prototype.toOriginal = function() {
                    return this.__state.conversion.write(this)
                }, e
            }();
        h.recalculateRGB = function(e, t, n) {
            if ("HEX" === e.__state.space) e.__state[t] = d["default"].component_from_hex(e.__state.hex, n);
            else {
                if ("HSV" !== e.__state.space) throw new Error("Corrupted color state");
                p["default"].extend(e.__state, d["default"].hsv_to_rgb(e.__state.h, e.__state.s, e.__state.v))
            }
        }, h.recalculateHSV = function(e) {
            var t = d["default"].rgb_to_hsv(e.r, e.g, e.b);
            p["default"].extend(e.__state, {
                s: t.s,
                v: t.v
            }), p["default"].isNaN(t.h) ? p["default"].isUndefined(e.__state.h) &amp;&amp; (e.__state.h = 0) : e.__state.h = t.h
        }, h.COMPONENTS = ["r", "g", "b", "h", "s", "v", "hex", "a"], r(h.prototype, "r", 2), r(h.prototype, "g", 1), r(h.prototype, "b", 0), a(h.prototype, "h"), a(h.prototype, "s"), a(h.prototype, "v"), Object.defineProperty(h.prototype, "a", {
            get: function() {
                return this.__state.a
            },
            set: function(e) {
                this.__state.a = e
            }
        }), Object.defineProperty(h.prototype, "hex", {
            get: function() {
                return "HEX" !== !this.__state.space &amp;&amp; (this.__state.hex = d["default"].rgb_to_hex(this.r, this.g, this.b)), this.__state.hex
            },
            set: function(e) {
                this.__state.space = "HEX", this.__state.hex = e
            }
        }), t["default"] = h
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }
        t.__esModule = !0;
        var i = n(4),
            r = o(i),
            a = n(5),
            l = o(a),
            s = [{
                litmus: l["default"].isString,
                conversions: {
                    THREE_CHAR_HEX: {
                        read: function(e) {
                            var t = e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);
                            return null !== t &amp;&amp; {
                                space: "HEX",
                                hex: parseInt("0x" + t[1].toString() + t[1].toString() + t[2].toString() + t[2].toString() + t[3].toString() + t[3].toString(), 0)
                            }
                        },
                        write: r["default"]
                    },
                    SIX_CHAR_HEX: {
                        read: function(e) {
                            var t = e.match(/^#([A-F0-9]{6})$/i);
                            return null !== t &amp;&amp; {
                                space: "HEX",
                                hex: parseInt("0x" + t[1].toString(), 0)
                            }
                        },
                        write: r["default"]
                    },
                    CSS_RGB: {
                        read: function(e) {
                            var t = e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);
                            return null !== t &amp;&amp; {
                                space: "RGB",
                                r: parseFloat(t[1]),
                                g: parseFloat(t[2]),
                                b: parseFloat(t[3])
                            }
                        },
                        write: r["default"]
                    },
                    CSS_RGBA: {
                        read: function(e) {
                            var t = e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);
                            return null !== t &amp;&amp; {
                                space: "RGB",
                                r: parseFloat(t[1]),
                                g: parseFloat(t[2]),
                                b: parseFloat(t[3]),
                                a: parseFloat(t[4])
                            }
                        },
                        write: r["default"]
                    }
                }
            }, {
                litmus: l["default"].isNumber,
                conversions: {
                    HEX: {
                        read: function(e) {
                            return {
                                space: "HEX",
                                hex: e,
                                conversionName: "HEX"
                            }
                        },
                        write: function(e) {
                            return e.hex
                        }
                    }
                }
            }, {
                litmus: l["default"].isArray,
                conversions: {
                    RGB_ARRAY: {
                        read: function(e) {
                            return 3 === e.length &amp;&amp; {
                                space: "RGB",
                                r: e[0],
                                g: e[1],
                                b: e[2]
                            }
                        },
                        write: function(e) {
                            return [e.r, e.g, e.b]
                        }
                    },
                    RGBA_ARRAY: {
                        read: function(e) {
                            return 4 === e.length &amp;&amp; {
                                space: "RGB",
                                r: e[0],
                                g: e[1],
                                b: e[2],
                                a: e[3]
                            }
                        },
                        write: function(e) {
                            return [e.r, e.g, e.b, e.a]
                        }
                    }
                }
            }, {
                litmus: l["default"].isObject,
                conversions: {
                    RGBA_OBJ: {
                        read: function(e) {
                            return !!(l["default"].isNumber(e.r) &amp;&amp; l["default"].isNumber(e.g) &amp;&amp; l["default"].isNumber(e.b) &amp;&amp; l["default"].isNumber(e.a)) &amp;&amp; {
                                space: "RGB",
                                r: e.r,
                                g: e.g,
                                b: e.b,
                                a: e.a
                            }
                        },
                        write: function(e) {
                            return {
                                r: e.r,
                                g: e.g,
                                b: e.b,
                                a: e.a
                            }
                        }
                    },
                    RGB_OBJ: {
                        read: function(e) {
                            return !!(l["default"].isNumber(e.r) &amp;&amp; l["default"].isNumber(e.g) &amp;&amp; l["default"].isNumber(e.b)) &amp;&amp; {
                                space: "RGB",
                                r: e.r,
                                g: e.g,
                                b: e.b
                            }
                        },
                        write: function(e) {
                            return {
                                r: e.r,
                                g: e.g,
                                b: e.b
                            }
                        }
                    },
                    HSVA_OBJ: {
                        read: function(e) {
                            return !!(l["default"].isNumber(e.h) &amp;&amp; l["default"].isNumber(e.s) &amp;&amp; l["default"].isNumber(e.v) &amp;&amp; l["default"].isNumber(e.a)) &amp;&amp; {
                                space: "HSV",
                                h: e.h,
                                s: e.s,
                                v: e.v,
                                a: e.a
                            }
                        },
                        write: function(e) {
                            return {
                                h: e.h,
                                s: e.s,
                                v: e.v,
                                a: e.a
                            }
                        }
                    },
                    HSV_OBJ: {
                        read: function(e) {
                            return !!(l["default"].isNumber(e.h) &amp;&amp; l["default"].isNumber(e.s) &amp;&amp; l["default"].isNumber(e.v)) &amp;&amp; {
                                space: "HSV",
                                h: e.h,
                                s: e.s,
                                v: e.v
                            }
                        },
                        write: function(e) {
                            return {
                                h: e.h,
                                s: e.s,
                                v: e.v
                            }
                        }
                    }
                }
            }],
            u = void 0,
            d = void 0,
            c = function() {
                d = !1;
                var e = arguments.length &gt; 1 ? l["default"].toArray(arguments) : arguments[0];
                return l["default"].each(s, function(t) {
                    if (t.litmus(e)) return l["default"].each(t.conversions, function(t, n) {
                        if (u = t.read(e), d === !1 &amp;&amp; u !== !1) return d = u, u.conversionName = n, u.conversion = t, l["default"].BREAK
                    }), l["default"].BREAK
                }), d
            };
        t["default"] = c
    }, function(e, t) {
        "use strict";
        t.__esModule = !0, t["default"] = function(e, t) {
            var n = e.__state.conversionName.toString(),
                o = Math.round(e.r),
                i = Math.round(e.g),
                r = Math.round(e.b),
                a = e.a,
                l = Math.round(e.h),
                s = e.s.toFixed(1),
                u = e.v.toFixed(1);
            if (t || "THREE_CHAR_HEX" === n || "SIX_CHAR_HEX" === n) {
                for (var d = e.hex.toString(16); d.length &lt; 6;) d = "0" + d;
                return "#" + d
            }
            return "CSS_RGB" === n ? "rgb(" + o + "," + i + "," + r + ")" : "CSS_RGBA" === n ? "rgba(" + o + "," + i + "," + r + "," + a + ")" : "HEX" === n ? "0x" + e.hex.toString(16) : "RGB_ARRAY" === n ? "[" + o + "," + i + "," + r + "]" : "RGBA_ARRAY" === n ? "[" + o + "," + i + "," + r + "," + a + "]" : "RGB_OBJ" === n ? "{r:" + o + ",g:" + i + ",b:" + r + "}" : "RGBA_OBJ" === n ? "{r:" + o + ",g:" + i + ",b:" + r + ",a:" + a + "}" : "HSV_OBJ" === n ? "{h:" + l + ",s:" + s + ",v:" + u + "}" : "HSVA_OBJ" === n ? "{h:" + l + ",s:" + s + ",v:" + u + ",a:" + a + "}" : "unknown format"
        }
    }, function(e, t) {
        "use strict";
        t.__esModule = !0;
        var n = Array.prototype.forEach,
            o = Array.prototype.slice,
            i = {
                BREAK: {},
                extend: function(e) {
                    return this.each(o.call(arguments, 1), function(t) {
                        var n = this.isObject(t) ? Object.keys(t) : [];
                        n.forEach(function(n) {
                            this.isUndefined(t[n]) || (e[n] = t[n])
                        }.bind(this))
                    }, this), e
                },
                defaults: function(e) {
                    return this.each(o.call(arguments, 1), function(t) {
                        var n = this.isObject(t) ? Object.keys(t) : [];
                        n.forEach(function(n) {
                            this.isUndefined(e[n]) &amp;&amp; (e[n] = t[n])
                        }.bind(this))
                    }, this), e
                },
                compose: function() {
                    var e = o.call(arguments);
                    return function() {
                        for (var t = o.call(arguments), n = e.length - 1; n &gt;= 0; n--) t = [e[n].apply(this, t)];
                        return t[0]
                    }
                },
                each: function(e, t, o) {
                    if (e)
                        if (n &amp;&amp; e.forEach &amp;&amp; e.forEach === n) e.forEach(t, o);
                        else if (e.length === e.length + 0) {
                        var i = void 0,
                            r = void 0;
                        for (i = 0, r = e.length; i &lt; r; i++)
                            if (i in e &amp;&amp; t.call(o, e[i], i) === this.BREAK) return
                    } else
                        for (var a in e)
                            if (t.call(o, e[a], a) === this.BREAK) return
                },
                defer: function(e) {
                    setTimeout(e, 0)
                },
                debounce: function(e, t) {
                    var n = void 0;
                    return function() {
                        function o() {
                            n = null
                        }
                        var i = this,
                            r = arguments,
                            a = !n;
                        clearTimeout(n), n = setTimeout(o, t), a &amp;&amp; e.apply(i, r)
                    }
                },
                toArray: function(e) {
                    return e.toArray ? e.toArray() : o.call(e)
                },
                isUndefined: function(e) {
                    return void 0 === e
                },
                isNull: function(e) {
                    return null === e
                },
                isNaN: function(e) {
                    function t(t) {
                        return e.apply(this, arguments)
                    }
                    return t.toString = function() {
                        return e.toString()
                    }, t
                }(function(e) {
                    return isNaN(e)
                }),
                isArray: Array.isArray || function(e) {
                    return e.constructor === Array
                },
                isObject: function(e) {
                    return e === Object(e)
                },
                isNumber: function(e) {
                    return e === e + 0
                },
                isString: function(e) {
                    return e === e + ""
                },
                isBoolean: function(e) {
                    return e === !1 || e === !0
                },
                isFunction: function(e) {
                    return "[object Function]" === Object.prototype.toString.call(e)
                }
            };
        t["default"] = i
    }, function(e, t) {
        "use strict";
        t.__esModule = !0;
        var n = void 0,
            o = {
                hsv_to_rgb: function(e, t, n) {
                    var o = Math.floor(e / 60) % 6,
                        i = e / 60 - Math.floor(e / 60),
                        r = n * (1 - t),
                        a = n * (1 - i * t),
                        l = n * (1 - (1 - i) * t),
                        s = [
                            [n, l, r],
                            [a, n, r],
                            [r, n, l],
                            [r, a, n],
                            [l, r, n],
                            [n, r, a]
                        ][o];
                    return {
                        r: 255 * s[0],
                        g: 255 * s[1],
                        b: 255 * s[2]
                    }
                },
                rgb_to_hsv: function(e, t, n) {
                    var o = Math.min(e, t, n),
                        i = Math.max(e, t, n),
                        r = i - o,
                        a = void 0,
                        l = void 0;
                    return 0 === i ? {
                        h: NaN,
                        s: 0,
                        v: 0
                    } : (l = r / i, a = e === i ? (t - n) / r : t === i ? 2 + (n - e) / r : 4 + (e - t) / r, a /= 6, a &lt; 0 &amp;&amp; (a += 1), {
                        h: 360 * a,
                        s: l,
                        v: i / 255
                    })
                },
                rgb_to_hex: function(e, t, n) {
                    var o = this.hex_with_component(0, 2, e);
                    return o = this.hex_with_component(o, 1, t), o = this.hex_with_component(o, 0, n)
                },
                component_from_hex: function(e, t) {
                    return e &gt;&gt; 8 * t &amp; 255
                },
                hex_with_component: function(e, t, o) {
                    return o &lt;&lt; (n = 8 * t) | e &amp; ~(255 &lt;&lt; n)
                }
            };
        t["default"] = o
    }, function(e, t) {
        "use strict";

        function n(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }
        t.__esModule = !0;
        var o = function() {
            function e(t, o) {
                n(this, e), this.initialValue = t[o], this.domElement = document.createElement("div"), this.object = t, this.property = o, this.__onChange = void 0, this.__onFinishChange = void 0
            }
            return e.prototype.onChange = function(e) {
                return this.__onChange = e, this
            }, e.prototype.onFinishChange = function(e) {
                return this.__onFinishChange = e, this
            }, e.prototype.setValue = function(e) {
                return this.object[this.property] = e, this.__onChange &amp;&amp; this.__onChange.call(this, e), this.updateDisplay(), this
            }, e.prototype.getValue = function() {
                return this.object[this.property]
            }, e.prototype.updateDisplay = function() {
                return this
            }, e.prototype.isModified = function() {
                return this.initialValue !== this.getValue()
            }, e
        }();
        t["default"] = o
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t) {
            if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
            return !t || "object" != typeof t &amp;&amp; "function" != typeof t ? e : t
        }

        function a(e, t) {
            if ("function" != typeof t &amp;&amp; null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
            e.prototype = Object.create(t &amp;&amp; t.prototype, {
                constructor: {
                    value: e,
                    enumerable: !1,
                    writable: !0,
                    configurable: !0
                }
            }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
        }
        t.__esModule = !0;
        var l = n(7),
            s = o(l),
            u = n(9),
            d = o(u),
            c = function(e) {
                function t(n, o) {
                    function a() {
                        s.setValue(!s.__prev)
                    }
                    i(this, t);
                    var l = r(this, e.call(this, n, o)),
                        s = l;
                    return l.__prev = l.getValue(), l.__checkbox = document.createElement("input"), l.__checkbox.setAttribute("type", "checkbox"), d["default"].bind(l.__checkbox, "change", a, !1), l.domElement.appendChild(l.__checkbox), l.updateDisplay(), l
                }
                return a(t, e), t.prototype.setValue = function(t) {
                    var n = e.prototype.setValue.call(this, t);
                    return this.__onFinishChange &amp;&amp; this.__onFinishChange.call(this, this.getValue()), this.__prev = this.getValue(), n
                }, t.prototype.updateDisplay = function() {
                    return this.getValue() === !0 ? (this.__checkbox.setAttribute("checked", "checked"), this.__checkbox.checked = !0) : this.__checkbox.checked = !1, e.prototype.updateDisplay.call(this)
                }, t
            }(s["default"]);
        t["default"] = c
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e) {
            if ("0" === e || a["default"].isUndefined(e)) return 0;
            var t = e.match(u);
            return a["default"].isNull(t) ? 0 : parseFloat(t[1])
        }
        t.__esModule = !0;
        var r = n(5),
            a = o(r),
            l = {
                HTMLEvents: ["change"],
                MouseEvents: ["click", "mousemove", "mousedown", "mouseup", "mouseover"],
                KeyboardEvents: ["keydown"]
            },
            s = {};
        a["default"].each(l, function(e, t) {
            a["default"].each(e, function(e) {
                s[e] = t
            })
        });
        var u = /(\d+(\.\d+)?)px/,
            d = {
                makeSelectable: function(e, t) {
                    void 0 !== e &amp;&amp; void 0 !== e.style &amp;&amp; (e.onselectstart = t ? function() {
                        return !1
                    } : function() {}, e.style.MozUserSelect = t ? "auto" : "none", e.style.KhtmlUserSelect = t ? "auto" : "none", e.unselectable = t ? "on" : "off")
                },
                makeFullscreen: function(e, t, n) {
                    var o = n,
                        i = t;
                    a["default"].isUndefined(i) &amp;&amp; (i = !0), a["default"].isUndefined(o) &amp;&amp; (o = !0), e.style.position = "absolute", i &amp;&amp; (e.style.left = 0, e.style.right = 0), o &amp;&amp; (e.style.top = 0, e.style.bottom = 0)
                },
                fakeEvent: function(e, t, n, o) {
                    var i = n || {},
                        r = s[t];
                    if (!r) throw new Error("Event type " + t + " not supported.");
                    var l = document.createEvent(r);
                    switch (r) {
                        case "MouseEvents":
                            var u = i.x || i.clientX || 0,
                                d = i.y || i.clientY || 0;
                            l.initMouseEvent(t, i.bubbles || !1, i.cancelable || !0, window, i.clickCount || 1, 0, 0, u, d, !1, !1, !1, !1, 0, null);
                            break;
                        case "KeyboardEvents":
                            var c = l.initKeyboardEvent || l.initKeyEvent;
                            a["default"].defaults(i, {
                                cancelable: !0,
                                ctrlKey: !1,
                                altKey: !1,
                                shiftKey: !1,
                                metaKey: !1,
                                keyCode: void 0,
                                charCode: void 0
                            }), c(t, i.bubbles || !1, i.cancelable, window, i.ctrlKey, i.altKey, i.shiftKey, i.metaKey, i.keyCode, i.charCode);
                            break;
                        default:
                            l.initEvent(t, i.bubbles || !1, i.cancelable || !0)
                    }
                    a["default"].defaults(l, o), e.dispatchEvent(l)
                },
                bind: function(e, t, n, o) {
                    var i = o || !1;
                    return e.addEventListener ? e.addEventListener(t, n, i) : e.attachEvent &amp;&amp; e.attachEvent("on" + t, n), d
                },
                unbind: function(e, t, n, o) {
                    var i = o || !1;
                    return e.removeEventListener ? e.removeEventListener(t, n, i) : e.detachEvent &amp;&amp; e.detachEvent("on" + t, n), d
                },
                addClass: function(e, t) {
                    if (void 0 === e.className) e.className = t;
                    else if (e.className !== t) {
                        var n = e.className.split(/ +/);
                        n.indexOf(t) === -1 &amp;&amp; (n.push(t), e.className = n.join(" ").replace(/^\s+/, "").replace(/\s+$/, ""))
                    }
                    return d
                },
                removeClass: function(e, t) {
                    if (t)
                        if (e.className === t) e.removeAttribute("class");
                        else {
                            var n = e.className.split(/ +/),
                                o = n.indexOf(t);
                            o !== -1 &amp;&amp; (n.splice(o, 1), e.className = n.join(" "))
                        }
                    else e.className = void 0;
                    return d
                },
                hasClass: function(e, t) {
                    return new RegExp("(?:^|\\s+)" + t + "(?:\\s+|$)").test(e.className) || !1
                },
                getWidth: function(e) {
                    var t = getComputedStyle(e);
                    return i(t["border-left-width"]) + i(t["border-right-width"]) + i(t["padding-left"]) + i(t["padding-right"]) + i(t.width)
                },
                getHeight: function(e) {
                    var t = getComputedStyle(e);
                    return i(t["border-top-width"]) + i(t["border-bottom-width"]) + i(t["padding-top"]) + i(t["padding-bottom"]) + i(t.height)
                },
                getOffset: function(e) {
                    var t = e,
                        n = {
                            left: 0,
                            top: 0
                        };
                    if (t.offsetParent)
                        do n.left += t.offsetLeft, n.top += t.offsetTop, t = t.offsetParent; while (t);
                    return n
                },
                isActive: function(e) {
                    return e === document.activeElement &amp;&amp; (e.type || e.href)
                }
            };
        t["default"] = d
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t) {
            if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
            return !t || "object" != typeof t &amp;&amp; "function" != typeof t ? e : t
        }

        function a(e, t) {
            if ("function" != typeof t &amp;&amp; null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
            e.prototype = Object.create(t &amp;&amp; t.prototype, {
                constructor: {
                    value: e,
                    enumerable: !1,
                    writable: !0,
                    configurable: !0
                }
            }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
        }
        t.__esModule = !0;
        var l = n(7),
            s = o(l),
            u = n(9),
            d = o(u),
            c = n(5),
            f = o(c),
            _ = function(e) {
                function t(n, o, a) {
                    i(this, t);
                    var l = r(this, e.call(this, n, o)),
                        s = a,
                        u = l;
                    return l.__select = document.createElement("select"), f["default"].isArray(s) &amp;&amp; ! function() {
                        var e = {};
                        f["default"].each(s, function(t) {
                            e[t] = t
                        }), s = e
                    }(), f["default"].each(s, function(e, t) {
                        var n = document.createElement("option");
                        n.innerHTML = t, n.setAttribute("value", e), u.__select.appendChild(n)
                    }), l.updateDisplay(), d["default"].bind(l.__select, "change", function() {
                        var e = this.options[this.selectedIndex].value;
                        u.setValue(e)
                    }), l.domElement.appendChild(l.__select), l
                }
                return a(t, e), t.prototype.setValue = function(t) {
                    var n = e.prototype.setValue.call(this, t);
                    return this.__onFinishChange &amp;&amp; this.__onFinishChange.call(this, this.getValue()), n
                }, t.prototype.updateDisplay = function() {
                    return d["default"].isActive(this.__select) ? this : (this.__select.value = this.getValue(), e.prototype.updateDisplay.call(this))
                }, t
            }(s["default"]);
        t["default"] = _
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t) {
            if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
            return !t || "object" != typeof t &amp;&amp; "function" != typeof t ? e : t
        }

        function a(e, t) {
            if ("function" != typeof t &amp;&amp; null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
            e.prototype = Object.create(t &amp;&amp; t.prototype, {
                constructor: {
                    value: e,
                    enumerable: !1,
                    writable: !0,
                    configurable: !0
                }
            }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
        }
        t.__esModule = !0;
        var l = n(7),
            s = o(l),
            u = n(9),
            d = o(u),
            c = function(e) {
                function t(n, o) {
                    function a() {
                        u.setValue(u.__input.value)
                    }

                    function l() {
                        u.__onFinishChange &amp;&amp; u.__onFinishChange.call(u, u.getValue())
                    }
                    i(this, t);
                    var s = r(this, e.call(this, n, o)),
                        u = s;
                    return s.__input = document.createElement("input"), s.__input.setAttribute("type", "text"), d["default"].bind(s.__input, "keyup", a), d["default"].bind(s.__input, "change", a), d["default"].bind(s.__input, "blur", l), d["default"].bind(s.__input, "keydown", function(e) {
                        13 === e.keyCode &amp;&amp; this.blur()
                    }), s.updateDisplay(), s.domElement.appendChild(s.__input), s
                }
                return a(t, e), t.prototype.updateDisplay = function() {
                    return d["default"].isActive(this.__input) || (this.__input.value = this.getValue()), e.prototype.updateDisplay.call(this)
                }, t
            }(s["default"]);
        t["default"] = c
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t) {
            if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
            return !t || "object" != typeof t &amp;&amp; "function" != typeof t ? e : t
        }

        function a(e, t) {
            if ("function" != typeof t &amp;&amp; null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
            e.prototype = Object.create(t &amp;&amp; t.prototype, {
                constructor: {
                    value: e,
                    enumerable: !1,
                    writable: !0,
                    configurable: !0
                }
            }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
        }

        function l(e) {
            var t = e.toString();
            return t.indexOf(".") &gt; -1 ? t.length - t.indexOf(".") - 1 : 0
        }
        t.__esModule = !0;
        var s = n(7),
            u = o(s),
            d = n(5),
            c = o(d),
            f = function(e) {
                function t(n, o, a) {
                    i(this, t);
                    var s = r(this, e.call(this, n, o)),
                        u = a || {};
                    return s.__min = u.min, s.__max = u.max, s.__step = u.step, c["default"].isUndefined(s.__step) ? 0 === s.initialValue ? s.__impliedStep = 1 : s.__impliedStep = Math.pow(10, Math.floor(Math.log(Math.abs(s.initialValue)) / Math.LN10)) / 10 : s.__impliedStep = s.__step, s.__precision = l(s.__impliedStep), s
                }
                return a(t, e), t.prototype.setValue = function(t) {
                    var n = t;
                    return void 0 !== this.__min &amp;&amp; n &lt; this.__min ? n = this.__min : void 0 !== this.__max &amp;&amp; n &gt; this.__max &amp;&amp; (n = this.__max), void 0 !== this.__step &amp;&amp; n % this.__step !== 0 &amp;&amp; (n = Math.round(n / this.__step) * this.__step), e.prototype.setValue.call(this, n)
                }, t.prototype.min = function(e) {
                    return this.__min = e, this
                }, t.prototype.max = function(e) {
                    return this.__max = e, this
                }, t.prototype.step = function(e) {
                    return this.__step = e, this.__impliedStep = e, this.__precision = l(e), this
                }, t
            }(u["default"]);
        t["default"] = f
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t) {
            if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
            return !t || "object" != typeof t &amp;&amp; "function" != typeof t ? e : t
        }

        function a(e, t) {
            if ("function" != typeof t &amp;&amp; null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
            e.prototype = Object.create(t &amp;&amp; t.prototype, {
                constructor: {
                    value: e,
                    enumerable: !1,
                    writable: !0,
                    configurable: !0
                }
            }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
        }

        function l(e, t) {
            var n = Math.pow(10, t);
            return Math.round(e * n) / n
        }
        t.__esModule = !0;
        var s = n(12),
            u = o(s),
            d = n(9),
            c = o(d),
            f = n(5),
            _ = o(f),
            p = function(e) {
                function t(n, o, a) {
                    function l() {
                        var e = parseFloat(m.__input.value);
                        _["default"].isNaN(e) || m.setValue(e)
                    }

                    function s() {
                        m.__onFinishChange &amp;&amp; m.__onFinishChange.call(m, m.getValue())
                    }

                    function u() {
                        s()
                    }

                    function d(e) {
                        var t = b - e.clientY;
                        m.setValue(m.getValue() + t * m.__impliedStep), b = e.clientY
                    }

                    function f() {
                        c["default"].unbind(window, "mousemove", d), c["default"].unbind(window, "mouseup", f), s()
                    }

                    function p(e) {
                        c["default"].bind(window, "mousemove", d), c["default"].bind(window, "mouseup", f), b = e.clientY
                    }
                    i(this, t);
                    var h = r(this, e.call(this, n, o, a));
                    h.__truncationSuspended = !1;
                    var m = h,
                        b = void 0;
                    return h.__input = document.createElement("input"), h.__input.setAttribute("type", "text"), c["default"].bind(h.__input, "change", l), c["default"].bind(h.__input, "blur", u), c["default"].bind(h.__input, "mousedown", p), c["default"].bind(h.__input, "keydown", function(e) {
                        13 === e.keyCode &amp;&amp; (m.__truncationSuspended = !0, this.blur(), m.__truncationSuspended = !1, s())
                    }), h.updateDisplay(), h.domElement.appendChild(h.__input), h
                }
                return a(t, e), t.prototype.updateDisplay = function() {
                    return this.__input.value = this.__truncationSuspended ? this.getValue() : l(this.getValue(), this.__precision), e.prototype.updateDisplay.call(this)
                }, t
            }(u["default"]);
        t["default"] = p
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t) {
            if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
            return !t || "object" != typeof t &amp;&amp; "function" != typeof t ? e : t
        }

        function a(e, t) {
            if ("function" != typeof t &amp;&amp; null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
            e.prototype = Object.create(t &amp;&amp; t.prototype, {
                constructor: {
                    value: e,
                    enumerable: !1,
                    writable: !0,
                    configurable: !0
                }
            }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
        }

        function l(e, t, n, o, i) {
            return o + (i - o) * ((e - t) / (n - t))
        }
        t.__esModule = !0;
        var s = n(12),
            u = o(s),
            d = n(9),
            c = o(d),
            f = function(e) {
                function t(n, o, a, s, u) {
                    function d(e) {
                        document.activeElement.blur(), c["default"].bind(window, "mousemove", f), c["default"].bind(window, "mouseup", _), f(e)
                    }

                    function f(e) {
                        e.preventDefault();
                        var t = h.__background.getBoundingClientRect();
                        return h.setValue(l(e.clientX, t.left, t.right, h.__min, h.__max)), !1
                    }

                    function _() {
                        c["default"].unbind(window, "mousemove", f), c["default"].unbind(window, "mouseup", _), h.__onFinishChange &amp;&amp; h.__onFinishChange.call(h, h.getValue())
                    }
                    i(this, t);
                    var p = r(this, e.call(this, n, o, {
                            min: a,
                            max: s,
                            step: u
                        })),
                        h = p;
                    return p.__background = document.createElement("div"), p.__foreground = document.createElement("div"), c["default"].bind(p.__background, "mousedown", d), c["default"].addClass(p.__background, "slider"), c["default"].addClass(p.__foreground, "slider-fg"), p.updateDisplay(), p.__background.appendChild(p.__foreground), p.domElement.appendChild(p.__background), p
                }
                return a(t, e), t.prototype.updateDisplay = function() {
                    var t = (this.getValue() - this.__min) / (this.__max - this.__min);
                    return this.__foreground.style.width = 100 * t + "%", e.prototype.updateDisplay.call(this)
                }, t
            }(u["default"]);
        t["default"] = f
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t) {
            if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
            return !t || "object" != typeof t &amp;&amp; "function" != typeof t ? e : t
        }

        function a(e, t) {
            if ("function" != typeof t &amp;&amp; null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
            e.prototype = Object.create(t &amp;&amp; t.prototype, {
                constructor: {
                    value: e,
                    enumerable: !1,
                    writable: !0,
                    configurable: !0
                }
            }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
        }
        t.__esModule = !0;
        var l = n(7),
            s = o(l),
            u = n(9),
            d = o(u),
            c = function(e) {
                function t(n, o, a) {
                    i(this, t);
                    var l = r(this, e.call(this, n, o)),
                        s = l;
                    return l.__button = document.createElement("div"), l.__button.innerHTML = void 0 === a ? "Fire" : a, d["default"].bind(l.__button, "click", function(e) {
                        return e.preventDefault(), s.fire(), !1
                    }), d["default"].addClass(l.__button, "button"), l.domElement.appendChild(l.__button), l
                }
                return a(t, e), t.prototype.fire = function() {
                    this.__onChange &amp;&amp; this.__onChange.call(this), this.getValue().call(this.object), this.__onFinishChange &amp;&amp; this.__onFinishChange.call(this, this.getValue())
                }, t
            }(s["default"]);
        t["default"] = c
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }

        function r(e, t) {
            if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
            return !t || "object" != typeof t &amp;&amp; "function" != typeof t ? e : t
        }

        function a(e, t) {
            if ("function" != typeof t &amp;&amp; null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
            e.prototype = Object.create(t &amp;&amp; t.prototype, {
                constructor: {
                    value: e,
                    enumerable: !1,
                    writable: !0,
                    configurable: !0
                }
            }), t &amp;&amp; (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
        }

        function l(e, t, n, o) {
            e.style.background = "", g["default"].each(y, function(i) {
                e.style.cssText += "background: " + i + "linear-gradient(" + t + ", " + n + " 0%, " + o + " 100%); "
            })
        }

        function s(e) {
            e.style.background = "", e.style.cssText += "background: -moz-linear-gradient(top,  #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);", e.style.cssText += "background: -webkit-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", e.style.cssText += "background: -o-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", e.style.cssText += "background: -ms-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", e.style.cssText += "background: linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"
        }
        t.__esModule = !0;
        var u = n(7),
            d = o(u),
            c = n(9),
            f = o(c),
            _ = n(2),
            p = o(_),
            h = n(3),
            m = o(h),
            b = n(5),
            g = o(b),
            v = function(e) {
                function t(n, o) {
                    function a(e) {
                        h(e), f["default"].bind(window, "mousemove", h), f["default"].bind(window, "mouseup", u)
                    }

                    function u() {
                        f["default"].unbind(window, "mousemove", h), f["default"].unbind(window, "mouseup", u), _()
                    }

                    function d() {
                        var e = (0, m["default"])(this.value);
                        e !== !1 ? (y.__color.__state = e, y.setValue(y.__color.toOriginal())) : this.value = y.__color.toString()
                    }

                    function c() {
                        f["default"].unbind(window, "mousemove", b), f["default"].unbind(window, "mouseup", c), _()
                    }

                    function _() {
                        y.__onFinishChange &amp;&amp; y.__onFinishChange.call(y, y.__color.toOriginal())
                    }

                    function h(e) {
                        e.preventDefault();
                        var t = y.__saturation_field.getBoundingClientRect(),
                            n = (e.clientX - t.left) / (t.right - t.left),
                            o = 1 - (e.clientY - t.top) / (t.bottom - t.top);
                        return o &gt; 1 ? o = 1 : o &lt; 0 &amp;&amp; (o = 0), n &gt; 1 ? n = 1 : n &lt; 0 &amp;&amp; (n = 0), y.__color.v = o, y.__color.s = n, y.setValue(y.__color.toOriginal()), !1
                    }

                    function b(e) {
                        e.preventDefault();
                        var t = y.__hue_field.getBoundingClientRect(),
                            n = 1 - (e.clientY - t.top) / (t.bottom - t.top);
                        return n &gt; 1 ? n = 1 : n &lt; 0 &amp;&amp; (n = 0), y.__color.h = 360 * n, y.setValue(y.__color.toOriginal()), !1
                    }
                    i(this, t);
                    var v = r(this, e.call(this, n, o));
                    v.__color = new p["default"](v.getValue()), v.__temp = new p["default"](0);
                    var y = v;
                    v.domElement = document.createElement("div"), f["default"].makeSelectable(v.domElement, !1), v.__selector = document.createElement("div"), v.__selector.className = "selector", v.__saturation_field = document.createElement("div"), v.__saturation_field.className = "saturation-field", v.__field_knob = document.createElement("div"), v.__field_knob.className = "field-knob", v.__field_knob_border = "2px solid ", v.__hue_knob = document.createElement("div"), v.__hue_knob.className = "hue-knob", v.__hue_field = document.createElement("div"), v.__hue_field.className = "hue-field", v.__input = document.createElement("input"), v.__input.type = "text", v.__input_textShadow = "0 1px 1px ", f["default"].bind(v.__input, "keydown", function(e) {
                        13 === e.keyCode &amp;&amp; d.call(this)
                    }), f["default"].bind(v.__input, "blur", d), f["default"].bind(v.__selector, "mousedown", function() {
                        f["default"].addClass(this, "drag").bind(window, "mouseup", function() {
                            f["default"].removeClass(y.__selector, "drag")
                        })
                    });
                    var w = document.createElement("div");
                    return g["default"].extend(v.__selector.style, {
                        width: "122px",
                        height: "102px",
                        padding: "3px",
                        backgroundColor: "#222",
                        boxShadow: "0px 1px 3px rgba(0,0,0,0.3)"
                    }), g["default"].extend(v.__field_knob.style, {
                        position: "absolute",
                        width: "12px",
                        height: "12px",
                        border: v.__field_knob_border + (v.__color.v &lt; .5 ? "#fff" : "#000"),
                        boxShadow: "0px 1px 3px rgba(0,0,0,0.5)",
                        borderRadius: "12px",
                        zIndex: 1
                    }), g["default"].extend(v.__hue_knob.style, {
                        position: "absolute",
                        width: "15px",
                        height: "2px",
                        borderRight: "4px solid #fff",
                        zIndex: 1
                    }), g["default"].extend(v.__saturation_field.style, {
                        width: "100px",
                        height: "100px",
                        border: "1px solid #555",
                        marginRight: "3px",
                        display: "inline-block",
                        cursor: "pointer"
                    }), g["default"].extend(w.style, {
                        width: "100%",
                        height: "100%",
                        background: "none"
                    }), l(w, "top", "rgba(0,0,0,0)", "#000"), g["default"].extend(v.__hue_field.style, {
                        width: "15px",
                        height: "100px",
                        border: "1px solid #555",
                        cursor: "ns-resize",
                        position: "absolute",
                        top: "3px",
                        right: "3px"
                    }), s(v.__hue_field), g["default"].extend(v.__input.style, {
                        outline: "none",
                        textAlign: "center",
                        color: "#fff",
                        border: 0,
                        fontWeight: "bold",
                        textShadow: v.__input_textShadow + "rgba(0,0,0,0.7)"
                    }), f["default"].bind(v.__saturation_field, "mousedown", a), f["default"].bind(v.__field_knob, "mousedown", a), f["default"].bind(v.__hue_field, "mousedown", function(e) {
                        b(e), f["default"].bind(window, "mousemove", b), f["default"].bind(window, "mouseup", c)
                    }), v.__saturation_field.appendChild(w), v.__selector.appendChild(v.__field_knob), v.__selector.appendChild(v.__saturation_field), v.__selector.appendChild(v.__hue_field), v.__hue_field.appendChild(v.__hue_knob), v.domElement.appendChild(v.__input), v.domElement.appendChild(v.__selector), v.updateDisplay(), v
                }
                return a(t, e), t.prototype.updateDisplay = function() {
                    var e = (0, m["default"])(this.getValue());
                    if (e !== !1) {
                        var t = !1;
                        g["default"].each(p["default"].COMPONENTS, function(n) {
                            if (!g["default"].isUndefined(e[n]) &amp;&amp; !g["default"].isUndefined(this.__color.__state[n]) &amp;&amp; e[n] !== this.__color.__state[n]) return t = !0, {}
                        }, this), t &amp;&amp; g["default"].extend(this.__color.__state, e)
                    }
                    g["default"].extend(this.__temp.__state, this.__color.__state), this.__temp.a = 1;
                    var n = this.__color.v &lt; .5 || this.__color.s &gt; .5 ? 255 : 0,
                        o = 255 - n;
                    g["default"].extend(this.__field_knob.style, {
                        marginLeft: 100 * this.__color.s - 7 + "px",
                        marginTop: 100 * (1 - this.__color.v) - 7 + "px",
                        backgroundColor: this.__temp.toHexString(),
                        border: this.__field_knob_border + "rgb(" + n + "," + n + "," + n + ")"
                    }), this.__hue_knob.style.marginTop = 100 * (1 - this.__color.h / 360) + "px", this.__temp.s = 1, this.__temp.v = 1, l(this.__saturation_field, "left", "#fff", this.__temp.toHexString()), this.__input.value = this.__color.toString(), g["default"].extend(this.__input.style, {
                        backgroundColor: this.__color.toHexString(),
                        color: "rgb(" + n + "," + n + "," + n + ")",
                        textShadow: this.__input_textShadow + "rgba(" + o + "," + o + "," + o + ",.7)"
                    })
                }, t
            }(d["default"]),
            y = ["-moz-", "-o-", "-webkit-", "-ms-", ""];
        t["default"] = v
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t, n) {
            var o = document.createElement("li");
            return t &amp;&amp; o.appendChild(t), n ? e.__ul.insertBefore(o, n) : e.__ul.appendChild(o), e.onResize(), o
        }

        function r(e, t) {
            var n = e.__preset_select[e.__preset_select.selectedIndex];
            t ? n.innerHTML = n.value + "*" : n.innerHTML = n.value
        }

        function a(e, t, n) {
            if (n.__li = t, n.__gui = e, U["default"].extend(n, {
                    options: function(t) {
                        if (arguments.length &gt; 1) {
                            var o = n.__li.nextElementSibling;
                            return n.remove(), s(e, n.object, n.property, {
                                before: o,
                                factoryArgs: [U["default"].toArray(arguments)]
                            })
                        }
                        if (U["default"].isArray(t) || U["default"].isObject(t)) {
                            var i = n.__li.nextElementSibling;
                            return n.remove(), s(e, n.object, n.property, {
                                before: i,
                                factoryArgs: [t]
                            })
                        }
                    },
                    name: function(e) {
                        return n.__li.firstElementChild.firstElementChild.innerHTML = e, n
                    },
                    listen: function() {
                        return n.__gui.listen(n), n
                    },
                    remove: function() {
                        return n.__gui.remove(n), n
                    }
                }), n instanceof B["default"]) ! function() {
                var e = new N["default"](n.object, n.property, {
                    min: n.__min,
                    max: n.__max,
                    step: n.__step
                });
                U["default"].each(["updateDisplay", "onChange", "onFinishChange", "step"], function(t) {
                    var o = n[t],
                        i = e[t];
                    n[t] = e[t] = function() {
                        var t = Array.prototype.slice.call(arguments);
                        return i.apply(e, t), o.apply(n, t)
                    }
                }), z["default"].addClass(t, "has-slider"), n.domElement.insertBefore(e.domElement, n.domElement.firstElementChild)
            }();
            else if (n instanceof N["default"]) {
                var o = function(t) {
                    if (U["default"].isNumber(n.__min) &amp;&amp; U["default"].isNumber(n.__max)) {
                        var o = n.__li.firstElementChild.firstElementChild.innerHTML,
                            i = n.__gui.__listening.indexOf(n) &gt; -1;
                        n.remove();
                        var r = s(e, n.object, n.property, {
                            before: n.__li.nextElementSibling,
                            factoryArgs: [n.__min, n.__max, n.__step]
                        });
                        return r.name(o), i &amp;&amp; r.listen(), r
                    }
                    return t
                };
                n.min = U["default"].compose(o, n.min), n.max = U["default"].compose(o, n.max)
            } else n instanceof O["default"] ? (z["default"].bind(t, "click", function() {
                z["default"].fakeEvent(n.__checkbox, "click")
            }), z["default"].bind(n.__checkbox, "click", function(e) {
                e.stopPropagation()
            })) : n instanceof R["default"] ? (z["default"].bind(t, "click", function() {
                z["default"].fakeEvent(n.__button, "click")
            }), z["default"].bind(t, "mouseover", function() {
                z["default"].addClass(n.__button, "hover")
            }), z["default"].bind(t, "mouseout", function() {
                z["default"].removeClass(n.__button, "hover")
            })) : n instanceof j["default"] &amp;&amp; (z["default"].addClass(t, "color"), n.updateDisplay = U["default"].compose(function(e) {
                return t.style.borderLeftColor = n.__color.toString(), e
            }, n.updateDisplay), n.updateDisplay());
            n.setValue = U["default"].compose(function(t) {
                return e.getRoot().__preset_select &amp;&amp; n.isModified() &amp;&amp; r(e.getRoot(), !0), t
            }, n.setValue)
        }

        function l(e, t) {
            var n = e.getRoot(),
                o = n.__rememberedObjects.indexOf(t.object);
            if (o !== -1) {
                var i = n.__rememberedObjectIndecesToControllers[o];
                if (void 0 === i &amp;&amp; (i = {}, n.__rememberedObjectIndecesToControllers[o] = i), i[t.property] = t, n.load &amp;&amp; n.load.remembered) {
                    var r = n.load.remembered,
                        a = void 0;
                    if (r[e.preset]) a = r[e.preset];
                    else {
                        if (!r[Q]) return;
                        a = r[Q]
                    }
                    if (a[o] &amp;&amp; void 0 !== a[o][t.property]) {
                        var l = a[o][t.property];
                        t.initialValue = l, t.setValue(l)
                    }
                }
            }
        }

        function s(e, t, n, o) {
            if (void 0 === t[n]) throw new Error('Object "' + t + '" has no property "' + n + '"');
            var r = void 0;
            if (o.color) r = new j["default"](t, n);
            else {
                var s = [t, n].concat(o.factoryArgs);
                r = C["default"].apply(e, s)
            }
            o.before instanceof S["default"] &amp;&amp; (o.before = o.before.__li), l(e, r), z["default"].addClass(r.domElement, "c");
            var u = document.createElement("span");
            z["default"].addClass(u, "property-name"), u.innerHTML = r.property;
            var d = document.createElement("div");
            d.appendChild(u), d.appendChild(r.domElement);
            var c = i(e, d, o.before);
            return z["default"].addClass(c, oe.CLASS_CONTROLLER_ROW), r instanceof j["default"] ? z["default"].addClass(c, "color") : z["default"].addClass(c, g(r.getValue())), a(e, c, r), e.__controllers.push(r), r
        }

        function u(e, t) {
            return document.location.href + "." + t
        }

        function d(e, t, n) {
            var o = document.createElement("option");
            o.innerHTML = t, o.value = t, e.__preset_select.appendChild(o), n &amp;&amp; (e.__preset_select.selectedIndex = e.__preset_select.length - 1)
        }

        function c(e, t) {
            t.style.display = e.useLocalStorage ? "block" : "none"
        }

        function f(e) {
            var t = e.__save_row = document.createElement("li");
            z["default"].addClass(e.domElement, "has-save"), e.__ul.insertBefore(t, e.__ul.firstChild), z["default"].addClass(t, "save-row");
            var n = document.createElement("span");
            n.innerHTML = "&amp;nbsp;", z["default"].addClass(n, "button gears");
            var o = document.createElement("span");
            o.innerHTML = "Save", z["default"].addClass(o, "button"), z["default"].addClass(o, "save");
            var i = document.createElement("span");
            i.innerHTML = "New", z["default"].addClass(i, "button"), z["default"].addClass(i, "save-as");
            var r = document.createElement("span");
            r.innerHTML = "Revert", z["default"].addClass(r, "button"), z["default"].addClass(r, "revert");
            var a = e.__preset_select = document.createElement("select");
            e.load &amp;&amp; e.load.remembered ? U["default"].each(e.load.remembered, function(t, n) {
                d(e, n, n === e.preset)
            }) : d(e, Q, !1), z["default"].bind(a, "change", function() {
                for (var t = 0; t &lt; e.__preset_select.length; t++) e.__preset_select[t].innerHTML = e.__preset_select[t].value;
                e.preset = this.value
            }), t.appendChild(a), t.appendChild(n), t.appendChild(o), t.appendChild(i), t.appendChild(r), q &amp;&amp; ! function() {
                var t = document.getElementById("dg-local-explain"),
                    n = document.getElementById("dg-local-storage"),
                    o = document.getElementById("dg-save-locally");
                o.style.display = "block", "true" === localStorage.getItem(u(e, "isLocal")) &amp;&amp; n.setAttribute("checked", "checked"), c(e, t), z["default"].bind(n, "change", function() {
                    e.useLocalStorage = !e.useLocalStorage, c(e, t)
                })
            }();
            var l = document.getElementById("dg-new-constructor");
            z["default"].bind(l, "keydown", function(e) {
                !e.metaKey || 67 !== e.which &amp;&amp; 67 !== e.keyCode || Z.hide()
            }), z["default"].bind(n, "click", function() {
                l.innerHTML = JSON.stringify(e.getSaveObject(), void 0, 2), Z.show(), l.focus(), l.select()
            }), z["default"].bind(o, "click", function() {
                e.save()
            }), z["default"].bind(i, "click", function() {
                var t = prompt("Enter a new preset name.");
                t &amp;&amp; e.saveAs(t)
            }), z["default"].bind(r, "click", function() {
                e.revert()
            })
        }

        function _(e) {
            function t(t) {
                return t.preventDefault(), e.width += i - t.clientX, e.onResize(), i = t.clientX, !1
            }

            function n() {
                z["default"].removeClass(e.__closeButton, oe.CLASS_DRAG), z["default"].unbind(window, "mousemove", t), z["default"].unbind(window, "mouseup", n)
            }

            function o(o) {
                return o.preventDefault(), i = o.clientX, z["default"].addClass(e.__closeButton, oe.CLASS_DRAG), z["default"].bind(window, "mousemove", t), z["default"].bind(window, "mouseup", n), !1
            }
            var i = void 0;
            e.__resize_handle = document.createElement("div"), U["default"].extend(e.__resize_handle.style, {
                width: "6px",
                marginLeft: "-3px",
                height: "200px",
                cursor: "ew-resize",
                position: "absolute"
            }), z["default"].bind(e.__resize_handle, "mousedown", o), z["default"].bind(e.__closeButton, "mousedown", o), e.domElement.insertBefore(e.__resize_handle, e.domElement.firstElementChild)
        }

        function p(e, t) {
            e.domElement.style.width = t + "px", e.__save_row &amp;&amp; e.autoPlace &amp;&amp; (e.__save_row.style.width = t + "px"), e.__closeButton &amp;&amp; (e.__closeButton.style.width = t + "px")
        }

        function h(e, t) {
            var n = {};
            return U["default"].each(e.__rememberedObjects, function(o, i) {
                var r = {},
                    a = e.__rememberedObjectIndecesToControllers[i];
                U["default"].each(a, function(e, n) {
                    r[n] = t ? e.initialValue : e.getValue()
                }), n[i] = r
            }), n
        }

        function m(e) {
            for (var t = 0; t &lt; e.__preset_select.length; t++) e.__preset_select[t].value === e.preset &amp;&amp; (e.__preset_select.selectedIndex = t)
        }

        function b(e) {
            0 !== e.length &amp;&amp; D["default"].call(window, function() {
                b(e)
            }), U["default"].each(e, function(e) {
                e.updateDisplay()
            })
        }
        var g = "function" == typeof Symbol &amp;&amp; "symbol" == typeof Symbol.iterator ? function(e) {
                return typeof e
            } : function(e) {
                return e &amp;&amp; "function" == typeof Symbol &amp;&amp; e.constructor === Symbol ? "symbol" : typeof e
            },
            v = n(18),
            y = o(v),
            w = n(19),
            x = o(w),
            E = n(20),
            C = o(E),
            A = n(7),
            S = o(A),
            k = n(8),
            O = o(k),
            T = n(15),
            R = o(T),
            L = n(13),
            N = o(L),
            M = n(14),
            B = o(M),
            H = n(16),
            j = o(H),
            P = n(21),
            D = o(P),
            V = n(22),
            F = o(V),
            I = n(9),
            z = o(I),
            G = n(5),
            U = o(G),
            X = n(23),
            K = o(X);
        y["default"].inject(K["default"]);
        var Y = "dg",
            J = 72,
            W = 20,
            Q = "Default",
            q = function() {
                try {
                    return "localStorage" in window &amp;&amp; null !== window.localStorage
                } catch (e) {
                    return !1
                }
            }(),
            Z = void 0,
            $ = !0,
            ee = void 0,
            te = !1,
            ne = [],
            oe = function ie(e) {
                function t() {
                    var e = n.getRoot();
                    e.width += 1, U["default"].defer(function() {
                        e.width -= 1
                    })
                }
                var n = this,
                    o = e || {};
                this.domElement = document.createElement("div"), this.__ul = document.createElement("ul"), this.domElement.appendChild(this.__ul), z["default"].addClass(this.domElement, Y), this.__folders = {}, this.__controllers = [], this.__rememberedObjects = [], this.__rememberedObjectIndecesToControllers = [], this.__listening = [], o = U["default"].defaults(o, {
                    autoPlace: !0,
                    width: ie.DEFAULT_WIDTH
                }), o = U["default"].defaults(o, {
                    resizable: o.autoPlace,
                    hideable: o.autoPlace
                }), U["default"].isUndefined(o.load) ? o.load = {
                    preset: Q
                } : o.preset &amp;&amp; (o.load.preset = o.preset), U["default"].isUndefined(o.parent) &amp;&amp; o.hideable &amp;&amp; ne.push(this), o.resizable = U["default"].isUndefined(o.parent) &amp;&amp; o.resizable, o.autoPlace &amp;&amp; U["default"].isUndefined(o.scrollable) &amp;&amp; (o.scrollable = !0);
                var r = q &amp;&amp; "true" === localStorage.getItem(u(this, "isLocal")),
                    a = void 0;
                if (Object.defineProperties(this, {
                        parent: {
                            get: function() {
                                return o.parent
                            }
                        },
                        scrollable: {
                            get: function() {
                                return o.scrollable
                            }
                        },
                        autoPlace: {
                            get: function() {
                                return o.autoPlace
                            }
                        },
                        preset: {
                            get: function() {
                                return n.parent ? n.getRoot().preset : o.load.preset
                            },
                            set: function(e) {
                                n.parent ? n.getRoot().preset = e : o.load.preset = e, m(this), n.revert()
                            }
                        },
                        width: {
                            get: function() {
                                return o.width
                            },
                            set: function(e) {
                                o.width = e, p(n, e)
                            }
                        },
                        name: {
                            get: function() {
                                return o.name
                            },
                            set: function(e) {
                                o.name = e, titleRowName &amp;&amp; (titleRowName.innerHTML = o.name)
                            }
                        },
                        closed: {
                            get: function() {
                                return o.closed
                            },
                            set: function(e) {
                                o.closed = e, o.closed ? z["default"].addClass(n.__ul, ie.CLASS_CLOSED) : z["default"].removeClass(n.__ul, ie.CLASS_CLOSED), this.onResize(), n.__closeButton &amp;&amp; (n.__closeButton.innerHTML = e ? ie.TEXT_OPEN : ie.TEXT_CLOSED)
                            }
                        },
                        load: {
                            get: function() {
                                return o.load
                            }
                        },
                        useLocalStorage: {
                            get: function() {
                                return r
                            },
                            set: function(e) {
                                q &amp;&amp; (r = e, e ? z["default"].bind(window, "unload", a) : z["default"].unbind(window, "unload", a), localStorage.setItem(u(n, "isLocal"), e))
                            }
                        }
                    }), U["default"].isUndefined(o.parent)) {
                    if (o.closed = !1, z["default"].addClass(this.domElement, ie.CLASS_MAIN), z["default"].makeSelectable(this.domElement, !1), q &amp;&amp; r) {
                        n.useLocalStorage = !0;
                        var l = localStorage.getItem(u(this, "gui"));
                        l &amp;&amp; (o.load = JSON.parse(l))
                    }
                    this.__closeButton = document.createElement("div"), this.__closeButton.innerHTML = ie.TEXT_CLOSED, z["default"].addClass(this.__closeButton, ie.CLASS_CLOSE_BUTTON), this.domElement.appendChild(this.__closeButton), z["default"].bind(this.__closeButton, "click", function() {
                        n.closed = !n.closed
                    })
                } else {
                    void 0 === o.closed &amp;&amp; (o.closed = !0);
                    var s = document.createTextNode(o.name);
                    z["default"].addClass(s, "controller-name");
                    var d = i(n, s),
                        c = function(e) {
                            return e.preventDefault(), n.closed = !n.closed, !1
                        };
                    z["default"].addClass(this.__ul, ie.CLASS_CLOSED), z["default"].addClass(d, "title"), z["default"].bind(d, "click", c), o.closed || (this.closed = !1)
                }
                o.autoPlace &amp;&amp; (U["default"].isUndefined(o.parent) &amp;&amp; ($ &amp;&amp; (ee = document.createElement("div"), z["default"].addClass(ee, Y), z["default"].addClass(ee, ie.CLASS_AUTO_PLACE_CONTAINER), document.body.appendChild(ee), $ = !1), ee.appendChild(this.domElement), z["default"].addClass(this.domElement, ie.CLASS_AUTO_PLACE)), this.parent || p(n, o.width)), this.__resizeHandler = function() {
                    n.onResizeDebounced()
                }, z["default"].bind(window, "resize", this.__resizeHandler), z["default"].bind(this.__ul, "webkitTransitionEnd", this.__resizeHandler), z["default"].bind(this.__ul, "transitionend", this.__resizeHandler), z["default"].bind(this.__ul, "oTransitionEnd", this.__resizeHandler), this.onResize(), o.resizable &amp;&amp; _(this), a = function() {
                    q &amp;&amp; "true" === localStorage.getItem(u(n, "isLocal")) &amp;&amp; localStorage.setItem(u(n, "gui"), JSON.stringify(n.getSaveObject()))
                }, this.saveToLocalStorageIfPossible = a, o.parent || t()
            };
        oe.toggleHide = function() {
            te = !te, U["default"].each(ne, function(e) {
                e.domElement.style.display = te ? "none" : ""
            })
        }, oe.CLASS_AUTO_PLACE = "a", oe.CLASS_AUTO_PLACE_CONTAINER = "ac", oe.CLASS_MAIN = "main", oe.CLASS_CONTROLLER_ROW = "cr", oe.CLASS_TOO_TALL = "taller-than-window", oe.CLASS_CLOSED = "closed", oe.CLASS_CLOSE_BUTTON = "close-button", oe.CLASS_DRAG = "drag", oe.DEFAULT_WIDTH = 245, oe.TEXT_CLOSED = "Close Controls", oe.TEXT_OPEN = "Open Controls", oe._keydownHandler = function(e) {
            "text" === document.activeElement.type || e.which !== J &amp;&amp; e.keyCode !== J || oe.toggleHide()
        }, z["default"].bind(window, "keydown", oe._keydownHandler, !1), U["default"].extend(oe.prototype, {
            add: function(e, t) {
                return s(this, e, t, {
                    factoryArgs: Array.prototype.slice.call(arguments, 2)
                })
            },
            addColor: function(e, t) {
                return s(this, e, t, {
                    color: !0
                })
            },
            remove: function(e) {
                this.__ul.removeChild(e.__li), this.__controllers.splice(this.__controllers.indexOf(e), 1);
                var t = this;
                U["default"].defer(function() {
                    t.onResize()
                })
            },
            destroy: function() {
                this.autoPlace &amp;&amp; ee.removeChild(this.domElement), z["default"].unbind(window, "keydown", oe._keydownHandler, !1), z["default"].unbind(window, "resize", this.__resizeHandler), this.saveToLocalStorageIfPossible &amp;&amp; z["default"].unbind(window, "unload", this.saveToLocalStorageIfPossible)
            },
            addFolder: function(e) {
                if (void 0 !== this.__folders[e]) throw new Error('You already have a folder in this GUI by the name "' + e + '"');
                var t = {
                    name: e,
                    parent: this
                };
                t.autoPlace = this.autoPlace, this.load &amp;&amp; this.load.folders &amp;&amp; this.load.folders[e] &amp;&amp; (t.closed = this.load.folders[e].closed, t.load = this.load.folders[e]);
                var n = new oe(t);
                this.__folders[e] = n;
                var o = i(this, n.domElement);
                return z["default"].addClass(o, "folder"), n
            },
            open: function() {
                this.closed = !1
            },
            close: function() {
                this.closed = !0
            },
            onResize: function() {
                var e = this.getRoot();
                if (e.scrollable) {
                    var t = z["default"].getOffset(e.__ul).top,
                        n = 0;
                    U["default"].each(e.__ul.childNodes, function(t) {
                        e.autoPlace &amp;&amp; t === e.__save_row || (n += z["default"].getHeight(t))
                    }), window.innerHeight - t - W &lt; n ? (z["default"].addClass(e.domElement, oe.CLASS_TOO_TALL), e.__ul.style.height = window.innerHeight - t - W + "px") : (z["default"].removeClass(e.domElement, oe.CLASS_TOO_TALL), e.__ul.style.height = "auto")
                }
                e.__resize_handle &amp;&amp; U["default"].defer(function() {
                    e.__resize_handle.style.height = e.__ul.offsetHeight + "px"
                }), e.__closeButton &amp;&amp; (e.__closeButton.style.width = e.width + "px")
            },
            onResizeDebounced: U["default"].debounce(function() {
                this.onResize()
            }, 200),
            remember: function() {
                if (U["default"].isUndefined(Z) &amp;&amp; (Z = new F["default"], Z.domElement.innerHTML = x["default"]), this.parent) throw new Error("You can only call remember on a top level GUI.");
                var e = this;
                U["default"].each(Array.prototype.slice.call(arguments), function(t) {
                    0 === e.__rememberedObjects.length &amp;&amp; f(e), e.__rememberedObjects.indexOf(t) === -1 &amp;&amp; e.__rememberedObjects.push(t)
                }), this.autoPlace &amp;&amp; p(this, this.width)
            },
            getRoot: function() {
                for (var e = this; e.parent;) e = e.parent;
                return e
            },
            getSaveObject: function() {
                var e = this.load;
                return e.closed = this.closed, this.__rememberedObjects.length &gt; 0 &amp;&amp; (e.preset = this.preset, e.remembered || (e.remembered = {}), e.remembered[this.preset] = h(this)), e.folders = {}, U["default"].each(this.__folders, function(t, n) {
                    e.folders[n] = t.getSaveObject()
                }), e
            },
            save: function() {
                this.load.remembered || (this.load.remembered = {}), this.load.remembered[this.preset] = h(this), r(this, !1), this.saveToLocalStorageIfPossible()
            },
            saveAs: function(e) {
                this.load.remembered || (this.load.remembered = {}, this.load.remembered[Q] = h(this, !0)), this.load.remembered[e] = h(this), this.preset = e, d(this, e, !0), this.saveToLocalStorageIfPossible()
            },
            revert: function(e) {
                U["default"].each(this.__controllers, function(t) {
                    this.getRoot().load.remembered ? l(e || this.getRoot(), t) : t.setValue(t.initialValue), t.__onFinishChange &amp;&amp; t.__onFinishChange.call(t, t.getValue())
                }, this), U["default"].each(this.__folders, function(e) {
                    e.revert(e)
                }), e || r(this.getRoot(), !1)
            },
            listen: function(e) {
                var t = 0 === this.__listening.length;
                this.__listening.push(e), t &amp;&amp; b(this.__listening)
            },
            updateDisplay: function() {
                U["default"].each(this.__controllers, function(e) {
                    e.updateDisplay()
                }), U["default"].each(this.__folders, function(e) {
                    e.updateDisplay()
                })
            }
        }), e.exports = oe
    }, function(e, t) {
        "use strict";
        e.exports = {
            load: function(e, t) {
                var n = t || document,
                    o = n.createElement("link");
                o.type = "text/css", o.rel = "stylesheet", o.href = e, n.getElementsByTagName("head")[0].appendChild(o)
            },
            inject: function(e, t) {
                var n = t || document,
                    o = document.createElement("style");
                o.type = "text/css", o.innerHTML = e;
                var i = n.getElementsByTagName("head")[0];
                try {
                    i.appendChild(o)
                } catch (r) {}
            }
        }
    }, function(e, t) {
        e.exports = "&lt;div id=dg-save class=\"dg dialogue\"&gt; Here's the new load parameter for your &lt;code&gt;GUI&lt;/code&gt;'s constructor: &lt;textarea id=dg-new-constructor&gt;&lt;/textarea&gt; &lt;div id=dg-save-locally&gt; &lt;input id=dg-local-storage type=checkbox /&gt; Automatically save values to &lt;code&gt;localStorage&lt;/code&gt; on exit. &lt;div id=dg-local-explain&gt;The values saved to &lt;code&gt;localStorage&lt;/code&gt; will override those passed to &lt;code&gt;dat.GUI&lt;/code&gt;'s constructor. This makes it easier to work incrementally, but &lt;code&gt;localStorage&lt;/code&gt; is fragile, and your friends may not see the same values you do. &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;"
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }
        t.__esModule = !0;
        var i = n(10),
            r = o(i),
            a = n(13),
            l = o(a),
            s = n(14),
            u = o(s),
            d = n(11),
            c = o(d),
            f = n(15),
            _ = o(f),
            p = n(8),
            h = o(p),
            m = n(5),
            b = o(m),
            g = function(e, t) {
                var n = e[t];
                return b["default"].isArray(arguments[2]) || b["default"].isObject(arguments[2]) ? new r["default"](e, t, arguments[2]) : b["default"].isNumber(n) ? b["default"].isNumber(arguments[2]) &amp;&amp; b["default"].isNumber(arguments[3]) ? b["default"].isNumber(arguments[4]) ? new u["default"](e, t, arguments[2], arguments[3], arguments[4]) : new u["default"](e, t, arguments[2], arguments[3]) : b["default"].isNumber(arguments[4]) ? new l["default"](e, t, {
                    min: arguments[2],
                    max: arguments[3],
                    step: arguments[4]
                }) : new l["default"](e, t, {
                    min: arguments[2],
                    max: arguments[3]
                }) : b["default"].isString(n) ? new c["default"](e, t) : b["default"].isFunction(n) ? new _["default"](e, t, "") : b["default"].isBoolean(n) ? new h["default"](e, t) : null
            };
        t["default"] = g
    }, function(e, t) {
        "use strict";

        function n(e) {
            setTimeout(e, 1e3 / 60)
        }
        t.__esModule = !0, t["default"] = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || n
    }, function(e, t, n) {
        "use strict";

        function o(e) {
            return e &amp;&amp; e.__esModule ? e : {
                "default": e
            }
        }

        function i(e, t) {
            if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
        }
        t.__esModule = !0;
        var r = n(9),
            a = o(r),
            l = n(5),
            s = o(l),
            u = function() {
                function e() {
                    i(this, e), this.backgroundElement = document.createElement("div"), s["default"].extend(this.backgroundElement.style, {
                        backgroundColor: "rgba(0,0,0,0.8)",
                        top: 0,
                        left: 0,
                        display: "none",
                        zIndex: "1000",
                        opacity: 0,
                        WebkitTransition: "opacity 0.2s linear",
                        transition: "opacity 0.2s linear"
                    }), a["default"].makeFullscreen(this.backgroundElement), this.backgroundElement.style.position = "fixed", this.domElement = document.createElement("div"), s["default"].extend(this.domElement.style, {
                        position: "fixed",
                        display: "none",
                        zIndex: "1001",
                        opacity: 0,
                        WebkitTransition: "-webkit-transform 0.2s ease-out, opacity 0.2s linear",
                        transition: "transform 0.2s ease-out, opacity 0.2s linear"
                    }), document.body.appendChild(this.backgroundElement), document.body.appendChild(this.domElement);
                    var t = this;
                    a["default"].bind(this.backgroundElement, "click", function() {
                        t.hide()
                    })
                }
                return e.prototype.show = function() {
                    var e = this;
                    this.backgroundElement.style.display = "block", this.domElement.style.display = "block", this.domElement.style.opacity = 0, this.domElement.style.webkitTransform = "scale(1.1)", this.layout(), s["default"].defer(function() {
                        e.backgroundElement.style.opacity = 1, e.domElement.style.opacity = 1, e.domElement.style.webkitTransform = "scale(1)"
                    })
                }, e.prototype.hide = function t() {
                    var e = this,
                        t = function n() {
                            e.domElement.style.display = "none", e.backgroundElement.style.display = "none", a["default"].unbind(e.domElement, "webkitTransitionEnd", n), a["default"].unbind(e.domElement, "transitionend", n), a["default"].unbind(e.domElement, "oTransitionEnd", n)
                        };
                    a["default"].bind(this.domElement, "webkitTransitionEnd", t), a["default"].bind(this.domElement, "transitionend", t), a["default"].bind(this.domElement, "oTransitionEnd", t), this.backgroundElement.style.opacity = 0, this.domElement.style.opacity = 0, this.domElement.style.webkitTransform = "scale(1.1)"
                }, e.prototype.layout = function() {
                    this.domElement.style.left = window.innerWidth / 2 - a["default"].getWidth(this.domElement) / 2 + "px", this.domElement.style.top = window.innerHeight / 2 - a["default"].getHeight(this.domElement) / 2 + "px"
                }, e
            }();
        t["default"] = u
    }, function(e, t, n) {
        t = e.exports = n(24)(), t.push([e.id, ".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1!important}.dg.main .close-button.drag,.dg.main:hover .close-button{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;transition:opacity .1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save&gt;ul{margin-top:27px}.dg.a.has-save&gt;ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height .1s ease-out;transition:height .1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid transparent}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li&gt;*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.boolean,.dg .cr.boolean *,.dg .cr.function,.dg .cr.function *,.dg .cr.function .property-name{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco,monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px Lucida Grande,sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid hsla(0,0%,100%,.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.boolean:hover,.dg .cr.function:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}", ""])
    }, function(e, t) {
        e.exports = function() {
            var e = [];
            return e.toString = function() {
                for (var e = [], t = 0; t &lt; this.length; t++) {
                    var n = this[t];
                    n[2] ? e.push("@media " + n[2] + "{" + n[1] + "}") : e.push(n[1])
                }
                return e.join("")
            }, e.i = function(t, n) {
                "string" == typeof t &amp;&amp; (t = [
                    [null, t, ""]
                ]);
                for (var o = {}, i = 0; i &lt; this.length; i++) {
                    var r = this[i][0];
                    "number" == typeof r &amp;&amp; (o[r] = !0)
                }
                for (i = 0; i &lt; t.length; i++) {
                    var a = t[i];
                    "number" == typeof a[0] &amp;&amp; o[a[0]] || (n &amp;&amp; !a[2] ? a[2] = n : n &amp;&amp; (a[2] = "(" + a[2] + ") and (" + n + ")"), e.push(a))
                }
            }, e
        }
    }])
});

pc.extend(pc, function() {
        var TweenManager = function(t) {
            this._app = t, this._tweens = [], this._add = []
        };
        TweenManager.prototype = {
            add: function(t) {
                return this._add.push(t), t
            },
            update: function(t) {
                for (var i = 0, e = this._tweens.length; i &lt; e;) this._tweens[i].update(t) ? i++ : (this._tweens.splice(i, 1), e--);
                this._add.length &amp;&amp; (this._tweens = this._tweens.concat(this._add), this._add.length = 0)
            }
        };
        var Tween = function(t, i, e) {
            pc.events.attach(this), this.manager = i, e &amp;&amp; (this.entity = null), this.time = 0, this.complete = !1, this.playing = !1, this.stopped = !0, this.pending = !1, this.target = t, this.duration = 0, this._currentDelay = 0, this.timeScale = 1, this._reverse = !1, this._delay = 0, this._yoyo = !1, this._count = 0, this._numRepeats = 0, this._repeatDelay = 0, this._from = !1, this._slerp = !1, this._fromQuat = new pc.Quat, this._toQuat = new pc.Quat, this._quat = new pc.Quat, this.easing = pc.EASE_LINEAR, this._sv = {}, this._ev = {}
        };
        Tween.prototype = {
            to: function(t, i, e, s, n, r) {
                return t instanceof pc.Vec3 ? this._properties = {
                    x: t.x,
                    y: t.y,
                    z: t.z
                } : t instanceof pc.Color ? (this._properties = {
                    r: t.r,
                    g: t.g,
                    b: t.b
                }, void 0 !== t.a &amp;&amp; (this._properties.a = t.a)) : this._properties = t, this.duration = i, e &amp;&amp; (this.easing = e), s &amp;&amp; this.delay(s), n &amp;&amp; this.repeat(n), r &amp;&amp; this.yoyo(r), this
            },
            from: function(t, i, e, s, n, r) {
                return t instanceof pc.Vec3 ? this._properties = {
                    x: t.x,
                    y: t.y,
                    z: t.z
                } : t instanceof pc.Color ? (this._properties = {
                    r: t.r,
                    g: t.g,
                    b: t.b
                }, void 0 !== t.a &amp;&amp; (this._properties.a = t.a)) : this._properties = t, this.duration = i, e &amp;&amp; (this.easing = e), s &amp;&amp; this.delay(s), n &amp;&amp; this.repeat(n), r &amp;&amp; this.yoyo(r), this._from = !0, this
            },
            rotate: function(t, i, e, s, n, r) {
                return t instanceof pc.Quat ? this._properties = {
                    x: t.x,
                    y: t.y,
                    z: t.z,
                    w: t.w
                } : t instanceof pc.Vec3 ? this._properties = {
                    x: t.x,
                    y: t.y,
                    z: t.z
                } : t instanceof pc.Color ? (this._properties = {
                    r: t.r,
                    g: t.g,
                    b: t.b
                }, void 0 !== t.a &amp;&amp; (this._properties.a = t.a)) : this._properties = t, this.duration = i, e &amp;&amp; (this.easing = e), s &amp;&amp; this.delay(s), n &amp;&amp; this.repeat(n), r &amp;&amp; this.yoyo(r), this._slerp = !0, this
            },
            start: function() {
                if (this.playing = !0, this.complete = !1, this.stopped = !1, this._count = 0, this.pending = this._delay &gt; 0, this._reverse &amp;&amp; !this.pending ? this.time = this.duration : this.time = 0, this._from) {
                    for (var t in this._properties) this._sv[t] = this._properties[t], this._ev[t] = this.target[t];
                    if (this._slerp) {
                        this._toQuat.setFromEulerAngles(this.target.x, this.target.y, this.target.z);
                        var i = void 0 !== this._properties.x ? this._properties.x : this.target.x,
                            e = void 0 !== this._properties.y ? this._properties.y : this.target.y,
                            s = void 0 !== this._properties.z ? this._properties.z : this.target.z;
                        this._fromQuat.setFromEulerAngles(i, e, s)
                    }
                } else {
                    for (var t in this._properties) this._sv[t] = this.target[t], this._ev[t] = this._properties[t];
                    if (this._slerp) {
                        this._fromQuat.set(this.target.x, this.target.y, this.target.z, this.target.w);
                        i = void 0 !== this._properties.x ? this._properties.x : this.target.x, e = void 0 !== this._properties.y ? this._properties.y : this.target.y, s = void 0 !== this._properties.z ? this._properties.z : this.target.z;
                        this._toQuat.setFromEulerAngles(i, e, s)
                    }
                }
                return this._currentDelay = this._delay, this.manager.add(this), this
            },
            pause: function() {
                this.playing = !1
            },
            resume: function() {
                this.playing = !0
            },
            stop: function() {
                this.playing = !1, this.stopped = !0
            },
            delay: function(t) {
                return this._delay = t, this.pending = !0, this
            },
            repeat: function(t, i) {
                return this._count = 0, this._numRepeats = t, this._repeatDelay = i || 0, this
            },
            loop: function(t) {
                return t ? (this._count = 0, this._numRepeats = 1 / 0) : this._numRepeats = 0, this
            },
            yoyo: function(t) {
                return this._yoyo = t, this
            },
            reverse: function() {
                return this._reverse = !this._reverse, this
            },
            chain: function() {
                for (var t = arguments.length; t--;) t &gt; 0 ? arguments[t - 1]._chained = arguments[t] : this._chained = arguments[t];
                return this
            },
            update: function(t) {
                if (this.stopped) return !1;
                if (!this.playing) return !0;
                if (!this._reverse || this.pending ? this.time += t * this.timeScale : this.time -= t * this.timeScale, this.pending) {
                    if (!(this.time &gt; this._currentDelay)) return !0;
                    this._reverse ? this.time = this.duration - (this.time - this._currentDelay) : this.time = this.time - this._currentDelay, this.pending = !1
                }
                var i = 0;
                (!this._reverse &amp;&amp; this.time &gt; this.duration || this._reverse &amp;&amp; this.time &lt; 0) &amp;&amp; (this._count++, this.complete = !0, this.playing = !1, this._reverse ? (i = this.duration - this.time, this.time = 0) : (i = this.time - this.duration, this.time = this.duration));
                var e, s, n = this.time / this.duration,
                    r = this.easing(n);
                for (var h in this._properties) e = this._sv[h], s = this._ev[h], this.target[h] = e + (s - e) * r;
                if (this._slerp &amp;&amp; this._quat.slerp(this._fromQuat, this._toQuat, r), this.entity &amp;&amp; (this.entity._dirtifyLocal(!0), this.element &amp;&amp; this.entity.element &amp;&amp; (this.entity.element[this.element] = this.target), this._slerp &amp;&amp; this.entity.setLocalRotation(this._quat)), this.fire("update", t), this.complete) {
                    var a = this._repeat(i);
                    return a ? this.fire("loop") : (this.fire("complete", i), this._chained &amp;&amp; this._chained.start()), a
                }
                return !0
            },
            _repeat: function(t) {
                if (this._count &lt; this._numRepeats) {
                    if (this._reverse ? this.time = this.duration - t : this.time = t, this.complete = !1, this.playing = !0, this._currentDelay = this._repeatDelay, this.pending = !0, this._yoyo) {
                        for (var i in this._properties) tmp = this._sv[i], this._sv[i] = this._ev[i], this._ev[i] = tmp;
                        this._slerp &amp;&amp; (this._quat.copy(this._fromQuat), this._fromQuat.copy(this._toQuat), this._toQuat.copy(this._quat))
                    }
                    return !0
                }
                return !1
            }
        };
        var BounceIn = function(t) {
                return 1 - BounceOut(1 - t)
            },
            BounceOut = function(t) {
                return t &lt; 1 / 2.75 ? 7.5625 * t * t : t &lt; 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t &lt; 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375
            };
        return {
            TweenManager: TweenManager,
            Tween: Tween,
            Linear: function(t) {
                return t
            },
            QuadraticIn: function(t) {
                return t * t
            },
            QuadraticOut: function(t) {
                return t * (2 - t)
            },
            QuadraticInOut: function(t) {
                return (t *= 2) &lt; 1 ? .5 * t * t : -.5 * (--t * (t - 2) - 1)
            },
            CubicIn: function(t) {
                return t * t * t
            },
            CubicOut: function(t) {
                return --t * t * t + 1
            },
            CubicInOut: function(t) {
                return (t *= 2) &lt; 1 ? .5 * t * t * t : .5 * ((t -= 2) * t * t + 2)
            },
            QuarticIn: function(t) {
                return t * t * t * t
            },
            QuarticOut: function(t) {
                return 1 - --t * t * t * t
            },
            QuarticInOut: function(t) {
                return (t *= 2) &lt; 1 ? .5 * t * t * t * t : -.5 * ((t -= 2) * t * t * t - 2)
            },
            QuinticIn: function(t) {
                return t * t * t * t * t
            },
            QuinticOut: function(t) {
                return --t * t * t * t * t + 1
            },
            QuinticInOut: function(t) {
                return (t *= 2) &lt; 1 ? .5 * t * t * t * t * t : .5 * ((t -= 2) * t * t * t * t + 2)
            },
            SineIn: function(t) {
                return 0 === t ? 0 : 1 === t ? 1 : 1 - Math.cos(t * Math.PI / 2)
            },
            SineOut: function(t) {
                return 0 === t ? 0 : 1 === t ? 1 : Math.sin(t * Math.PI / 2)
            },
            SineInOut: function(t) {
                return 0 === t ? 0 : 1 === t ? 1 : .5 * (1 - Math.cos(Math.PI * t))
            },
            ExponentialIn: function(t) {
                return 0 === t ? 0 : Math.pow(1024, t - 1)
            },
            ExponentialOut: function(t) {
                return 1 === t ? 1 : 1 - Math.pow(2, -10 * t)
            },
            ExponentialInOut: function(t) {
                return 0 === t ? 0 : 1 === t ? 1 : (t *= 2) &lt; 1 ? .5 * Math.pow(1024, t - 1) : .5 * (2 - Math.pow(2, -10 * (t - 1)))
            },
            CircularIn: function(t) {
                return 1 - Math.sqrt(1 - t * t)
            },
            CircularOut: function(t) {
                return Math.sqrt(1 - --t * t)
            },
            CircularInOut: function(t) {
                return (t *= 2) &lt; 1 ? -.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1)
            },
            BackIn: function(t) {
                var i = 1.70158;
                return t * t * ((i + 1) * t - i)
            },
            BackOut: function(t) {
                var i = 1.70158;
                return --t * t * ((i + 1) * t + i) + 1
            },
            BackInOut: function(t) {
                var i = 2.5949095;
                return (t *= 2) &lt; 1 ? t * t * ((i + 1) * t - i) * .5 : .5 * ((t -= 2) * t * ((i + 1) * t + i) + 2)
            },
            BounceIn: BounceIn,
            BounceOut: BounceOut,
            BounceInOut: function(t) {
                return t &lt; .5 ? .5 * BounceIn(2 * t) : .5 * BounceOut(2 * t - 1) + .5
            },
            ElasticIn: function(t) {
                var i, e = .1;
                return 0 === t ? 0 : 1 === t ? 1 : (!e || e &lt; 1 ? (e = 1, i = .1) : i = .4 * Math.asin(1 / e) / (2 * Math.PI), -e * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - i) * (2 * Math.PI) / .4))
            },
            ElasticOut: function(t) {
                var i, e = .1;
                return 0 === t ? 0 : 1 === t ? 1 : (!e || e &lt; 1 ? (e = 1, i = .1) : i = .4 * Math.asin(1 / e) / (2 * Math.PI), e * Math.pow(2, -10 * t) * Math.sin((t - i) * (2 * Math.PI) / .4) + 1)
            },
            ElasticInOut: function(t) {
                var i, e = .1,
                    s = .4;
                return 0 === t ? 0 : 1 === t ? 1 : (!e || e &lt; 1 ? (e = 1, i = .1) : i = s * Math.asin(1 / e) / (2 * Math.PI), (t *= 2) &lt; 1 ? e * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - i) * (2 * Math.PI) / s) * -.5 : e * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - i) * (2 * Math.PI) / s) * .5 + 1)
            },
            Bounce: function(t) {
                return t &lt; .5 ? -(4 * t - 1) * (4 * t - 1) + 1 : .5 * (-(4 * t - 3) * (4 * t - 3) + 1)
            }
        }
    }()),
    function() {
        var t = pc.Application.getApplication();
        t &amp;&amp; (t._tweenManager = new pc.TweenManager(t), t.on("update", (function(i) {
            t._tweenManager.update(i)
        })), pc.Application.prototype.tween = function(t) {
            return new pc.Tween(t, this._tweenManager)
        }, pc.Entity.prototype.tween = function(t, i) {
            var e = this._app.tween(t);
            return e.entity = this, this.on("destroy", (function() {
                e.stop()
            })), i &amp;&amp; i.element &amp;&amp; (e.element = element), e
        })
    }();
var DynamicElement = pc.createScript("dynamicElement"),
    ElementPreset = Object.freeze([{
        NONE: "NONE"
    }, {
        TOPLEFT: "TOPLEFT"
    }, {
        TOPLEFT_ANCHOR: "TOPLEFT_ANCHOR"
    }, {
        TOP: "TOP"
    }, {
        TOP_ANCHOR: "TOP_ANCHOR"
    }, {
        TOPRIGHT: "TOPRIGHT"
    }, {
        TOPRIGHT_ANCHOR: "TOPRIGHT_ANCHOR"
    }, {
        LEFT: "LEFT"
    }, {
        LEFT_ANCHOR: "LEFT_ANCHOR"
    }, {
        CENTER: "CENTER"
    }, {
        CENTER_ANCHOR: "CENTER_ANCHOR"
    }, {
        RIGHT: "RIGHT"
    }, {
        RIGHT_ANCHOR: "RIGHT_ANCHOR"
    }, {
        BOTTOMLEFT: "BOTTOMLEFT"
    }, {
        BOTTOMLEFT_ANCHOR: "BOTTOMLEFT_ANCHOR"
    }, {
        BOTTOM: "BOTTOM"
    }, {
        BOTTOM_ANCHOR: "BOTTOM_ANCHOR"
    }, {
        BOTTOMRIGHT: "BOTTOMRIGHT"
    }, {
        BOTTOMRIGHT_ANCHOR: "BOTTOMRIGHT_ANCHOR"
    }]),
    defaultString = "------------------------------------------------------";
DynamicElement.attributes.add("a", {
    type: "string",
    title: "Desktop Landscape",
    default: defaultString
}), DynamicElement.attributes.add("desktopLandscapePreset", {
    type: "string",
    enum: ElementPreset,
    title: "Preset",
    default: "NONE"
}), DynamicElement.attributes.add("desktopLandscapeAnchor", {
    type: "vec4",
    title: "Anchor"
}), DynamicElement.attributes.add("desktopLandscapePivot", {
    type: "vec2",
    title: "Pivot"
}), DynamicElement.attributes.add("desktopLandscapePosition", {
    type: "vec3",
    title: "Position"
}), DynamicElement.attributes.add("desktopLandscapeRotation", {
    type: "vec3",
    title: "Rotation"
}), DynamicElement.attributes.add("desktopLandscapeScale", {
    type: "vec3",
    title: "Scale",
    default: [1, 1, 1]
}), DynamicElement.attributes.add("b", {
    type: "string",
    title: "Desktop Portrait",
    default: defaultString
}), DynamicElement.attributes.add("desktopPortraitPreset", {
    type: "string",
    enum: ElementPreset,
    title: "Preset",
    default: "NONE"
}), DynamicElement.attributes.add("desktopPortraitAnchor", {
    type: "vec4",
    title: "Anchor"
}), DynamicElement.attributes.add("desktopPortraitPivot", {
    type: "vec2",
    title: "Pivot"
}), DynamicElement.attributes.add("desktopPortraitPosition", {
    type: "vec3",
    title: "Position"
}), DynamicElement.attributes.add("desktopPortraitRotation", {
    type: "vec3",
    title: "Rotation"
}), DynamicElement.attributes.add("desktopPortraitScale", {
    type: "vec3",
    title: "Scale",
    default: [1, 1, 1]
}), DynamicElement.attributes.add("c", {
    type: "string",
    title: "Mobile Landscape",
    default: defaultString
}), DynamicElement.attributes.add("mobileLandscapePreset", {
    type: "string",
    enum: ElementPreset,
    title: "Preset",
    default: "NONE"
}), DynamicElement.attributes.add("mobileLandscapeAnchor", {
    type: "vec4",
    title: "Anchor"
}), DynamicElement.attributes.add("mobileLandscapePivot", {
    type: "vec2",
    title: "Pivot"
}), DynamicElement.attributes.add("mobileLandscapePosition", {
    type: "vec3",
    title: "Position"
}), DynamicElement.attributes.add("mobileLandscapeRotation", {
    type: "vec3",
    title: "Rotation"
}), DynamicElement.attributes.add("mobileLandscapeScale", {
    type: "vec3",
    title: "Scale",
    default: [1.5, 1.5, 1.5]
}), DynamicElement.attributes.add("d", {
    type: "string",
    title: "Mobile Portrait",
    default: defaultString
}), DynamicElement.attributes.add("mobilePortraitPreset", {
    type: "string",
    enum: ElementPreset,
    title: "Preset",
    default: "NONE"
}), DynamicElement.attributes.add("mobilePortraitAnchor", {
    type: "vec4",
    title: "Anchor"
}), DynamicElement.attributes.add("mobilePortraitPivot", {
    type: "vec2",
    title: "Pivot"
}), DynamicElement.attributes.add("mobilePortraitPosition", {
    type: "vec3",
    title: "Position"
}), DynamicElement.attributes.add("mobilePortraitRotation", {
    type: "vec3",
    title: "Rotation"
}), DynamicElement.attributes.add("mobilePortraitScale", {
    type: "vec3",
    title: "Scale",
    default: [1, 1, 1]
}), DynamicElement.attributes.add("updatePosition", {
    type: "boolean",
    default: !0,
    title: "Update Position"
}), DynamicElement.attributes.add("updateRotation", {
    type: "boolean",
    default: !0,
    title: "Update Rotation"
}), DynamicElement.attributes.add("updateScale", {
    type: "boolean",
    default: !0,
    title: "Update Scale"
}), DynamicElement.attributes.add("debug", {
    type: "boolean",
    default: !1,
    title: "Debug"
}), pc.extend(DynamicElement.prototype, {
    initialize: function() {
        this._orientation = "", this._device = "", this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _setCurrentProperties: function(t, e) {
        this._orientation = t, this._device = e
    },
    _onResize: function(t, e, i, n) {
        this._setCorrectOrientation(t || "landscape", n)
    },
    _setCorrectOrientation: function(t, e) {
        if (this._orientation !== t || this._device !== e) return this._setCurrentProperties(t, e), e === deviceEnum.DESKTOP ? this._orientation === orientationEnum.LANDSCAPE ? void this._applyOrientationTransform(this.desktopLandscapePreset, this.desktopLandscapePosition, this.desktopLandscapeRotation, this.desktopLandscapeScale, this.desktopLandscapeAnchor, this.desktopLandscapePivot) : this._orientation === orientationEnum.PORTRAIT ? void this._applyOrientationTransform(this.desktopPortraitPreset, this.desktopPortraitPosition, this.desktopPortraitRotation, this.desktopPortraitScale, this.desktopPortraitAnchor, this.desktopPortraitPivot) : void console.warn("Orientation", this._orientation, "is not recognized!") : e === deviceEnum.MOBILE ? this._orientation === orientationEnum.LANDSCAPE ? void this._applyOrientationTransform(this.mobileLandscapePreset, this.mobileLandscapePosition, this.mobileLandscapeRotation, this.mobileLandscapeScale, this.mobileLandscapeAnchor, this.mobileLandscapePivot) : this._orientation === orientationEnum.PORTRAIT ? void this._applyOrientationTransform(this.mobilePortraitPreset, this.mobilePortraitPosition, this.mobilePortraitRotation, this.mobilePortraitScale, this.mobilePortraitAnchor, this.mobilePortraitPivot) : void console.warn("Orientation", this._orientation, "is not recognized!") : void console.warn("Device", e, "is not recognized!")
    },
    _applyOrientationTransform: function(t, e, i, n, a, o) {
        if ("string" == typeof t) {
            var s = ElementPresetEnum[t];
            s ? void 0 !== this.entity.element &amp;&amp; (s.anchor ? this.entity.element.anchor.set(s.anchor.x, s.anchor.y, s.anchor.z, s.anchor.w) : this.entity.element.anchor.set(a.x, a.y, a.z, a.w), s.pivot ? this.entity.element.pivot.set(s.pivot.x, s.pivot.y) : this.entity.element.pivot.set(o.x, o.y), this.debug &amp;&amp; console.log(this.entity.element.anchor, this.entity.element.pivot), this.entity.element.anchor = this.entity.element.anchor, this.entity.element.pivot = this.entity.element.pivot, this.updatePosition &amp;&amp; this.entity.setLocalPosition(e), this.updateRotation &amp;&amp; this.entity.setLocalEulerAngles(i), this.updateScale &amp;&amp; this.entity.setLocalScale(n)) : console.error("Something went wrong", t, s)
        } else console.error("Preset should be a string", t)
    }
});
var DebugGui = pc.createScript("debugGui");
DebugGui.attributes.add("name", {
    type: "string",
    default: "NAME"
}), DebugGui.attributes.add("closed", {
    type: "boolean",
    default: !1
}), DebugGui.attributes.add("gameManager", {
    type: "entity"
}), pc.extend(DebugGui.prototype, {
    postInitialize: function() {
        var e = new dat.GUI({
            name: this.name,
            closed: this.closed
        });
        e.addFolder("Gems");
        e.add(pc.deck, "maxColors").onChange(function(e) {
            this.reloadLevel()
        }.bind(this)), e.add(pc.gridManager, "rows").onChange(function(e) {
            this.reloadLevel()
        }.bind(this)), e.add(pc.gridManager, "columns").onChange(function(e) {
            this.reloadLevel()
        }.bind(this))
    },
    setChecked: function(e) {
        for (var a in this._parameters) this.gameManager.script.gameManager[a] = !1;
        this.gameManager.script.gameManager[e] = !0
    },
    reloadLevel: function() {
        pc.gridManager.despawnAll(), pc.gridManager.spawnLevel()
    }
});
var NotificationBadge = pc.createScript("notificationBadge");
NotificationBadge.attributes.add("id", {
    type: "string",
    default: "TEMPLATE_ID",
    description: "This is an unique id, which is used to get the correct notification badge."
}), NotificationBadge.attributes.add("textEntity", {
    type: "entity",
    description: "Optional: A text entity in the notification badge that needs to be changed."
}), NotificationBadge.attributes.add("tween", {
    type: "string",
    enum: [{
        None: "null"
    }, {
        "Tween Scale": "tweenScale"
    }, {
        "Tween Position": "tweenPosition"
    }, {
        "Tween Rotation": "tweenRotation"
    }, {
        "Tween Alpha": "tweenAlpha"
    }]
}), NotificationBadge.attributes.add("disableOnClick", {
    type: "boolean",
    default: !1,
    description: 'If true, this notification badge will be disabled automatically when clicked on the button. It can also be disabled with the function "disable"'
}), NotificationBadge.attributes.add("buttonEntity", {
    type: "entity"
}), pc.extend(NotificationBadge.prototype, {
    initialize: function() {
        NotificationBadgeManager.instance.initializeBadge(this.entity, this.id), this._setDisableEvent()
    },
    postInitialize: function() {
        this.setState()
    },
    _setDisableEvent: function() {
        this.disableOnClick &amp;&amp; (this.buttonEntity ? this.buttonEntity.script &amp;&amp; this.buttonEntity.script.switchUibutton ? this.buttonEntity.script.switchUibutton.on("click", this.disable, this) : this.buttonEntity.element.on("click", this.disable, this) : this.entity.parent.element ? this.entity.parent.element.on("click", this.disable, this) : console.warn("No viable button could be found."))
    },
    setState: function(t) {
        t || (t = NotificationBadgeManager.instance.getBadgeProperties(this.id)), t ? (this.entity.enabled = t.enabled, this.entity.enabled ? this._startTween() : this._stopTween(), this.textEntity &amp;&amp; this.textEntity.element &amp;&amp; (this.textEntity.element.text = t.text)) : console.warn("No properties are found with the id", this.id)
    },
    _startTween: function() {
        this.tween &amp;&amp; "null" !== this.tween &amp;&amp; (this.entity.script[this.tween] ? this.entity.script[this.tween].startTween() : console.warn(this.entity.name, "doesn't have the script", this.tween))
    },
    _stopTween: function() {},
    disable: function() {
        this.entity.enabled = !1, NotificationBadgeManager.instance.setBadgeProperties(this.id, !1)
    }
});
var NotificationBadgeManager = pc.createScript("notificationBadgeManager");
pc.extend(NotificationBadgeManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (NotificationBadgeManager.instance = this), this._badgeStates = Object.freeze({
            DISABLED: !1,
            ENABLED: !0
        }), this._notificationBadges = {}, this.app.on("NotificationBadgeManager:set", this.setBadgeProperties, this)
    },
    initializeBadge: function(t, i) {
        this._notificationBadges[i] || "TEMPLATE_ID" === i ? console.warn("Change the id of the notification badge with the id", i) : this._notificationBadges[i] = {
            enabled: this._badgeStates.DISABLED,
            text: null,
            entity: t
        }
    },
    setBadgeProperties: function(t, i, e) {
        var a = this._notificationBadges[t];
        a ? (a.enabled = i, e &amp;&amp; (a.text = e), a.entity.script.notificationBadge.setState(a)) : console.log("No properties are found with the id", t, "That entity could be disabled from the beginning")
    },
    getBadgeProperties: function(t) {
        return this._notificationBadges[t]
    }
});
var ContinuousCollisionDetection = pc.createScript("continuousCollisionDetection");
ContinuousCollisionDetection.attributes.add("motionThreshold", {
    type: "number",
    default: 1,
    title: "Motion Threshold",
    description: "Number of meters moved in one frame before CCD is enabled"
}), ContinuousCollisionDetection.attributes.add("sweptSphereRadius", {
    type: "number",
    default: .2,
    title: "Swept Sphere Radius",
    description: "This should be below the half extent of the collision volume. E.g For an object of dimensions 1 meter, try 0.2"
}), pc.extend(ContinuousCollisionDetection.prototype, {
    initialize: function() {
        var t;
        (t = this.entity.rigidbody.body).setCcdMotionThreshold(this.motionThreshold), t.setCcdSweptSphereRadius(this.sweptSphereRadius), this.on("attr:motionThreshold", (function(e, o) {
            (t = this.entity.rigidbody.body).setCcdMotionThreshold(e)
        })), this.on("attr:sweptSphereRadius", (function(e, o) {
            (t = this.entity.rigidbody.body).setCcdSweptSphereRadius(e)
        }))
    }
});
var PhysicsLayer = pc.createScript("physicsLayer");
PhysicsLayer.attributes.add("groupA", {
    type: "boolean",
    default: !1,
    title: "Group A"
}), PhysicsLayer.attributes.add("groupB", {
    type: "boolean",
    default: !1,
    title: "Group B"
}), PhysicsLayer.attributes.add("groupC", {
    type: "boolean",
    default: !1,
    title: "Group C"
}), PhysicsLayer.attributes.add("groupD", {
    type: "boolean",
    default: !1,
    title: "Group D"
}), PhysicsLayer.attributes.add("maskAll", {
    type: "boolean",
    default: !0,
    title: "Mask All"
}), PhysicsLayer.attributes.add("maskA", {
    type: "boolean",
    default: !1,
    title: "Mask A"
}), PhysicsLayer.attributes.add("maskB", {
    type: "boolean",
    default: !1,
    title: "Mask B"
}), PhysicsLayer.attributes.add("maskC", {
    type: "boolean",
    default: !1,
    title: "Mask C"
}), PhysicsLayer.attributes.add("maskD", {
    type: "boolean",
    default: !1,
    title: "Mask D"
}), pc.extend(PhysicsLayer.prototype, {
    initialize: function() {
        var t = this.entity.rigidbody;
        this.groupA &amp;&amp; (t.group |= pc.BODYGROUP_USER_1), this.groupB &amp;&amp; (t.group |= pc.BODYGROUP_USER_2), this.groupC &amp;&amp; (t.group |= pc.BODYGROUP_USER_3), this.groupD &amp;&amp; (t.group |= pc.BODYGROUP_USER_4), t.mask = pc.BODYGROUP_TRIGGER, this.maskAll &amp;&amp; (t.mask |= pc.BODYMASK_ALL), this.maskA &amp;&amp; (t.mask |= pc.BODYGROUP_USER_1), this.maskB &amp;&amp; (t.mask |= pc.BODYGROUP_USER_2), this.maskC &amp;&amp; (t.mask |= pc.BODYGROUP_USER_3), this.maskD &amp;&amp; (t.mask |= pc.BODYGROUP_USER_4), this.defaultGroup = t.group, this.defaultMask = t.mask
    },
    setMask: function(t) {
        var a = this.entity.rigidbody;
        switch (a.group = 1, a.mask = pc.BODYGROUP_TRIGGER, t) {
            case "A":
                a.group |= pc.BODYGROUP_USER_1, a.mask |= pc.BODYGROUP_USER_1;
                break;
            case "B":
                a.group |= pc.BODYGROUP_USER_1, a.mask |= pc.BODYGROUP_USER_1, a.group |= pc.BODYGROUP_USER_2, a.mask |= pc.BODYGROUP_USER_2;
                break;
            case "C":
                a.group |= pc.BODYGROUP_USER_1, a.mask |= pc.BODYGROUP_USER_1, a.group |= pc.BODYGROUP_USER_3, a.mask |= pc.BODYGROUP_USER_3, a.group |= pc.BODYGROUP_USER_4, a.mask |= pc.BODYGROUP_USER_4;
                break;
            case "D":
                a.group |= pc.BODYGROUP_USER_1, a.mask |= pc.BODYGROUP_USER_1, a.group |= pc.BODYGROUP_USER_4, a.mask |= pc.BODYGROUP_USER_4;
                break;
            default:
                console.log("Letter not recognized")
        }
    },
    reset: function() {
        this.entity.rigidbody.group = this.defaultGroup, this.entity.rigidbody.mask = this.defaultMask
    }
});
var PauseScreen = pc.createScript("pauseScreen");
pc.extend(PauseScreen.prototype, {
    initialize: function() {},
    onUIEntityOpen: function() {
        this.app.timeScale = 0, PlayerData.instance.inputBetweenGames = !1
    },
    onUIEntityClose: function() {
        this.app.timeScale = 1, PlayerData.instance.inputBetweenGames = !0
    }
});
var ViewportManager = pc.createScript("viewportManager");
ViewportManager.attributes.add("delay", {
    type: "number",
    default: 0,
    title: "Delay",
    description: "Time till the dimension of the viewport is recalculated.",
    placeholder: "ms"
}), ViewportManager.attributes.add("delayIOS", {
    type: "number",
    default: 300,
    title: "Delay IOS",
    description: "Time till the dimension of the viewport is recalculated.",
    placeholder: "ms"
}), pc.extend(ViewportManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (ViewportManager.instance = this), Wrapper.instance.setOnOrientationChange(this.onOrientationChange, this)
    },
    onOrientationChange: function() {
        clearTimeout(this._timeout), this.app.fire("ViewportManager:preResize"), this._timeout = setTimeout(this._onResize.bind(this), pc.platform.ios ? this.delayIOS : this.delay)
    },
    _onResize: function() {
        this.app.resizeCanvas(innerWidth, innerHeight), this.app.fire("ViewportManager:onResize", Wrapper.instance.getOrientation(), innerWidth, innerHeight, this.getDevice())
    },
    getDevice: function() {
        return pc.platform.desktop ? deviceEnum.DESKTOP : pc.platform.mobile ? deviceEnum.MOBILE : ""
    },
    getOrientation: function() {
        return Wrapper.instance.getOrientation()
    }
});
var deviceEnum = Object.freeze({
        DESKTOP: "desktop",
        MOBILE: "mobile"
    }),
    orientationEnum = Object.freeze({
        LANDSCAPE: "landscape",
        PORTRAIT: "portrait"
    }),
    ElementPresetEnum = Object.freeze({
        TOPLEFT: {
            anchor: new pc.Vec4(0, 1, 0, 1),
            pivot: new pc.Vec2(0, 1)
        },
        TOPLEFT_ANCHOR: {
            anchor: new pc.Vec4(0, 1, 0, 1)
        },
        TOP: {
            anchor: new pc.Vec4(.5, 1, .5, 1),
            pivot: new pc.Vec2(.5, 1)
        },
        TOP_ANCHOR: {
            anchor: new pc.Vec4(.5, 1, .5, 1)
        },
        TOPRIGHT: {
            anchor: new pc.Vec4(1, 1, 1, 1),
            pivot: new pc.Vec2(1, 1)
        },
        TOPRIGHT_ANCHOR: {
            anchor: new pc.Vec4(1, 1, 1, 1)
        },
        LEFT: {
            anchor: new pc.Vec4(0, .5, 0, .5),
            pivot: new pc.Vec2(0, .5)
        },
        LEFT_ANCHOR: {
            anchor: new pc.Vec4(0, .5, 0, .5)
        },
        CENTER: {
            anchor: new pc.Vec4(.5, .5, .5, .5),
            pivot: new pc.Vec2(.5, .5)
        },
        CENTER_ANCHOR: {
            anchor: new pc.Vec4(.5, .5, .5, .5)
        },
        RIGHT: {
            anchor: new pc.Vec4(1, .5, 1, .5),
            pivot: new pc.Vec2(1, .5)
        },
        RIGHT_ANCHOR: {
            anchor: new pc.Vec4(1, .5, 1, .5)
        },
        BOTTOMLEFT: {
            anchor: new pc.Vec4(0, 0, 0, 0),
            pivot: new pc.Vec2(0, 0)
        },
        BOTTOMLEFT_ANCHOR: {
            anchor: new pc.Vec4(0, 0, 0, 0)
        },
        BOTTOM: {
            anchor: new pc.Vec4(.5, 0, .5, 0),
            pivot: new pc.Vec2(.5, 0)
        },
        BOTTOM_ANCHOR: {
            anchor: new pc.Vec4(.5, 0, .5, 0)
        },
        BOTTOMRIGHT: {
            anchor: new pc.Vec4(1, 0, 1, 0),
            pivot: new pc.Vec2(1, 0)
        },
        BOTTOMRIGHT_ANCHOR: {
            anchor: new pc.Vec4(1, 0, 1, 0)
        },
        NONE: {}
    }),
    LayoutOrientationEnum = Object.freeze({
        VERTICAL: pc.ORIENTATION_VERTICAL,
        HORIZONTAL: pc.ORIENTATION_HORIZONTAL
    });
var DynamicGroup = pc.createScript("dynamicGroup");
DynamicGroup.attributes.add("desktopClamp", {
    type: "boolean",
    default: !0
}), DynamicGroup.attributes.add("desktopClampWidth", {
    type: "number",
    default: 1500
}), DynamicGroup.attributes.add("mobileClamp", {
    type: "boolean",
    default: !1
}), DynamicGroup.attributes.add("mobileClampWidth", {
    type: "number",
    default: 0
}), pc.extend(DynamicGroup.prototype, {
    initialize: function() {
        this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _onResize: function(e, t, i, n) {
        this._calculateDimensions(t, i), this._setClamp(n)
    },
    _calculateDimensions: function(e, t) {
        var i = UIManager.instance.getReferenceResolution().y / t;
        this.entity.element &amp;&amp; (this.entity.element.width = e * i, this.entity.element.height = t * i)
    },
    _setClamp: function(e) {
        var t = !1,
            i = 0;
        (e === deviceEnum.DESKTOP &amp;&amp; (t = this.desktopClamp, i = this.desktopClampWidth), e === deviceEnum.MOBILE &amp;&amp; (t = this.mobileClamp, i = this.mobileClampWidth), t) &amp;&amp; (this.entity.element.width &gt; i &amp;&amp; (this.entity.element.width = i));
        this.fire("onChange")
    }
});
var InputManager = pc.createScript("inputManager");
InputManager.attributes.add("disableContextMenu", {
    type: "boolean",
    default: !0,
    description: "Disable the context menu usually activated with right-click.",
    title: "Disable Context Menu"
}), InputManager.attributes.add("preventDefault", {
    type: "boolean",
    default: !0,
    title: "Prevent Default"
}), InputManager.attributes.add("disablePreventDefaultForKeyboardCodes", {
    type: "string",
    array: !0,
    default: ["F12", "F5"]
}), pc.extend(InputManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (InputManager.instance = this), this._supportTouch = pc.platform.touch, this._supportMouse = !0, this._hasFocus = document.hasFocus(), window.addEventListener("focus", this._onFocus.bind(this)), window.addEventListener("blur", this._onBlur.bind(this)), this._supportTouch &amp;&amp; this.disableContextMenu &amp;&amp; this.app.mouse.disableContextMenu(), this.app.mouse &amp;&amp; (this.app.mouse.on(pc.EVENT_MOUSEDOWN, this._onInput, this), this.app.mouse.on(pc.EVENT_MOUSEUP, this._onInput, this), this.app.mouse.on(pc.EVENT_MOUSEWHEEL, this._onInput, this)), this.app.keyboard &amp;&amp; (this.app.keyboard.on(pc.EVENT_KEYDOWN, this._onKeyInput, this), this.app.keyboard.on(pc.EVENT_KEYUP, this._onKeyInput, this)), this.app.touch &amp;&amp; (this.app.touch.on(pc.EVENT_TOUCHCANCEL, this._onInput, this), this.app.touch.on(pc.EVENT_TOUCHEND, this._onInput, this), this.app.touch.on(pc.EVENT_TOUCHMOVE, this._onInput, this), this.app.touch.on(pc.EVENT_TOUCHSTART, this._onInput, this))
    },
    _onFocus: function() {
        this._hasFocus = !0
    },
    _onBlur: function() {
        this._hasFocus = !1
    },
    _sendInputEvent: function(t) {
        this.app.fire("InputManager:input", t)
    },
    _onInput: function(t) {
        this.doPreventDefault(t), this._sendInputEvent(t)
    },
    _onKeyInput: function(t) {
        this.keyboardPreventDefault(t), this._sendInputEvent(t)
    },
    getSupportTouch: function() {
        return this._supportTouch
    },
    getSupportMouse: function() {
        return this._supportMouse
    },
    keyboardPreventDefault: function(t) {
        -1 === this.disablePreventDefaultForKeyboardCodes.indexOf(t.event.code) &amp;&amp; this.doPreventDefault(t)
    },
    doPreventDefault: function(t) {
        t ? this.preventDefault &amp;&amp; this._hasFocus &amp;&amp; t.event.preventDefault() : console.warn("Event is undefined")
    }
});
var ElementInput = pc.createScript("elementInput");
ElementInput.attributes.add("inputDownEvent", {
    type: "boolean",
    default: !1,
    title: "Input Down Event",
    description: "Send a input down event"
}), ElementInput.attributes.add("inputUpEvent", {
    type: "boolean",
    default: !1,
    title: "Input Up Event",
    description: "Send a input up event"
}), ElementInput.attributes.add("inputClickEvent", {
    type: "boolean",
    default: !0,
    title: "Input Click Event",
    description: "Send a input click event"
}), ElementInput.attributes.add("inputMoveEvent", {
    type: "boolean",
    default: !1,
    title: "Input Move Event",
    description: "Send a input move event"
}), ElementInput.attributes.add("clickSFX", {
    type: "string",
    default: "button_click.mp3"
});
var inputEvents = Object.freeze({
    DOWN: "down",
    UP: "up",
    CLICK: "click",
    MOVE: "move"
});
pc.extend(ElementInput.prototype, {
    initialize: function() {
        GameInput.instance = this, this._touch = InputManager.instance.getSupportTouch(), this._mouse = InputManager.instance.getSupportMouse(), this._element = this.entity.element, this._button = this.entity.button, this._enter = !1, this._inputDown = !1, this._createButtonEvents(), this._createElementEvents()
    },
    _createButtonEvents: function() {
        this.on("enable", this._resetButton, this)
    },
    _resetButton: function() {
        this._button &amp;&amp; (this._button._isHovering = !1)
    },
    _createElementEvents: function() {
        this._element ? (this._element.useInput || console.warn("This entity with the name", this.entity.name, "has input disabled! Please turn it on."), this._touch &amp;&amp; (this._element.on(pc.EVENT_TOUCHSTART, this._onTouchStart, this), this._element.on(pc.EVENT_TOUCHMOVE, this._onTouchMove, this), this._element.on("touchleave", this._onTouchLeave, this), this._element.on(pc.EVENT_TOUCHEND, this._onTouchEnd, this)), this._mouse &amp;&amp; (this._element.on(pc.EVENT_MOUSEDOWN, this._onMouseDown, this), this._element.on(pc.EVENT_MOUSEMOVE, this._onMouseMove, this), this._element.on("mouseleave", this._onMouseLeave, this), this._element.on("mouseenter", this._onMouseEnter, this), this._element.on(pc.EVENT_MOUSEUP, this._onMouseUp, this))) : console.warn("This entity with the name", this.entity.name, "has no element component!")
    },
    _onTouchStart: function(t) {
        this.getButtonActive() &amp;&amp; (this._inputDown = !0, this._enter = !0, this._sendDownEvent(t), this.fire("onButtonInputChange", this._inputDown, this._enter, this.getButtonActive()))
    },
    _onTouchEnd: function(t) {
        this.getButtonActive() &amp;&amp; (this._sendUpEvent(t), this._enter &amp;&amp; this._inputDown &amp;&amp; this._sendClickEvent(t), this._enter = !1, this._inputDown = !1, this.fire("onButtonInputChange", this._inputDown, this._enter, this.getButtonActive()))
    },
    _onTouchLeave: function(t) {
        this.getButtonActive() &amp;&amp; (this._enter = !1, this._inputDown = !1, this.fire("onButtonInputChange", this._inputDown, this._enter, this.getButtonActive()))
    },
    _onTouchMove: function() {
        this.getButtonActive() &amp;&amp; this._enter &amp;&amp; this._sendMoveEvent(event)
    },
    _onMouseDown: function(t) {
        this.getButtonActive() &amp;&amp; (this._inputDown = !0, this._enter = !0, this._sendDownEvent(t), this.fire("onButtonInputChange", this._inputDown, this._enter, this.getButtonActive()))
    },
    _onMouseLeave: function(t) {
        this.getButtonActive() &amp;&amp; (this._enter = !1, this._inputDown = !1, this.fire("onButtonInputChange", this._inputDown, this._enter, this.getButtonActive()))
    },
    _onMouseEnter: function(t) {
        this.getButtonActive() &amp;&amp; (this._enter = !0, this.fire("onButtonInputChange", this._inputDown, this._enter, this.getButtonActive()))
    },
    _onMouseMove: function(t) {
        this.getButtonActive() &amp;&amp; this._inputDown &amp;&amp; this._enter &amp;&amp; this._sendMoveEvent(t)
    },
    _onMouseUp: function(t) {
        this.getButtonActive() &amp;&amp; (this._sendUpEvent(t), this._enter &amp;&amp; this._inputDown &amp;&amp; this._sendClickEvent(t), this._enter = !1, this._inputDown = !1, this.fire("onButtonInputChange", this._inputDown, this._enter, this.getButtonActive()))
    },
    _sendMoveEvent: function(t) {
        this.inputMoveEvent &amp;&amp; this.fire(inputEvents.MOVE, t)
    },
    _sendDownEvent: function(t) {
        this.inputDownEvent &amp;&amp; this.fire(inputEvents.DOWN, t)
    },
    _sendUpEvent: function(t) {
        this.inputUpEvent &amp;&amp; this.fire(inputEvents.UP, t)
    },
    _sendClickEvent: function(t) {
        this.inputClickEvent &amp;&amp; (this.clickSFX &amp;&amp; this.app.fire("Audio:sfx", this.clickSFX), this.fire(inputEvents.CLICK, t))
    },
    setActive: function(t) {
        this._button.active = t, this.fire("onButtonInputChange", this._inputDown, this._enter, this.getButtonActive())
    },
    getButtonActive: function() {
        return !this._button || this._button.active
    }
});
var Wrapper = pc.createScript("wrapper");
Wrapper.attributes.add("api", {
    type: "string",
    enum: [{
        DEFAULT: "defaultApi"
    }, {
        FAMOBI: "famobiApi"
    }]
}), pc.extend(Wrapper.prototype, {
    initialize: function() {
        Wrapper.instance = this, this._script = this._getAPIScript(), this.app.on("FamobiAPI:cooldown", this._checkHasRewardedAd, this)
    },
    _getAPIScript: function() {
        if (this.entity.script[this.api]) return this.entity.script[this.api];
        console.warn("There is no api script", this.api)
    },
    getBrandingButtonImage: function() {
        return this._script.getBrandingButtonImage()
    },
    moreGamesLink: function() {
        this._script.moreGamesLink()
    },
    showInterstitialAd: function() {
        return this._script.showInterstitialAd()
    },
    hasRewardedAd: function() {
        return this._script.hasRewardedAd()
    },
    rewardedAd: function(t, e) {
        this._script.rewardedAd(t.bind(e))
    },
    setOnPauseRequested: function(t, e) {
        this._script.setOnPauseRequested(t, e)
    },
    setOnResumeRequested: function(t, e) {
        this._script.setOnResumeRequested(t, e)
    },
    get: function(t) {
        return this._script.get(t)
    },
    getCurrentLanguage: function() {
        return this._script.getCurrentLanguage()
    },
    setLocalStorageItem: function(t, e) {
        this._script.setLocalStorageItem(t, e)
    },
    getLocalStorageItem: function(t) {
        return this._script.getLocalStorageItem(t)
    },
    removeLocalStorageItem: function(t) {
        this._script.removeLocalStorageItem(t)
    },
    clearLocalStorage: function() {
        this._script.clearLocalStorage()
    },
    localStorageHasKey: function() {
        return this._script.localStorageHasKey()
    },
    setSessionStorageItem: function(t, e) {
        this._script.setSessionStorageItem(t, e)
    },
    getSessionStorageItem: function(t) {
        return this._script.getSessionStorageItem(t)
    },
    removeSessionStorageItem: function(t) {
        this._script.removeSessionStorageItem(t)
    },
    clearSessionStorage: function() {
        this._script.clearSessionStorage()
    },
    getOrientation: function() {
        return this._script.getOrientation()
    },
    setOnOrientationChange: function(t, e) {
        this._script.setOnOrientationChange(t.bind(e))
    },
    _checkHasRewardedAd: function() {
        if (!this.hasRewardedAd()) {
            var t = this;
            this._interval = setInterval((function() {
                var e = t.hasRewardedAd();
                t.app.fire("Wrapper:checkHasRewardedAd", e), e &amp;&amp; clearInterval(t._interval)
            }), 1e3)
        }
    }
});
var DefaultApi = pc.createScript("defaultApi"),
    templateName = "TEMPLATE_NAME-";
DefaultApi.attributes.add("templateName", {
    type: "string",
    default: templateName,
    title: "Template Name",
    description: "This value is used for saving in the localStorage. Make sure to make it unique, so it doesn't override any other storages."
}), DefaultApi.attributes.add("hasRewardedAdValue", {
    type: "boolean",
    default: !0
}), DefaultApi.attributes.add("interstitialAdDuration", {
    type: "number",
    default: 3e3
}), DefaultApi.attributes.add("rewardedAdDuration", {
    type: "number",
    default: 3e3
}), DefaultApi.attributes.add("currentLanguage", {
    type: "string",
    default: "en",
    title: "Default Language",
    enum: [{
        German: "de"
    }, {
        English: "en"
    }, {
        Turkish: "tr"
    }, {
        Polish: "pl"
    }, {
        Russian: "ru"
    }, {
        Dutch: "nl"
    }, {
        Spanish: "es"
    }, {
        Portuguese: "pt"
    }, {
        French: "fr"
    }]
}), pc.extend(DefaultApi.prototype, {
    initialize: function() {
        this.templateName === templateName &amp;&amp; console.warn("Please change the template name of the API")
    },
    getBrandingButtonImage: function() {
        return "randomLink"
    },
    moreGamesLink: function() {
        alert("Opening more games")
    },
    showInterstitialAd: function() {
        console.log("[Show Interstitital Ad] Waiting for " + this.interstitialAdDuration / 1e3 + " seconds"), "function" == typeof window.defaultAPI_onPauseRequested &amp;&amp; window.defaultAPI_onPauseRequested();
        var e = this.interstitialAdDuration;
        return new Promise((function(t, n) {
            setTimeout((function() {
                "function" == typeof window.defaultAPI_onResumeRequested &amp;&amp; window.defaultAPI_onResumeRequested(), t()
            }), e)
        }))
    },
    hasRewardedAd: function() {
        return this.hasRewardedAdValue
    },
    rewardedAd: function(e) {
        console.log("[Show Rewarded Ad] Waiting for " + this.rewardedAdDuration / 1e3 + " seconds"), "function" == typeof window.defaultAPI_onPauseRequested &amp;&amp; window.defaultAPI_onPauseRequested(), setTimeout((function() {
            "function" == typeof window.defaultAPI_onResumeRequested &amp;&amp; window.defaultAPI_onResumeRequested(), e()
        }), this.rewardedAdDuration)
    },
    setOnPauseRequested: function(e, t) {
        window.defaultAPI_onPauseRequested = e.bind(t || this)
    },
    setOnResumeRequested: function(e, t) {
        window.defaultAPI_onResumeRequested = e.bind(t || this)
    },
    get: function(e) {
        return console.log("need a smart solution for this."), e
    },
    getCurrentLanguage: function() {
        return this.currentLanguage
    },
    setLocalStorageItem: function(e, t) {
        window.localStorage.setItem(this.templateName + ":" + e, t)
    },
    getLocalStorageItem: function(e) {
        return window.localStorage.getItem(this.templateName + ":" + e)
    },
    removeLocalStorageItem: function(e) {
        window.localStorage.removeItem(this.templateName + ":" + e)
    },
    clearLocalStorage: function() {
        for (var e in window.localStorage) e.startsWith(this.templateName + ":") &amp;&amp; window.localStorage.removeItem(e)
    },
    setSessionStorageItem: function(e, t) {
        window.sessionStorage.setItem(this.templateName + ":" + e, t)
    },
    getSessionStorageItem: function(e) {
        return window.sessionStorage.getItem(this.templateName + ":" + e)
    },
    removeSessionStorageItem: function(e) {
        window.sessionStorage.removeItem(this.templateName + ": " + e)
    },
    clearSessionStorage: function() {
        for (var e in window.sessionStorage) e.startsWith(this.templateName + ":") &amp;&amp; window.sessionStorage.removeItem(e)
    },
    getOrientation: function() {
        var e = window.innerWidth,
            t = window.innerHeight;
        return e &gt; t ? "landscape" : e &lt; t ? "portrait" : ""
    },
    setOnOrientationChange: function(e) {
        window.addEventListener("resize", e)
    }
});
var boilerplateVersion = "0.0.7",
    type = "prod";
console.log("%cWanted 5 Games Boilerplate | " + type + " " + boilerplateVersion, "background: #000; color: #FFF;");
var Singleton = pc.createScript("singleton");
pc.extend(Singleton.prototype, {
    initialize: function() {
        this.canCreateInstance(this) &amp;&amp; (Singleton.instance = this)
    },
    canCreateInstance: function(n) {
        var t = Object.getPrototypeOf(n).constructor;
        return t.instance &amp;&amp; console.error("A singleton instance is already made of", t.__name), !t.instance
    },
    createInstance: function(n, t) {
        this.canCreateInstance(t) &amp;&amp; (n.instance = t)
    }
});
var StorageManager = pc.createScript("storageManager");
StorageManager.attributes.add("defaultSaveData", {
    type: "asset",
    assetType: "json"
}), pc.extend(StorageManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (StorageManager.instance = this), this._basicInfo = this.defaultSaveData.resource, this._storages = Object.freeze({
            LOCALSTORAGE: "LOCALSTORAGE",
            SESSIONSTORAGE: "SESSIONSTORAGE"
        }), this._localStorage = {}, this._sessionStorage = {}, this.loadSaveData()
    },
    get: function(t, e) {
        switch ((e = e || "LOCALSTORAGE").toUpperCase()) {
            case this._storages.LOCALSTORAGE:
                return this._localStorage[t];
            case this._storages.SESSIONSTORAGE:
                return this._sessionStorage[t];
            default:
                return console.warn("Storage is " + e + ", which is incorrect."), null
        }
    },
    set: function(t, e, a, s) {
        if (s = s || "localStorage", a = a || !1) {
            var r = this.get(t);
            switch (typeof e) {
                case "number":
                    if (e &lt;= r) return
            }
        }
        this._writeToStorage(t, e, s)
    },
    remove: function(t, e) {
        switch (this._getStorage(e)[t] = this._basicInfo[t], e.toUpperCase()) {
            case this._storages.LOCALSTORAGE:
                Wrapper.instance.removeLocalStorageItem(t);
                break;
            case this._storages.SESSIONSTORAGE:
                Wrapper.instance.removeSessionStorageItem(t);
                break;
            default:
                console.warn("Storage is not recognized.", "Key is " + t)
        }
    },
    delete: function(t) {
        this._getStorage(t);
        switch (this._basicInfo, t.toUpperCase()) {
            case this._storages.LOCALSTORAGE:
                Wrapper.instance.clearLocalStorage();
                break;
            case this._storages.SESSIONSTORAGE:
                Wrapper.instance.clearSessionStorage();
                break;
            default:
                console.warn("Storage is not recognized.")
        }
    },
    _writeToStorage: function(t, e, a) {
        switch (this._getStorage(a)[t] = e, a.toUpperCase()) {
            case this._storages.LOCALSTORAGE:
                Wrapper.instance.setLocalStorageItem(t, JSON.stringify(e));
                break;
            case this._storages.SESSIONSTORAGE:
                Wrapper.instance.setSessionStorageItem(t, JSON.stringify(e));
                break;
            default:
                console.warn("Storage is not recognized.", "Key is " + t)
        }
    },
    _getStorage: function(t) {
        switch (t.toUpperCase()) {
            case this._storages.LOCALSTORAGE:
            case this._storages.SESSIONSTORAGE:
                return this._localStorage;
            default:
                return console.warn("Storage " + t + " not found"), null
        }
    },
    loadSaveData: function() {
        for (var t = Object.keys(this._basicInfo), e = 0; e &lt; t.length; e += 1) {
            var a = t[e],
                s = Wrapper.instance.getLocalStorageItem(a);
            try {
                this._localStorage[a] = JSON.parse(s)
            } catch (t) {
                this._localStorage[a] = s
            }
            void 0 !== this._localStorage[a] &amp;&amp; null !== this._localStorage[a] &amp;&amp; typeof this._localStorage[a] == typeof this._basicInfo[a] &amp;&amp; Array.isArray(this._localStorage[a]) === Array.isArray(this._basicInfo[a]) || (this._localStorage[a] = this._basicInfo[a], this.set(a, this._localStorage[a])), Array.isArray(this._basicInfo[a]) &amp;&amp; !Array.isArray(this._localStorage[a]) &amp;&amp; (this._localStorage[a] = this._basicInfo[a], this.set(a, this._localStorage[a])), typeof this._localStorage[a] != typeof this._basicInfo[a] &amp;&amp; (this._localStorage[a] = this._basicInfo[a], this.set(a, this._localStorage[a]))
        }
    }
});
var TilePrefabManager = pc.createScript("tilePrefabManager");
pc.extend(TilePrefabManager.prototype, {
    initialize: function() {
        TilePrefabManager.instance = this, this._objectPools = {};
        for (var e = this.entity.findComponents("script"), t = 0; t &lt; e.length; t++) {
            var o = e[t].get("objectPool");
            o &amp;&amp; (this._objectPools[o.entity.name] = o)
        }
    },
    getObjectPool: function(e) {
        var t = this._objectPools[e];
        return t instanceof ObjectPool || console.warn(t, "is not an object pool"), t
    }
});
var TileLibrary = pc.createScript("tileLibrary"),
    tileLayerEnum = {
        FOREGROUND: 0,
        BACKGROUND: 1
    },
    foregroundTileEnum = Object.freeze({
        EMPTY: 0,
        DEFAULT: 1,
        LINE_H: 2,
        LINE_V: 3,
        BOMB: 4,
        COLORBOMB: 5,
        DROPPER: 6,
        KEY: 7,
        SWITCHER: 8,
        EXPLODER: 9,
        DROPPER_COLLECTION: 10
    }),
    backgroundTileEnum = Object.freeze({
        EMPTY: 0,
        WALL: 1,
        PANEL: 2,
        BLOCKER: 3,
        LOCKER: 4,
        VIRUS: 5,
        COAT: 6,
        SINKER: 7,
        CHEST: 8,
        STICKER: 9,
        POPPER: 10
    }),
    tileColorEnum = Object.freeze({
        NONE: 0,
        BLUE: 1,
        YELLOW: 2,
        RED: 3,
        PURPLE: 4,
        GREEN: 5,
        ORANGE: 6
    });
TileLibrary.backgroundTiles = backgroundTileEnum, TileLibrary.attributes.add("pyzomathLibrary", {
    type: "asset",
    assetType: "json"
}), pc.extend(TileLibrary.prototype, {
    initialize: function() {
        TileLibrary.instance = this, this._objectPoolTypeEnum = Object.freeze({
            COLOR: 0,
            NOCOLOR: 1
        })
    },
    postInitialize: function() {
        this._createLibrary(), this._pyzomathLibrary = this.pyzomathLibrary.resource.gameLibrary, this._createLibraryLink()
    },
    getObject: function(e, o, t) {
        if (!this._library.hasOwnProperty(e) || !this._library[e].hasOwnProperty(o)) return null;
        var i = this._library[e][o].prefab,
            r = this._getColorOrNoColorPool(i, t);
        return this._tryUsePool(r)
    },
    returnObject: function(e, o, t, i) {
        if (!this._library.hasOwnProperty(o) || !this._library[o].hasOwnProperty(t)) return null;
        var r = this._library[o][t].prefab,
            n = this._getColorOrNoColorPool(r, i);
        this._tryReturnPool(n, e) || console.error("Tries recycling object to pool but it failed", e, o, t, i)
    },
    getTileData: function(e, o) {
        return this._library.hasOwnProperty(e) &amp;&amp; this._library[e].hasOwnProperty(o) ? this._library[e][o] : null
    },
    isTileColored: function(e, o) {
        return !(!this._library.hasOwnProperty(e) || !this._library[e].hasOwnProperty(o)) &amp;&amp; this._library[e][o].prefab.hasOwnProperty(this._objectPoolTypeEnum.COLOR)
    },
    getOriginalTypeID: function(e, o) {
        return this._linkLibrary[e].hasOwnProperty(o) ? this._linkLibrary[e][o] : null
    },
    getTileSprite: function(e) {
        if ("object" == typeof e) {
            if (0 === e.layerID &amp;&amp; 0 === e.typeID &amp;&amp; 0 === e.colorID) return this.app.assets.find("115_ui_icon_highscore.png");
            if (e.layerID === tileLayerEnum.FOREGROUND &amp;&amp; e.typeID === foregroundTileEnum.DROPPER_COLLECTION) return WorldManager.instance.getPartAssets(WorldManager.instance.getWorldIndex()).partSprite;
            var o = this._library[e.layerID][e.typeID].sprite;
            return e.colorID ? o[this._objectPoolTypeEnum.COLOR][e.colorID] : o[this._objectPoolTypeEnum.NOCOLOR]
        }
        if (e.includes("default")) {
            var t = e.split("_"),
                i = Number(t[1]);
            return this._library[tileLayerEnum.FOREGROUND][foregroundTileEnum.DEFAULT].sprite[this._objectPoolTypeEnum.COLOR][i]
        }
        if (e.includes("points")) return this.app.assets.find("115_ui_icon_highscore.png");
        switch (e) {
            case "panel":
                return this._library[tileLayerEnum.BACKGROUND][backgroundTileEnum.PANEL].sprite[this._objectPoolTypeEnum.NOCOLOR];
            case "blocker":
                return this._library[tileLayerEnum.BACKGROUND][backgroundTileEnum.BLOCKER].sprite[this._objectPoolTypeEnum.NOCOLOR];
            case "dropper":
                return this._library[tileLayerEnum.FOREGROUND][foregroundTileEnum.DROPPER].sprite[this._objectPoolTypeEnum.NOCOLOR];
            case "collectdropper":
                return WorldManager.instance.getPartAssets(WorldManager.instance.getWorldIndex()).partSprite;
            case "locker":
            case "Locker":
                return this._library[tileLayerEnum.BACKGROUND][backgroundTileEnum.LOCKER].sprite[this._objectPoolTypeEnum.NOCOLOR];
            case "virus":
                return this._library[tileLayerEnum.BACKGROUND][backgroundTileEnum.VIRUS].sprite[this._objectPoolTypeEnum.NOCOLOR];
            case "score":
                return this.app.assets.find("115_ui_icon_highscore.png");
            default:
                console.warn("Nothing found with the name", e)
        }
    },
    _getColorOrNoColorPool: function(e, o) {
        return e.hasOwnProperty(this._objectPoolTypeEnum.COLOR) ? void 0 === o ? (console.warn("Object is a colored object, but color was not provided", e, o), null) : e[this._objectPoolTypeEnum.COLOR].hasOwnProperty(o) ? e[this._objectPoolTypeEnum.COLOR][o] : (console.warn("Object is a colored object, but color does not exist", e, o), null) : e.hasOwnProperty(this._objectPoolTypeEnum.NOCOLOR) ? e[this._objectPoolTypeEnum.NOCOLOR] : null
    },
    _tryUsePool: function(e) {
        return e instanceof ObjectPool ? e.use() : (console.warn("Objectpool missing in library for object"), null)
    },
    _tryReturnPool: function(e, o) {
        return e instanceof ObjectPool ? (e.recycle(o), !0) : (console.warn("Objectpool missing in library for object"), !1)
    },
    _createLibraryLink: function() {
        this._linkLibrary = {
            [tileLayerEnum.FOREGROUND]: {},
            [tileLayerEnum.BACKGROUND]: {}
        };
        for (var e = Object.keys(this._library[tileLayerEnum.FOREGROUND]), o = 0; o &lt; this._pyzomathLibrary.foregrounds.length; o += 1)
            for (var t = this._pyzomathLibrary.foregrounds[o], i = 0; i &lt; e.length; i += 1) {
                this._library[tileLayerEnum.FOREGROUND][e[i]].name === t.name &amp;&amp; (this._linkLibrary[tileLayerEnum.FOREGROUND][t.id] = parseInt(e[i]))
            }
        var r = Object.keys(this._library[tileLayerEnum.BACKGROUND]);
        for (o = 0; o &lt; this._pyzomathLibrary.backgrounds.length; o += 1)
            for (t = this._pyzomathLibrary.backgrounds[o], i = 0; i &lt; r.length; i += 1) {
                this._library[tileLayerEnum.BACKGROUND][r[i]].name === t.name &amp;&amp; (this._linkLibrary[tileLayerEnum.BACKGROUND][t.id] = parseInt(r[i]))
            }
    },
    _createLibrary: function() {
        this._library = {
            [tileLayerEnum.FOREGROUND]: {
                [foregroundTileEnum.DEFAULT]: {
                    name: "default",
                    prefab: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: TilePrefabManager.instance.getObjectPool("TileBlueObjectPool"),
                            [tileColorEnum.YELLOW]: TilePrefabManager.instance.getObjectPool("TileYellowObjectPool"),
                            [tileColorEnum.RED]: TilePrefabManager.instance.getObjectPool("TileRedObjectPool"),
                            [tileColorEnum.PURPLE]: TilePrefabManager.instance.getObjectPool("TilePurpleObjectPool"),
                            [tileColorEnum.GREEN]: TilePrefabManager.instance.getObjectPool("TileGreenObjectPool"),
                            [tileColorEnum.ORANGE]: TilePrefabManager.instance.getObjectPool("TileOrangeObjectPool")
                        }
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: this.app.assets.find("120_ui_objective_default_blue.png"),
                            [tileColorEnum.YELLOW]: this.app.assets.find("125_ui_objective_default_yellow.png"),
                            [tileColorEnum.RED]: this.app.assets.find("124_ui_objective_default_red.png"),
                            [tileColorEnum.PURPLE]: this.app.assets.find("123_ui_objective_default_purple.png"),
                            [tileColorEnum.GREEN]: this.app.assets.find("121_ui_objective_default_green.png"),
                            [tileColorEnum.ORANGE]: this.app.assets.find("122_ui_objective_default_orange.png")
                        }
                    }
                },
                [foregroundTileEnum.LINE_H]: {
                    name: "line_h",
                    prefab: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: TilePrefabManager.instance.getObjectPool("HorizontalBlueObjectPool"),
                            [tileColorEnum.YELLOW]: TilePrefabManager.instance.getObjectPool("HorizontalYellowObjectPool"),
                            [tileColorEnum.RED]: TilePrefabManager.instance.getObjectPool("HorizontalRedObjectPool"),
                            [tileColorEnum.PURPLE]: TilePrefabManager.instance.getObjectPool("HorizontalPurpleObjectPool"),
                            [tileColorEnum.GREEN]: TilePrefabManager.instance.getObjectPool("HorizontalGreenObjectPool"),
                            [tileColorEnum.ORANGE]: TilePrefabManager.instance.getObjectPool("HorizontalOrangeObjectPool")
                        }
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: this.app.assets.find("040_tile_lineh.png"),
                            [tileColorEnum.YELLOW]: this.app.assets.find("040_tile_lineh.png"),
                            [tileColorEnum.RED]: this.app.assets.find("040_tile_lineh.png"),
                            [tileColorEnum.PURPLE]: this.app.assets.find("040_tile_lineh.png"),
                            [tileColorEnum.GREEN]: this.app.assets.find("040_tile_lineh.png"),
                            [tileColorEnum.ORANGE]: this.app.assets.find("040_tile_lineh.png")
                        }
                    }
                },
                [foregroundTileEnum.LINE_V]: {
                    name: "line_v",
                    prefab: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: TilePrefabManager.instance.getObjectPool("VerticalBlueObjectPool"),
                            [tileColorEnum.YELLOW]: TilePrefabManager.instance.getObjectPool("VerticalYellowObjectPool"),
                            [tileColorEnum.RED]: TilePrefabManager.instance.getObjectPool("VerticalRedObjectPool"),
                            [tileColorEnum.PURPLE]: TilePrefabManager.instance.getObjectPool("VerticalPurpleObjectPool"),
                            [tileColorEnum.GREEN]: TilePrefabManager.instance.getObjectPool("VerticalGreenObjectPool"),
                            [tileColorEnum.ORANGE]: TilePrefabManager.instance.getObjectPool("VerticalOrangeObjectPool")
                        }
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: this.app.assets.find("040_tile_linev.png"),
                            [tileColorEnum.YELLOW]: this.app.assets.find("040_tile_linev.png"),
                            [tileColorEnum.RED]: this.app.assets.find("040_tile_linev.png"),
                            [tileColorEnum.PURPLE]: this.app.assets.find("040_tile_linev.png"),
                            [tileColorEnum.GREEN]: this.app.assets.find("040_tile_linev.png"),
                            [tileColorEnum.ORANGE]: this.app.assets.find("040_tile_linev.png")
                        }
                    }
                },
                [foregroundTileEnum.BOMB]: {
                    name: "bomb",
                    prefab: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: TilePrefabManager.instance.getObjectPool("BombBlueObjectPool"),
                            [tileColorEnum.YELLOW]: TilePrefabManager.instance.getObjectPool("BombYellowObjectPool"),
                            [tileColorEnum.RED]: TilePrefabManager.instance.getObjectPool("BombRedObjectPool"),
                            [tileColorEnum.PURPLE]: TilePrefabManager.instance.getObjectPool("BombPurpleObjectPool"),
                            [tileColorEnum.GREEN]: TilePrefabManager.instance.getObjectPool("BombGreenObjectPool"),
                            [tileColorEnum.ORANGE]: TilePrefabManager.instance.getObjectPool("BombOrangeObjectPool")
                        }
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: this.app.assets.find("039_tile_bomb.png"),
                            [tileColorEnum.YELLOW]: this.app.assets.find("039_tile_bomb.png"),
                            [tileColorEnum.RED]: this.app.assets.find("039_tile_bomb.png"),
                            [tileColorEnum.PURPLE]: this.app.assets.find("039_tile_bomb.png"),
                            [tileColorEnum.GREEN]: this.app.assets.find("039_tile_bomb.png"),
                            [tileColorEnum.ORANGE]: this.app.assets.find("039_tile_bomb.png")
                        }
                    }
                },
                [foregroundTileEnum.COLORBOMB]: {
                    name: "colorbomb",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("ColorBombObjectPool")
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.NOCOLOR]: this.app.assets.find("041_tile_colorbomb.png")
                    }
                },
                [foregroundTileEnum.DROPPER]: {
                    name: "dropper",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("DropperObjectPool")
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.NOCOLOR]: this.app.assets.find("079_ui_objective_dropper_1.png")
                    }
                },
                [foregroundTileEnum.KEY]: {
                    name: "key",
                    prefab: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: "getPool",
                            [tileColorEnum.YELLOW]: "getPool",
                            [tileColorEnum.RED]: "getPool",
                            [tileColorEnum.PURPLE]: "getPool",
                            [tileColorEnum.GREEN]: "getPool",
                            [tileColorEnum.ORANGE]: "getPool"
                        }
                    }
                },
                [foregroundTileEnum.SWITCHER]: {
                    name: "switcher",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: "getPool"
                    }
                },
                [foregroundTileEnum.EXPLODER]: {
                    name: "exploder",
                    prefab: {
                        [this._objectPoolTypeEnum.COLOR]: {
                            [tileColorEnum.BLUE]: "getPool",
                            [tileColorEnum.YELLOW]: "getPool",
                            [tileColorEnum.RED]: "getPool",
                            [tileColorEnum.PURPLE]: "getPool",
                            [tileColorEnum.GREEN]: "getPool",
                            [tileColorEnum.ORANGE]: "getPool"
                        }
                    }
                },
                [foregroundTileEnum.DROPPER_COLLECTION]: {
                    name: "collectdropper",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("DropperCollectionObjectPool")
                    }
                }
            },
            [tileLayerEnum.BACKGROUND]: {
                [backgroundTileEnum.EMPTY]: {
                    name: "empty",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("DefaultBackgroundTileObjectPool")
                    }
                },
                [backgroundTileEnum.WALL]: {
                    name: "inaccessible",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("WallObjectPool")
                    }
                },
                [backgroundTileEnum.PANEL]: {
                    name: "panel",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("PanelObjectPool")
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.NOCOLOR]: this.app.assets.find("119_ui_objective_panel.png")
                    }
                },
                [backgroundTileEnum.BLOCKER]: {
                    name: "blocker",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("BlockerObjectPool")
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.NOCOLOR]: this.app.assets.find("118_ui_objective_blocker.png")
                    }
                },
                [backgroundTileEnum.LOCKER]: {
                    name: "locker",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("LockerObjectPool")
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.NOCOLOR]: this.app.assets.find("147_icon_objective_locker.png")
                    }
                },
                [backgroundTileEnum.VIRUS]: {
                    name: "virus",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: TilePrefabManager.instance.getObjectPool("VirusObjectPool")
                    },
                    sprite: {
                        [this._objectPoolTypeEnum.NOCOLOR]: this.app.assets.find("152_ui_objective_virus.png")
                    }
                },
                [backgroundTileEnum.COAT]: {
                    name: "coat",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: "getPool"
                    }
                },
                [backgroundTileEnum.SINKER]: {
                    name: "sinker",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: "getPool"
                    }
                },
                [backgroundTileEnum.CHEST]: {
                    name: "chest",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: "getPool"
                    }
                },
                [backgroundTileEnum.STICKER]: {
                    name: "sticker",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: "getPool"
                    }
                },
                [backgroundTileEnum.POPPER]: {
                    name: "popper",
                    prefab: {
                        [this._objectPoolTypeEnum.NOCOLOR]: "getPool"
                    }
                }
            }
        }
    }
});
var SwapMode = pc.createScript("swapMode");
SwapMode.attributes.add("minimalLength", {
    type: "number",
    default: 3
}), SwapMode.attributes.add("endModePowerTilesAmount", {
    type: "number",
    default: 3
}), SwapMode.attributes.add("endModeMaxCascades", {
    type: "number",
    default: 2
}), SwapMode.attributes.add("endModeSpawnDelay", {
    type: "number",
    default: .2
});
var matchStates = Object.freeze({
    WAIT: 0,
    MATCH: 1,
    DESPAWN: 2,
    GRAVITY: 3,
    END: 4,
    ENDSPAWN: 5
});
pc.extend(SwapMode.prototype, {
    initialize: function() {
        SwapMode.instance = this, this._selectedTile1 = null, this._selectedTile2 = null, this.tutorialTile = null, this._triedMatch = !1, this._cascadeCounter = 0, this.app.on("SwapMode:inputStopped", this.setTriedMatch, this), this.app.on("GameInput:forced" + inputEvents.DOWN, this._onClick, this), this._counter = 0, this._isCounting = !1, this._endModeMaxCascadeCounter = 0, this.startedEnd = !1, this.app.on("SwapMode:deselect", this.deselect, this)
    },
    _onClick: function() {
        this.startedEnd &amp;&amp; (this.app.timeScale = 2, this.app.fire("SwapMode:speedUp"))
    },
    update: function(e) {
        this._isCounting &amp;&amp; (this._counter += e, this._counter &gt;= this.currentStateDuration &amp;&amp; (this._isCounting = !1, this._onStateEnd()))
    },
    setup: function() {
        this.setState(matchStates.WAIT), this._endModeMaxCascadeCounter = 0, this.startedEnd = !1, this.deselect()
    },
    onSelect: function(e, t) {
        (e.isSwappable() || BoosterManager.instance.isBoosterActive(boosterEnum.BREAKER)) &amp;&amp; (this._selectedTile1 !== e &amp;&amp; !this._triedMatch || BoosterManager.instance.isBoosterActive(boosterEnum.BREAKER)) &amp;&amp; (this._selectedTile1 ? (this._selectedTile2 = e, this._selectedTile2.setHighlight(!0), this._triedMatch = this._swap()) : this._select(e))
    },
    _swap: function() {
        return MatchLogic.areNeighbours(this._selectedTile1, this._selectedTile2) ? (this._startSwap(), !0) : (this._select(this._selectedTile2), !1)
    },
    _select: function(e) {
        (GridManager.instance.setAbleToSpawnDropper(!0), BoosterManager.instance.isBoosterActive(boosterEnum.BREAKER)) ? TutorialManager.instance.active &amp;&amp; !TutorialManager.instance.canUseBooster(e) || BoosterManager.instance.doBreaker(e) &amp;&amp; this.app.fire("GameInput:toggleGameInput", !1): BoosterManager.instance.isBoosterActive(boosterEnum.CROSSBOMB) ? TutorialManager.instance.active &amp;&amp; !TutorialManager.instance.canUseBooster(e) || BoosterManager.instance.doCrossBomb(e) &amp;&amp; this.app.fire("GameInput:toggleGameInput", !1) : (this._selectedTile1 &amp;&amp; this._selectedTile1.setHighlight(!1), this._selectedTile1 = e, this._selectedTile1.setHighlight(!0), this._selectedTile2 = null)
    },
    deselect: function() {
        this._selectedTile1 &amp;&amp; this._selectedTile1.setHighlight(!1), this._selectedTile2 &amp;&amp; this._selectedTile2.setHighlight(!1), this._selectedTile1 = null, this._selectedTile2 = null
    },
    _startSwap: function() {
        this.app.fire("GameInput:toggleGameInput", !1), this.app.fire("Audio:sfx", "tile_swap.mp3");
        var e = BoosterManager.instance.isBoosterActive(boosterEnum.FREESWAP),
            t = e ? BoosterManager.instance.freeSwapAnimationDelay : 0;
        e &amp;&amp; BoosterManager.instance.doFreeSwapAnimation(this._selectedTile1, this._selectedTile2), GridManager.instance.swapTiles(this._selectedTile1, this._selectedTile2, t), this.setState(matchStates.MATCH, GridManager.instance.moveDuration + t)
    },
    _handlePlayerMatches: function() {
        var e = !1;
        if (!TutorialManager.instance.checkAllowedSwap(this._selectedTile1, this._selectedTile2)) return GridManager.instance.swapTiles(this._selectedTile1, this._selectedTile2), this.setState(matchStates.WAIT), void this.deselect();
        var t = [];
        BoosterManager.instance.isBoosterActive(boosterEnum.FREESWAP) ? e = !0 : t = PowerTileManager.instance.onTileSwap(this._selectedTile1, this._selectedTile2), t = MatchLogic.getChainedPowerTileMatches(t);
        var a = MatchLogic.getDropperMatches(),
            i = [],
            s = [];
        if (this._selectedTile1.typeID !== foregroundTileEnum.COLORBOMB &amp;&amp; this._selectedTile2.typeID !== foregroundTileEnum.COLORBOMB &amp;&amp; (i = MatchLogic.getMatch(this._selectedTile1, this.minimalLength), s = MatchLogic.getMatch(this._selectedTile2, this.minimalLength)), this._checkIfPlayerIsAllowedToSwap(i, s, t)) {
            e || this.app.fire("SwapMode:onMoveStart");
            var n = GridManager.instance.getLongestTileDespawnDuration();
            this.setState(matchStates.DESPAWN, n), i.length &gt; 0 &amp;&amp; this.app.fire("SwapMode:onTileMatch", i), s.length &gt; 0 &amp;&amp; this.app.fire("SwapMode:onTileMatch", s), t.length &gt; 0 &amp;&amp; this.app.fire("SwapMode:onTileMatch", t), a.length &gt; 0 &amp;&amp; this.app.fire("SwapMode:onTileMatch", a), this._updateMatchStatistics(i.length, s.length, t.length), GridManager.instance.spawnPowerTiles(), GridManager.instance.active(!1)
        } else GridManager.instance.swapTiles(this._selectedTile1, this._selectedTile2), this.setState(matchStates.WAIT);
        this.deselect()
    },
    _checkIfPlayerIsAllowedToSwap: function(e, t, a) {
        return BoosterManager.instance.isBoosterActive(boosterEnum.FREESWAP) ? (BoosterManager.instance.doFreeSwap(), !0) : (e.length &gt; 0 || t.length &gt; 0 || a.length &gt; 0) &amp;&amp; (this.app.fire("SwapMode:onPlayerMove"), !0)
    },
    _updateMatchStatistics: function(e, t, a) {
        e &gt; 0 &amp;&amp; StatisticsManager.instance.incrementStatistic("matches_made", 1), t &gt; 0 &amp;&amp; StatisticsManager.instance.incrementStatistic("matches_made", 1), a &gt; 0 &amp;&amp; StatisticsManager.instance.incrementStatistic("matches_made", 1), 3 === e &amp;&amp; StatisticsManager.instance.incrementStatistic("three_flower_matches_made", 1), 4 === e &amp;&amp; StatisticsManager.instance.incrementStatistic("four_flower_matches_made", 1), 5 === e &amp;&amp; StatisticsManager.instance.incrementStatistic("five_flower_matches_made", 1), 3 === t &amp;&amp; StatisticsManager.instance.incrementStatistic("three_flower_matches_made", 1), 4 === t &amp;&amp; StatisticsManager.instance.incrementStatistic("four_flower_matches_made", 1), 5 === t &amp;&amp; StatisticsManager.instance.incrementStatistic("five_flower_matches_made", 1)
    },
    _handleCascadeMatches: function() {
        GridManager.instance.resetDespawnDelay(), this.app.fire("SwapMode:onCascadeNext");
        var e = MatchLogic.getCascadeMatches(this.minimalLength);
        if (e.length &gt; 0) {
            this._cascadeCounter++;
            var t = pc.math.clamp(this._cascadeCounter + 1, 2, 7);
            this.app.fire("Audio:sfx", "combo_" + t + ".mp3");
            var a = GridManager.instance.getLongestTileDespawnDuration();
            this.setState(matchStates.DESPAWN, a), this.app.fire("SwapMode:onTileMatch", e), GridManager.instance.spawnPowerTiles()
        } else this.startedEnd || GridManager.instance.active(!0), GridManager.instance.expandVirus(), this.app.fire("CascadeIndicatorInterface:onCascade", this._cascadeCounter), this._cascadeCounter = 0, this.app.fire("SwapMode:onCascadeDone"), this._handleEndOfMove(), StatisticsManager.instance.saveStatistics();
        this.app.fire("SwapMode:onGravityEnd")
    },
    _handleEndOfMove: function() {
        var e = null;
        this.startedEnd || !(e = LevelManager.instance.onMoveDone()) ? this.startedEnd ? this.setState(matchStates.END, .2) : !1 === e ? this.app.fire("GameInput:toggleGameInput", !1) : null === e &amp;&amp; (GridManager.instance.checkAllPossibleMatches(), this.setState(matchStates.WAIT)) : this._startFinale()
    },
    _startFinale: function() {
        this.app.fire("SwapMode:onEndStart"), this.app.fire("Audio:bgm", "end_mode.mp3"), this.startedEnd = !0, this._endModeMaxCascadeCounter = 0, GridManager.instance.active(!1), this._spawnEndGamePowerups()
    },
    _handleEndMatches: function() {
        var e = GridManager.instance.getAllPowerTiles();
        if (e.length &gt; 0) {
            var t = [];
            if (this.endModePowerTilesAmount &gt; 0) {
                for (var a = 0; a &lt; this.endModePowerTilesAmount; a += 1)
                    if (e.length &gt; 0) {
                        var i = Math.floor(Math.random() * e.length);
                        t.push(e[i]), e.splice(i, 1)
                    }
            } else t = e;
            t = MatchLogic.getChainedPowerTileMatches(t);
            var s = GridManager.instance.getLongestTileDespawnDuration();
            this.setState(matchStates.DESPAWN, s), this.app.fire("SwapMode:onTileMatch", t)
        } else this.startedEnd = !1, this.setState(matchStates.WAIT), this.app.fire("SwapMode:onFinaleDone"), this.app.timeScale = 1
    },
    _applyGravity: function() {
        this._endModeMaxCascadeCounter += 1;
        var e = TutorialManager.instance.active;
        this.startedEnd &amp;&amp; (ColorManager.instance.endGameIncreaseColor(this._endModeMaxCascadeCounter) &amp;&amp; (this._endModeMaxCascadeCounter = 0));
        var t = GridManager.instance.applyGravityToTiles(e);
        this.setState(matchStates.GRAVITY, t)
    },
    _spawnEndGamePowerups: function() {
        GridManager.instance.active(!1);
        for (var e = GridManager.instance.getForegroundTilesOfType(foregroundTileEnum.DEFAULT, 0), t = MovesManager.instance.getMoves(), a = [foregroundTileEnum.LINE_H, foregroundTileEnum.LINE_V, foregroundTileEnum.BOMB], i = 1; i &lt;= t; i++) {
            0 === e.length &amp;&amp; (e = GridManager.instance.getForegroundTilesOfType([foregroundTileEnum.LINE_V, foregroundTileEnum.LINE_H, foregroundTileEnum.BOMB]));
            var s = Math.floor(Math.random() * e.length),
                n = e[s];
            if (n) {
                var r = a[Math.floor(Math.random() * a.length)],
                    c = PowerTileManager.instance.switchTilePower(n, r, this.endModeSpawnDelay * i);
                PowerTileManager.instance.setTileState(c, ForegroundTile._PowerStates.ACTIVE)
            }
            this.app.fire("ScoreManager:scoreEndModeCreatePower", n), e.splice(s, 1)
        }
        this.setState(matchStates.ENDSPAWN, t * this.endModeSpawnDelay)
    },
    setTriedMatch: function(e) {
        this._triedMatch = e
    },
    setState: function(e, t) {
        this.currentState = e, this._onStateSwitch(), this.currentStateDuration = t, this._counter = 0, this._isCounting = "number" == typeof t
    },
    _onStateSwitch: function() {
        switch (this.currentState) {
            case matchStates.WAIT:
                this.app.fire("GameInput:toggleGameInput", !0), this.app.fire("SwapMode:onWait");
                break;
            case matchStates.MATCH:
            case matchStates.DESPAWN:
            case matchStates.GRAVITY:
            case matchStates.END:
            case matchStates.ENDSPAWN:
        }
    },
    _onStateEnd: function() {
        switch (this.currentState) {
            case matchStates.WAIT:
                break;
            case matchStates.MATCH:
                this._handlePlayerMatches();
                break;
            case matchStates.DESPAWN:
                this._applyGravity();
                break;
            case matchStates.GRAVITY:
                this._handleCascadeMatches();
                break;
            case matchStates.END:
                this._handleEndMatches();
                break;
            case matchStates.ENDSPAWN:
                this.setState(matchStates.END, 1)
        }
    }
});
var TapMode = pc.createScript("tapMode");
TapMode.attributes.add("minimalAmount", {
    type: "number",
    default: 2
}), pc.extend(TapMode.prototype, {
    initialize: function() {},
    setup: function() {
        pc.pickerFrameBuffer.setInputEnabled(!0), pc.gridManager.setTilesLayer(tileLayersEnum.DEFAULT)
    },
    onSelect: function(e, i) {
        pc.pickerFrameBuffer.setInputEnabled(!1);
        var t = pc.gridManager.getAllNestedNeighbours(e);
        t.length &lt; this.minimalAmount ? pc.pickerFrameBuffer.setInputEnabled(!0) : (this._despawnAll(t), this._finishMove())
    },
    _checkTileActive: function(e, i) {
        return !(!e || !e.isActive() || e.id !== i) &amp;&amp; (this.onSelect(e, i), !0)
    },
    _despawnAll: function(e) {
        for (var i = 0; i &lt; e.length; i++) e[i].despawn()
    },
    _finishMove: function() {
        pc.gridManager.deactiveTiles(), pc.gridManager.applyGravityToTiles(), pc.gridManager.spawnNewTiles(), setTimeout(function() {
            pc.pickerFrameBuffer.setInputEnabled(!0)
        }.bind(this), 500)
    }
});
var Utils = pc.createScript("utils");
pc.extend(Utils.prototype, {
    initialize: function() {
        pc.utils = this
    },
    addButtonClickEvent: function(r, n, t) {
        r.element.on("click", n, t)
    },
    shuffleArray: function(r) {
        for (var n = r.length - 1; n &gt; 0; n--) {
            var t = Math.floor(Math.random() * (n + 1)),
                e = r[n];
            r[n] = r[t], r[t] = e
        }
    },
    multiDimensionArray: function(r) {
        for (var n = [], t = 0; t &lt; r[0]; t += 1) n.push(1 === r.length ? 0 : this.multiDimensionArray(r.slice(1)));
        return n
    },
    fuseArray: function(r, n) {
        for (var t = 0; t &lt; n.length; t++) r.push(n[t])
    },
    fuseUniqueArray: function(r, n) {
        for (var t = 0; t &lt; n.length; t++) - 1 === r.indexOf(n[t]) &amp;&amp; r.push(n[t])
    },
    removeDuplicate: function(r, n) {
        for (var t = r.length - 1; t &gt;= 0; t--) - 1 !== n.indexOf(r[t]) &amp;&amp; r.splice(t, 1)
    },
    duplicateArray: function(r) {
        for (var n = [], t = 0; t &lt; r.length; t++) n.push(r[t]);
        return n
    },
    isElementInArray: function(r, n) {
        for (var t = 0; t &lt; n.length; t++)
            if (n[t] === r) return !0;
        return !1
    },
    isElementIn2DArray: function(r, n) {
        for (var t = 0; t &lt; n.length; t++)
            for (var e = 0; e &lt; n[t].length; e++)
                if (n[t][e] === r) return !0;
        return !1
    },
    isDuplicateIn2DArrayAndArray: function(r, n) {
        for (var t = 0; t &lt; r.length; t++)
            for (var e = 0; e &lt; r[t].length; e++)
                if (-1 !== n.indexOf(r[t][e])) return !0;
        return !1
    },
    delay: function(r) {
        return new Promise((function(n) {
            setTimeout(n, r)
        }))
    }
});
var CenterShape = pc.createScript("centerShape");
CenterShape.attributes.add("topEntity", {
    type: "entity"
}), CenterShape.attributes.add("bottomEntity", {
    type: "entity"
}), CenterShape.attributes.add("gridMaterial", {
    type: "asset",
    assetType: "material"
}), CenterShape.attributes.add("topPropEntity", {
    type: "entity"
}), CenterShape.attributes.add("bottomPropEntity", {
    type: "entity"
}), pc.extend(CenterShape.prototype, {
    initialize: function() {
        this.app.on("GridManager:onLevelSpawn", this.setShape, this), this.app.on("GridManager:onDespawn", this.disableShape, this), this.material = this.entity.model.meshInstances[0].material, this.propSize = 5, this.setShapeSize(), this.setCaps(), this.setProps()
    },
    setShape: function() {
        this.setShapeSize(), this.setCaps(), this.setProps(), this.setGridMaterial(), this.enableShape()
    },
    setShapeSize: function() {
        console.log(MatchLogic.rows), this.entity.setLocalScale(2 * GridManager.instance.radius, GridManager.instance.height, 2 * GridManager.instance.radius), this.entity.setLocalPosition(0, GridManager.instance.height / 2 - GridManager.instance.height / MatchLogic.rows / 2, 0)
    },
    setCaps: function() {
        this.topEntity.setLocalScale(1, 2 * GridManager.instance.radius / GridManager.instance.height, 1), this.bottomEntity.setLocalScale(1, 2 * GridManager.instance.radius / GridManager.instance.height, 1)
    },
    setProps: function() {
        var t = 1 / (2 * GridManager.instance.radius) * this.propSize;
        GridManager.instance.radius, GridManager.instance.height
    },
    setGridMaterial: function() {
        this.material.diffuseMapTiling = new pc.Vec2(MatchLogic.columns / 2, MatchLogic.rows / 2), this.material.update()
    },
    disableShape: function() {
        this.entity.enabled = !1
    },
    enableShape: function() {
        this.entity.enabled = !0
    }
});
var ColorManager = pc.createScript("colorManager");
pc.extend(ColorManager.prototype, {
    initialize: function() {
        ColorManager.instance = this, this.maxColors = 4, this.colorAppearOrder = [tileColorEnum.YELLOW, tileColorEnum.GREEN, tileColorEnum.RED, tileColorEnum.BLUE, tileColorEnum.PURPLE, tileColorEnum.ORANGE]
    },
    getRandomColor: function() {
        return this.colorAppearOrder[Math.floor(pc.math.random(0, this.maxColors))]
    },
    getColorInOrder: function(o) {
        return this.colorAppearOrder[o - 1]
    },
    endGameIncreaseColor: function(o) {
        return o &gt;= this._endGameIncreaseColorOn() &amp;&amp; (this.maxColors &lt; this.colorAppearOrder.length &amp;&amp; (this.maxColors += 1, this.hasIncreasedColorOnce = !0), !0)
    },
    _endGameIncreaseColorOn: function() {
        return this.hasIncreasedColorOnce ? 2 : 5
    },
    getColorMostInGrid: function() {
        for (var o = GridManager.instance.rows, r = GridManager.instance.columns, e = {}, l = [], n = 0; n &lt; r; n++)
            for (var t = 0; t &lt; o; t++) {
                var a = GridManager.instance.getTile(n, t);
                a &amp;&amp; a.isActive() &amp;&amp; a.colorID !== tileColorEnum.NONE &amp;&amp; !a.isHitByPower() &amp;&amp; (e[a.colorID] = void 0 !== e[a.colorID] ? e[a.colorID] + 1 : 1)
            }
        for (var i in e) 0 === l.length || e[i] &gt; e[l[0]] ? (l.length = 0, l.push(i)) : e[i] == e[l[0]] &amp;&amp; l.push(i);
        return parseInt(l[Math.floor(pc.math.random(0, l.length))])
    },
    getRandomColorNoMatch: function(o, r, e, l, n, t) {
        null !== o &amp;&amp; null !== e &amp;&amp; (o.colorID, e.colorID), null !== r &amp;&amp; null !== l &amp;&amp; (r.colorID, l.colorID);
        var a = this.getEasyNoMatchColor(o, r, n, t);
        return null === a &amp;&amp; this.getComplexNoMatchColor(o, r, e, l), null === a &amp;&amp; (console.warn("There was a mistake in the spawn algorithm, no posssible gem was found: Spawning gem with ID 0"), a = tileColorEnum.BLUE), a
    },
    getEasyNoMatchColor: function(o, r, e, l) {
        for (var n = [], t = 0; t &lt; this.maxColors; t += 1) {
            var a = null === o || this.colorAppearOrder[t] !== o.colorID,
                i = null === r || this.colorAppearOrder[t] !== r.colorID,
                c = null === o || this.colorAppearOrder[t] !== o.colorID,
                s = null === r || this.colorAppearOrder[t] !== r.colorID;
            a &amp;&amp; i &amp;&amp; c &amp;&amp; s &amp;&amp; n.push(this.colorAppearOrder[t])
        }
        return 0 === n.length ? null : n[Math.floor(pc.math.random(0, n.length))]
    },
    getComplexNoMatchColor: function(o, r, e, l) {
        for (var n = [], t = 0; t &lt; this.maxColors; t += 1) {
            var a = null === o || this.colorAppearOrder[t] !== o.colorID,
                i = null === r || this.colorAppearOrder[t] !== r.colorID,
                c = !twoTheSameAbove || a,
                s = !twoTheSameLeft || i;
            c &amp;&amp; s &amp;&amp; n.push(this.colorAppearOrder[t])
        }
        return 0 === n.length ? null : n[Math.floor(pc.math.random(0, n.length))]
    }
});
var PickerFramebuffer = pc.createScript("pickerFramebuffer");
PickerFramebuffer.attributes.add("layerName", {
    type: "string",
    default: "World"
}), pc.extend(PickerFramebuffer.prototype, {
    initialize: function() {
        pc.pickerFrameBuffer = this, this.picker = new pc.Picker(this.app, 1024, 1024), this._layer = this.app.scene.layers.getLayerByName(this.layerName), this._position = new pc.Vec2, this._inputEnabled = !0, PlayerData.instance.inputBetweenGames = !1, this._selectedEntity = null, this._isTileInput = !1
    },
    _onMouseDown: function(t) {
        this._position.set(t.x, t.y), this._selectedEntity = this._onSelect("start"), this.checkTileInput(), this._checkEntitySelect(this._selectedEntity)
    },
    _onMouseMove: function(t) {
        this.app.mouse.isPressed(pc.MOUSEBUTTON_LEFT) &amp;&amp; (this._position.set(t.x, t.y), this._isTileInput &amp;&amp; (this._selectedEntity = this._onSelect(), this._checkEntitySelect(this._selectedEntity)))
    },
    _onMouseUp: function(t) {
        this._position.set(t.x, t.y);
        var e = this._onSelect();
        this._checkEntitySelect(e), this._isTileInput = !1, this.app.fire("SwapMode:inputStopped", !1)
    },
    _onTouchStart: function(t) {
        var e = t.touches[0];
        this._position.set(e.x || e.clientX, e.y || e.clientY), this._selectedEntity = this._onSelect("start"), this.checkTileInput(), this._checkEntitySelect(this._selectedEntity)
    },
    _onTouchMove: function(t) {
        var e = t.touches[0];
        this._position.set(e.x || e.clientX, e.y || e.clientY), this._isTileInput &amp;&amp; (this._selectedEntity = this._onSelect(), this._checkEntitySelect(this._selectedEntity))
    },
    _onTouchEnd: function(t) {
        var e = this._onSelect();
        this._checkEntitySelect(e), this._isTileInput = !1, this.app.fire("SwapMode:inputStopped", !1)
    },
    _checkEntitySelect: function(t) {
        t &amp;&amp; this._selectedEntity &amp;&amp; this._inputEnabled &amp;&amp; PlayerData.instance.inputBetweenGames &amp;&amp; t === this._selectedEntity &amp;&amp; t.script &amp;&amp; t.script.tile &amp;&amp; GameManager.instance.onSelect(t.script.tile), this._selectedEntity = null
    },
    _onSelect: function(t) {
        var e = this.app.graphicsDevice.canvas,
            i = parseInt(e.clientWidth, 10),
            n = parseInt(e.clientHeight, 10),
            s = this.entity.camera,
            c = this.app.scene,
            h = this.picker;
        h.prepare(s, c, this._layer);
        var a = h.getSelection(Math.floor(this._position.x * (h.width / i)), Math.floor(this._position.y * (h.height / n)));
        if (a.length &gt; 0 &amp;&amp; void 0 !== a[0]) {
            for (var l = a[0].node; !(l instanceof pc.Entity) &amp;&amp; null !== l;) l = l.parent;
            if ("start" === t &amp;&amp; (this._isTileInput = !0), l) {
                for (; l &amp;&amp; !l.tags.has("tile");) l = l.parent;
                if (l &amp;&amp; l.script &amp;&amp; l.script.tile) return l
            }
        }
        return null
    },
    checkTileInput: function() {
        this._selectedEntity ? this._isTileInput = this._selectedEntity.tags.has("tile") || this._selectedEntity.tags.has("tileChild") : this._isTileInput = !1
    },
    isTileInput: function() {
        return this._isTileInput
    },
    setInputEnabled: function(t) {
        this._inputEnabled = t
    },
    setInputBetweenGamesEnabled: function(t) {
        PlayerData.instance.inputBetweenGames = t
    }
});
GridManager = pc.createScript("gridManager"), GridManager.attributes.add("tileOffset", {
    type: "number"
}), GridManager.attributes.add("shape", {
    type: "number",
    enum: [{
        circle: 0
    }, {
        heart: 1
    }, {
        flat: 2
    }]
}), GridManager.attributes.add("cellWidth", {
    type: "number",
    default: 1
}), GridManager.attributes.add("cellHeight", {
    type: "number",
    default: 1
}), GridManager.attributes.add("objectPoolEntity", {
    type: "entity"
}), GridManager.attributes.add("focusPoint", {
    type: "entity"
}), GridManager.attributes.add("camera", {
    type: "entity"
}), GridManager.attributes.add("centerShape", {
    type: "entity"
}), GridManager.attributes.add("startFallDuration", {
    type: "number",
    default: .3
}), GridManager.attributes.add("fallDurationPerCell", {
    type: "number",
    default: .1
}), GridManager.attributes.add("despawnDuration", {
    type: "number",
    default: .3
}), GridManager.attributes.add("moveDuration", {
    type: "number",
    default: .3
}), GridManager.attributes.add("powerTileCreationDuration", {
    type: "number",
    default: .6
}), GridManager.attributes.add("scoreDistance", {
    type: "number"
}), GridManager.attributes.add("hintDelay", {
    type: "number"
}), GridManager.attributes.add("shuffleDuration", {
    type: "number",
    default: 1
}), GridManager.attributes.add("tutorialHand", {
    type: "entity"
}), pc.extend(GridManager.prototype, {
    initialize: function() {
        GridManager.instance = this, this.columns = 0, this.rows = 0, this.skipSpawnShine = !1, this.scorePool = TilePrefabManager.instance.getObjectPool("ScoreTextObjectPool"), this.particlePool = TilePrefabManager.instance.getObjectPool("ParticleObjectPool"), this._active = !1, this._dropperAmount = 0, this._droppers = [], this._viruses = [], this._virusHit = !1, this.nViruses = 0, this._exits = [], this._spawnPoints = [], this._canSpawnDropper = !1, this._maxDropperAmount = 0, this._tempVec3 = new pc.Vec3, this.app.on("SwapMode:onCascadeDone", this.startHintCountdown, this), this.app.on("SwapMode:onPlayerMove", this.stopHint, this), this.app.on("SwapMode:onTileMatch", this.explodeTiles, this), this.app.on("ObjectiveManager:onObjectiveAdd", this._onObjectAdd, this), this._sfxPlayed = [], this.powerTileArray = [], this.tutorialHand.enabled = !1, this.on("destroy", this._onDestroy, this), this.app.on("WorldSelection:switchScene", this._onSwitchScene, this)
    },
    _onSwitchScene: function() {
        this.despawnAllInstant()
    },
    _onObjectAdd: function(t) {
        t.orderTypeObject.layerID === tileLayerEnum.FOREGROUND &amp;&amp; t.orderTypeObject.typeID === foregroundTileEnum.DROPPER &amp;&amp; (this._dropperAmount = t.values.goal - this._droppers.length, this._maxDropperAmount = this._droppers.length || 1, 0 === this._droppers.length &amp;&amp; this.setAbleToSpawnDropper(!0))
    },
    _onDestroy: function() {
        this.app.off("SwapMode:onCascadeDone", this.startHintCountdown, this), this.app.off("SwapMode:onPlayerMove", this.stopHint, this), this.app.off("SwapMode:onTileMatch", this.explodeTiles, this)
    },
    postInitialize: function() {},
    active: function(t) {
        this._active = t
    },
    playSFX: function(t) {
        LevelManager.instance.playing &amp;&amp; -1 === this._sfxPlayed.indexOf(t) &amp;&amp; (this._sfxPlayed.push(t), this.app.fire("Audio:sfx", t))
    },
    resetSFX: function() {
        this._sfxPlayed.length = 0
    },
    update: function(t) {
        if (this.resetSFX(), !TutorialManager.instance.active &amp;&amp; this._active) {
            if (this._waitingForHint &amp;&amp; (this._hintCountdown += t, this._hintCountdown &gt; this.hintDelay)) {
                var e = MatchLogic.getAllPossibleMatches();
                this.setHintMatch(e), this.showHint()
            }
            this.shuffling &amp;&amp; (this._shuffleTimer += t, this._shuffleTimer &gt; this.shuffleDuration &amp;&amp; this._onShuffleEnd())
        }
    },
    _setFocusPoint: function() {},
    setAbleToSpawnDropper: function(t) {
        this._canSpawnDropper = t
    },
    spawnLevel: function(t, e, r) {
        t &amp;&amp; (this.columns = t), e &amp;&amp; (this.rows = e), this._hasDropperCollection = !1, this._tileArrayForeground = pc.utils.multiDimensionArray([this.columns, this.rows]), this._tileArrayBackground = pc.utils.multiDimensionArray([this.columns, this.rows]), this._spawnOvershoot = new Array(this.columns).fill(0), this._exits.length = 0, this._spawnPoints.length = 0, this._dropperAmount = 0, this._droppers.length = 0, this._viruses.length = 0, this._virusHit = !1, this._canSpawnDropper = !1, this._maxDropperAmount = 0, MatchLogic.setGridSize(this.columns, this.rows), this._calculateShapeSize(), this._spawnTiles(r), this._setFocusPoint(), this.stopHint(), this.startHintCountdown(), this._predefinedTiles = r, BackgroundMeshHandler.instance.generateMesh(this._tileArrayBackground), BackgroundBorderHandler.instance.generateMesh(this._tileArrayBackground), MatchLogic.setGrid(this._tileArrayForeground, this._tileArrayBackground, this._exits), DropperExitManager.instance.setExits(this._exits, this._droppers.length &gt; 0 || this._hasDropperCollection), PerspectiveView.instance.setAABB(BackgroundBorderHandler.instance.getAABB()), this.checkAllPossibleMatches(!0)
    },
    removeDropper: function(t) {
        var e = this._droppers.indexOf(t.entity); - 1 !== e ? this._droppers.splice(e, 1) : console.warn("Something went wrong", t, this._droppers)
    },
    _spawnTiles: function(t) {
        for (var e = 0; e &lt; t.length; e += 1) {
            var r = t[e];
            r.setExit &amp;&amp; this._exits.push({
                x: r.x,
                y: r.y
            }), r.setSpawnPoint &amp;&amp; this._spawnPoints.push({
                x: r.x,
                y: r.y
            });
            var i = r.setBackground,
                n = null;
            if (n = null !== TileLibrary.instance.getOriginalTypeID(tileLayerEnum.BACKGROUND, i.background) ? this._spawnBackgroundTile(i.background, r.x, r.y, 0, i.layers) : this._spawnBackgroundTile(backgroundTileEnum.EMPTY, r.x, r.y, 0, 1), this._tileArrayBackground[r.x][r.y] = n, this._tileArrayBackground[r.x][r.y].hasForeground) {
                var o = r.setForeground,
                    a = TileLibrary.instance.getOriginalTypeID(tileLayerEnum.FOREGROUND, o.foreground),
                    s = null;
                null !== a ? (s = this._spawnForegroundTile(r.x, r.y, !0, 0, ColorManager.instance.getColorInOrder(o.color), a, !0, 0, !1)).setPredefined() : s = this._spawnForegroundTile(r.x, r.y, !0, 0, null, foregroundTileEnum.DEFAULT, !0, 0, !1), this._tileArrayForeground[r.x][r.y] = s
            }
        }
        this.app.fire("GridManager:onLevelSpawn")
    },
    _spawnBackgroundTile: function(t, e, r, i, n) {
        i = i || 0;
        var o, a = TileLibrary.instance.getObject(tileLayerEnum.BACKGROUND, t);
        return t === backgroundTileEnum.VIRUS &amp;&amp; (this._viruses.push(a.script.backgroundTile), this.nViruses = this._viruses.length), null === a &amp;&amp; (a = TileLibrary.instance.getObject(tileLayerEnum.BACKGROUND, backgroundTileEnum.EMPTY)), o = this.calculatePosition(e, r + i, .1), a.enabled = !0, a.script.backgroundTile.awake(o, this, n), a.script.backgroundTile.setProperties(e, r), a.script.backgroundTile
    },
    _spawnForegroundTile: function(t, e, r, i, n, o, a, s, l) {
        i = i || 0, s = s || 0, l = l || !1;
        var h = e - 1 &gt;= 0 ? this._tileArrayForeground[t][e - 1] : null,
            u = t - 1 &gt;= 0 ? this._tileArrayForeground[t - 1][e] : null,
            c = e - 2 &gt;= 0 ? this._tileArrayForeground[t][e - 2] : null,
            d = t - 2 &gt;= 0 ? this._tileArrayForeground[t - 2][e] : null,
            g = e + 1 &lt; this.rows ? this._tileArrayForeground[t][e + 1] : null,
            p = t + 1 &lt; this.columns ? this._tileArrayForeground[t + 1][e] : null;
        null === p &amp;&amp; (p = this._tileArrayForeground[0][e]), n !== tileColorEnum.NONE &amp;&amp; null !== n || (n = r ? ColorManager.instance.getRandomColorNoMatch(h, u, c, d, g, p) : ColorManager.instance.getRandomColor()), void 0 === o &amp;&amp; (o = backgroundTileEnum.EMPTY);
        var f = TileLibrary.instance.getObject(tileLayerEnum.FOREGROUND, o, n);
        null === f &amp;&amp; (f = TileLibrary.instance.getObject(tileLayerEnum.FOREGROUND, foregroundTileEnum.DEFAULT, n)), f.enabled = !0, o === foregroundTileEnum.DROPPER &amp;&amp; this._droppers.push(f), o === foregroundTileEnum.DROPPER_COLLECTION &amp;&amp; (this._hasDropperCollection = !0);
        var y = this.calculatePosition(t, e + i, .2);
        return f.script.foregroundTile.awake(y, this), f.script.foregroundTile.setProperties(t, e), a &amp;&amp; f.script.foregroundTile.spawnAnimation(void 0, s, l), f.script.foregroundTile
    },
    intersectsRay: function(t, e) {
        if ((this.columns || this.rows) &amp;&amp; this._tileArrayForeground) {
            for (var r = [], i = 0; i &lt; this.columns; i++)
                for (var n = 0; n &lt; this.rows; n++) this._tileArrayForeground[i][n] &amp;&amp; this._tileArrayForeground[i][n].intersectsRay(t) &amp;&amp; r.push(this._tileArrayForeground[i][n]);
            if (0 === r.length) return null;
            if (1 === r.length) return r[0];
            for (var o = Number.POSITIVE_INFINITY, a = null, s = 0; s &lt; r.length; s++) {
                var l = r[s],
                    h = l.entity.getPosition(),
                    u = e.x - h.x,
                    c = e.y - h.y,
                    d = e.z - h.z;
                u * u + c * c + d * d &lt; o &amp;&amp; (a = l)
            }
            return a
        }
    },
    getTile: function(t, e) {
        t &lt; 0 &amp;&amp; (t += this._tileArrayForeground.length), t &gt;= this._tileArrayForeground.length &amp;&amp; (t -= this._tileArrayForeground.length);
        this._tileArrayForeground[t];
        return this._tileArrayForeground[t][e]
    },
    getBackgroundTile: function(t, e) {
        return t &lt; 0 || t &gt; this.columns - 1 ? null : this._tileArrayBackground[t][e]
    },
    calculatePosition: function(t, e, r) {
        switch (this.shape) {
            case 0:
                var i = 360 / this.columns * t * Math.PI / 180,
                    n = Math.sin(i) * r,
                    o = Math.cos(i) * r,
                    a = this.height / this.rows * e;
                return new pc.Vec3(n, a, o);
            case 1:
                var s = t / this.columns * 2 * Math.PI;
                n = r * Math.pow(Math.sin(s), 3), o = 13 * r / 16 * Math.cos(s) - 5 * r / 16 * Math.cos(2 * s) - 2 * r / 16 * Math.cos(3 * s) - r / 16 * Math.cos(4 * s), a = this.height / this.rows * e;
                return new pc.Vec3(n, a, o);
            case 2:
                return new pc.Vec3((t - this.columns / 2 + .5) * this.cellWidth, (e - this.rows / 2 + .5) * this.cellHeight, r)
        }
    },
    _despawnTile: function(t, e) {
        this._tileArrayForeground[t][e] &amp;&amp; !this._tileArrayForeground[t][e].isActive() &amp;&amp; (this._tileArrayForeground[t][e] = null)
    },
    explodeTiles: function(t) {
        for (var e = 0; e &lt; t.length; e++)
            if (t[e].isActive()) {
                var r = t[e].explode(),
                    i = t[e].getDespawnDelay();
                this.explodeBackground(t[e].x, t[e].y, i, r), r &amp;&amp; (t[e].updateFlowerStatistics(), this._despawnTile(t[e].x, t[e].y))
            }
    },
    explodeBackground: function(t, e, r, i) {
        var n = this._tileArrayBackground[t][e];
        n.explodeMethod === BackgroundTile.ExplodeMethodEnum.EXPLODES_IF_HIT &amp;&amp; n.explode(r);
        for (var o = MatchLogic.getNeighbours(n, null, tileLayerEnum.BACKGROUND), a = 0; a &lt; o.length; a++) o[a].explodeMethod === BackgroundTile.ExplodeMethodEnum.EXPLODES_IF_ADJACENT &amp;&amp; i &amp;&amp; o[a].explode(r)
    },
    removeAllDestroyedBackgroundTiles: function() {
        for (var t = !1, e = 0; e &lt; this.columns; e++)
            for (var r = 0; r &lt; this.rows; r++) {
                var i = this._tileArrayBackground[e][r];
                i.isDestroyed ? (this._tileArrayBackground[e][r] = this._spawnBackgroundTile(backgroundTileEnum.EMPTY, e, r), t = !0) : i.hasExploded = !1
            }
        return t
    },
    applyGravityToTiles: function(t) {
        var e = 0;
        this._spawnOvershoot.fill(0);
        for (this.removeAllDestroyedBackgroundTiles();;) {
            var r = this._applyGravityVertical(),
                i = this.spawnNewTiles(t),
                n = this._applyGravityDiagonal();
            if (e = Math.max(e, i, r, n), !(r || i || n)) break
        }
        return e
    },
    _applyGravityVertical: function() {
        for (var t = 0, e = 0, r = 0; r &lt; this._tileArrayForeground.length; r++)
            for (var i = 0, n = 0; n &lt; this._tileArrayForeground[0].length; n++)
                if (this._tileArrayForeground[r][n]) {
                    if (i &gt; 0) {
                        if (!this._tileArrayBackground[r][n].hasGravity) {
                            i = 0;
                            continue
                        }
                        if (i &lt;= 0) {
                            console.error("Fall index", "Something went wrong!", this._tileArrayForeground[r][n]);
                            continue
                        }
                        n - i === n &amp;&amp; console.error("Fall index", "Something went wrong!", this._tileArrayForeground[r][n]);
                        var o = this._tileArrayForeground[r][n].applyGravity(r, n, r, n - i, i * this.fallDurationPerCell);
                        this._tileArrayForeground[r][n - i] = this._tileArrayForeground[r][n], this._tileArrayForeground[r][n] = null, t = Math.max(t, o)
                    }
                } else {
                    if (!this._tileArrayBackground[r][n].hasForeground || !this._tileArrayBackground[r][n].hasGravity) {
                        i = 0;
                        continue
                    }
                    e &lt; (i += 1) &amp;&amp; (e = i)
                }
        return t
    },
    _applyGravityDiagonal: function() {
        for (var t = 0, e = this._tileArrayForeground.length - 1; e &gt;= 0; e--)
            for (var r = this._tileArrayForeground[0].length - 2; r &gt;= 0; r--)
                if (!this._tileArrayForeground[e][r] &amp;&amp; this._tileArrayBackground[e][r].hasForeground &amp;&amp; this._tileArrayBackground[e][r].hasGravity &amp;&amp; !this._isAnyForegroundTileAbove(e, r)) {
                    if (this._tileArrayForeground[e + 1] &amp;&amp; this._tileArrayForeground[e + 1][r + 1] &amp;&amp; this._tileArrayBackground[e + 1][r + 1].hasGravity) {
                        if (!this._tileArrayForeground[e + 1][r] &amp;&amp; this._tileArrayBackground[e + 1][r].hasForeground) continue;
                        var i = this._tileArrayForeground[e + 1][r + 1],
                            n = this.fallDiagonal(i, e, r, 1, 1);
                        t = Math.max(n, t);
                        continue
                    }
                    if (this._tileArrayForeground[e - 1] &amp;&amp; this._tileArrayForeground[e - 1][r + 1] &amp;&amp; this._tileArrayBackground[e - 1][r + 1].hasGravity) {
                        if (!this._tileArrayForeground[e - 1][r] &amp;&amp; this._tileArrayBackground[e - 1][r].hasForeground &amp;&amp; this._tileArrayBackground[e - 1][r].hasGravity) continue;
                        i = this._tileArrayForeground[e - 1][r + 1], n = this.fallDiagonal(i, e, r, -1, 1);
                        t = Math.max(n, t);
                        continue
                    }
                }
        return t
    },
    _isAnyForegroundTileAbove: function(t, e) {
        for (;;) {
            if (++e &gt;= this.rows) return !0;
            if (!this._tileArrayBackground[t][e].hasForeground || !this._tileArrayBackground[t][e].hasGravity) return !1;
            if (this._tileArrayForeground[t][e]) return !0
        }
    },
    spawnNewTiles: function(t) {
        var e = -1;
        if (this._canSpawnDropper &amp;&amp; this._dropperAmount &gt; 0 &amp;&amp; this._droppers.length &lt; this._maxDropperAmount) {
            for (var r = 0, i = 0; i &lt; this._spawnPoints.length; i++) {
                var n = this._spawnPoints[i];
                (p = this.getTile(n.x, n.y)) || this.getBackgroundTile(n.x, n.y).hasForeground &amp;&amp; this.getBackgroundTile(n.x, n.y).hasGravity &amp;&amp; r++
            }
            r &gt; 0 &amp;&amp; (e = Math.floor(Math.random() * r))
        }
        for (var o = 0, a = 0, s = 0; s &lt; this.columns; s++)
            for (var l = 0; l &lt; this.rows; l++)
                if (!this._tileArrayForeground[s][l] &amp;&amp; this._tileArrayBackground[s][l].hasForeground &amp;&amp; this._tileArrayBackground[s][l].hasGravity) {
                    var h = this.isColumnFree(s, l);
                    if (h.free) {
                        var u = this._spawnOvershoot[s]++,
                            c = h.y,
                            d = l,
                            g = c - d,
                            p = null,
                            f = u * this.fallDurationPerCell;
                        this.isSpawnPoint(s, l) ? (a === e ? (this._dropperAmount--, this.setAbleToSpawnDropper(!1), p = this._spawnForegroundTile(s, l, !1, g, tileColorEnum.NONE, foregroundTileEnum.DROPPER, !0, f, !1)) : p = this._spawnForegroundTile(s, l, t, g, null, null, !0, f, !1), a++) : p = this._spawnForegroundTile(s, l, t, g, null, null, !0, f, !1), p.appear(s, c, (c - d) * this.fallDurationPerCell, f), o &lt; g &amp;&amp; (o = g), this._tileArrayForeground[s][l] = p
                    }
                }
        return 0 === o ? 0 : o * this.fallDurationPerCell + .5
    },
    fallDiagonal: function(t, e, r, i, n) {
        return 0 === i &amp;&amp; 0 === n &amp;&amp; console.error("Something went wrong!", t, e, r, i, n), this._tileArrayForeground[e][r] = t, this._tileArrayForeground[e + i][r + n] = null, t.applyGravity(e + i, r + n, e, r, this.fallDurationPerCell)
    },
    isSpawnPoint: function(t, e) {
        for (var r = 0; r &lt; this._spawnPoints.length; r++) {
            var i = this._spawnPoints[r];
            if (i.x === t &amp;&amp; i.y === e) return !0
        }
        return !1
    },
    isColumnFree: function(t, e) {
        var r = e,
            i = this._spawnPoints.filter((function(e) {
                return t === e.x
            }));
        if (0 === i.length) return {
            free: !1
        };
        for (;;) {
            if (r &gt;= this.rows) return {
                free: !1
            };
            if (!this._tileArrayBackground[t][r].hasForeground || !this._tileArrayBackground[t][r].hasGravity) return {
                free: !1
            };
            for (var n = 0; n &lt; i.length; n++)
                if (i[n].y === r) return {
                    free: !0,
                    y: r + 1
                };
            r++
        }
    },
    swapTiles: function(t, e, r) {
        var i = t.x,
            n = t.y;
        t.move(e.x, e.y, this.moveDuration, r), e.move(i, n, this.moveDuration, r), this._tileArrayForeground[t.x][t.y] = t, this._tileArrayForeground[e.x][e.y] = e
    },
    addScoreForEachTileInMatch: function(t) {
        var e = 1;
        t.horizontalMatch.length &gt; 0 &amp;&amp; (e += t.horizontalMatch.length - 1), t.verticalMatch.length &gt; 0 &amp;&amp; (e += t.verticalMatch.length - 1), this.app.fire("ScoreManager:onTileMatch", e, t.matchTile)
    },
    _getDuplicateInCascadeMatches: function(t, e) {
        for (var r = 0; r &lt; t.length; r++)
            for (var i = t[r].horizontalMatch, n = 0; n &lt; i.length; n++)
                if (-1 !== e.indexOf(i[n])) return {
                    matchID: r,
                    tileID: n
                };
        return null
    },
    setTileConvergencePoint: function(t, e, r, i) {
        for (var n = 0; n &lt; r.length; n += 1) this.canExplode(r[n].x, r[n].y) &amp;&amp; r[n].setDespawnEndPosition(t, e);
        for (var o = 0; o &lt; i.length; o += 1) this.canExplode(i[o].x, i[o].y) &amp;&amp; i[o].setDespawnEndPosition(t, e)
    },
    spawnPowerTiles: function() {
        for (var t = 0; t &lt; this.powerTileArray.length; t++) {
            var e = this._spawnForegroundTile(this.powerTileArray[t].x, this.powerTileArray[t].y, !0, 0, this.powerTileArray[t].colorID, this.powerTileArray[t].typeID, !0, 0, !0);
            e.isMovedTile = !0;
            var r = this._tileArrayForeground[this.powerTileArray[t].x][this.powerTileArray[t].y];
            r &amp;&amp; r.despawn(), this._tileArrayForeground[this.powerTileArray[t].x][this.powerTileArray[t].y] = e
        }
        this.powerTileArray.length = 0
    },
    _calculateShapeSize: function(t, e) {
        var r = 1,
            i = 1,
            n = .9;
        switch (this.shape) {
            case 0:
            case 1:
                r = n * this.rows + (this.rows - 1) * this.tileOffset, i = (n * this.columns + this.columns * this.tileOffset) / (2 * Math.PI)
        }
        this.height = r, this.radius = i
    },
    despawnAll: function() {
        if (this._tileArrayForeground &amp;&amp; 0 !== this._tileArrayForeground.length) {
            for (var t = 0; t &lt; this._tileArrayForeground.length; t++) {
                for (var e = 0; e &lt; this._tileArrayForeground[t].length; e++) {
                    var r = this.getTile(t, e);
                    r &amp;&amp; this._despawnForegroundTile(r)
                }
                this._tileArrayForeground[t].length = 0
            }
            MatchLogic.removeGrid(), BackgroundMeshHandler.instance.reset(), BackgroundBorderHandler.instance.reset(), DropperExitManager.instance.removeExits(), this._despawnAllBackgroundTiles(), this.app.fire("GridManager:onDespawn")
        }
    },
    _despawnForegroundTile: function(t) {
        t instanceof ForegroundTile ? (t.stopAllTweens(), t.despawn(), this._despawnTile(t.x, t.y)) : console.warn("This is not a foreground tile")
    },
    despawnAllInstant: function() {
        for (var t = 0; t &lt; this._tileArrayForeground.length; t++)
            for (var e = 0; e &lt; this._tileArrayForeground[t].length; e++) this._tileArrayForeground[t][e] &amp;&amp; (this._tileArrayForeground[t][e].despawnInstant(), this.recycleTile(this._tileArrayForeground[t][e].entity));
        this._tileArrayForeground.length = 0, MatchLogic.removeGrid(), DropperExitManager.instance.removeExits(), this._despawnAllBackgroundTiles()
    },
    _despawnBackgroundTile: function(t) {
        var e = this._tileArrayBackground[t.x][t.y];
        e.despawnInstant(), e.entity.enabled = !1, e.entity.reparent(null), TileLibrary.instance.returnObject(e.entity, tileLayerEnum.BACKGROUND, e.typeID, e.colorID), this._tileArrayBackground[t.x][t.y] = null
    },
    _despawnAllBackgroundTiles: function() {
        for (var t = 0; t &lt; this._tileArrayBackground.length; t++)
            for (var e = 0; e &lt; this._tileArrayBackground[t].length; e++) {
                var r = this._tileArrayBackground[t][e];
                r &amp;&amp; this._despawnBackgroundTile(r)
            }
    },
    _getMovedTiles: function() {
        for (var t = [], e = 0; e &lt; this._tileArrayForeground.length; e++)
            for (var r = 0; r &lt; this._tileArrayForeground[e].length; r++) this._tileArrayForeground[e][r].isMovedTile &amp;&amp; (t.push(this._tileArrayForeground[e][r]), this._tileArrayForeground[e][r].isMovedTile = !1);
        return t
    },
    getLongestTileDespawnDuration: function() {
        for (var t = 0, e = 0; e &lt; this._tileArrayForeground.length; e++)
            for (var r = 0; r &lt; this._tileArrayForeground[e].length; r++) {
                if (this._tileArrayForeground[e][r])(i = this._tileArrayForeground[e][r].getDespawnDelay()) &gt; t &amp;&amp; (t = i)
            }
        for (e = 0; e &lt; this._tileArrayBackground.length; e++)
            for (r = 0; r &lt; this._tileArrayBackground[e].length; r++) {
                var i;
                if (this._tileArrayBackground[e][r])(i = this._tileArrayBackground[e][r].getDespawnDelay()) &gt; t &amp;&amp; (t = i)
            }
        return this.powerTileArray.length &gt; 0 &amp;&amp; (t += this.powerTileCreationDuration), t
    },
    cheatPowerTile: function(t, e, r) {
        var i = this.getTile(t, e).entity.script.powerTileHandler;
        i.switchTilePower(r), i.setTileState(i.tileStates.ACTIVE)
    },
    showScore: function(t, e) {
        if (LevelManager.instance.playing) {
            var r = this.scorePool.use();
            r.enabled = !0;
            var i = this.calculatePosition(t.x, t.y, this.radius + this.scoreDistance),
                n = t.hasColor || t.customScoreColor &amp;&amp; t.scoreColorId ? t.scoreColorId : null,
                o = t.hasColor || t.customScoreColor &amp;&amp; t.scoreOutlineColorId ? t.scoreOutlineColorId : null;
            if (t.typeID === foregroundTileEnum.COLORBOMB) {
                var a = t.colorBombCause;
                n = a &amp;&amp; (a.hasColor || a.customScoreColor) &amp;&amp; a.scoreColorId ? a.scoreColorId : null, o = a &amp;&amp; (a.hasColor || a.customScoreColor) &amp;&amp; a.scoreOutlineColorId ? a.scoreOutlineColorId : null, t.colorBombCause = null
            }
            r.script.hoverScore.awake(e, i, this.entity, t.y, n, o)
        }
    },
    recycleScore: function(t) {
        t.enabled = !1, t.reparent(null), this.scorePool.recycle(t)
    },
    showParticle: function(t, e, r, i) {
        var n = this.particlePool.use();
        n.enabled = !0;
        var o = new pc.Vec3(90, 0, 0),
            a = this.calculatePosition(t, e, this.radius);
        n.script.particleHandler.awake(a, o, this.entity, r, i)
    },
    recycleParticle: function(t) {
        t.enabled = !1, t.reparent(null), this.particlePool.recycle(t)
    },
    startHintCountdown: function() {
        null !== this.hintMatch &amp;&amp; (this._hintCountdown = 0, this._waitingForHint = !0, TutorialManager.instance.active &amp;&amp; (this._hintCountdown = this.hintDelay))
    },
    setHintMatch: function(t) {
        var e, r = {};
        this.hintMatch = t[Math.floor(Math.random() * t.length)];
        for (var i = 0; i &lt; t.length; i++) this._isFullyColorless(t[i].matchTiles) || (5 === t[i].matchTiles.length &amp;&amp; this._checkIfMatchOnTheSameAxis(t[i].matchTiles) ? (r.colorBomb || (r.colorBomb = [], e = "colorBomb"), r.colorBomb.push(t[i])) : (r[t[i].matchTiles.length] || (r[t[i].matchTiles.length] = [], (!e || t[i].matchTiles.length &gt; e) &amp;&amp; (e = t[i].matchTiles.length)), r[t[i].matchTiles.length].push(t[i])));
        if (3 === e) {
            var n;
            for (i = 0; i &lt; r[e].length; i++)
                for (var o = 0; o &lt; r[e][i].matchTiles.length; o++) !r[e][i].matchTiles[o].isPowerTile() || n &amp;&amp; !PowerTileManager.instance.isPowerStronger(r[e][i].matchTiles[o], n) || (n = r[e][i]);
            this.hintMatch = n || r[e][Math.floor(Math.random() * r[e].length)]
        } else 0 === Object.keys(r).length ? this.hintMatch = null : (console.log(r), this.hintMatch = r[e][Math.floor(Math.random() * r[e].length)])
    },
    _isFullyColorless: function(t) {
        for (var e = 1; e &lt; t.length; e++)
            if (t[e].colorID !== tileColorEnum.NONE) return !1;
        return !0
    },
    _checkIfMatchOnTheSameAxis: function(t) {
        for (var e = 1, r = 1, i = 1; i &lt; t.length; i++) t[i].x === t[0].x &amp;&amp; e++, t[i].y === t[0].y &amp;&amp; r++;
        return e == t.length - 1 || r == t.length - 1
    },
    getMovableSwitchTile: function() {
        for (var t = 0; t &lt; this.hintMatch.matchTiles.length; t++)
            for (var e = 0; e &lt; this.hintMatch.switchTiles.length; e++)
                if (this.hintMatch.matchTiles[t] === this.hintMatch.switchTiles[e]) return this.hintMatch.switchTiles[e]
    },
    showHint: function() {
        if (this.backgroundTile = null, this._waitingForHint = !1, this.hintMatch) {
            this.showHintMove();
            for (var t = 0; t &lt; this.hintMatch.matchTiles.length; t += 1) this.hintMatch.matchTiles[t].doHintAnimation(), this.backgroundTile = this.getBackgroundTile(this.hintMatch.matchTiles[t].x, this.hintMatch.matchTiles[t].y), this.backgroundTile &amp;&amp; this.backgroundTile.doHintAnimation()
        }
    },
    showHintMove: function() {
        for (var t = this.getMovableSwitchTile(), e = 0; e &lt; this.hintMatch.switchTiles.length; e++) t !== this.hintMatch.switchTiles[e] &amp;&amp; t.makeHintMoveAnimation(t.x - this.hintMatch.switchTiles[e].x, t.y - this.hintMatch.switchTiles[e].y)
    },
    stopHint: function() {
        this._waitingForHint = !1;
        for (var t = 0; t &lt; this._tileArrayForeground.length; t++)
            for (var e = 0; e &lt; this._tileArrayForeground[t].length; e++) this._tileArrayForeground[t][e] &amp;&amp; (this._tileArrayForeground[t][e].stopHintAnimation(), this.backgroundTile = this.getBackgroundTile(t, e), this.backgroundTile &amp;&amp; this.backgroundTile.stopHintAnimation())
    },
    setTileDespawnDelay: function(t) {
        for (var e = 0; e &lt; t.length; e += 1) t[e].setDespawnDelay(0)
    },
    getAllPowerTiles: function() {
        for (var t = [], e = 0; e &lt; this._tileArrayForeground.length; e++)
            for (var r = 0; r &lt; this._tileArrayForeground[e].length; r++) this._tileArrayForeground[e][r] &amp;&amp; this._tileArrayForeground[e][r].isPowerTile() &amp;&amp; t.push(this._tileArrayForeground[e][r]);
        return t
    },
    shuffle: function(t, e, r) {
        try {
            for (var i = [], n = 0; n &lt; this.columns; n++)
                for (var o = 0; o &lt; this.rows; o++) {
                    var a = this._tileArrayForeground[n][o];
                    if (a) {
                        if (a.isPredefined()) continue;
                        if (a.isMovedTile = !0, t) {
                            if (!a.isFlower() &amp;&amp; !a.isPowerTile()) continue
                        } else if (!a.isFlower()) continue;
                        if (!a.isSwappable()) continue;
                        i.push(a)
                    }
                }
            for (this._shuffleTileArray(i);;) {
                if (0 === (l = MatchLogic.getCascadeMatches(3, !0)).length) break;
                for (var s = 0; s &lt; l.length; s++) this._shuffleTile(l[s], i)
            }
            var l;
            if (0 === (l = MatchLogic.getAllPossibleMatches()).length) return r &gt; 30 ? (this.app.fire("UIManager:hideAll"), void this.app.fire("UIManager:showUI", "Lose")) : void this.shuffle(!0, e, ++r);
            for (var h = 0; h &lt; i.length; h++) {
                var u = i[h];
                e || u.stopAllTweens(), u.move(u.x, u.y, e ? .001 : 1)
            }
            this.stopHint(), e || (this.shuffling = !0, this._shuffleTimer = 0, this.app.fire("GridManager:onShuffleStart"))
        } catch (t) {
            this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "Lose")
        }
    },
    _shuffleTile: function(t, e) {
        var r = t,
            i = e[Math.floor(Math.random() * e.length)];
        if (r.isFlower() &amp;&amp; r.isSwappable() &amp;&amp; i.isSwappable()) {
            var n = r.x,
                o = r.y,
                a = i.x,
                s = i.y;
            this._tileArrayForeground[n][o] = i, this._tileArrayForeground[a][s] = r, r.x = a, r.y = s, i.x = n, i.y = o, r.isMovedTile = !0, i.isMovedTile = !0
        }
    },
    _shuffleTileArray: function(t) {
        for (var e = t.length - 1; e &gt; 0; e--) {
            var r = Math.floor(Math.random() * (e + 1)),
                i = t[e],
                n = t[r],
                o = i.x,
                a = i.y,
                s = n.x,
                l = n.y;
            this._tileArrayForeground[o][a] = n, this._tileArrayForeground[s][l] = i, i.x = s, i.y = l, n.x = o, n.y = a
        }
    },
    _onShuffleEnd: function() {
        this.app.fire("GridManager:onShuffleEnd"), this.shuffling = !1, this.startHintCountdown()
    },
    _shuffleRefill: function() {
        for (var t = 0; t &lt; this._tileArrayForeground.length; t++)
            for (var e = 0; e &lt; this._tileArrayForeground[t].length; e++) {
                this._tileArrayForeground[t][e];
                if (null === this._tileArrayForeground[t][e]) {
                    var r = this._spawnForegroundTile(t, e, !0, 0, null, void 0, !0, 0, !1);
                    this._tileArrayForeground[t][e] = r
                }
            }
    },
    checkAllPossibleMatches: function(t) {
        SwapMode.instance.startedEnd || (MatchLogic.getAllPossibleMatches().length &gt; 0 || this.shuffle(!1, t, 0))
    },
    getForegroundTilesOfType: function(t, e, r) {
        for (var i = [], n = 0, o = 0; o &lt; this.columns; o++)
            for (var a = 0; a &lt; this.rows; a++) {
                var s = this._tileArrayForeground[o][a];
                if (s)
                    if (Array.isArray(t)) t.includes(s.typeID) &amp;&amp; i.push(s);
                    else if (s.typeID == t) {
                    var l = MatchLogic.getAmountOfNeighbours(s, r);
                    if (l &gt; n &amp;&amp; (n = l), l &lt; e) continue;
                    i.push(s)
                }
            }
        return 0 === i.length ? this.getForegroundTilesOfType(t, n) : i
    },
    showTutorialHint: function(t) {
        this.hintMatch = {
            matchTiles: t
        }, this.showHint()
    },
    showTutorialMatch: function(t) {
        for (var e = MatchLogic.getAllPossibleMatches(), r = 0; r &lt; e.length; r++) {
            var i = e[r],
                n = -1 !== t.indexOf(i.switchTiles[0]),
                o = -1 !== t.indexOf(i.switchTiles[1]);
            if (n &amp;&amp; o &amp;&amp; -1 !== i.matchTiles.indexOf(t[0])) return this.hintMatch = i, void this.showHint()
        }
    },
    calculateAngle: function(t, e, r, i) {
        var n = t - r,
            o = e - i;
        return -1 * (180 * Math.atan2(o, n) / Math.PI) + 90
    },
    resetDespawnDelay: function() {
        for (var t = 0; t &lt; this.columns; t++)
            for (var e = 0; e &lt; this.rows; e++) {
                this._tileArrayForeground[t][e] instanceof ForegroundTile &amp;&amp; (this._tileArrayForeground[t][e].despawnDelay = 0)
            }
    },
    canExplode: function(t, e) {
        return !this.getBackgroundTile(t, e).onlyBackgroundExplodes
    },
    onVirusDespawn: function(t) {
        var e = this._viruses.indexOf(t); - 1 !== e ? this._viruses.splice(e, 1) : console.warn("No virus has been found", t, this._viruses)
    },
    onVirusHit: function() {
        this._virusHit = !0, this.nViruses--
    },
    expandVirus: function() {
        var t = [];
        if (!this._virusHit &amp;&amp; this._viruses.length &gt; 0) {
            for (var e = 0; e &lt; this._viruses.length; e++)
                for (var r = this._viruses[e], i = MatchLogic.getNeighbours(r, null, tileLayerEnum.FOREGROUND, !0), n = 0; n &lt; i.length; n++) {
                    var o = i[n];
                    o instanceof ForegroundTile || "number" != typeof o.x ? (o.isFlower() || o.isPowerTile()) &amp;&amp; this.getBackgroundTile(o.x, o.y).isDefault() &amp;&amp; t.push({
                        virus: r,
                        neighbour: o
                    }) : this.getBackgroundTile(o.x, o.y).isDefault() &amp;&amp; t.push({
                        virus: r,
                        neighbour: o
                    })
                }
            if (t.length &gt; 0) {
                var a = t[Math.floor(Math.random() * t.length)],
                    s = a.neighbour instanceof ForegroundTile,
                    l = a.neighbour.x,
                    h = a.neighbour.y;
                s &amp;&amp; (this._despawnForegroundTile(a.neighbour), a.neighbour.ignoreDespawnStats()), a.virus.playAnimation("virus_angry.glb"), this._despawnBackgroundTile(this.getBackgroundTile(l, h)), (r = this._spawnBackgroundTile(backgroundTileEnum.VIRUS, l, h, 0, 1)).playAnimation("virus_spawn.glb"), r.playAnimation("virus_angry.glb"), ObjectiveManager.instance.increaseVirusObjective(), this._tileArrayBackground[l][h] = r, this.playSFX("virus_multiply.mp3")
            }
        }
        this._virusHit = !1
    }
});
var BoosterManager = pc.createScript("boosterManager"),
    boosterEnum = Object.freeze({
        FREESWAP: 0,
        BREAKER: 1,
        CROSSBOMB: 2
    }),
    preGameBoosters = Object.freeze({
        LINECLEAR: [foregroundTileEnum.LINE_H, foregroundTileEnum.LINE_V],
        COLORBOMB: foregroundTileEnum.COLORBOMB,
        BOMB: foregroundTileEnum.BOMB
    });
BoosterManager.attributes.add("preBoostDelay", {
    type: "number",
    default: .3
}), BoosterManager.attributes.add("shovelAnimationPool", {
    type: "entity"
}), BoosterManager.attributes.add("freeswapAnimationPool", {
    type: "entity"
}), BoosterManager.attributes.add("crossbombAnimationPool", {
    type: "entity"
}), BoosterManager.attributes.add("preboosterAnimationTime", {
    type: "number",
    default: 2
}), pc.extend(BoosterManager.prototype, {
    initialize: function() {
        for (var e in BoosterManager.instance = this, this.crossBombBehaviour = new CrossBombBehaviour, this.preGameBoosterQueue = [], this._boostersActive = {}, boosterEnum) this._boostersActive[boosterEnum[e]] = !1;
        this.preboosterAnimationLibrary = Object.freeze({
            [foregroundTileEnum.LINE_H]: powerAnimationTypes.LINES,
            [foregroundTileEnum.LINE_V]: powerAnimationTypes.LINES,
            [foregroundTileEnum.BOMB]: powerAnimationTypes.BOMB,
            [foregroundTileEnum.COLORBOMB]: powerAnimationTypes.COLORBOMB
        }), this.shovelPool = this.shovelAnimationPool.script.objectPool, this.handPool = this.freeswapAnimationPool.script.objectPool, this.crossBombPool = this.crossbombAnimationPool.script.objectPool, this.freeSwapAnimationDelay = .3
    },
    addPreBoosterToQueue: function(e, t) {
        if (Array.isArray(e))
            for (i = 1; i &lt;= t; i++) this.preGameBoosterQueue.push({
                typeID: e[i % e.length],
                amount: 1
            });
        else this.preGameBoosterQueue.push({
            typeID: e,
            amount: t
        })
    },
    reset: function() {
        for (var e = 0; e &lt; this.preGameBoosterQueue.length; e++) {
            var t = this.preGameBoosterQueue[e];
            switch (t.typeID) {
                case preGameBoosters.LINECLEAR[0]:
                    Inventory.instance.addItem("PREBOOSTER_1");
                    break;
                case preGameBoosters.BOMB:
                    Inventory.instance.addItem("PREBOOSTER_2");
                    break;
                case preGameBoosters.COLORBOMB:
                    Inventory.instance.addItem("PREBOOSTER_3");
                    break;
                default:
                    console.warn(t.typeID, "not found")
            }
        }
        this.preGameBoosterQueue.length = 0
    },
    spawnPreGameBoosters: function() {
        for (var e = GridManager.instance.getForegroundTilesOfType(foregroundTileEnum.DEFAULT, 3, !0); this.preGameBoosterQueue.length &gt; 0;)
            for (var t = this.preGameBoosterQueue.pop(), o = 0; o &lt; t.amount; o++) {
                0 === e.length &amp;&amp; (e = GridManager.instance.getForegroundTilesOfType(foregroundTileEnum.DEFAULT, 2, !0));
                var i = e.length * Math.random() | 0,
                    a = e[i];
                e.splice(i, 1);
                var n = PowerTileManager.instance.switchTilePower(a, t.typeID, this.preboosterAnimationTime);
                PowerTileManager.instance.setTileState(n, ForegroundTile._PowerStates.ACTIVE);
                var r = a.x,
                    s = a.y,
                    c = GridManager.instance.calculateAngle(r, s, 0, 0);
                a.shakeTile(), a.enlargeTile();
                var u = this.preboosterAnimationLibrary[t.typeID];
                PowerAnimationManager.instance.preboosterSpawnAnimation(new pc.Vec2(0, 0), this.preboosterAnimationTime, 0 === r, r &lt; 0, r, s, c, Math.max(Math.abs(0 - r), Math.abs(0 - s)), a.colorID, a, u)
            }
        GridManager.instance.checkAllPossibleMatches(), GridManager.instance.startHintCountdown()
    },
    doFreeSwap: function() {
        this._boostersActive[boosterEnum.FREESWAP] = !1, GridManager.instance.stopHint(), this.app.fire("BoosterManager:confirmedBooster", boosterEnum.FREESWAP)
    },
    doBreaker: function(e) {
        if (!e.canExplode) return !1;
        this.app.fire("SwapMode:onPlayerMove"), this.app.fire("Audio:sfx", "shovel_dig.mp3");
        var t = [];
        e.setDespawnDelay(1), PowerTileManager.instance.isPowerTile(e.typeID) &amp;&amp; (t = PowerTileManager.instance.activatePower(e), t = MatchLogic.getChainedPowerTileMatches(t)), t.push(e);
        var o = GridManager.instance.getLongestTileDespawnDuration();
        return SwapMode.instance.setState(matchStates.DESPAWN, o), this.app.fire("SwapMode:onTileMatch", t), this.app.fire("BoosterManager:confirmedBooster", boosterEnum.BREAKER), this._boostersActive[boosterEnum.BREAKER] = !1, this.doBreakerAnimation(e.x, e.y), !0
    },
    doCrossBomb: function(e) {
        if (!e.canExplode) return !1;
        this.app.fire("SwapMode:onPlayerMove");
        var t = this.crossBombBehaviour.getAffectedTiles(e);
        this.crossBombBehaviour.doActivateAnimation(e), t = MatchLogic.getChainedPowerTileMatches(t);
        var o = GridManager.instance.getLongestTileDespawnDuration();
        return SwapMode.instance.setState(matchStates.DESPAWN, o), t.push(e), this.app.fire("SwapMode:onTileMatch", t), this.app.fire("Audio:sfx", "beehive_hit.mp3"), this.app.fire("BoosterManager:confirmedBooster", boosterEnum.CROSSBOMB), this.doCrossBombAnimation(e.x, e.y), this._boostersActive[boosterEnum.CROSSBOMB] = !1, !0
    },
    isBoosterActive: function(e) {
        return this._boostersActive[e]
    },
    activateBooster: function(e) {
        this._boostersActive[e] = !0
    },
    cancelBooster: function(e) {
        this._boostersActive[e] = !1
    },
    doBreakerAnimation: function(e, t) {
        var o = this.shovelPool.use();
        o.enabled = !0, o.reparent(GridManager.instance.entity);
        var i = GridManager.instance.calculatePosition(e, t, 0);
        o.setPosition(i.x, i.y, i.z), o.animation.play("shovel_dig.glb", 0), setTimeout(function() {
            this.shovelPool.recycle(o)
        }.bind(this), 1500)
    },
    doFreeSwapAnimation: function(e, t) {
        var o = this.handPool.use();
        o.enabled = !0, o.reparent(GridManager.instance.entity);
        var i = GridManager.instance.calculatePosition(e.x, e.y, .5);
        o.setPosition(i.x, i.y, i.z), o.animation.play("freeswap_hand_grab.glb", 0);
        var a = GridManager.instance.calculatePosition(t.x, t.y, i.z);
        o.tween(o.getLocalPosition()).to({
            x: a.x,
            y: a.y,
            z: a.z
        }, GridManager.instance.moveDuration, pc.QuadraticInOut, this.freeSwapAnimationDelay).start();
        setTimeout(function() {
            this.handPool.recycle(o)
        }.bind(this), 1500)
    },
    doCrossBombAnimation: function(e, t) {
        var o = this.crossBombPool.use();
        o.enabled = !0, o.reparent(GridManager.instance.entity);
        var i = GridManager.instance.calculatePosition(e, t, 0);
        o.setPosition(i.x, i.y, i.z), o.animation.play("beehiveabimnew.glb", 0), setTimeout(function() {
            this.crossBombPool.recycle(o)
        }.bind(this), 1500)
    }
});
var LineHBehaviour = function() {
    this.initialize()
};
LineHBehaviour.duration = new pc.Vec2(0, .1), pc.extend(LineHBehaviour.prototype, {
    initialize: function() {
        this.combinationBehaviourScripts = Object.freeze({
            [foregroundTileEnum.LINE_H]: new LineCrossBehaviour,
            [foregroundTileEnum.LINE_V]: new LineCrossBehaviour,
            [foregroundTileEnum.COLORBOMB]: new LineColorBombBehaviour,
            [foregroundTileEnum.BOMB]: new LineBombHBehaviour
        }), this.app = pc.Application.getApplication(), this.gridOvershoot = 2
    },
    getAffectedTiles: function(e) {
        for (var i = [], n = 0; n &lt; MatchLogic.columns; n += 1) {
            var o = GridManager.instance.getBackgroundTile(n, e.y),
                a = Math.abs(n - e.x);
            if (o.canExplode() &amp;&amp; o.explode(PowerTileManager.instance.calculateDespawnDelay(a, LineHBehaviour.duration.x, LineHBehaviour.duration.y) + e.getDespawnDelay()), !o.onlyBackgroundExplodes) {
                var r = GridManager.instance.getTile(n, e.y);
                r &amp;&amp; r.canExplode &amp;&amp; (r.isHitByPower() || (i.push(r), r.setHitByPower(), r.typeID !== foregroundTileEnum.NONE &amp;&amp; r.typeID !== foregroundTileEnum.DEFAULT &amp;&amp; r.setDespawnCause(foregroundTileEnum.LINE_H), PowerTileManager.instance.setTileDespawnDelay(e, r, a, LineHBehaviour.duration.x, LineHBehaviour.duration.y), ImpulseManager.applyPulse(r.x, r.y, 1, .3, .05 + r.despawnDelay, .2)))
            }
        }
        return i
    },
    getCombinationScript: function(e) {
        var i = this.combinationBehaviourScripts[e];
        return i || null
    },
    doActivateAnimation: function(e) {
        var i = 0 - this.gridOvershoot,
            n = MatchLogic.columns - 1 + this.gridOvershoot;
        GridManager.instance.playSFX("line_flowers.mp3"), PowerAnimationManager.instance.createLineAnimation(e, LineHBehaviour.duration, !1, !0, i, e.y, 270, e.colorID), PowerAnimationManager.instance.createLineAnimation(e, LineHBehaviour.duration, !1, !1, n, e.y, 90, e.colorID)
    }
});
var LineVBehaviour = function() {
    this.initialize()
};
LineVBehaviour.duration = new pc.Vec2(0, .1), pc.extend(LineVBehaviour.prototype, {
    initialize: function() {
        this.combinationBehaviourScripts = Object.freeze({
            [foregroundTileEnum.LINE_H]: new LineCrossBehaviour,
            [foregroundTileEnum.LINE_V]: new LineCrossBehaviour,
            [foregroundTileEnum.COLORBOMB]: new LineColorBombBehaviour,
            [foregroundTileEnum.BOMB]: new LineBombVBehaviour
        }), this.app = pc.Application.getApplication(), this.gridOvershoot = 2
    },
    getAffectedTiles: function(e) {
        for (var i = [], n = 0; n &lt; MatchLogic.rows; n += 1) {
            var o = GridManager.instance.getBackgroundTile(e.x, n),
                a = Math.abs(n - e.y);
            if (o.canExplode() &amp;&amp; o.explode(PowerTileManager.instance.calculateDespawnDelay(a, LineVBehaviour.duration.x, LineVBehaviour.duration.y) + e.getDespawnDelay()), !o.onlyBackgroundExplodes) {
                var r = GridManager.instance.getTile(e.x, n);
                r &amp;&amp; r.canExplode &amp;&amp; (r.isHitByPower() || (i.push(r), r.setHitByPower(), r.typeID !== foregroundTileEnum.NONE &amp;&amp; r.typeID !== foregroundTileEnum.DEFAULT &amp;&amp; r.setDespawnCause(foregroundTileEnum.LINE_V), PowerTileManager.instance.setTileDespawnDelay(e, r, a, LineVBehaviour.duration.x, LineVBehaviour.duration.y), ImpulseManager.applyPulse(r.x, r.y, 1, .3, .05 + r.despawnDelay, .2)))
            }
        }
        return i
    },
    getCombinationScript: function(e) {
        var i = this.combinationBehaviourScripts[e];
        return i || null
    },
    doActivateAnimation: function(e) {
        var i = 0 - this.gridOvershoot,
            n = MatchLogic.rows - 1 + this.gridOvershoot;
        PowerAnimationManager.instance.createLineAnimation(e, LineVBehaviour.duration, !0, !0, e.x, i, 180, e.colorID), PowerAnimationManager.instance.createLineAnimation(e, LineVBehaviour.duration, !0, !0, e.x, n, 0, e.colorID), GridManager.instance.playSFX("line_flowers.mp3")
    }
});
var BombBehaviour = function() {
    this.initialize()
};
BombBehaviour.duration = new pc.Vec2(0, .2), pc.extend(BombBehaviour.prototype, {
    initialize: function() {
        this.combinationBehaviourScripts = Object.freeze({
            [foregroundTileEnum.LINE_H]: new LineBombHBehaviour,
            [foregroundTileEnum.LINE_V]: new LineBombVBehaviour,
            [foregroundTileEnum.COLORBOMB]: new BombColorBombBehaviour,
            [foregroundTileEnum.BOMB]: new BigBombBehaviour
        }), this.app = pc.Application.getApplication(), this.duration = new pc.Vec2(0, 0)
    },
    getAffectedTiles: function(a) {
        for (var e = [], i = a.x - 2; i &lt;= a.x + 2; i += 1) {
            var n = 2;
            i !== a.x - 2 &amp;&amp; i !== a.x + 2 || (n = 1);
            for (var o = a.y - n; o &lt;= a.y + n; o += 1)
                if (!(i &lt; 0) &amp;&amp; !(i &gt;= MatchLogic.columns) &amp;&amp; o &gt;= 0 &amp;&amp; o &lt; MatchLogic.rows) {
                    var t = GridManager.instance.getBackgroundTile(i, o),
                        r = Math.abs(a.x - i),
                        u = Math.abs(a.y - o);
                    if (t.canExplode() &amp;&amp; t.explode(PowerTileManager.instance.calculateDespawnDelay(Math.max(r, u), BombBehaviour.duration.x, BombBehaviour.duration.y) + a.getDespawnDelay()), t.onlyBackgroundExplodes) continue;
                    var c = GridManager.instance.getTile(i, o);
                    if (!c) continue;
                    if (!c.canExplode) continue;
                    if (c.isHitByPower()) continue;
                    e.push(c), c.setHitByPower(), c.typeID !== foregroundTileEnum.NONE &amp;&amp; c.typeID !== foregroundTileEnum.DEFAULT &amp;&amp; c.setDespawnCause(foregroundTileEnum.BOMB), PowerTileManager.instance.setTileDespawnDelay(a, c, Math.max(r, u), BombBehaviour.duration.x, BombBehaviour.duration.y)
                }
        }
        return ImpulseManager.applyPulse(a.x, a.y, 5, 1, .05 + a.despawnDelay, .2), e
    },
    getCombinationScript: function(a) {
        var e = this.combinationBehaviourScripts[a];
        return e || null
    },
    doActivateAnimation: function(a) {
        var e = !0;
        GridManager.instance.playSFX("bomb_detonate_flowers.mp3");
        for (var i = a.x - 2; i &lt;= a.x + 2; i += 1) {
            var n = 2;
            i !== a.x - 2 &amp;&amp; i !== a.x + 2 || (n = 1);
            for (var o = a.y - n; o &lt;= a.y + n; o += 1)
                if (!(o &gt; a.y - n &amp;&amp; o &lt; a.y + n &amp;&amp; i !== a.x - 2 &amp;&amp; i !== a.x + 2)) {
                    var t = i,
                        r = o,
                        u = this.calculateAngle(i, o, a.x, a.y);
                    this.duration.set(BombBehaviour.duration.x / Math.max(Math.abs(a.x - t), Math.abs(a.y - r)) * 2, BombBehaviour.duration.y / Math.max(Math.abs(a.x - t), Math.abs(a.y - r)) * 2), PowerAnimationManager.instance.createBombAnimation(a, this.duration, t === a.x, t &lt; a.x, t, r, u, Math.max(Math.abs(a.x - t), Math.abs(a.y - r)), a.colorID, e), e = !1
                }
        }
    },
    calculateAngle: function(a, e, i, n) {
        var o = a - i,
            t = e - n;
        return -1 * (180 * Math.atan2(t, o) / Math.PI) + 90
    }
});
var ColorBombBehaviour = function() {
    this.initialize()
};
ColorBombBehaviour.duration = new pc.Vec2(0, 2), pc.extend(ColorBombBehaviour.prototype, {
    initialize: function() {
        this.combinationBehaviourScripts = Object.freeze({
            [foregroundTileEnum.LINE_H]: new LineColorBombBehaviour,
            [foregroundTileEnum.LINE_V]: new LineColorBombBehaviour,
            [foregroundTileEnum.COLORBOMB]: new UltimateColorBombBehaviour,
            [foregroundTileEnum.BOMB]: new BombColorBombBehaviour
        }), this.app = pc.Application.getApplication()
    },
    getAffectedTiles: function(o, e) {
        var i = null;
        if (e) {
            if ((i = e.colorID) === tileColorEnum.NONE) return [];
            o.colorBombCause = e
        } else i = ColorManager.instance.getColorMostInGrid();
        for (var r = [], a = MatchLogic.rows - 1; a &gt;= 0; a -= 1)
            for (var n = 0; n &lt; MatchLogic.columns; n += 1) {
                var t = GridManager.instance.getTile(n, a);
                t &amp;&amp; (t.canExplode &amp;&amp; (t.isHitByPower() || t.colorID !== i || t.isHitByPower() || (r.push(t), t.setHitByPower(), o.colorBombCause || (o.colorBombCause = t), PowerTileManager.instance.setTileDespawnDelay(o, t, 1, ColorBombBehaviour.duration.x, ColorBombBehaviour.duration.y))))
            }
        return r.push(o), o.setDespawnCause(foregroundTileEnum.COLORBOMB), PowerTileManager.instance.setTileDespawnDelay(o, o, 0, ColorBombBehaviour.duration.x, ColorBombBehaviour.duration.y), r
    },
    getCombinationScript: function(o) {
        var e = this.combinationBehaviourScripts[o];
        return e || null
    },
    doActivateAnimation: function(o, e) {
        for (var i = 0; i &lt; e.length; i++) {
            var r = e[i].x,
                a = e[i].y,
                n = GridManager.instance.calculateAngle(r, a, o.x, o.y);
            if (r !== o.x || a !== o.y) {
                PowerAnimationManager.instance.createColorBombParticleAnimation(o, ColorBombBehaviour.duration.y, r === o.x, r &lt; o.x, r, a, n, Math.max(Math.abs(o.x - r), Math.abs(o.y - a)), o.colorID, e[i], powerAnimationTypes.COLORBOMB), e[i].shakeTile();
                var t = GridManager.instance.getBackgroundTile(e[i].x, e[i].y);
                t &amp;&amp; t.shakeTile(), e[i].enlargeTile()
            }
        }
        PowerAnimationManager.instance.createColorBombAnimation(o, ColorBombBehaviour.duration.y), GridManager.instance.playSFX("colorbomb_flowers.mp3")
    }
});
var ScoreManager = pc.createScript("scoreManager");
pc.extend(ScoreManager.prototype, {
    initialize: function() {
        ScoreManager.instance = this, this._score = 0, this._levelScore = 0, this._cascadeValue = 1, this._cascadeIncrease = 1, this._threeTileMatchScore = 60, this._fourTileMatchScore = 120, this._fiveTileMatchScore = 200, this._powerTilePoints = 60, this._createdEndPowerTilePoints = 3e3, this._backgroundDefaultPoints = 20, this._backgroundObjectivePoints = 100, this._foregroundObjectivePoints = 100, this._foregroundSpecialPoints = 1e4, this._foregroundExploderPoints = 3e3, this.app.on("SwapMode:onCascadeNext", this._increaseCascadeValue, this), this.app.on("SwapMode:onCascadeDone", this._resetCascadeValue, this), this.app.on("ScoreManager:onTileMatch", this._tileMatchScore, this), this.app.on("ScoreManager:scoreEachPowerTile", this._addDestroyedPowerTilePoints, this), this.app.on("ScoreManager:scoreBackgroundTile", this._scoreBackgroundTile, this), this.app.on("ScoreManager:scoreForegroundTile", this._scoreForegroundTile, this), this.app.on("ScoreManager:scoreEndModeCreatePower", this._scoreEndModeCreatePower, this), this.app.on("LevelManager:onLevelStart", this._resetScore, this), this.app.on("LevelManager:levelComplete", this._onGameFinish, this)
    },
    _addToScore: function(e) {
        this._score += e, this._levelScore += e, this.app.fire("ScoreManager:setScore", this._score)
    },
    _tileMatchScore: function(e, t) {
        3 === e ? this._threeTileMatch(t) : 4 === e ? this._fourTileMatch(t) : e &gt;= 5 &amp;&amp; this._overFiveMatch(t)
    },
    _threeTileMatch: function(e) {
        var t = this._threeTileMatchScore * this._cascadeValue;
        e.setScoreAfterDelay(t), this._addToScore(t)
    },
    _fourTileMatch: function(e) {
        var t = this._fourTileMatchScore * this._cascadeValue;
        e.setScoreAfterDelay(t), this._addToScore(t)
    },
    _overFiveMatch: function(e) {
        var t = this._fiveTileMatchScore * this._cascadeValue;
        e.setScoreAfterDelay(t), this._addToScore(t)
    },
    _addDestroyedPowerTilePoints: function(e) {
        for (var t = this._powerTilePoints * e.length, r = 0; r &lt; e.length; r += 1) {
            var s = e[r];
            e[r].setScoreAfterDelay(this._powerTilePoints), GridManager.instance.canExplode(s.x, s.y) || (t -= this._powerTilePoints, console.log(this._powerTilePoints, s.x, s.y))
        }
        this._addToScore(t)
    },
    _scoreEndModeCreatePower: function(e) {
        var t = this._createdEndPowerTilePoints;
        e.setScoreAfterDelay(t), this._addToScore(t)
    },
    _scoreBackgroundTile: function(e, t, r) {
        var s = 0;
        s = t ? this._backgroundObjectivePoints : this._backgroundDefaultPoints, r.setScoreAfterDelay(s), this._addToScore(s)
    },
    _scoreForegroundTile: function(e, t, r) {
        var s = 0;
        switch (e) {
            case foregroundTileEnum.EXPLODER:
                s = this._foregroundExploderPoints;
                break;
            case foregroundTileEnum.DROPPER || foregroundTileEnum.SWITCHER:
                s = this._foregroundSpecialPoints;
                break;
            case foregroundTileEnum.DEFAULT:
                s = t ? this._foregroundObjectivePoints : 0
        }
        0 !== s &amp;&amp; (r.setScoreAfterDelay(s), this._addToScore(s))
    },
    _increaseCascadeValue: function() {
        this._cascadeValue += this._cascadeIncrease, TrackingManager.instance.updateScore()
    },
    _resetCascadeValue: function() {
        this._cascadeValue = 1
    },
    _onGameFinish: function() {},
    _resetScore: function() {
        this._score = 0, this.resetLevelScore(), this.app.fire("ScoreManager:setScore", this._score)
    },
    resetLevelScore: function() {
        this._levelScore = 0
    },
    getCurrentLevelScore: function() {
        return this._levelScore
    },
    getScore: function() {
        return this._score
    },
    getStars: function() {
        var e = 1;
        return this._score &gt;= this.star3Value ? e = 3 : this._score &gt;= this.star2Value ? e = 2 : this._score &gt;= this.star1Value &amp;&amp; (e = 1), e
    },
    setStarValues: function(e) {
        this.star3Value = e[2], this.star2Value = e[1], this.star1Value = e[0], this.app.fire("ScoreManager:setStarValues", this.star1Value, this.star2Value, this.star3Value)
    },
    cheatStars: function(e) {
        e || (e = 1), this._score = 3 === e ? this.star3Value : 2 === e ? this.star2Value : this.star1Value, this.app.fire("ScoreManager:setScore", this._score)
    }
});
var LineCrossBehaviour = function() {
    this.initialize()
};
LineCrossBehaviour.duration = new pc.Vec2(1.2, .15), pc.extend(LineCrossBehaviour.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication()
    },
    getAffectedTiles: function(e, n) {
        for (var a, i = [], o = 0; o &lt; MatchLogic.columns; o += 1) {
            var r = GridManager.instance.getBackgroundTile(o, e.y),
                t = Math.abs(o - e.x);
            r.canExplode() &amp;&amp; r.explode(PowerTileManager.instance.calculateDespawnDelay(t, LineCrossBehaviour.duration.x, LineCrossBehaviour.duration.y)), r.onlyBackgroundExplodes || (a = GridManager.instance.getTile(o, e.y)) &amp;&amp; a !== e &amp;&amp; a !== n &amp;&amp; a.canExplode &amp;&amp; (a.isHitByPower() || (i.push(a), a.setDespawnCause(foregroundTileEnum.LINE_H), PowerTileManager.instance.setTileDespawnDelay(e, a, t, LineCrossBehaviour.duration.x, LineCrossBehaviour.duration.y), ImpulseManager.applyPulse(a.x, a.y, 1, .3, .05 + a.despawnDelay, .2)))
        }
        for (var s = 0; s &lt; MatchLogic.rows; s += 1) {
            r = GridManager.instance.getBackgroundTile(e.x, s);
            var u = Math.abs(s - e.y);
            r.canExplode() &amp;&amp; r.explode(PowerTileManager.instance.calculateDespawnDelay(u, LineCrossBehaviour.duration.x, LineCrossBehaviour.duration.y)), r.onlyBackgroundExplodes || (a = GridManager.instance.getTile(e.x, s)) &amp;&amp; a !== e &amp;&amp; a !== n &amp;&amp; a.canExplode &amp;&amp; (i.push(a), a.setHitByPower(), a.setDespawnCause(foregroundTileEnum.LINE_V), PowerTileManager.instance.setTileDespawnDelay(e, a, u, LineCrossBehaviour.duration.x, LineCrossBehaviour.duration.y), ImpulseManager.applyPulse(a.x, a.y, 1, .3, .05 + a.despawnDelay, .2))
        }
        return i.push(e, n), e.setHitByPower(), n.setHitByPower(), i
    },
    doActivateAnimation: function(e, n, a) {
        PowerAnimationManager.instance.createPowerCombinationAnimation(e, a, LineCrossBehaviour.duration.x, this.onFuseAnimDone.bind(this))
    },
    onFuseAnimDone: function(e, n) {
        this.app.fire("ShakeCamera:shake", LineCrossBehaviour.duration.x), PowerAnimationManager.instance.createLineAnimation(e, LineCrossBehaviour.duration, !0, !0, e.x, 0, 180, e.colorID), PowerAnimationManager.instance.createLineAnimation(e, LineCrossBehaviour.duration, !0, !0, e.x, MatchLogic.rows - 1, 0, e.colorID), PowerAnimationManager.instance.createLineAnimation(e, LineCrossBehaviour.duration, !1, !0, 0, e.y, 270, n.colorID), PowerAnimationManager.instance.createLineAnimation(e, LineCrossBehaviour.duration, !1, !1, MatchLogic.columns - 1, e.y, 90, n.colorID), GridManager.instance.playSFX("line_flowers.mp3")
    }
});
var LineBombVBehaviour = function() {
    this.initialize()
};
LineBombVBehaviour.duration = new pc.Vec2(1.2, .07), pc.extend(LineBombVBehaviour.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication(), this.gridOvershoot = 2
    },
    getAffectedTiles: function(i, e) {
        for (var n = [], a = i.x - 1; a &lt;= i.x + 1; a += 1)
            for (var o = 0; o &lt; MatchLogic.rows; o += 1)
                if (!(a &lt; 0 || a &gt;= MatchLogic.columns)) {
                    var r = GridManager.instance.getBackgroundTile(a, o);
                    if (r.canExplode() &amp;&amp; r.explode(PowerTileManager.instance.calculateDespawnDelay(Math.abs(o - i.y), LineBombVBehaviour.duration.x, LineBombVBehaviour.duration.y)), !r.onlyBackgroundExplodes) {
                        var t = GridManager.instance.getTile(a, o);
                        t &amp;&amp; t !== i &amp;&amp; t !== e &amp;&amp; t.canExplode &amp;&amp; (t.isHitByPower() || (n.push(t), t.setHitByPower(), t.typeID !== foregroundTileEnum.NONE &amp;&amp; t.typeID !== foregroundTileEnum.DEFAULT &amp;&amp; t.setDespawnCause(foregroundTileEnum.LINE_V), PowerTileManager.instance.setTileDespawnDelay(i, t, Math.abs(o - i.y), LineBombVBehaviour.duration.x, LineBombVBehaviour.duration.y), ImpulseManager.applyPulse(t.x, t.y, 1, .3, .05 + t.despawnDelay, .2)))
                    }
                }
        return n.push(i, e), i.setHitByPower(), e.setHitByPower(), n
    },
    doActivateAnimation: function(i, e, n) {
        PowerAnimationManager.instance.createPowerCombinationAnimation(i, n, LineBombVBehaviour.duration.x, this.onFuseAnimDone.bind(this))
    },
    onFuseAnimDone: function(i, e) {
        var n, a = 0 - this.gridOvershoot,
            o = MatchLogic.rows - 1 + this.gridOvershoot;
        PowerAnimationManager.instance.createLineAnimation(i, LineBombHBehaviour.duration, !0, !0, i.x, a, 180, i.colorID), PowerAnimationManager.instance.createLineAnimation(i, LineBombHBehaviour.duration, !0, !0, i.x, o, 0, i.colorID), n = -1 * (a - i.x) &gt; o - i.x ? Math.abs(a - i.x) * LineBombHBehaviour.duration.y : Math.abs(o - i.x) * LineBombHBehaviour.duration.y, this.app.fire("ShakeCamera:shake", n), PowerAnimationManager.instance.createLineAnimation(i, LineBombVBehaviour.duration, !0, !0, i.x, a, 180, i.colorID), PowerAnimationManager.instance.createLineAnimation(i, LineBombVBehaviour.duration, !0, !0, i.x, o, 0, i.colorID);
        var r = i.x - 1;
        r &gt;= 0 &amp;&amp; (PowerAnimationManager.instance.createLineAnimationBomb(i, LineBombVBehaviour.duration, !0, !0, r, a, 180, e.colorID), PowerAnimationManager.instance.createLineAnimationBomb(i, LineBombVBehaviour.duration, !0, !0, r, o, 0, e.colorID));
        var t = i.x + 1;
        t &lt; MatchLogic.columns &amp;&amp; (PowerAnimationManager.instance.createLineAnimationBomb(i, LineBombVBehaviour.duration, !0, !0, t, a, 180, e.colorID), PowerAnimationManager.instance.createLineAnimationBomb(i, LineBombVBehaviour.duration, !0, !0, t, o, 0, e.colorID)), GridManager.instance.playSFX("line_flowers.mp3")
    }
});
var LineBombHBehaviour = function() {
    this.initialize()
};
LineBombHBehaviour.duration = new pc.Vec2(1.2, .07), pc.extend(LineBombHBehaviour.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication(), this.gridOvershoot = 2
    },
    getAffectedTiles: function(i, e) {
        for (var n = [], o = 0; o &lt; MatchLogic.columns; o += 1)
            for (var a = i.y - 1; a &lt;= i.y + 1; a += 1)
                if (a &gt;= 0 &amp;&amp; a &lt; MatchLogic.rows) {
                    var r = GridManager.instance.getBackgroundTile(o, a);
                    if (r.canExplode() &amp;&amp; r.explode(PowerTileManager.instance.calculateDespawnDelay(Math.abs(o - i.x), LineBombHBehaviour.duration.x, LineBombHBehaviour.duration.y)), r.onlyBackgroundExplodes) continue;
                    var t = GridManager.instance.getTile(o, a);
                    if (!t) continue;
                    if (t === i || t === e) continue;
                    if (!t.canExplode) continue;
                    if (t.isHitByPower()) continue;
                    n.push(t), t.setHitByPower(), t.typeID !== foregroundTileEnum.NONE &amp;&amp; t.typeID !== foregroundTileEnum.DEFAULT &amp;&amp; t.setDespawnCause(foregroundTileEnum.LINE_H), PowerTileManager.instance.setTileDespawnDelay(i, t, Math.abs(o - i.x), LineBombHBehaviour.duration.x, LineBombHBehaviour.duration.y), ImpulseManager.applyPulse(t.x, t.y, 1, .3, .05 + t.despawnDelay, .2)
                }
        return n.push(i, e), i.setHitByPower(), e.setHitByPower(), n
    },
    doActivateAnimation: function(i, e, n) {
        PowerAnimationManager.instance.createPowerCombinationAnimation(i, n, LineBombHBehaviour.duration.x, this.onFuseAnimDone.bind(this))
    },
    onFuseAnimDone: function(i, e) {
        var n, o = 0 - this.gridOvershoot,
            a = MatchLogic.columns - 1 + this.gridOvershoot;
        n = -1 * (o - i.x) &gt; a - i.x ? Math.abs(o - i.x) * LineBombHBehaviour.duration.y : Math.abs(a - i.x) * LineBombHBehaviour.duration.y, this.app.fire("ShakeCamera:shake", n), PowerAnimationManager.instance.createLineAnimation(i, LineBombHBehaviour.duration, !1, !0, o, i.y, 270, i.colorID), PowerAnimationManager.instance.createLineAnimation(i, LineBombHBehaviour.duration, !1, !1, a, i.y, 90, i.colorID);
        var r = i.y + 1;
        r &lt; MatchLogic.rows &amp;&amp; (PowerAnimationManager.instance.createLineAnimationBomb(i, LineBombHBehaviour.duration, !1, !0, o, r, 270, e.colorID), PowerAnimationManager.instance.createLineAnimationBomb(i, LineBombHBehaviour.duration, !1, !1, a, r, 90, e.colorID));
        var t = i.y - 1;
        t &gt;= 0 &amp;&amp; (PowerAnimationManager.instance.createLineAnimationBomb(i, LineBombHBehaviour.duration, !1, !0, o, t, 270, e.colorID), PowerAnimationManager.instance.createLineAnimationBomb(i, LineBombHBehaviour.duration, !1, !1, a, t, 90, e.colorID)), GridManager.instance.playSFX("line_flowers.mp3")
    }
});
var BigBombBehaviour = function() {
    this.initialize()
};
BigBombBehaviour.duration = new pc.Vec2(1.2, .07), pc.extend(BigBombBehaviour.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication()
    },
    getAffectedTiles: function(a, i) {
        for (var e = [], n = a.x - 3; n &lt;= a.x + 3; n += 1)
            for (var o = a.y - 3; o &lt;= a.y + 3; o += 1)
                if (!(n &lt; 0) &amp;&amp; !(n &gt;= MatchLogic.columns) &amp;&amp; o &gt;= 0 &amp;&amp; o &lt; MatchLogic.rows) {
                    if ((n === a.x - 3 || n === a.x + 3) &amp;&amp; (o &lt;= a.y - 2 || o &gt;= a.y + 2)) continue;
                    if ((n === a.x - 2 || n === a.x + 2) &amp;&amp; (o &lt;= a.y - 3 || o &gt;= a.y + 3)) continue;
                    var t = GridManager.instance.getBackgroundTile(n, o),
                        r = Math.abs(a.x - n),
                        c = Math.abs(a.y - o);
                    if (t.canExplode() &amp;&amp; t.explode(PowerTileManager.instance.calculateDespawnDelay(Math.max(r, c), BigBombBehaviour.duration.x, BigBombBehaviour.duration.y)), t.onlyBackgroundExplodes) continue;
                    var u = GridManager.instance.getTile(n, o);
                    if (!u) continue;
                    if (u === a || u === i) continue;
                    if (!u.canExplode) continue;
                    if (u.isHitByPower()) continue;
                    e.push(u), u.setHitByPower(), u !== i &amp;&amp; PowerTileManager.instance.setTileDespawnDelay(a, u, Math.max(r, c), BigBombBehaviour.duration.x, BigBombBehaviour.duration.y)
                }
        return ImpulseManager.applyPulse(a.x, a.y, 6, 1, .05 + BigBombBehaviour.duration.x, .2), e.push(a, i), a.setHitByPower(), i.setHitByPower(), e
    },
    doActivateAnimation: function(a, i, e) {
        PowerAnimationManager.instance.createPowerCombinationAnimation(a, e, BigBombBehaviour.duration.x, this.onFuseAnimDone.bind(this))
    },
    onFuseAnimDone: function(a, i) {
        var e = 0,
            n = !0;
        GridManager.instance.playSFX("bomb_detonate_flowers.mp3");
        for (var o = a.x - 3; o &lt;= a.x + 3; o += 1) {
            var t = 3;
            o !== a.x - 2 &amp;&amp; o !== a.x + 2 || (t = 2), o !== a.x - 3 &amp;&amp; o !== a.x + 3 || (t = 1);
            for (var r = a.y - t; r &lt;= a.y + t; r += 1)
                if (!(r &gt; a.y - t &amp;&amp; r &lt; a.y + t &amp;&amp; o !== a.x - 3 &amp;&amp; o !== a.x + 3)) {
                    var c = o,
                        u = r,
                        B = this.calculateAngle(o, r, a.x, a.y),
                        s = e % 2 == 0 ? a.colorID : i.colorID,
                        h = new pc.Vec2(BigBombBehaviour.duration.x / Math.max(Math.abs(a.x - c), Math.abs(a.y - u)) * 3, BigBombBehaviour.duration.y / Math.max(Math.abs(a.x - c), Math.abs(a.y - u)) * 3);
                    PowerAnimationManager.instance.createBombAnimation(a, h, c === a.x, c &lt; a.x, c, u, B, Math.max(Math.abs(a.x - c), Math.abs(a.y - u)), s, n), e += 1, n = !1
                }
        }
        this.app.fire("ShakeCamera:shake", BigBombBehaviour.duration.x)
    },
    calculateAngle: function(a, i, e, n) {
        var o = a - e,
            t = i - n;
        return -1 * (180 * Math.atan2(t, o) / Math.PI) + 90
    }
});
var LineColorBombBehaviour = function() {
    this.initialize()
};
LineColorBombBehaviour.duration = new pc.Vec3(1.2, 2), pc.extend(LineColorBombBehaviour.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication()
    },
    getAffectedTiles: function(e, o, i) {
        var a = [];
        this.tiles = [];
        for (var n = 0; n &lt; MatchLogic.columns; n += 1)
            for (var r = 0; r &lt; MatchLogic.rows; r += 1) {
                var t = GridManager.instance.getBackgroundTile(n, r);
                t.canExplode() &amp;&amp; t.explode(PowerTileManager.instance.calculateDespawnDelay(1, LineColorBombBehaviour.duration.x, LineColorBombBehaviour.duration.y));
                var l = GridManager.instance.getTile(n, r);
                if (l &amp;&amp; (l.canExplode &amp;&amp; l.typeID === foregroundTileEnum.DEFAULT &amp;&amp; !l.isHitByPower() &amp;&amp; l.colorID === i &amp;&amp; l !== o &amp;&amp; l !== e)) {
                    this.tiles.push(l);
                    var s = Math.random() &gt;= .5,
                        u = (s ? Math.abs(n - o.x) : Math.abs(r - o.y), s ? foregroundTileEnum.LINE_H : foregroundTileEnum.LINE_V),
                        c = PowerTileManager.instance.switchTilePower(l, u, LineColorBombBehaviour.duration.x + LineColorBombBehaviour.duration.y);
                    if (PowerTileManager.instance.setTileState(c, ForegroundTile._PowerStates.ACTIVE), t.onlyBackgroundExplodes) continue;
                    a.push(c), c.setHitByPower(), PowerTileManager.instance.setTileDespawnDelay(e, c, 1, LineColorBombBehaviour.duration.x, LineColorBombBehaviour.duration.y)
                }
            }
        return a.push(e, o), e.setHitByPower(), o.setHitByPower(), a
    },
    doActivateAnimation: function(e, o, i) {
        PowerAnimationManager.instance.createPowerCombinationAnimation(e, i, LineColorBombBehaviour.duration.x, this.onFuseAnimDone.bind(this))
    },
    onFuseAnimDone: function(e, o) {
        this.app.fire("ShakeCamera:shake", LineColorBombBehaviour.duration.y);
        for (var i = this.tiles, a = 0; a &lt; i.length; a++) {
            var n = i[a].x,
                r = i[a].y,
                t = GridManager.instance.calculateAngle(n, r, e.x, e.y);
            n === e.x &amp;&amp; r === e.y || (PowerAnimationManager.instance.createColorBombParticleAnimation(e, LineColorBombBehaviour.duration.y, n === e.x, n &lt; e.x, n, r, t, Math.max(Math.abs(e.x - n), Math.abs(e.y - r)), i[a].colorID, i[a], powerAnimationTypes.LINES), i[a].shakeTile(), i[a].enlargeTile())
        }
        GridManager.instance.playSFX("colorbomb_flowers.mp3")
    }
});
var TrackingManager = pc.createScript("trackingManager");
TrackingManager.attributes.add("settings", {
    type: "asset",
    assetType: "json"
}), TrackingManager.attributes.add("delay", {
    type: "number",
    placeholder: "sec",
    default: .05
}), pc.extend(TrackingManager.prototype, {
    initialize: function() {
        TrackingManager.instance = this, this._resetData(), this._settings = this.settings.resource, window.famobi_tracking.init(this._settings.gameTitle, this._settings.preferredUid, this._settings.versionNumber, this._settings.enableLog, this._settings.trackAds), this.app.on("TrackingManager:freeSwap", this._updatePowerUpFreeSwap, this), this.app.on("TrackingManager:breaker", this._updatePowerUpBreaker, this), this.app.on("TrackingManager:crossbomb", this._updatePowerUpCrossbomb, this)
    },
    update: function(t) {
        this._ended || this._update &amp;&amp; (this._timer += t, this._timer &gt; this.delay &amp;&amp; (this._end ? this._levelEnd() : this._levelUpdate(), this._timer = 0, this._update = !1))
    },
    _resetData: function() {
        this._timer = 0, this._update = !1, this._end = !1, this._ended = !0, this._currentData = {}, this._powerUpJSON = {}, this.data = {}
    },
    updateScore: function() {
        this._currentData.score = ScoreManager.instance.getCurrentLevelScore(), this._update = !0
    },
    _updatePowerUpFreeSwap: function() {
        this._powerUpJSON.freeSwap || (this._powerUpJSON.freeSwap = 0), this._currentData.powerups || (this._currentData.powerups = this._powerUpJSON), this._powerUpJSON.freeSwap += 1, this._update = !0
    },
    _updatePowerUpBreaker: function() {
        this._powerUpJSON.breaker || (this._powerUpJSON.breaker = 0), this._currentData.powerups || (this._currentData.powerups = this._powerUpJSON), this._powerUpJSON.breaker += 1, this._update = !0
    },
    _updatePowerUpCrossbomb: function() {
        this._powerUpJSON.crossbomb || (this._powerUpJSON.crossbomb = 0), this._currentData.powerups || (this._currentData.powerups = this._powerUpJSON), this._powerUpJSON.crossbomb += 1, this._update = !0
    },
    _levelUpdate: function() {
        window.famobi_tracking.trackEvent(window.famobi_tracking.EVENTS.LEVEL_UPDATE, this._getCurrentData())
    },
    _levelEnd: function() {
        window.famobi_tracking.trackEvent(window.famobi_tracking.EVENTS.LEVEL_END, this._getCurrentData()), this._ended = !0
    },
    _getCurrentData: function() {
        return JSON.parse(JSON.stringify(this._currentData))
    },
    levelStart: function() {
        this._resetData(), this._ended = !1, this._currentData.level = LevelManager.instance.getCurrentLevelNumber(), window.famobi_tracking.trackEvent(window.famobi_tracking.EVENTS.LEVEL_START, this._getCurrentData())
    },
    levelEnd: function(t) {
        this.updateScore(), this._end = !0, this._update = !0, this._currentData.success = t
    }
});
var BombColorBombBehaviour = function() {
    this.initialize()
};
BombColorBombBehaviour.duration = new pc.Vec2(1.2, 2), pc.extend(BombColorBombBehaviour.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication()
    },
    getAffectedTiles: function(o, e, i) {
        var a = [];
        this.tiles = [];
        for (var n = 0; n &lt; MatchLogic.columns; n += 1)
            for (var r = 0; r &lt; MatchLogic.rows; r += 1) {
                var t = GridManager.instance.getTile(n, r);
                if (t &amp;&amp; t.colorID === i &amp;&amp; t !== e &amp;&amp; t !== o) {
                    var l = GridManager.instance.getBackgroundTile(n, r);
                    if (l.canExplode() &amp;&amp; l.explode(PowerTileManager.instance.calculateDespawnDelay(1, BombColorBombBehaviour.duration.x, BombColorBombBehaviour.duration.y)), !t.canExplode) continue;
                    if (t.typeID !== foregroundTileEnum.DEFAULT) continue;
                    if (t.isHitByPower()) continue;
                    this.tiles.push(t);
                    var c = PowerTileManager.instance.switchTilePower(t, foregroundTileEnum.BOMB, BombColorBombBehaviour.duration.x + 1 * BombColorBombBehaviour.duration.y);
                    if (PowerTileManager.instance.setTileState(c, ForegroundTile._PowerStates.ACTIVE), l.onlyBackgroundExplodes) continue;
                    c.setHitByPower(), a.push(c), PowerTileManager.instance.setTileDespawnDelay(o, c, 1, BombColorBombBehaviour.duration.x, BombColorBombBehaviour.duration.y)
                }
            }
        return a.push(o, e), o.setHitByPower(), e.setHitByPower(), a
    },
    doActivateAnimation: function(o, e, i) {
        PowerAnimationManager.instance.createPowerCombinationAnimation(o, i, BombColorBombBehaviour.duration.x, this.onFuseAnimDone.bind(this))
    },
    onFuseAnimDone: function(o, e) {
        this.app.fire("ShakeCamera:shake", BombColorBombBehaviour.duration.y);
        for (var i = this.tiles, a = 0; a &lt; i.length; a++) {
            var n = i[a].x,
                r = i[a].y,
                t = GridManager.instance.calculateAngle(n, r, o.x, o.y);
            n === o.x &amp;&amp; r === o.y || (PowerAnimationManager.instance.createColorBombParticleAnimation(o, ColorBombBehaviour.duration.y, n === o.x, n &lt; o.x, n, r, t, Math.max(Math.abs(o.x - n), Math.abs(o.y - r)), i[a].colorID, i[a], powerAnimationTypes.BOMB), i[a].shakeTile(), i[a].enlargeTile())
        }
        PowerAnimationManager.instance.createColorBombAnimation(o, ColorBombBehaviour.duration.y), GridManager.instance.playSFX("colorbomb_flowers.mp3")
    }
});
var UltimateColorBombBehaviour = function() {
    this.initialize()
};
UltimateColorBombBehaviour.duration = new pc.Vec2(1.2, .05), pc.extend(UltimateColorBombBehaviour.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication()
    },
    getAffectedTiles: function(e, i) {
        for (var a = [], o = 0, t = MatchLogic.rows - 1; t &gt;= 0; t -= 1)
            for (var n = 0; n &lt; MatchLogic.columns; n += 1) {
                var r = GridManager.instance.getBackgroundTile(n, t);
                if (r.canExplode() &amp;&amp; (r.explode(PowerTileManager.instance.calculateDespawnDelay(o, UltimateColorBombBehaviour.duration.x, UltimateColorBombBehaviour.duration.y)), o += 1), !r.onlyBackgroundExplodes) {
                    var l = GridManager.instance.getTile(n, t);
                    l &amp;&amp; l.canExplode &amp;&amp; (l.isHitByPower() || l !== i &amp;&amp; l !== e &amp;&amp; (a.push(l), l.setHitByPower(), PowerTileManager.instance.setTileDespawnDelay(e, l, o, UltimateColorBombBehaviour.duration.x, UltimateColorBombBehaviour.duration.y), this.lastDespawnDelay = l.getDespawnDelay(), o += 1))
                }
            }
        return a.push(e, i), e.setHitByPower(), i.setHitByPower(), a
    },
    doActivateAnimation: function(e, i, a) {
        PowerAnimationManager.instance.createPowerCombinationAnimation(e, a, UltimateColorBombBehaviour.duration.x, this.onFuseAnimDone.bind(this)), this.affectedTiles = i
    },
    onFuseAnimDone: function(e, i) {
        this.app.fire("ShakeCamera:shake", this.lastDespawnDelay), PowerAnimationManager.instance.createColorBombAnimation(e, this.affectedTiles.length * UltimateColorBombBehaviour.duration.y), this.affectedTiles = null, GridManager.instance.playSFX("colorbomb_flowers.mp3")
    }
});
var LevelManager = pc.createScript("levelManager");
LevelManager.attributes.add("levelsData", {
    type: "asset"
}), pc.extend(LevelManager.prototype, {
    initialize: function() {
        LevelManager.instance = this, this.playing = !1, this.currentChapter = null, this.currentLevel = null, this.app.on("SwapMode:onFinaleDone", this.onWin, this), this.app.on("GameManager:quit", this.onQuit, this)
    },
    postInitialize: function() {
        StorageManager.instance.get("finishedTutorial")
    },
    _loadLevel: function(e) {
        LevelLoader.instance.loadLevel(e, this._onLevelLoaded, this)
    },
    _onLevelLoaded: function(e) {
        this._currentLevelData = e.resource, this.canAddMoves = !0, ColorManager.instance.maxColors = PyzomathDataReader.getColors(this._currentLevelData), MovesManager.instance.setMoveAmount(PyzomathDataReader.getMoves(this._currentLevelData)), ScoreManager.instance.setStarValues(PyzomathDataReader.getStarValues(this._currentLevelData));
        var a = PyzomathDataReader.getObjectives(this._currentLevelData);
        this.app.fire("LevelManager:onLevelStart", this._currentLevelData);
        var t = PyzomathDataReader.getColumns(this._currentLevelData),
            n = PyzomathDataReader.getRows(this._currentLevelData);
        GridManager.instance.despawnAll(), GridManager.instance.spawnLevel(t, n, PyzomathDataReader.getTiles(this._currentLevelData)), ObjectiveManager.instance.setObjectives(a), SwapMode.instance.setup(), this.app.fire("UIManager:hideAll"), CameraAnimations.instance.playRandomIntro().once("complete", this._onCameraComplete, this)
    },
    _onCameraComplete: function() {
        this.app.fire("UIManager:showUI", "Intro"), this.playing = !0
    },
    startLevel: function(e, a, t) {
        this.reset(), this.currentLevel = e, this.currentChapter = a, GameManager.instance.trackEventLevelStart(t).then(function() {
            TrackingManager.instance.levelStart(), this._loadLevel(e)
        }.bind(this)), this.app.fire("AudioManager:stopBgm"), setTimeout(function() {
            this.app.fire("Audio:sfx", "level_intro.mp3")
        }.bind(this), 500)
    },
    onWin: function() {
        this.playing = !1, this.app.fire("GameInput:toggleGameInput", !1), AudioManager.instance.fadeOutMusicSlot(1, 1.5), CameraAnimations.instance.playRandomOutro().once("complete", (function() {
            this.reset();
            var e = LevelManager.instance.getCurrentLevelNumber() === LevelDataManager.instance.getCurrentLevel();
            if (this.app.fire("LevelManager:levelComplete", !0), this.app.fire("UIManager:hideAll"), this.currentLevel === LevelDataManager.instance.getCurrentLevel() &amp;&amp; WorldManager.instance.isEndOfPage(this.currentLevel)) {
                var a = WorldManager.instance.getPartAssets(this.getCurrentChapterNumber()),
                    t = LevelDataManager.instance.getPartsData(this.currentChapter) + 1,
                    n = WorldManager.instance.getNumberOfParts(this.currentChapter);
                StatisticsManager.instance.incrementStatistic("flowerparts_collected", 1), t === n &amp;&amp; StatisticsManager.instance.incrementStatistic("flowers_collected", 1), CollectibleUnlockInterface.instance.unlockObject(function() {
                    this._onWinAnimationDone(e)
                }.bind(this), a.partModel, t, n, a.completedModel), this.app.fire("LevelManager:unlockNewPage", this.currentLevel, !0)
            } else this.app.fire("UIManager:showUI", "Win", e);
            LevelDataManager.instance.saveLevelData(this.currentChapter, this.currentLevel, ScoreManager.instance.getScore(), ScoreManager.instance.getStars()), FirstTimeUserManager.instance.checkEntities(), this.app.fire("GameInput:toggleGameInput", !0)
        }), this)
    },
    _onWinAnimationDone: function(e) {
        this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "Win", e)
    },
    onLose: function() {
        this.playing = !1, this.reset(), this.app.fire("LevelManager:levelComplete", !1), TrackingManager.instance.levelEnd(!1), this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "Lose"), this.app.fire("AudioManager:stopBgm"), CameraAnimations.instance.playRandomOutro()
    },
    onQuit: function() {
        this.playing = !1, this.app.fire("Audio:bgm", "main_ost.mp3")
    },
    onMoveDone: function() {
        return !!ObjectiveManager.instance.isObjectivesCompleted() || (MovesManager.instance.getMoves() &lt;= 0 &amp;&amp; (this.app.fire("LevelManager:noMoreMoves"), this.app.fire("Audio:sfx", "goals_failed.mp3"), this.canAddMoves) ? (this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "AddMoves"), !1) : null)
    },
    onIntroDone: function() {
        this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "Game"), this.app.fire("Audio:bgm", "ingame_ost_world" + this.currentChapter + ".mp3"), TutorialManager.instance.startLevel(this.currentLevel), this.app.off("TutorialManager:stopTutorial", this._spawnPreGameBoostersOnCascade, this), this.app.off("SwapMode:onCascadeDone", BoosterManager.instance.spawnPreGameBoosters, BoosterManager.instance), TutorialManager.instance.active ? this.app.on("TutorialManager:stopTutorial", this._spawnPreGameBoostersOnCascade, this) : BoosterManager.instance.spawnPreGameBoosters()
    },
    _spawnPreGameBoostersOnCascade: function() {
        this.app.once("SwapMode:onCascadeDone", BoosterManager.instance.spawnPreGameBoosters, BoosterManager.instance)
    },
    _showGameUi: function() {
        this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "Game")
    },
    reset: function() {
        SwapMode.instance.setState(matchStates.WAIT), GridManager.instance.despawnAll(), TutorialManager.instance.endTutorial(!0), ObjectiveManager.instance.reset(), pc.pickerFrameBuffer.setInputBetweenGamesEnabled(!0)
    },
    getCurrentLevelData: function() {
        return this._currentLevelData
    },
    getCurrentLevelNumber: function() {
        return this.currentLevel
    },
    getCurrentChapterNumber: function() {
        return this.currentChapter
    },
    getLevelData: function(e) {
        var a = String(e).padStart(4, "0");
        return this.levelsData.resource[a]
    }
});
var StartGameButton = pc.createScript("startGameButton");
StartGameButton.attributes.add("doTutorial", {
    type: "boolean"
}), pc.extend(StartGameButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onClick: function() {
        LevelManager.instance.startLevel(1)
    }
});
var IntroScreen = pc.createScript("introScreen");
IntroScreen.attributes.add("levelText", {
    type: "entity"
}), IntroScreen.attributes.add("objectiveTextEntities", {
    type: "entity",
    array: !0
}), IntroScreen.attributes.add("objectiveIconEntities", {
    type: "entity",
    array: !0
}), IntroScreen.attributes.add("backDrop", {
    type: "entity"
}), IntroScreen.attributes.add("screenDuration", {
    type: "number"
}), pc.extend(IntroScreen.prototype, {
    initialize: function() {
        this.backDrop.script.elementInput.on(inputEvents.DOWN, this.closeScreen, this)
    },
    onUIEntityOpen: function() {
        TutorialManager.instance.active ? this.closeScreen() : (this.levelText.element.text = "Level " + LevelManager.instance.currentLevel, this._counter = 0, this._isCounting = !0);
        for (var e = ObjectiveManager.instance.getObjectives(), t = 0; t &lt; this.objectiveTextEntities.length; t++) {
            var n = e[t];
            if (n) {
                var i = TileLibrary.instance.getTileSprite(n.orderTypeObject),
                    r = n.values.goal;
                this.objectiveTextEntities[t].element.text = r, this.objectiveIconEntities[t].element.spriteAsset = i, this.objectiveTextEntities[t].enabled = !0, this.objectiveIconEntities[t].enabled = !0
            } else this.objectiveTextEntities[t].enabled = !1, this.objectiveIconEntities[t].enabled = !1
        }
    },
    onUIEntityClose: function() {},
    update: function(e) {
        this._isCounting &amp;&amp; (this._counter += e, this._counter &gt; this.screenDuration &amp;&amp; this.closeScreen())
    },
    closeScreen: function() {
        this._isCounting = !1, LevelManager.instance.onIntroDone(), this.app.fire("IntroScreen:introDone")
    }
});
var HoverScore = pc.createScript("hoverScore");
pc.extend(HoverScore.prototype, {
    initialize: function() {
        this.element = this.entity.findComponent("element"), this.scoreText = this.element.text, this.defaultColor = this.element.color.clone(), this.defaultOutline = this.element.outlineColor.clone(), this.app.on("GameManager:quit", this.stopAnimation, this)
    },
    awake: function(t, e, i, n, s, a) {
        this.app.fire("AsyncScoreManager:setScore", t), this._active = !0, this.camera = this.app.root.findByName("Camera"), this.scoreText !== String(t) &amp;&amp; (this.element.text = t), this.element.color = null !== s ? s : this.defaultColor, this.element.outlineColor = null !== a ? a : this.defaultOutline, this.element.shadowColor = null !== a ? a : this.defaultOutline, this.scoreText = this.element.text, this.entity.setPosition(e), this.entity.reparent(i), this.startAnimation(n)
    },
    setRotation: function() {
        this.entity.enabled &amp;&amp; (this.camera || (this.camera = this.app.root.findByTag("worldcamera")[0]), this.entity.setRotation(this.camera.getRotation()))
    },
    startAnimation: function(t) {
        var e = t + 1;
        this.entity.setLocalScale(0, 0, 0), this.appearTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: .01,
            y: .01,
            z: .01
        }, .2, pc.Linear);
        var i = GridManager.instance.calculatePosition(0, e, 0);
        this.riseTween = this.entity.tween(this.entity.getLocalPosition()).to({
            x: this.entity.getLocalPosition().x,
            y: i.y,
            z: this.entity.getLocalPosition().z
        }, 1, pc.Linear), this.riseTween.on("complete", this._recycle, this), this.appearTween.chain(this.riseTween), this.appearTween.start()
    },
    stopAnimation: function() {
        this.riseTween &amp;&amp; this.riseTween.stop(), this.appearTween &amp;&amp; this.appearTween.stop(), this._recycle()
    },
    _recycle: function() {
        this.riseTween = null, this.appearTween = null, this._active &amp;&amp; GridManager.instance.recycleScore(this.entity), this._active = !1
    }
});
var ResetGameButton = pc.createScript("resetGameButton");
pc.extend(ResetGameButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onClick: function() {
        LevelManager.instance.reset()
    }
});
var ScoreInterface = pc.createScript("scoreInterface");
pc.extend(ScoreInterface.prototype, {
    initialize: function() {
        this.app.on("AsyncScoreManager:showScore", this.setScore, this), this._update = !1, this._score = 0, this.currentScore = 0, this.setScore(0), this.app.on("LevelManager:onLevelStart", this._reset, this), this.app.on("GameManager:quit", this._reset, this)
    },
    _reset: function() {
        this._update = !1, this._score = 0, this.currentScore = 0, this.setScore(0), this.entity.setLocalScale(1, 1, 1), this.stopAnim()
    },
    postUpdate: function() {
        this._update &amp;&amp; (this._update = !1, this.entity.element.text = String(this._score), this.startAnim())
    },
    setScore: function(t) {
        this._update = !0, this._score = t
    },
    stopAnim: function() {
        this.bobbleTween &amp;&amp; this.bobbleTween.stop()
    },
    startAnim: function() {
        this.stopAnim(), this.bobbleTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1.2,
            y: 1.2,
            z: 1.2
        }, .1, pc.SineInOut).yoyo(!0).repeat(2).start()
    }
});
pc.extend(pc.Entity.prototype, {
    findScripts: function(t, e) {
        if (e = e || [], this.script &amp;&amp; this.script[t] &amp;&amp; e.push(this.script[t]), this.children)
            for (var n = 0; n &lt; this.children.length; n++) this.children[n] instanceof pc.Entity &amp;&amp; this.children[n].findScripts(t, e);
        return e
    },
    setEulerAnglesComplex: function(t, e, n) {
        this.setLocalEulerAngles(t, e, 0);
        var i = new pc.Entity;
        i.reparent(this), i.setLocalEulerAngles(0, -n, 0), this.setLocalEulerAngles(i.getEulerAngles()), i.destroy()
    },
    getEulerAnglesComplex: function(t, e, n) {
        var i = new pc.Entity;
        i.setEulerAnglesComplex(t, e, n);
        var s = i.getEulerAngles();
        return i.destroy(), s
    },
    getUIPosition: function(t, e) {
        return t || (t = this), e || (e = new pc.Vec3), e.add(t.getLocalPosition()), t.parent instanceof pc.Entity &amp;&amp; this.getUIPosition(t.parent, e), e
    }
});
var ButtonComponentHelper = pc.createScript("buttonComponentHelper");
ButtonComponentHelper.attributes.add("defaultTint", {
    type: "rgb",
    default: [1, 1, 1]
}), ButtonComponentHelper.attributes.add("hoverTint", {
    type: "rgb",
    default: [.9, .9, .9]
}), ButtonComponentHelper.attributes.add("pressedTint", {
    type: "rgb",
    default: [.65, .65, .65]
}), ButtonComponentHelper.attributes.add("inactiveTint", {
    type: "rgb",
    default: [.5, .5, .5]
}), ButtonComponentHelper.attributes.add("fadeDuration", {
    type: "number",
    default: 100,
    placeholder: "ms"
}), pc.extend(ButtonComponentHelper.prototype, {
    initialize: function() {
        this.entity.button || this._createButtonComponent(), this._setButtonValues()
    },
    _createButtonComponent: function() {
        this.entity.button || this.entity.addComponent("button", {
            attributes: {}
        })
    },
    _setButtonValues: function() {
        this.entity.button.defaultTint = this.defaultTint, this.entity.button.hoverTint = this.hoverTint, this.entity.button.pressedTint = this.pressedTint, this.entity.button.inactiveTint = this.inactiveTint, this.entity.button.fadeDuration = this.fadeDuration, this.entity.button.imageEntity = this.entity
    }
});
var AnimationObject = pc.createScript("animationObject");
AnimationObject.attributes.add("colorMaterials", {
    type: "json",
    schema: [{
        name: "0",
        type: "asset",
        title: "none"
    }, {
        name: "1",
        type: "asset",
        title: "blue"
    }, {
        name: "2",
        type: "asset",
        title: "yellow"
    }, {
        name: "3",
        type: "asset",
        title: "red"
    }, {
        name: "4",
        type: "asset",
        title: "purple"
    }, {
        name: "5",
        type: "asset",
        title: "green"
    }, {
        name: "6",
        type: "asset",
        title: "orange"
    }]
}), pc.extend(AnimationObject.prototype, {
    initialize: function() {
        this._isMoving = !1, this._isDelaying = !1
    },
    update: function(t) {
        this._isMoving ? (this._moveTimer += t, this._lerpEntity(), this._moveTimer &gt;= this._tweenData.duration &amp;&amp; this._endAnimation()) : this._isDelaying &amp;&amp; (this._delayCounter += t, this._delayCounter &gt;= this._delay &amp;&amp; this._onDelayDone())
    },
    objectInit: function(t, e, i, a, n) {
        if (t = GridManager.instance.entity, this.entity.enabled = !0, n &amp;&amp; this.colorMaterials.hasOwnProperty(n))
            for (var s = 0; s &lt; this.entity.model.model.meshInstances.length; s++) this.entity.model.model.meshInstances[s].material = this.colorMaterials[n].resource;
        e &amp;&amp; this.entity.setPosition(e), a &amp;&amp; this.entity.setLocalScale(a), i &amp;&amp; (0 === i.z ? (this.entity.setLocalEulerAngles(i.x, i.y, i.z), this.objectAngle = 0) : (this.entity.setEulerAnglesComplex(i.x, i.y, i.z), this.objectAngle = i.z)), t &amp;&amp; this.entity.reparent(t)
    },
    moveTo: function(t, e, i, a, n, s, o, l, h, r, c, _) {
        var d, y = this.entity.getEulerAngles();
        _ || (_ = 0), r &amp;&amp; (d = 0 === this.objectAngle ? new pc.Vec3(this.entity.localPosition.x, 360, this.objectAngle) : this.entity.getEulerAnglesComplex(90, 360, this.objectAngle)), this._tweenData = {
            startPosition: t,
            endPosition: e,
            startScale: i,
            endScale: a,
            duration: o,
            easing: l,
            goLeft: h,
            startRadius: n,
            endRadius: s,
            followRotation: r,
            startRotation: y,
            endRotation: d,
            callback: c
        }, 0 === _ ? (this._isMoving = !0, this._moveTimer = 0) : (this._delayCounter = 0, this._isDelaying = !0, this._delay = _)
    },
    _onDelayDone: function() {
        this._isMoving = !0, this._moveTimer = 0, this._isDelaying = !1, this.entity.enabled = !0
    },
    _lerpEntity: function() {
        var t = this._tweenData.easing(this._moveTimer / this._tweenData.duration);
        if (this._tweenData.startPosition !== this._tweenData.endPosition || this._tweenData.startRadius !== this._tweenData.endRadius) {
            var e = this._tweenData.startRadius + (this._tweenData.endRadius - this._tweenData.startRadius) * t,
                i = this._tweenData.endPosition.y - this._tweenData.startPosition.y,
                a = 0;
            a = this._tweenData.goLeft ? this._tweenData.endPosition.x &gt; this._tweenData.startPosition.x ? this._tweenData.endPosition.x - MatchLogic.columns - this._tweenData.startPosition.x : this._tweenData.endPosition.x - this._tweenData.startPosition.x : this._tweenData.endPosition.x &lt; this._tweenData.startPosition.x ? this._tweenData.endPosition.x + MatchLogic.columns - this._tweenData.startPosition.x : this._tweenData.endPosition.x - this._tweenData.startPosition.x;
            var n = new pc.Vec2(a, i);
            n.scale(t);
            var s = this._tweenData.startPosition.clone().add(n),
                o = GridManager.instance.calculatePosition(s.x, s.y, e);
            this.entity.setLocalPosition(o.x, o.y, o.z)
        }
        if (this._tweenData.startScale !== this._tweenData.endScale) {
            var l = this._tweenData.startScale.clone().add(this._tweenData.endScale.clone().sub(this._tweenData.startScale).scale(t));
            this.entity.setLocalScale(l)
        }
    },
    _endAnimation: function() {
        this._isMoving = !1, this._tweenData.callback &amp;&amp; this._tweenData.callback.call()
    }
});
var BoosterButton = pc.createScript("boosterButton");
BoosterButton.boosterEnum = [{
    FREESWAP: boosterEnum.FREESWAP
}, {
    BREAKER: boosterEnum.BREAKER
}, {
    CROSSBOMB: boosterEnum.CROSSBOMB
}], BoosterButton.attributes.add("type", {
    type: "number",
    enum: BoosterButton.boosterEnum
}), BoosterButton.attributes.add("inventoryKey", {
    type: "string"
}), BoosterButton.attributes.add("amountEntity", {
    type: "entity"
}), BoosterButton.attributes.add("adGroup", {
    type: "entity"
}), BoosterButton.attributes.add("activeGroup", {
    type: "entity"
}), BoosterButton.attributes.add("inactiveGroup", {
    type: "entity"
}), BoosterButton.attributes.add("emptyGroup", {
    type: "entity"
}), BoosterButton.attributes.add("useRewarded", {
    type: "boolean"
}), pc.extend(BoosterButton.prototype, {
    initialize: function() {
        this.buttonStates = Object.freeze({
            EMPTY: 0,
            INACTIVE: 1,
            AD: 2,
            WAITFORAD: 3,
            ACTIVE: 4,
            DISABLED: 5
        }), this.tutorialIndicator = this.entity.findByName("Hand"), this._setState(this.buttonStates.INACTIVE), this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.app.on("LevelManager:onLevelStart", this.getInventoryAmount, this), this.app.on("BoosterManager:confirmedBooster", this.onBoosterConfirmed, this), this.app.on("BoosterButton:disableAll", this.deactivateBooster, this), this.app.on("BoosterShopManager:onItemBought", this.getInventoryAmount, this), this.app.on("LevelManager:noMoreMoves", this.deactivateBooster, this), this.app.on("LevelManager:levelComplete", this.deactivateBooster, this), this.on("state", function(t) {
            t &amp;&amp; this._setState(this._currentState)
        }.bind(this))
    },
    getInventoryAmount: function() {
        this.currentAmount = Inventory.instance.getItem(this.inventoryKey), this.setAmountText(this.currentAmount), this._checkState()
    },
    _onClick: function() {
        switch (this._currentState) {
            case this.buttonStates.EMPTY:
                if (TutorialManager.instance.active) break;
                this.app.fire("UIManager:showUI", "BoosterShop");
                break;
            case this.buttonStates.INACTIVE:
                this.doBooster(), this.fire("use"), this.enableTutorial(!1);
                break;
            case this.buttonStates.AD:
                GameManager.instance.doTimeCount = !1, this._setState(this.buttonStates.WAITFORAD), Wrapper.instance.rewardedAd(this.onWatchedAd, this);
                break;
            case this.buttonStates.WAITFORAD:
                break;
            case this.buttonStates.ACTIVE:
                this.fire("cancel"), this._setState(this.buttonStates.INACTIVE), BoosterManager.instance.cancelBooster(this.type);
                break;
            case this.buttonStates.DISABLED:
        }
        this._checkState()
    },
    onWatchedAd: function() {
        GameManager.instance.doTimeCount = !0, Inventory.instance.addItem(this.inventoryKey, 1), this.doBooster(), this._checkState()
    },
    _onReset: function() {
        this._checkState()
    },
    _setState: function(t) {
        this._currentState = "number" == typeof t ? t : this.buttonStates.ACTIVE, this.inactiveGroup.enabled = this._currentState === this.buttonStates.INACTIVE, this.adGroup.enabled = this._currentState === this.buttonStates.AD, this.emptyGroup.enabled = this._currentState === this.buttonStates.EMPTY, this.activeGroup.enabled = this._currentState === this.buttonStates.ACTIVE, this.inactiveGroup.enabled = this._currentState === this.buttonStates.INACTIVE, this.entity.enabled = this._currentState !== this.buttonStates.DISABLED, this._currentState === this.buttonStates.ACTIVE ? (this.app.fire("ActivePowerUpeffect:toggleActivation", !0), this.entity.script.activePowerUpeffect.toggleUI(!0), this.entity.setLocalEulerAngles(0, 0, -5), this.shakeTween &amp;&amp; this.shakeTween.stop(), this.shakeTween = this.entity.tween(this.entity.getLocalRotation()).rotate(new pc.Vec3(0, 0, 5), .1, pc.SineInOut).loop(!0).yoyo(!0).start()) : (this.shakeTween &amp;&amp; this.shakeTween.stop(), BoosterManager.instance.cancelBooster(this.type), this.entity.setLocalEulerAngles(0, 0, 0), this.entity.script.activePowerUpeffect.toggleUI(!1))
    },
    _checkState: function() {
        if (this._currentState !== this.buttonStates.WAITFORAD &amp;&amp; this._currentState !== this.buttonStates.ACTIVE) {
            var t = Wrapper.instance.hasRewardedAd();
            this.currentAmount &gt; 0 || this._tutorial ? this._setState(this.buttonStates.INACTIVE) : !(this.currentAmount &lt;= 0) || t &amp;&amp; this.useRewarded ? this.currentAmount &lt;= 0 &amp;&amp; t &amp;&amp; this._setState(this.buttonStates.AD) : this._setState(this.buttonStates.EMPTY)
        }
    },
    setAmountText: function(t) {
        this.amountEntity.element.text = String(t)
    },
    doBooster: function() {
        SwapMode.instance.deselect(), this.type === boosterEnum.BREAKER || this.type === boosterEnum.FREESWAP || this.type === boosterEnum.CROSSBOMB ? (BoosterManager.instance.activateBooster(this.type), this.app.fire("BoosterButton:disableAll"), this._setState(this.buttonStates.ACTIVE)) : (Inventory.instance.tryPayItem(this.inventoryKey, 1), this.getInventoryAmount()), this._checkState()
    },
    _updateBoosterStatistics: function() {
        StatisticsManager.instance.incrementStatistic("boosters_used", 1), this.type === boosterEnum.FREESWAP &amp;&amp; (StatisticsManager.instance.incrementStatistic("free_swap_booster_used", 1), this.app.fire("TrackingManager:freeSwap")), this.type === boosterEnum.BREAKER &amp;&amp; (StatisticsManager.instance.incrementStatistic("breaker_booster_used", 1), this.app.fire("TrackingManager:breaker")), this.type === boosterEnum.CROSSBOMB &amp;&amp; (StatisticsManager.instance.incrementStatistic("crossbomb_booster_used", 1), this.app.fire("TrackingManager:crossbomb"))
    },
    onBoosterConfirmed: function(t) {
        t === this.type &amp;&amp; (this._tutorial ? this.setTutorial(!1) : Inventory.instance.tryPayItem(this.inventoryKey, 1), this.getInventoryAmount(), this._setState(this.buttonStates.INACTIVE), this._checkState())
    },
    setActiveIfUsable: function() {
        this.disabledForTutorial || 5 !== this._currentState &amp;&amp; (this.entity.enabled = !0)
    },
    deactivateBooster: function() {
        this._currentState === this.buttonStates.ACTIVE &amp;&amp; this._setState(this.buttonStates.INACTIVE)
    },
    enableInput: function(t) {
        this.entity.element.useInput = t
    },
    enableTutorial: function(t) {
        this.tutorialIndicator.enabled = t
    },
    activate: function(t) {
        if (this._active = t, t) {
            this.entity.element.useInput = !0;
            for (var e = this.entity.findComponents("element"), s = 0; s &lt; e.length; s++) e[s].opacity = 1, e[s].color = (new pc.Color).fromString("#FFFFFF")
        } else {
            this.entity.element.useInput = !1;
            for (e = this.entity.findComponents("element"), s = 0; s &lt; e.length; s++) e[s].opacity = BoosterButton.DISABLE_OPACITY, e[s].color = (new pc.Color).fromString("#3E3E3E")
        }
    },
    setTutorial: function(t) {
        this._tutorial = t, this._tutorial &amp;&amp; (this.setAmountText(this.currentAmount + 1), this._setState(this.buttonStates.INACTIVE))
    }
}), BoosterButton.DISABLE_OPACITY = .5;
var PowerUpGroup = pc.createScript("powerUpGroup");
pc.extend(PowerUpGroup.prototype, {
    initialize: function() {
        this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _onResize: function(t, i, o, e) {
        e === deviceEnum.MOBILE &amp;&amp; t === orientationEnum.LANDSCAPE ? this.entity.layoutgroup.orientation = pc.ORIENTATION_VERTICAL : this.entity.layoutgroup.orientation = pc.ORIENTATION_HORIZONTAL
    }
});
var PowerAnimationManager = pc.createScript("powerAnimationManager");
PowerAnimationManager.attributes.add("lineAnimationObjectPool", {
    type: "entity"
}), PowerAnimationManager.attributes.add("colorbombAnimationObjectPool", {
    type: "entity"
}), PowerAnimationManager.attributes.add("bombAnimationObjectPool", {
    type: "entity"
}), PowerAnimationManager.attributes.add("PowerCombinationParticleObjectPool", {
    type: "entity"
}), PowerAnimationManager.attributes.add("PowerCombinationMaterial", {
    type: "asset",
    assetType: "material"
});
var powerAnimationTypes = Object.freeze({
    BOMB: 1,
    COLORBOMB: 2,
    LINES: 3
});
pc.extend(PowerAnimationManager.prototype, {
    initialize: function() {
        PowerAnimationManager.instance = this, this.linePool = this.lineAnimationObjectPool.script.objectPool, this.colorbombPool = this.colorbombAnimationObjectPool.script.objectPool, this.bombPool = this.bombAnimationObjectPool.script.objectPool, this.particlePool = this.PowerCombinationParticleObjectPool.script.objectPool, this.app.on("PowerAnimationManager:afterMove", this.startRotateAnimation, this)
    },
    update: function() {
        this.parent &amp;&amp; !0 === this.startRotate &amp;&amp; this.parent.rotateLocal(0, 0, 1)
    },
    recycleLineObject: function(e) {
        e.enabled = !1, e.reparent(null), this.linePool.recycle(e)
    },
    recycleColorObject: function(e) {
        e.enabled = !1, e.reparent(null), this.colorbombPool.recycle(e)
    },
    recycleBombObject: function(e) {
        e.enabled = !1, e.reparent(null), this.bombPool.recycle(e)
    },
    createLineAnimation: function(e, t, n, i, o, a, c, s, r) {
        var l = Math.abs(o - e.x),
            p = Math.abs(a - e.y),
            b = n ? p * t.y : l * t.y,
            m = this.linePool.use();
        m.script.animationObject.objectInit(this.entity, e.entity.getLocalPosition(), new pc.Vec3(90, 0, c), pc.Vec3.ONE, s), m.animation.play("bee_animated.json", 0);
        var y = m.tween(m.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.Linear);
        y.on("complete", function() {
            m.animation.play("bee_idle.json", 0), this.recycleLineObject(m)
        }.bind(this)), m.script.animationObject.moveTo(n ? new pc.Vec2(o, e.y) : new pc.Vec2(e.x, a), new pc.Vec2(o, a), new pc.Vec3(.8, .8, .8), pc.Vec3.ONE, GridManager.instance.radius + 1, GridManager.instance.radius + 1, b, pc.SineInOut, i, !n, function() {
            y.start()
        }.bind(this))
    },
    createColorBombAnimation: function(e, t) {
        var n = this.colorbombPool.use();
        n.script.animationObject.objectInit(this.entity, e.entity.getLocalPosition(), new pc.Vec3(90, 0, 0), pc.Vec3.ONE, null), n.animation.play("butterfly_animated.json", 0);
        var i = n.tween(n.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.BackIn);
        i.on("complete", function() {
            n.animation.play("butterfly_idle.json", 0), this.recycleColorObject(n)
        }.bind(this)), n.script.animationObject.moveTo(new pc.Vec2(e.x, e.y), new pc.Vec2(e.x, e.y), pc.Vec3.ONE, new pc.Vec3(1.5, 1.5, 1.5), GridManager.instance.radius + 0, GridManager.instance.radius + 1, t, pc.SineIn, !1, !1, function() {
            i.start()
        }.bind(this))
    },
    createBombAnimation: function(e, t, n, i, o, a, c, s, r, l, p) {
        var b = t.y * s,
            m = this.bombPool.use();
        m.script.animationObject.objectInit(this.entity, e.entity.getLocalPosition(), new pc.Vec3(90, 0, c), pc.Vec3.ONE, r), m.animation.play("ladybug_animated.json", 0);
        var y = m.tween(m.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.Linear);
        y.on("complete", function() {
            m.animation.play("ladybug_idle.json", 0), this.recycleBombObject(m)
        }.bind(this)), m.script.animationObject.moveTo(new pc.Vec2(e.x, e.y), new pc.Vec2(o, a), new pc.Vec3(.4, .4, .4), pc.Vec3.ONE, GridManager.instance.radius + 1, GridManager.instance.radius + 1, b, pc.SineInOut, i, !n, function() {
            y.start(), l &amp;&amp; GridManager.instance.playSFX("bomb_hit_flowers.mp3")
        }.bind(this))
    },
    createColorBombParticleAnimation: function(e, t, n, i, o, a, c, s, r, l, p) {
        var b = null,
            m = null,
            y = null;
        switch (p) {
            case powerAnimationTypes.BOMB:
                b = this.bombPool.use(), m = "ladybug_animated.json", y = "ladybug_idle.json";
                break;
            case powerAnimationTypes.COLORBOMB:
                b = this.colorbombPool.use(), m = "butterfly_animated.json", y = "butterfly_idle.json";
                break;
            case powerAnimationTypes.LINES:
                b = this.linePool.use(), m = "bee_animated.json", y = "bee_idle.json"
        }
        var u = e.entity ? e.entity.getLocalPosition() : GridManager.instance.calculatePosition(e.x, e.y);
        b.script.animationObject.objectInit(this.entity, u, new pc.Vec3(90, 0, c), pc.Vec3.ONE, r), b.animation.play(m, 0);
        var d = b.tween(b.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.Linear);
        d.on("complete", function() {
            switch (b.animation.play(y, 0), p) {
                case powerAnimationTypes.BOMB:
                    this.recycleBombObject(b);
                    break;
                case powerAnimationTypes.COLORBOMB:
                    this.recycleColorObject(b);
                    break;
                case powerAnimationTypes.LINES:
                    this.recycleLineObject(b)
            }
        }.bind(this));
        var h = b.getLocalEulerAngles().clone();
        b.setLocalEulerAngles(180, h.y, h.z), b.tween(b.getLocalRotation()).rotate({
            x: 90,
            y: h.y,
            z: h.z
        }, t / 2, pc.SineIn).on("complete", (function() {
            b.tween(b.getLocalRotation()).rotate({
                x: 0,
                y: h.y,
                z: h.z
            }, t / 2, pc.SineOut).start()
        })).start(), b.tween(b.getLocalPosition()).to({
            z: 25
        }, t / 2, pc.SineInOut).yoyo(!0).repeat(2).on("complete", (function() {
            l.stopAffectedTweens()
        })).start(), b.enabled = !0, b.script.animationObject.moveTo(new pc.Vec2(e.x, e.y), new pc.Vec2(o, a), new pc.Vec3(.4, .4, .4), pc.Vec3.ONE, GridManager.instance.radius + 1, GridManager.instance.radius + 1, t, pc.SineInOut, i, !n, function() {
            d.start()
        }.bind(this))
    },
    preboosterSpawnAnimation: function(e, t, n, i, o, a, c, s, r, l, p) {
        var b = null,
            m = null,
            y = null;
        switch (p) {
            case powerAnimationTypes.BOMB:
                b = this.bombPool.use(), m = "ladybug_animated.json", y = "ladybug_idle.json";
                break;
            case powerAnimationTypes.COLORBOMB:
                b = this.colorbombPool.use(), m = "butterfly_animated.json", y = "butterfly_idle.json";
                break;
            case powerAnimationTypes.LINES:
                b = this.linePool.use(), m = "bee_animated.json", y = "bee_idle.json"
        }
        var u = e.entity ? e.entity.getLocalPosition() : GridManager.instance.calculatePosition(e.x, e.y);
        b.script.animationObject.objectInit(this.entity, u, new pc.Vec3(90, 0, c), pc.Vec3.ONE, r), b.animation.play(m, 0);
        var d = b.tween(b.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.Linear);
        d.on("complete", function() {
            switch (b.animation.play(y, 0), p) {
                case powerAnimationTypes.BOMB:
                    this.recycleBombObject(b);
                    break;
                case powerAnimationTypes.COLORBOMB:
                    this.recycleColorObject(b);
                    break;
                case powerAnimationTypes.LINES:
                    this.recycleLineObject(b)
            }
        }.bind(this));
        var h = b.getLocalEulerAngles().clone();
        b.tween(b.getLocalRotation()).rotate({
            x: 90,
            y: h.y,
            z: h.z
        }, t / 2, pc.SineIn).on("complete", (function() {
            b.tween(b.getLocalRotation()).rotate({
                x: 0,
                y: h.y,
                z: h.z
            }, t / 2, pc.SineOut).start()
        })).start(), b.setLocalPosition(b.getLocalPosition().x, b.getLocalPosition().y, 25), b.tween(b.getLocalPosition()).to({
            z: 0
        }, t, pc.SineInOut).yoyo(!0).repeat(2).on("complete", (function() {
            l.stopAffectedTweens()
        })).start(), b.enabled = !0, b.script.animationObject.moveTo(new pc.Vec2(e.x, e.y), new pc.Vec2(o, a), new pc.Vec3(.4, .4, .4), pc.Vec3.ONE, GridManager.instance.radius + 1, GridManager.instance.radius + 1, t, pc.SineInOut, i, !n, function() {
            d.start()
        }.bind(this))
    },
    spawnAnimationByType: function(e) {
        var t, n = null;
        switch (e.typeID) {
            case foregroundTileEnum.BOMB:
                n = this.bombPool.use();
                break;
            case foregroundTileEnum.COLORBOMB:
                n = this.colorbombPool.use();
                break;
            case foregroundTileEnum.LINE_V:
                t = 0, n = this.linePool.use();
                break;
            case foregroundTileEnum.LINE_H:
                t = -90, n = this.linePool.use()
        }
        return n.script.animationObject.objectInit(this.entity, e.entity.getLocalPosition(), new pc.Vec3(90, 0, t), pc.Vec3.ONE, e.colorID), n
    },
    despawnAnimationByType: function(e, t, n) {
        e.on("complete", function() {
            switch (t.typeID) {
                case foregroundTileEnum.BOMB:
                    this.recycleBombObject(n);
                    break;
                case foregroundTileEnum.COLORBOMB:
                    this.recycleColorObject(n);
                    break;
                case foregroundTileEnum.LINE_V:
                case foregroundTileEnum.LINE_H:
                    this.recycleLineObject(n)
            }
        }.bind(this))
    },
    changeMesh: function(e, t) {
        for (var n = e.model.meshInstances, i = [], o = 0; o &lt; n.length; ++o) {
            var a = n[o];
            i[o] = a.material, a.material = void 0 !== t ? t[o] : this.PowerCombinationMaterial.resource
        }
        return i
    },
    createPowerCombinationAnimation: function(e, t, n, i) {
        var o = this.spawnAnimationByType(e),
            a = this.spawnAnimationByType(t),
            c = this.changeMesh(a),
            s = this.changeMesh(o),
            r = this.particlePool.use();
        r.particlesystem.lifetime = n, r.enabled = !0, r.reparent(this.app.root), r.setLocalPosition(e.entity.getLocalPosition().x, e.entity.getLocalPosition().y, .8), r.particlesystem.reset(), r.particlesystem.play();
        var l = r.children[0];
        l.particlesystem.numParticles = Math.round(3.75 * n), l.particlesystem.reset(), l.particlesystem.play();
        var p = o.tween(o.getLocalScale()).to({
                x: 0,
                y: 0,
                z: 0
            }, 0, pc.Linear),
            b = a.tween(a.getLocalScale()).to({
                x: 0,
                y: 0,
                z: 0
            }, 0, pc.Linear);
        this.despawnAnimationByType(p, e, o), this.despawnAnimationByType(b, t, a), a.tween(a.getLocalScale()).to({
            x: a.getLocalScale().x / 2,
            y: a.getLocalScale().y / 2,
            z: a.getLocalScale().x / 2
        }, .75 * n, pc.Linear).start(), o.tween(o.getLocalScale()).to({
            x: o.getLocalScale().x / 2,
            y: o.getLocalScale().y / 2,
            z: o.getLocalScale().x / 2
        }, .75 * n, pc.Linear).start(), a.tween(a.getLocalPosition()).to(o.getLocalPosition(), n, pc.CubicOut).start().on("complete", function() {
            p.start(), b.start().on("complete", function() {
                i(e, t), this.changeMesh(a, c), this.changeMesh(o, s)
            }.bind(this))
        }.bind(this))
    },
    createLineAnimationBomb: function(e, t, n, i, o, a, c, s) {
        var r = Math.abs(o - e.x),
            l = Math.abs(a - e.y),
            p = n ? l * t.y : r * t.y,
            b = this.bombPool.use();
        b.script.animationObject.objectInit(this.entity, e.entity.getLocalPosition(), new pc.Vec3(90, 0, c), pc.Vec3.ONE, s), b.animation.play("ladybug_animated.json", 0);
        var m = b.tween(b.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.Linear);
        m.on("complete", function() {
            b.animation.play("ladybug_idle.json", 0), this.recycleBombObject(b)
        }.bind(this)), b.script.animationObject.moveTo(n ? new pc.Vec2(o, e.y) : new pc.Vec2(e.x, a), new pc.Vec2(o, a), new pc.Vec3(.8, .8, .8), pc.Vec3.ONE, GridManager.instance.radius + 1, GridManager.instance.radius + 1, p, pc.SineInOut, i, !n, function() {
            m.start()
        }.bind(this))
    },
    createLineAnimationCrossbomb: function(e, t, n, i, o, a, c, s, r, l) {
        var p = Math.abs(a - e),
            b = Math.abs(c - t),
            m = i ? b * n.y : p * n.y,
            y = this.linePool.use();
        y.script.animationObject.objectInit(this.entity, GridManager.instance.calculatePosition(e, t, 0), new pc.Vec3(90, 0, s), pc.Vec3.ONE, r), y.animation.play("bee_animated.json", 0);
        var u = y.tween(y.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.Linear);
        u.on("complete", function() {
            y.animation.play("bee_idle.json", 0), this.recycleLineObject(y)
        }.bind(this)), y.script.animationObject.moveTo(i ? new pc.Vec2(a, t) : new pc.Vec2(e, c), new pc.Vec2(a, c), new pc.Vec3(.8, .8, .8), pc.Vec3.ONE, GridManager.instance.radius + 1, GridManager.instance.radius + 1, m, pc.SineInOut, o, !i, function() {
            u.start()
        }.bind(this), l), y.setLocalScale(0, 0, 0)
    }
});
var ActivePowerUpeffect = pc.createScript("activePowerUpeffect");
ActivePowerUpeffect.attributes.add("UIToActivate", {
    type: "entity",
    array: !0
}), ActivePowerUpeffect.attributes.add("UIToDeactivate", {
    type: "entity",
    array: !0
}), pc.extend(ActivePowerUpeffect.prototype, {
    initialize: function() {
        this.toggleUI(!1)
    },
    toggleUI: function(t) {
        for (var e = 0; e &lt; this.UIToActivate.length; e++) this.UIToActivate[e].enabled = t;
        for (var i = 0; i &lt; this.UIToDeactivate.length; i++) this.UIToDeactivate[i].tags.has("Booster") &amp;&amp; !t ? this.UIToDeactivate[i].script.boosterButton.setActiveIfUsable() : this.UIToDeactivate[i].enabled = !t
    }
});
var ScaleElementToscreenSize = pc.createScript("scaleElementToscreenSize");
pc.extend(ScaleElementToscreenSize.prototype, {
    initialize: function() {
        this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _onResize: function(e, n, i, t) {
        var a = UIManager.instance.getReferenceResolution().y / i;
        this.entity.element.width = n * a, this.entity.element.height = i * a
    }
}); // ButtonSlider.js
// var ButtonSlider = pc.createScript('buttonSlider');

// ButtonSlider.attributes.add('handle', { type: 'entity' });
// ButtonSlider.attributes.add('camera', { type: 'entity' });
// ButtonSlider.attributes.add('deadZone', { type: 'number', default: 0.1 });
// ButtonSlider.attributes.add('maxSpeed', { type: 'number', default: 2 });
// ButtonSlider.attributes.add('disableSlider', { type: 'boolean'});

// pc.extend(ButtonSlider.prototype, {

//     initialize: function() {
//         ButtonSlider.instance = this;

//         this.orbitCamera = this.camera.script.orbitCamera;

//         this.scrollbar = this.entity.scrollbar;

//         this.startPosition = this.scrollbar.value;

//         this.rotationSpeedFactor = 0;

//         this.moving = false;

//         this.scrollbar.on('set:value', this.setRotationSpeedFactor, this);

//         if (this.disableSlider) {
//             this.entity.parent.enabled = false;
//         }
//     },

//     update: function() {

//         if (this.scrollbar._handleDragHelper._isDragging) {
//             this.moving = true;

//             if (Math.abs(this.rotationSpeedFactor) &gt; this.deadZone) {
//                 this.orbitCamera.yaw += this.rotationSpeedFactor * this.maxSpeed;
//                 this.app.fire('OrbitCamera:rotate');
//             }
//         } else {
//             this.moving = false;
//             if (this.scrollbar.value !== this.startPosition) {
//                 this.resetHandle();
//             }
//         }
//     },

//     resetHandle: function() {
//         this.scrollbar.value = this.startPosition;
//     },

//     setRotationSpeedFactor: function() {
//         var newSpeedFactor = 2 * this.scrollbar.value - 1;

//         this.rotationSpeedFactor = newSpeedFactor;
//     },

//     isSliderInput: function() {
//         return this.moving;
//     } 
// });

var TileParticle = pc.createScript("tileParticle");
TileParticle.attributes.add("sprite", {
    type: "asset"
}), TileParticle.attributes.add("color", {
    type: "rgb"
}), pc.extend(TileParticle.prototype, {
    getColor: function() {
        return this.color
    },
    getTexture: function() {
        return this.sprite.resource
    }
});
var HamburgerMenu = pc.createScript("hamburgerMenu");
HamburgerMenu.attributes.add("menuButton", {
    type: "entity"
}), HamburgerMenu.attributes.add("content", {
    type: "entity",
    array: !0
}), HamburgerMenu.attributes.add("unfoldDirectionType", {
    type: "number",
    enum: [{
        top: 0
    }, {
        bottom: 1
    }, {
        left: 2
    }, {
        right: 3
    }]
}), HamburgerMenu.attributes.add("unfoldDistance", {
    type: "number",
    default: 10
}), HamburgerMenu.attributes.add("unfoldDuration", {
    type: "number",
    default: 1
}), HamburgerMenu.attributes.add("autoCloseTimer", {
    type: "number"
}), HamburgerMenu.attributes.add("closeOnUIChange", {
    type: "boolean"
}), pc.extend(HamburgerMenu.prototype, {
    initialize: function() {
        this.directionTranslate = [new pc.Vec2(0, 1), new pc.Vec2(0, -1), new pc.Vec2(-1, 0), new pc.Vec2(1, 0)], this.unfoldDirection = this.directionTranslate[this.unfoldDirectionType], this.countdown = !1, this.counter = 0, this.isOpen = !1, this.toggleMenu(!0, !1), this.menuButton.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.on("state", function(t) {
            t &amp;&amp; this.toggleMenu(!0, !1)
        }.bind(this));
        for (var t = 0; t &lt; this.content.length; t += 1) this.content[t].script.elementInput ? this.content[t].script.elementInput.on(inputEvents.CLICK, this.resetCloseTimer, this) : console.warn("No elementInput on settings content: ", this.content[t]);
        this.closeOnUIChange &amp;&amp; this.app.on("UIManager:showUI", this.toggleMenu(!0, !1), this)
    },
    update: function(t) {
        this.countdown &amp;&amp; (this.counter -= t, this.counter &lt;= 0 &amp;&amp; (this.countdown = !1, this.counter = 0, this.toggleMenu(!1, !1)))
    },
    _onClick: function() {
        this.toggleMenu(), this.app.fire("Audio:playSFX", "button.mp3")
    },
    resetCloseTimer: function() {
        this.counter = this.autoCloseTimer
    },
    toggleMenu: function(t, e) {
        this.isOpen = void 0 === e ? !this.isOpen : e, this.isOpen &amp;&amp; this.autoCloseTimer &amp;&amp; 0 !== this.autoCloseTimer &amp;&amp; (this.countdown = !0, this.counter = this.autoCloseTimer);
        for (var n = 1, i = 0; i &lt; this.content.length; i += 1) this._setItemPosition(this.content[i], this.isOpen ? this.unfoldDirection.clone().scale(this.unfoldDistance * n) : new pc.Vec2(0, 0), t), null !== this.content[i].parent &amp;&amp; (n += 1);
        this.fire("MenuToggle", this.isOpen)
    },
    _setItemPosition: function(t, e, n) {
        if (n) t.setLocalPosition(e.x, e.y, 0), t.enabled = this.isOpen;
        else {
            var i = new pc.Vec3(e.x, e.y, 0);
            this.isOpen &amp;&amp; (t.enabled = !0), t.tween(t.getLocalPosition()).to(i, this.unfoldDuration, pc.SineOut).start().on("complete", function() {
                this.isOpen || (t.enabled = !1)
            }.bind(this))
        }
    }
});
var VibrateButton = pc.createScript("vibrateButton");
VibrateButton.attributes.add("icon", {
    type: "entity"
}), VibrateButton.attributes.add("iconSprites", {
    type: "asset",
    assetType: "sprite",
    array: !0
}), pc.extend(VibrateButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    postInitialize: function() {
        this.setVisibility() ? (this.on("state", function(t) {
            this.setButtonState()
        }.bind(this)), this.setButtonState()) : this.entity.destroy()
    },
    _onClick: function() {
        this.app.fire("Audio:playSFX", "button.mp3"), this.vibrate = !this.vibrate, this.setActive(this.vibrate)
    },
    setVisibility: function() {
        return this.entity.enabled = VibrationManager.instance.isVibrationSupported(), this.entity.enabled
    },
    setButtonState: function() {
        this.vibrate = StorageManager.instance.get("vibrate"), this.setActive(this.vibrate)
    },
    setActive: function(t) {
        this.icon.element.sprite = this.iconSprites[+t].resource, VibrationManager.instance.set(t), t &amp;&amp; this.app.fire("vibrate")
    }
});
var CascadeIndicatorInterface = pc.createScript("cascadeIndicatorInterface");
CascadeIndicatorInterface.attributes.add("cascadeTextEntity", {
    type: "entity"
}), CascadeIndicatorInterface.attributes.add("cascadeImageEntity", {
    type: "entity"
}), CascadeIndicatorInterface.attributes.add("wordImages", {
    type: "asset",
    assetType: "sprite",
    array: !0
}), CascadeIndicatorInterface.attributes.add("duration", {
    type: "number"
}), CascadeIndicatorInterface.attributes.add("durationIncreasePerType", {
    type: "number"
}), CascadeIndicatorInterface.attributes.add("shineImage", {
    type: "entity"
}), pc.extend(CascadeIndicatorInterface.prototype, {
    initialize: function() {
        this.entity.enabled = !1, this.counter = 0, this.isCounting = !1, this.shouldShow = !1, this.app.on("CascadeIndicatorInterface:onCascade", this._handleCascadeIndicator, this), this.app.on("IntroScreen:introDone", this._onLevelIntroDone, this), this.app.on("LevelManager:levelComplete", this._onLevelEnd, this)
    },
    update: function(t) {
        this.isCounting &amp;&amp; (this.counter += t, this.counter &gt;= this.currentDuration &amp;&amp; this.onEnd())
    },
    _handleCascadeIndicator: function(t) {
        ObjectiveManager.instance.isObjectivesCompleted() || (this.shineImage.enabled = !1, 1 === t ? (this.app.fire("Audio:sfx", "lucy_lovely.mp3"), this.onStart(this.wordImages[0], 0)) : 2 === t ? (this.app.fire("Audio:sfx", "lucy_dazzling.mp3"), this.onStart(this.wordImages[1], 1)) : 3 === t ? (this.app.fire("Audio:sfx", "lucy_delightful.mp3"), this.onStart(this.wordImages[2], 2)) : 4 === t ? (this.app.fire("Audio:sfx", "lucy_stunning.mp3"), this.onStart(this.wordImages[3], 3)) : 5 === t ? (this.app.fire("Audio:sfx", "lucy_majestic.mp3"), this.onStart(this.wordImages[4], 4), this.shineImage.enabled = !0) : t &gt;= 6 &amp;&amp; (this.app.fire("Audio:sfx", "lucy_kabloom.mp3"), this.onStart(this.wordImages[5], 5), this.shineImage.enabled = !0))
    },
    onStart: function(t, e) {
        if (this.shouldShow) {
            var i = t.resource.atlas.frames[t.resource.frameKeys[0]].rect;
            this.cascadeImageEntity.element.sprite = t.resource, this.cascadeImageEntity.element.width = i.z, this.cascadeImageEntity.element.height = i.w, this.counter = 0, this.isCounting = !0, this.currentDuration = this.duration + this.durationIncreasePerType * e, this.entity.setLocalScale(pc.Vec3.ZERO), this.entity.enabled = !0, this.appearTween = this.entity.tween(this.entity.getLocalScale()).to({
                x: 1,
                y: 1,
                z: 1
            }, .1, pc.BackOut).start()
        }
    },
    onEnd: function() {
        this.isCounting = !1, this.disappearTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .1, pc.BackIn).start().on("complete", function() {
            this.entity.enabled = !1
        }.bind(this))
    },
    _onLevelIntroDone: function() {
        this.isCounting = !1, this.entity.enabled = !1, this.shouldShow = !0
    },
    _onLevelEnd: function() {
        this.shouldShow = !1
    }
});
var ShufflingInterface = pc.createScript("shufflingInterface");
pc.extend(ShufflingInterface.prototype, {
    initialize: function() {
        this.app.on("GridManager:onShuffleStart", this.onShuffleStart, this), this.app.on("GridManager:onShuffleEnd", this.onShuffleEnd, this), this.entity.enabled = !1
    },
    onShuffleStart: function() {
        this.disappearTween &amp;&amp; (this.disappearTween.stop(), this.disappearTween = null), this.entity.setLocalScale(pc.Vec3.ZERO), this.entity.enabled = !0, this.appearTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1,
            y: 1,
            z: 1
        }, .1, pc.BackOut).start()
    },
    onShuffleEnd: function() {
        this.appearTween &amp;&amp; (this.appearTween.stop(), this.appearTween = null), this.disappearTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .1, pc.BackIn).start().on("complete", function() {
            this.entity.enabled = !1
        }.bind(this))
    }
});
var EndStateInterface = pc.createScript("endStateInterface");
EndStateInterface.attributes.add("duration", {
    type: "number"
}), pc.extend(EndStateInterface.prototype, {
    initialize: function() {
        this.app.on("SwapMode:onEndStart", this.onStart, this), this.app.on("LevelManager:onLevelStart", this.onEnd, this), this.entity.enabled = !1, this.counter = 0, this.isCounting = !1
    },
    update: function(t) {
        this.isCounting &amp;&amp; (this.counter += t, this.counter &gt;= this.duration &amp;&amp; this.onEnd())
    },
    onStart: function() {
        this.app.fire("Audio:sfx", "goals_completed.mp3"), this.counter = 0, this.isCounting = !0, this.entity.setLocalScale(pc.Vec3.ZERO), this.entity.enabled = !0, this.appearTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1,
            y: 1,
            z: 1
        }, .1, pc.BackOut).start()
    },
    onEnd: function() {
        this.isCounting = !1, this.disappearTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .1, pc.BackIn).start().on("complete", function() {
            this.entity.enabled = !1
        }.bind(this))
    }
});
var MusicButton = pc.createScript("musicButton");
MusicButton.attributes.add("icon", {
    type: "entity"
}), MusicButton.attributes.add("iconSprites", {
    type: "asset",
    assetType: "sprite",
    array: !0
}), pc.extend(MusicButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.on("state", function(t) {
            this.setButtonState()
        }.bind(this))
    },
    postInitialize: function() {
        this.bgmKey = AudioManager.instance.bgmSettingKey, this.setButtonState()
    },
    setButtonState: function() {
        this.bgmKey &amp;&amp; (this.useBgm = StorageManager.instance.get(this.bgmKey), this.setIcon(this.useBgm))
    },
    _onClick: function() {
        this.app.fire("Audio:playSFX", "button.mp3"), this.useBgm = !this.useBgm, this.setIcon(this.useBgm), this.setSettings(this.useBgm)
    },
    setIcon: function(t) {
        this.icon.element.sprite = this.iconSprites[t ? 1 : 0].resource
    },
    setSettings: function(t) {
        StorageManager.instance.set(this.bgmKey, t ? 1 : 0), AudioManager.instance.setBGMSetting(t), GameManager.instance.trackEventVolumeChange()
    }
});
var LevelInterface = pc.createScript("levelInterface");
pc.extend(LevelInterface.prototype, {
    initialize: function() {
        this.app.on("LevelManager:onLevelStart", this.setLevel, this), this.setLevel()
    },
    setLevel: function() {
        TutorialManager.instance.active || (LocalizationManager.instance.setText(this.entity, "IN_GAME_LEVEL", [String(LevelManager.instance.currentLevel)]), this.startAnim())
    },
    startAnim: function() {
        this.bobbleTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1.2,
            y: 1.2,
            z: 1.2
        }, .1, pc.SineInOut).yoyo(!0).repeat(2).start()
    }
});
var SoundButton = pc.createScript("soundButton");
SoundButton.attributes.add("icon", {
    type: "entity"
}), SoundButton.attributes.add("iconSprites", {
    type: "asset",
    assetType: "sprite",
    array: !0
}), pc.extend(SoundButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.on("state", function(t) {
            this.setButtonState()
        }.bind(this))
    },
    postInitialize: function() {
        this.sfxKey = AudioManager.instance.sfxSettingKey, this.setButtonState()
    },
    setButtonState: function() {
        this.sfxKey &amp;&amp; (this.useSFX = StorageManager.instance.get(this.sfxKey), this.setIcon(this.useSFX))
    },
    _onClick: function() {
        this.useSFX = !this.useSFX, this.setIcon(this.useSFX), this.setSettings(this.useSFX), this.app.fire("Audio:playSFX", "button.mp3")
    },
    setIcon: function(t) {
        this.icon.element.sprite = this.iconSprites[t ? 1 : 0].resource
    },
    setSettings: function(t) {
        StorageManager.instance.set(this.sfxKey, t ? 1 : 0), AudioManager.instance.setSFXSetting(t), GameManager.instance.trackEventVolumeChange()
    }
});
var SkipOrderTutorialStep = pc.createScript("skipOrderTutorialStep");
pc.extend(SkipOrderTutorialStep.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onClick: function() {
        this.app.fire("TutorialManager:skipStep")
    }
});
var TutorialToggleElement = pc.createScript("tutorialToggleElement");
pc.extend(TutorialToggleElement.prototype, {
    initialize: function() {
        this.app.on("TutorialManager:startTutorial", this.toggleOff, this), this.app.on("TutorialManager:stopTutorial", this.toggleOn, this)
    },
    toggleOff: function() {
        this.entity.enabled = !1
    },
    toggleOn: function() {
        this.entity.enabled = !0
    }
});
var DynamicLayoutGroup = pc.createScript("dynamicLayoutGroup"),
    OrientationPreset = Object.freeze([{
        VERTICAL: "1"
    }, {
        HORIZONTAL: "0"
    }]),
    defaultString = "------------------------------------------------------";
DynamicLayoutGroup.attributes.add("a", {
    type: "string",
    title: "Desktop Landscape",
    default: defaultString
}), DynamicLayoutGroup.attributes.add("desktopLandscapePreset", {
    type: "string",
    enum: OrientationPreset,
    title: "Preset"
}), DynamicLayoutGroup.attributes.add("b", {
    type: "string",
    title: "Desktop Portrait",
    default: defaultString
}), DynamicLayoutGroup.attributes.add("desktopPortraitPreset", {
    type: "string",
    enum: OrientationPreset,
    title: "Preset"
}), DynamicLayoutGroup.attributes.add("c", {
    type: "string",
    title: "Mobile Landscape",
    default: defaultString
}), DynamicLayoutGroup.attributes.add("mobileLandscapePreset", {
    type: "string",
    enum: OrientationPreset,
    title: "Preset"
}), DynamicLayoutGroup.attributes.add("d", {
    type: "string",
    title: "Mobile Portrait",
    default: defaultString
}), DynamicLayoutGroup.attributes.add("mobilePortraitPreset", {
    type: "string",
    enum: OrientationPreset,
    title: "Preset"
}), pc.extend(DynamicLayoutGroup.prototype, {
    initialize: function() {
        this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _onResize: function(t, e, i, n) {
        return n === deviceEnum.DESKTOP ? t === orientationEnum.LANDSCAPE ? void this._applyOrientation(this.desktopLandscapePreset) : t === orientationEnum.PORTRAIT ? void this._applyOrientation(this.desktopPortraitPreset) : void console.warn("Orientation", this._orientation, "is not recognized!") : n === deviceEnum.MOBILE ? t === orientationEnum.LANDSCAPE ? void this._applyOrientation(this.mobileLandscapePreset) : t === orientationEnum.PORTRAIT ? void this._applyOrientation(this.mobilePortraitPreset) : void console.warn("Orientation", this._orientation, "is not recognized!") : void 0
    },
    _applyOrientation: function(t) {
        this.entity.layoutgroup.orientation = parseInt(t)
    }
});
var PickerRaycast = pc.createScript("pickerRaycast");
pc.extend(PickerRaycast.prototype, {
    initialize: function() {
        pc.pickerFrameBuffer = this, this._layer = this.app.scene.layers.getLayerByName(this.layerName), this._position = new pc.Vec2, this._inputBetweenGames = !1, this._selectedEntity = null, this._isTileInput = !1, this._mouseMovementSet = !1, this.app.on("GameInput:" + inputEvents.DOWN, this._onDown, this), this.app.on("GameInput:" + inputEvents.MOVE, this._onMove, this), this.app.on("GameInput:" + inputEvents.UP, this._onUp, this), this.on("destroy", this._onDestroy, this)
    },
    _onDown: function(t) {
        t instanceof pc.ElementMouseEvent ? this._onMouseDown(t) : t instanceof pc.ElementTouchEvent || t instanceof TouchEvent ? this._onTouchStart(t) : t instanceof MouseEvent ? this._onMouseDown(t) : console.warn("something went wrong", t)
    },
    _onUp: function(t) {
        t instanceof pc.ElementMouseEvent ? this._onMouseUp(t) : t instanceof pc.ElementTouchEvent || t instanceof TouchEvent ? this._onTouchEnd(t) : t instanceof MouseEvent ? this._onMouseUp(t) : console.warn("something went wrong", t)
    },
    _onMove: function(t) {
        t instanceof pc.ElementMouseEvent ? this._onMouseMove(t) : t instanceof pc.ElementTouchEvent || t instanceof TouchEvent ? this._onTouchMove(t) : t instanceof MouseEvent ? this._onMouseMove(t) : console.warn("something went wrong", t)
    },
    _onDestroy: function() {
        this.app.mouse ? (this._mouseMovementSet = !1, this.app.mouse.off(pc.EVENT_MOUSEDOWN, this._onMouseDown, this), this.app.mouse.off(pc.EVENT_MOUSEMOVE, this._onMouseMove, this), this.app.mouse.off(pc.EVENT_MOUSEUP, this._onMouseUp, this)) : this.app.touch &amp;&amp; (this.app.touch.off(pc.EVENT_TOUCHSTART, this._onTouchStart, this), this.app.touch.off(pc.EVENT_TOUCHMOVE, this._onTouchMove, this), this.app.touch.off(pc.EVENT_TOUCHEND, this._onTouchEnd, this))
    },
    _destroyMouseInput: function() {
        !0 === this._mouseMovementSet &amp;&amp; (this._mouseMovementSet = !1, this.app.mouse.off(pc.EVENT_MOUSEDOWN, this._onMouseDown, this), this.app.mouse.off(pc.EVENT_MOUSEMOVE, this._onMouseMove, this), this.app.mouse.off(pc.EVENT_MOUSEUP, this._onMouseUp, this))
    },
    _onMouseDown: function(t) {
        this._position.set(t.x, t.y), this._selectedEntity = this._onSelect("start"), this.checkTileInput(), this.app.fire("PickerRaycast:onClick", this._selectedEntity), this._selectedEntity &amp;&amp; this._selectedEntity &amp;&amp; this._checkEntitySelect(this._selectedEntity)
    },
    _onMouseMove: function(t) {
        this.app.mouse.isPressed(pc.MOUSEBUTTON_LEFT) &amp;&amp; (this._position.set(t.x, t.y), this._isTileInput &amp;&amp; (this._selectedEntity = this._onSelect(), this._selectedEntity &amp;&amp; this._checkEntitySelect(this._selectedEntity)))
    },
    _onMouseUp: function(t) {
        this._position.set(t.x, t.y), this._selectedEntity = this._onSelect(), this._selectedEntity &amp;&amp; this._checkEntitySelect(this.selectedEntity), this._isTileInput = !1, this.app.fire("SwapMode:inputStopped", !1)
    },
    _onTouchStart: function(t) {
        this._destroyMouseInput();
        var e = t.touches[0];
        this._position.set(e.x || e.clientX, e.y || e.clientY), this._selectedEntity = this._onSelect("start"), this.checkTileInput(), this._selectedEntity &amp;&amp; this._selectedEntity &amp;&amp; this._checkEntitySelect(this._selectedEntity)
    },
    _onTouchMove: function(t) {
        var e = t.touches[0];
        this._position.set(e.x || e.clientX, e.y || e.clientY), this._isTileInput &amp;&amp; (this._selectedEntity = this._onSelect(), this._selectedEntity &amp;&amp; this._selectedEntity &amp;&amp; this._checkEntitySelect(this._selectedEntity))
    },
    _onTouchEnd: function(t) {
        var e = this._onSelect();
        this._selectedEntity &amp;&amp; this._selectedEntity &amp;&amp; this._checkEntitySelect(e), this._isTileInput = !1, this.app.fire("SwapMode:inputStopped", !1)
    },
    _checkEntitySelect: function(t) {
        t &amp;&amp; this._selectedEntity &amp;&amp; this._inputBetweenGames &amp;&amp; t === this._selectedEntity &amp;&amp; t.script &amp;&amp; t.script.foregroundTile &amp;&amp; t.script.foregroundTile.swappable &amp;&amp; GameManager.instance.onSelect(t.script.foregroundTile), this._selectedEntity = null
    },
    _onSelect: function() {
        var t = this.entity.camera.screenToWorld(this._position.x, this._position.y, this.entity.camera.nearClip),
            e = this.entity.camera.screenToWorld(this._position.x, this._position.y, this.entity.camera.farClip),
            i = new pc.Ray(t, e.clone().sub(t).normalize()),
            s = GridManager.instance.intersectsRay(i, this.entity.getPosition());
        return s ? s.entity : null
    },
    checkTileInput: function() {
        this._selectedEntity ? this._isTileInput = this._selectedEntity.tags.has("tile") : this._isTileInput = !1
    },
    isTileInput: function() {
        return this._isTileInput
    },
    setInputBetweenGamesEnabled: function(t) {
        this._inputBetweenGames = t
    }
});
var BrandingButton = pc.createScript("brandingButton");
pc.extend(BrandingButton.prototype, {
    initialize: function() {
        var e = window.famobi.getBrandingButtonImage(),
            t = new pc.Asset("famobi_branding_button", "texture", {
                url: e
            });
        this.app.assets.add(t), LazyLoader.instance.lazyLoad(t, this.onLoadedAsset, this), this.entity.element.on("mouseup", this.onRelease, this), this.entity.element.on("touchend", this.onRelease, this)
    },
    onLoadedAsset: function(e) {
        this.entity.element.enabled = !0, this.entity.element.texture = e.resource
    },
    onRelease: function() {
        window.famobi.openBrandingLink()
    }
});
var TutorialBoosterToggle = pc.createScript("tutorialBoosterToggle");
TutorialBoosterToggle.attributes.add("buttonsInOrderOfType", {
    type: "entity",
    array: !0
}), pc.extend(TutorialBoosterToggle.prototype, {
    initialize: function() {
        this.app.on("TutorialManager:enableBooster", this.toggleOn, this), this.app.on("TutorialManager:enableBoosters", this.toggleAll, this), this.app.on("TutorialManager:disableBoosters", this.toggleOff, this)
    },
    toggleOff: function() {
        for (var t = 0; t &lt; this.buttonsInOrderOfType.length; t++) this.buttonsInOrderOfType[t].script.boosterButton.disableForTutorial()
    },
    toggleOn: function(t) {
        for (var e = 0; e &lt; this.buttonsInOrderOfType.length; e++) {
            var o = e === t;
            this.buttonsInOrderOfType[e].script.boosterButton.enableInput(o), this.buttonsInOrderOfType[e].script.boosterButton.enableTutorial(o), o ? (this.buttonsInOrderOfType[e].script.boosterButton.setTutorial(!0), TutorialManager.instance.setBoosterEntity(this.buttonsInOrderOfType[e])) : this.buttonsInOrderOfType[e].script.boosterButton.setTutorial(!1)
        }
        this.entity.enabled = !0
    },
    toggleAll: function() {
        for (var t = 0; t &lt; this.buttonsInOrderOfType.length; t++) this.buttonsInOrderOfType[t].script.boosterButton._active &amp;&amp; this.buttonsInOrderOfType[t].script.boosterButton.enableInput(!0), this.buttonsInOrderOfType[t].script.boosterButton.setTutorial(!1), this.buttonsInOrderOfType[t].script.boosterButton.enableTutorial(!1)
    }
});
var Confetti = pc.createScript("confetti");
Confetti.attributes.add("confettiParticles", {
    type: "entity",
    array: !0
}), pc.extend(Confetti.prototype, {
    initialize: function() {
        for (var t = 0; t &lt; this.confettiParticles.length; t++) {
            this.confettiParticles[t].particlesystem.reset()
        }
        this.app.on("ConfirmLeaveGameButton:leave", this.stop, this), this.app.on("SwapMode:onEndStart", this.play, this), this.app.on("WinScreen:close", this.stop, this)
    },
    play: function() {
        for (var t = 0; t &lt; this.confettiParticles.length; t++) {
            var e = this.confettiParticles[t].particlesystem;
            e.reset(), e.play()
        }
    },
    pause: function() {
        for (var t = 0; t &lt; this.confettiParticles.length; t++) {
            this.confettiParticles[t].particlesystem.pause()
        }
    },
    stop: function() {
        for (var t = 0; t &lt; this.confettiParticles.length; t++) {
            var e = this.confettiParticles[t].particlesystem;
            e.reset(), e.stop()
        }
    }
}); // LoadScreenController.js
// var LoadScreenController = pc.createScript('loadScreenController');

// LoadScreenController.isLoading = false;
// LoadScreenController.WAIT_FOR_NEXT_SCENE = 1;
// LoadScreenController._States = Object.freeze({
//     START: 0,
//     FADEOUT: 1,
//     LOADSCREEN: 2,
//     PRELOADSCENE: 3,
//     LOADSCENE: 4,
//     POSTLOADSCENE: 5,
//     FINISH: 6,
// });

// // LoadScreenController.WORLD_BATCH_GROUPS = {
// //     holland01: 100000,
// //     holland02: 100002,
// // };

// LoadScreenController.WORLD_BATCH_GROUPS = 100000;

// pc.extend(LoadScreenController, {

//     /// &lt;summary&gt;
//     /// Loads the specified scene.
//     /// Will fade the screen to black, and show the loadscreen while loading.
//     /// Once done, screen will be faded to black and left there.
//     /// &lt;/summary&gt;
//     load: function(scene, noInitialFade, loadScreenText, musicToSetWhenLoading) {
//         if (LoadScreenController.isLoading) {
//             console.error("Cannot start a new LoadScreenController when one is already in process.");
//         }
//         else {
//             LoadScreenController.isLoading = true;

//             // Instantiate LoadScreenController
//             var controllerGO = new pc.Entity("LoadScreenController");
//             controllerGO.reparent(pc.Application.getApplication().root)
//             // GameObject.DontDestroyOnLoad(controllerGO);
//             controllerGO.addComponent('script');
//             var controller = controllerGO.script.create('loadScreenController');
//             controller.startLoadCoroutine(scene, noInitialFade, loadScreenText, musicToSetWhenLoading);
//         }
//     },
// });

// pc.extend(LoadScreenController.prototype, {

//     initialize: function() {
//         this._loading = false;

//         this._sceneToLoad = null;
//         this._noInitialFade = null;
//         this._loadScreenText = null;
//         this._musicToSetWhenLoading = null;

//         this._sceneLoaded = false;

//         this._timer = 0;

//         this._currentState = LoadScreenController._States.START;
//     },

//     startLoadCoroutine: function(sceneToLoad, noInitialFade, loadScreenText, musicToSetWhenLoading) {

//         this._loading = true;
//         this._sceneLoaded = false;        

//         this._currentState = LoadScreenController._States.START;

//         this._sceneToLoad = sceneToLoad;
//         this._noInitialFade = noInitialFade;

//         this._loadScreenText = loadScreenText;
//         this._musicToSetWhenLoading = musicToSetWhenLoading;

//         // Hide starcounter
//         // if (StarCounter.isInstanced) {
//         //     StarCounter.instance.hide(false);
//         // }

//         //if (!noInitialFade) {
//             // Fade to black
//             //UIController.instance.screenFader.fadeToColor(Globals.LOADINGSCREEN_FADE_COLOR, Globals.DEFAULT_FADE_DURATION, true);
//         //}

//         this._goToNextState();
//     },

//     _startLoadScreen: function() {
//         // Remove all UI screens
//         //this.app.fire('UIManager:hideAll');

//         // Show loadscreen
//         //this._loadScreen = UIController.instance.pushScreen(UIController.SCREEN_LOAD);
//         //this._loadScreen.setMainLabel(this._loadScreenText);
//         //this._loadScreen.setProgress(0);

//         //if (!this._noInitialFade) {
//             // Fade to clear

//             //UIController.instance.screenFader.fadeToColor(Globals.LOADINGSCREEN_FADE_COLOR_CLEAR, Globals.DEFAULT_FADE_DURATION, true);
//         //}

//         this._goToNextState();
//     },

//     _startPreLoadScene: function() {
//         // Set music
//         // if (this._musicToSetWhenLoading !== MusicController.MusicID.None) {
//         //     MusicController.instance.setMusic(this._musicToSetWhenLoading);
//         // }

//         //StarCounter.instance.hide(true);

//     },

//     _startLoadScene: function() {
//         Application.loadLevelAsync(this._sceneToLoad, this._onSceneLoaded, this);
//     },

//     _startPostLoadScene: function() {
//         //UIController.instance.screenFader.fadeToColor(Globals.LOADINGSCREEN_FADE_COLOR, Globals.DEFAULT_FADE_DURATION, true);
//     },

//     _startFinish: function() {
//         this.app.batcher.markGroupDirty(LoadScreenController.WORLD_BATCH_GROUPS);

//         this.app.fire('switchedScene');

//         // Hide loadscreen
//         this.app.fire('UIManager:hideAll');
//         //this.app.fire('UIManager:showUI', 'Menu');

//         // Let GameManager know if it is instanced
//         if (pc.gameManager) {
//             pc.gameManager.loadScreenDone();
//         }

//         // Destroy self
//         this.entity.destroy();

//         LoadScreenController.isLoading = false;
//     },

//     _onSceneLoaded: function() {
//         this._sceneLoaded = true;
//         var assetsToLoad = this.app.assets._assets.filter(function(asset) { 
//             return asset.loading; 
//         });

//         this._totalAssetsToLoad = assetsToLoad.length;
//         this._assetsLoaded = 0;

//         var loaded = 0;

//         for (var i = 0; i &lt; assetsToLoad.length; i++) {
//             assetsToLoad[i].ready(this._updateProgress, this);
//         }

//         if (this._totalAssetsToLoad === 0) {
//             //this._loadScreen.setProgress(1);
//             this._goToNextState();
//         }
//     },

//     _updateProgress: function() {
//         this._assetsLoaded++;

//        // this._loadScreen.setProgress(this._assetsLoaded / this._totalAssetsToLoad);

//         var assetsToLoad = this.app.assets._assets.filter(function(asset) { 
//             return asset.loading; 
//         });

//         // TODO Fix this
//         if ((this._assetsLoaded + assetsToLoad.length) &gt; this._totalAssetsToLoad) {
//             //this._totalAssetsToLoad +=  (this._assetsLoaded + assetsToLoad.length) - this._totalAssetsToLoad;
//         }
//         if (this._assetsLoaded &gt;= this._totalAssetsToLoad) {
//             this._goToNextState();
//         }
//     },


//     update: function() {
//         if (!this._loading) {
//             return;
//         }

//         // console.log(this.app.assets._loader._requests)

//         switch (this._currentState) {
//             case LoadScreenController._States.FADEOUT:
//                 this._waitForFadeIsDone();
//                 break;

//             case LoadScreenController._States.PRELOADSCENE:
//                 this._wait(LoadScreenController.WAIT_FOR_NEXT_SCENE);
//                 break;

//             case LoadScreenController._States.POSTLOADSCENE:
//                 this._waitForFadeIsDone();
//                 break;
//         }
//     },

//     _waitForFadeIsDone: function() {
//         //if (!UIController.instance.screenFader.isFading) {

//             this._goToNextState();
//         //}
//     },

//     _wait: function(duration) {
//         //this._timer += Time.deltaTime;

//         //if (this._timer &gt;= duration) {
//             this._goToNextState();
//         //}
//     },

//     _goToNextState: function() {
//         this._currentState++;

//         switch (this._currentState) {
//             case LoadScreenController._States.FADEOUT:
//                 break;

//             case LoadScreenController._States.LOADSCREEN:
//                 this._startLoadScreen();
//                 break;

//             case LoadScreenController._States.PRELOADSCENE:
//                 this._timer = 0;
//                 this._startPreLoadScene();
//                 break;

//             case LoadScreenController._States.LOADSCENE:
//                 this._startLoadScene();
//                 break;

//             case LoadScreenController._States.POSTLOADSCENE:
//                 this.app.lightmapper.bake();
//                 this._startPostLoadScene();
//                 break;

//             case LoadScreenController._States.FINISH:
//                 this._startFinish();
//                 break;
//         }
//     },
// });

var MatchLogic = {};
Object.defineProperty(MatchLogic, "columns", {
    get: function() {
        return this._columns
    }
}), Object.defineProperty(MatchLogic, "rows", {
    get: function() {
        return this._rows
    }
}), pc.extend(MatchLogic, {
    initialize: function() {
        this.app = pc.Application.getApplication(), this._foreground = null, this._background = null, this._exits = null, this._columns = 0, this._rows = 0, this.app = pc.Application.getApplication()
    },
    setGridSize: function(e, i) {
        this._columns = e, this._rows = i
    },
    setGrid: function(e, i, t) {
        this._foreground = e, this._background = i, this._exits = t
    },
    removeGrid: function() {
        this._foreground = null, this._columns = 0, this._rows = 0
    },
    getMatch: function(e, i) {
        if (e.typeID === foregroundTileEnum.DROPPER) return [];
        var t = this._getMatchHorizontal(e, tileLayerEnum.FOREGROUND),
            r = this._getMatchVertical(e, tileLayerEnum.FOREGROUND),
            a = [];
        return t.length &gt;= i &amp;&amp; pc.utils.fuseUniqueArray(a, t), r.length &gt;= i &amp;&amp; pc.utils.fuseUniqueArray(a, r), GridManager.instance.setTileDespawnDelay(a), this.app.fire("ScoreManager:onTileMatch", a.length, e), a = this.getChainedPowerTileMatches(a), this._checkPowerTileChange(e, t, r), a
    },
    getDropperMatches: function() {
        for (var e = [], i = this._getLayerArray(tileLayerEnum.FOREGROUND), t = 0; t &lt; this._exits.length; t++) {
            var r = this._exits[t],
                a = i[r.x][r.y];
            a &amp;&amp; (a.typeID === foregroundTileEnum.DROPPER || a.typeID === foregroundTileEnum.DROPPER_COLLECTION) &amp;&amp; a.isActive() &amp;&amp; a.isSwappable() &amp;&amp; e.push(a)
        }
        return e
    },
    getCascadeMatches: function(e, i) {
        for (var t = this._getMovedTiles(tileLayerEnum.FOREGROUND), r = [], a = [], n = [], s = [], h = 0; h &lt; t.length; h += 1) {
            var o = this._getMatchHorizontal(t[h], tileLayerEnum.FOREGROUND);
            if (o.length &gt;= e &amp;&amp; (!pc.utils.isDuplicateIn2DArrayAndArray(n, o) || 0 === n.length))
                for (n.push(o), pc.utils.fuseUniqueArray(a, o);;) {
                    var l = o[Math.floor(Math.random() * o.length)];
                    if (GridManager.instance.canExplode(l.x, l.y)) {
                        r.push({
                            matchTile: l,
                            horizontalMatch: o,
                            verticalMatch: []
                        });
                        break
                    }
                }
        }
        for (var u = pc.utils.duplicateArray(r), c = 0; c &lt; t.length; c += 1) {
            var g = this._getMatchVertical(t[c], tileLayerEnum.FOREGROUND);
            if (g.length &gt;= e &amp;&amp; (!pc.utils.isDuplicateIn2DArrayAndArray(s, g) || 0 === s.length)) {
                s.push(g), pc.utils.fuseUniqueArray(a, g);
                var f = this._getDuplicateInCascadeMatches(u, g);
                if (null !== f) r[f.matchID].verticalMatch = g, r[f.matchID].matchTile = r[f.matchID].horizontalMatch[f.tileID];
                else
                    for (;;) {
                        l = g[Math.floor(Math.random() * g.length)];
                        if (GridManager.instance.canExplode(l.x, l.y)) {
                            r.push({
                                matchTile: l,
                                horizontalMatch: [],
                                verticalMatch: g
                            });
                            break
                        }
                    }
            }
        }
        if (!i) {
            GridManager.instance.setTileDespawnDelay(a);
            for (var p = 0; p &lt; r.length; p += 1) GridManager.instance.addScoreForEachTileInMatch(r[p]), a = this.getChainedPowerTileMatches(a), this._checkPowerTileChange(r[p].matchTile, r[p].horizontalMatch, r[p].verticalMatch)
        }
        var _ = this.getDropperMatches();
        for (p = 0; p &lt; _.length; p++) a.push(_[p]);
        return a
    },
    _getDuplicateInCascadeMatches: function(e, i) {
        for (var t = 0; t &lt; e.length; t++)
            for (var r = e[t].horizontalMatch, a = 0; a &lt; r.length; a++)
                if (-1 !== i.indexOf(r[a])) return {
                    matchID: t,
                    tileID: a
                };
        return null
    },
    getAllPossibleMatches: function() {
        for (var e = this._getLayerArray(tileLayerEnum.FOREGROUND), i = [], t = 0; t &lt; this._columns; t++)
            for (var r = 0; r &lt; this._rows; r++)
                if (e[t][r])
                    for (var a = this.getPossibleMatches(e[t][r]), n = 0; n &lt; a.length; n++) {
                        for (var s = !1, h = 0; h &lt; i.length &amp;&amp; !(s = this.isSameMatch(i[h], a[n])); h++);
                        s || i.push(a[n])
                    }
        return i
    },
    getPossibleMatches: function(e) {
        var i = [],
            t = e.colorID,
            r = this._getNeighboursLeft(e, 3, tileLayerEnum.FOREGROUND),
            a = this._getNeighboursRight(e, 3, tileLayerEnum.FOREGROUND),
            n = this._getNeighboursUp(e, 3, tileLayerEnum.FOREGROUND),
            s = this._getNeighboursDown(e, 3, tileLayerEnum.FOREGROUND),
            h = null,
            o = null,
            l = null,
            u = null,
            c = null,
            g = -1;
        if (3 === r.length &amp;&amp; this.sumOfIdEqualToTwo(r, t) &amp;&amp; -1 !== (g = this.getTileIndexNotEqualId(r, t)) &amp;&amp; (h = r[g]).isSwappable()) {
            if (o = 0 === g ? this._getNeighboursLeft(h, 2, tileLayerEnum.FOREGROUND)[0] : null, l = 2 === g ? this._getNeighboursRight(h, 2, tileLayerEnum.FOREGROUND)[1] : null, u = this._getNeighboursUp(h, 2, tileLayerEnum.FOREGROUND)[0], c = this._getNeighboursDown(h, 2, tileLayerEnum.FOREGROUND)[1], -1 !== r.indexOf(u) &amp;&amp; console.warn("something went wrong, leftArray", u, r), -1 !== r.indexOf(c) &amp;&amp; console.warn("something went wrong, leftArray", c, r), o &amp;&amp; o.colorID === t &amp;&amp; this._columns &gt;= 3 &amp;&amp; o.isSwappable()) {
                (p = this._increaseMatchHorizontal(r, t, o, tileLayerEnum.FOREGROUND)).push(o);
                var f = [h, o];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (l &amp;&amp; l.colorID === t &amp;&amp; this._columns &gt;= 4 &amp;&amp; l.isSwappable()) {
                (p = this._increaseMatchHorizontal(r, t, l, tileLayerEnum.FOREGROUND)).push(l);
                f = [h, l];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (u &amp;&amp; u.colorID === t &amp;&amp; u.isSwappable()) {
                (p = this._increaseMatchHorizontal(r, t, u, tileLayerEnum.FOREGROUND)).push(u);
                f = [h, u];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (c &amp;&amp; c.colorID === t &amp;&amp; c.isSwappable()) {
                (p = this._increaseMatchHorizontal(r, t, c, tileLayerEnum.FOREGROUND)).push(c);
                f = [h, c];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
        }
        if (3 === a.length &amp;&amp; this.sumOfIdEqualToTwo(a, t) &amp;&amp; -1 !== (g = this.getTileIndexNotEqualId(a, t)) &amp;&amp; (h = a[g]).isSwappable()) {
            if (o = 0 === g ? this._getNeighboursLeft(h, 2, tileLayerEnum.FOREGROUND)[0] : null, l = 2 === g ? this._getNeighboursRight(h, 2, tileLayerEnum.FOREGROUND)[1] : null, u = this._getNeighboursUp(h, 2, tileLayerEnum.FOREGROUND)[0], c = this._getNeighboursDown(h, 2, tileLayerEnum.FOREGROUND)[1], -1 !== a.indexOf(u) &amp;&amp; console.warn("something went wrong, rightArray", u, a), -1 !== a.indexOf(c) &amp;&amp; console.warn("something went wrong, rightArray", c, a), o &amp;&amp; o.colorID === t &amp;&amp; this._columns &gt;= 3 &amp;&amp; o.isSwappable()) {
                (p = this._increaseMatchHorizontal(a, t, o, tileLayerEnum.FOREGROUND)).push(o);
                f = [h, o];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (l &amp;&amp; l.colorID === t &amp;&amp; this._columns &gt;= 4 &amp;&amp; l.isSwappable()) {
                (p = this._increaseMatchHorizontal(a, t, l, tileLayerEnum.FOREGROUND)).push(l);
                f = [h, l];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (u &amp;&amp; u.colorID === t &amp;&amp; u.isSwappable()) {
                (p = this._increaseMatchHorizontal(a, t, u, tileLayerEnum.FOREGROUND)).push(u);
                f = [h, u];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (c &amp;&amp; c.colorID === t &amp;&amp; c.isSwappable()) {
                (p = this._increaseMatchHorizontal(a, t, c, tileLayerEnum.FOREGROUND)).push(c);
                f = [h, c];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
        }
        if (3 === n.length &amp;&amp; this.sumOfIdEqualToTwo(n, t) &amp;&amp; -1 !== (g = this.getTileIndexNotEqualId(n, t)) &amp;&amp; (h = n[g]).isSwappable()) {
            if (u = 0 === g ? this._getNeighboursUp(h, 2, tileLayerEnum.FOREGROUND)[0] : null, c = 2 === g ? this._getNeighboursDown(h, 2, tileLayerEnum.FOREGROUND)[1] : null, o = this._getNeighboursLeft(h, 2, tileLayerEnum.FOREGROUND)[0], l = this._getNeighboursRight(h, 2, tileLayerEnum.FOREGROUND)[1], -1 !== n.indexOf(u) &amp;&amp; console.warn("something went wrong", u, n), -1 !== n.indexOf(c) &amp;&amp; console.warn("something went wrong", c, n), o &amp;&amp; o.colorID === t &amp;&amp; this._columns &gt;= 3 &amp;&amp; o.isSwappable()) {
                (p = this._increaseMatchVertical(n, t, o, tileLayerEnum.FOREGROUND)).push(o);
                f = [h, o];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (l &amp;&amp; l.colorID === t &amp;&amp; this._columns &gt;= 4 &amp;&amp; l.isSwappable()) {
                (p = this._increaseMatchVertical(n, t, l, tileLayerEnum.FOREGROUND)).push(l);
                f = [h, l];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (u &amp;&amp; u.colorID === t &amp;&amp; u.isSwappable()) {
                (p = this._increaseMatchVertical(n, t, u, tileLayerEnum.FOREGROUND)).push(u);
                f = [h, u];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (c &amp;&amp; c.colorID === t &amp;&amp; c.isSwappable()) {
                (p = this._increaseMatchVertical(n, t, c, tileLayerEnum.FOREGROUND)).push(c);
                f = [h, c];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
        }
        if (3 === s.length &amp;&amp; this.sumOfIdEqualToTwo(s, t) &amp;&amp; -1 !== (g = this.getTileIndexNotEqualId(s, t)) &amp;&amp; (h = s[g]).isSwappable()) {
            if (u = 0 === g ? this._getNeighboursUp(h, 2, tileLayerEnum.FOREGROUND)[0] : null, c = 2 === g ? this._getNeighboursDown(h, 2, tileLayerEnum.FOREGROUND)[1] : null, o = this._getNeighboursLeft(h, 2, tileLayerEnum.FOREGROUND)[0], l = this._getNeighboursRight(h, 2, tileLayerEnum.FOREGROUND)[1], -1 !== s.indexOf(u) &amp;&amp; console.warn("something went wrong, down", u, s), -1 !== s.indexOf(c) &amp;&amp; console.warn("something went wrong, down", c, s), o &amp;&amp; o.colorID === t &amp;&amp; this._columns &gt;= 3 &amp;&amp; o.isSwappable()) {
                (p = this._increaseMatchVertical(s, t, o, tileLayerEnum.FOREGROUND)).push(o);
                f = [h, o];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (l &amp;&amp; l.colorID === t &amp;&amp; this._columns &gt;= 4 &amp;&amp; l.isSwappable()) {
                (p = this._increaseMatchVertical(s, t, l, tileLayerEnum.FOREGROUND)).push(l);
                f = [h, l];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (u &amp;&amp; u.colorID === t &amp;&amp; u.isSwappable()) {
                (p = this._increaseMatchVertical(s, t, u, tileLayerEnum.FOREGROUND)).push(u);
                f = [h, u];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
            if (c &amp;&amp; c.colorID === t &amp;&amp; c.isSwappable()) {
                var p;
                (p = this._increaseMatchVertical(s, t, c, tileLayerEnum.FOREGROUND)).push(c);
                f = [h, c];
                i.push({
                    matchTiles: p,
                    switchTiles: f
                })
            }
        }
        if (e.isPowerTile() &amp;&amp; e.isSwappable()) {
            var _ = null;
            if (e.isColorPowerTile()) {
                _ = this._getNeighbours(e, null, tileLayerEnum.FOREGROUND);
                for (var y = 0; y &lt; _.length; y++) {
                    (R = _[y]).isSwappable() &amp;&amp; i.push({
                        matchTiles: [e, _[y]],
                        switchTiles: [e, _[y]]
                    })
                }
            } else {
                _ = this._getNeighbours(e, null, tileLayerEnum.FOREGROUND);
                for (var m = 0; m &lt; _.length; m++) {
                    var R;
                    (R = _[m]).isPowerTile() &amp;&amp; !R.isColorPowerTile() &amp;&amp; R.isSwappable() &amp;&amp; i.push({
                        matchTiles: [e, R],
                        switchTiles: [e, R]
                    })
                }
            }
        }
        return i
    },
    isSameMatch: function(e, i) {
        if (e.matchTiles.length !== i.matchTiles.length) return !1;
        for (var t = 0; t &lt; e.matchTiles.length; t++) {
            for (var r = !1, a = 0; a &lt; i.matchTiles.length; a++) {
                var n = e.matchTiles[t],
                    s = i.matchTiles[a];
                if (n.x === s.x &amp;&amp; n.y === s.y) {
                    r = !0;
                    break
                }
            }
            if (!r) return !1
        }
        return !0
    },
    _getMatchHorizontal: function(e, i) {
        var t = this._getLayerArray(i),
            r = [e],
            a = e.colorID;
        if (e.colorID === tileColorEnum.NONE) return r;
        for (var n = e.x, s = e.y, h = null;;) {
            if (!this._isXInRange(--n)) break;
            if (!(h = t[n][s]) || h.colorID !== a || !h.isActive()) break;
            r.push(h)
        }
        for (n = e.x;;) {
            if (!this._isXInRange(++n)) break;
            if (!(h = t[n][s]) || h.colorID !== a || !h.isActive()) break;
            r.push(h)
        }
        return r
    },
    _getMatchVertical: function(e, i) {
        var t = this._getLayerArray(i),
            r = [e],
            a = e.colorID;
        if (e.colorID === tileColorEnum.NONE) return r;
        for (var n = e.x, s = e.y, h = null;;) {
            if (!this._isYInRange(--s)) break;
            if (!(h = t[n][s]) || h.colorID !== a || !h.isActive()) break;
            r.push(h)
        }
        for (s = e.y;;) {
            if (!this._isYInRange(++s)) break;
            if (!(h = t[n][s]) || h.colorID !== a || !h.isActive()) break;
            r.push(h)
        }
        return r
    },
    _checkPowerTileChange: function(e, i, t) {
        var r = PowerTileManager.instance.checkPowerTileSpawn(i.length, t.length);
        PowerTileManager.instance.isPowerTile(r) &amp;&amp; (GridManager.instance.powerTileArray.push({
            x: e.x,
            y: e.y,
            colorID: e.colorID,
            typeID: r
        }), GridManager.instance.setTileConvergencePoint(e.x, e.y, i, t))
    },
    getChainedPowerTileMatches: function(e) {
        var i, t;
        do {
            i = e.length, t = (e = this._getPowerTileMatches(e)).length
        } while (i !== t);
        return e
    },
    _getPowerTileMatches: function(e, i) {
        for (var t = [], r = 0; r &lt; e.length; r++) powerMatchArray = PowerTileManager.instance.onTileMatch(e[r]), powerMatchArray.length &gt; 0 &amp;&amp; pc.utils.fuseArray(t, powerMatchArray);
        return pc.utils.fuseUniqueArray(e, t), e
    },
    _increaseMatchHorizontal: function(e, i, t, r) {
        var a = this._getLayerArray(r),
            n = -1,
            s = -1,
            h = -1,
            o = e[this.getTileIndexNotEqualId(e, i)],
            l = [];
        for (s = o.x, h = o.y; this._isYInRange(--h);) {
            var u = a[s][h];
            if (!u || u.colorID !== i) break;
            if (u === t) break;
            l.push(u)
        }
        for (s = o.x, h = o.y; this._isYInRange(++h);) {
            var c = a[s][h];
            if (!c || c.colorID !== i) break;
            if (c === t) break;
            l.push(c)
        }
        var g = e.filter((function(e) {
            return e.colorID === i
        }));
        for (n = 0, s = g[0].x, h = g[0].y; n &lt; this._columns &amp;&amp; (n++, this._isXInRange(--s));) {
            var f = a[s][h];
            if (f === o);
            else {
                if (!f || f.colorID !== i) break;
                if (-1 !== g.indexOf(f) || t === f) break;
                g.unshift(f)
            }
        }
        for (n = 0, s = g[g.length - 1].x, h = g[g.length - 1].y; n &lt; this._columns &amp;&amp; (n++, this._isXInRange(++s));) {
            var p = a[s][h];
            if (p === o);
            else {
                if (!p || p.colorID !== i) break;
                if (-1 !== g.indexOf(p) || t === p) break;
                g.push(p)
            }
        }
        if (l.length &gt;= 2)
            for (var _ = 0; _ &lt; l.length; _++) g.push(l[_]);
        return g.hasDuplicate() &amp;&amp; console.error("has duplicate post horizontal"), g
    },
    _increaseMatchVertical: function(e, i, t, r) {
        var a = this._getLayerArray(r),
            n = -1,
            s = -1,
            h = -1,
            o = e[this.getTileIndexNotEqualId(e, i)],
            l = [];
        for (s = o.x, h = o.y; this._isXInRange(--s);) {
            var u = a[s][h];
            if (!u || u.colorID !== i) break;
            if (-1 !== l.indexOf(u) || u === t) break;
            l.push(u)
        }
        for (s = o.x, h = o.y; this._isXInRange(++s);) {
            var c = a[s][h];
            if (!c || c.colorID !== i) break;
            if (-1 !== l.indexOf(c) || c === t) break;
            l.push(c)
        }
        var g = e.filter((function(e) {
            return e.colorID === i
        }));
        for (n = 0, s = g[0].x, h = g[0].y; n &lt; this._rows &amp;&amp; (n++, this._isYInRange(++h));) {
            var f = a[s][h];
            if (-1 !== g.indexOf(f) &amp;&amp; console.warn("Something went wrong", f), f === o);
            else {
                if (!f || f.colorID !== i || t === f) break;
                g.unshift(f)
            }
        }
        for (n = 0, s = g[g.length - 1].x, h = g[g.length - 1].y; n &lt; this._rows &amp;&amp; (n++, this._isYInRange(--h));) {
            var p = a[s][h];
            if (-1 !== g.indexOf(p) &amp;&amp; console.warn("Something went wrong", p), p === o);
            else {
                if (!p || p.colorID !== i || t === p) break;
                g.push(p)
            }
        }
        if (l.length &gt;= 2)
            for (var _ = 0; _ &lt; l.length; _++) g.push(l[_]);
        return g.hasDuplicate() &amp;&amp; console.error("has duplicate post Vertical"), g
    },
    _getNeighboursLeft: function(e, i, t, r) {
        var a = this._getLayerArray(t),
            n = [];
        if (!e) return console.warn("something went wrong"), [];
        for (var s = e.x, h = e.y, o = i - 1; o &gt;= 0; o--) {
            var l = s - o;
            if (!this._isXInRange(l)) break;
            var u = a[l][h];
            if (!u) break;
            if (r &amp;&amp; !this._background[l][h].foregroundSwappable) break;
            n.push(u)
        }
        return n
    },
    _getNeighboursRight: function(e, i, t, r) {
        for (var a = this._getLayerArray(t), n = [], s = e.x, h = e.y, o = 0; o &lt; i; o++) {
            var l = s + o;
            if (!this._isXInRange(l)) break;
            var u = a[l][h];
            if (!u) break;
            if (r &amp;&amp; !this._background[l][h].foregroundSwappable) break;
            n.push(u)
        }
        return n
    },
    _getNeighboursUp: function(e, i, t, r) {
        for (var a = this._getLayerArray(t), n = [], s = e.x, h = e.y, o = i - 1; o &gt;= 0; o--) {
            var l = h + o;
            if (!this._isYInRange(l)) break;
            var u = a[s][l];
            if (!u) break;
            if (r &amp;&amp; !this._background[s][l].foregroundSwappable) break;
            n.push(u)
        }
        return n
    },
    _getNeighboursDown: function(e, i, t, r) {
        for (var a = this._getLayerArray(t), n = [], s = e.x, h = e.y, o = 0; o &lt; i; o++) {
            var l = h - o;
            if (!this._isYInRange(l)) break;
            var u = a[s][l];
            if (!u) break;
            if (r &amp;&amp; !this._background[s][l].foregroundSwappable) break;
            n.push(u)
        }
        return n
    },
    getNeighbours: function(e, i, t, r) {
        return this._getNeighbours(e, i, t, r)
    },
    _getNeighbours: function(e, i, t, r) {
        var a = this._getLayerArray(t),
            n = [],
            s = e.x,
            h = e.y,
            o = s - 1,
            l = s + 1,
            u = h + 1,
            c = h - 1;
        return this._isXInRange(o) &amp;&amp; (i &amp;&amp; i === a[o][h].colorID || !i) &amp;&amp; (a[o][h] ? n.push(a[o][h]) : r &amp;&amp; n.push({
            x: o,
            y: h
        })), this._isXInRange(l) &amp;&amp; (i &amp;&amp; i === a[l][h].colorID || !i) &amp;&amp; (a[l][h] ? n.push(a[l][h]) : r &amp;&amp; n.push({
            x: l,
            y: h
        })), this._isYInRange(u) &amp;&amp; (i &amp;&amp; i === a[s][u].colorID || !i) &amp;&amp; (a[s][u] ? n.push(a[s][u]) : r &amp;&amp; n.push({
            x: s,
            y: u
        })), this._isYInRange(c) &amp;&amp; (i &amp;&amp; i === a[s][c].colorID || !i) &amp;&amp; (a[s][c] ? n.push(a[s][c]) : r &amp;&amp; n.push({
            x: s,
            y: c
        })), n
    },
    areNeighbours: function(e, i) {
        var t = Math.abs(e.x - i.x),
            r = Math.abs(e.y - i.y);
        return 1 === t &amp;&amp; 0 === r || 0 === t &amp;&amp; 1 === r
    },
    _getLayerArray: function(e) {
        if ("number" != typeof e) return console.warn("No layer is selected: ", e, ". Set to foreground"), this._foreground;
        switch (e) {
            case tileLayerEnum.FOREGROUND:
                return this._foreground;
            case tileLayerEnum.BACKGROUND:
                return this._background;
            default:
                console.error("Cannot find this layer", e, "Here are the available layers:", MatchLogic.Layers)
        }
        return null
    },
    _isXInRange: function(e) {
        return !(e &lt; 0) &amp;&amp; !(e &gt;= this._columns)
    },
    _isYInRange: function(e) {
        return !(e &lt; 0) &amp;&amp; !(e &gt;= this._rows)
    },
    sumOfIdEqualToTwo: function(e, i) {
        return 2 === e.reduce((function(e, t) {
            return t &amp;&amp; t.colorID === i ? e + 1 : e
        }), 0)
    },
    getTileIndexNotEqualId: function(e, i) {
        return e.findIndex((function(e) {
            return e instanceof ForegroundTile &amp;&amp; e.colorID !== i
        }))
    },
    _getMovedTiles: function(e) {
        for (var i = this._getLayerArray(e), t = [], r = 0; r &lt; i.length; r++)
            for (var a = 0; a &lt; i[r].length; a++) i[r][a] &amp;&amp; i[r][a].isMovedTile &amp;&amp; (t.push(i[r][a]), i[r][a].isMovedTile = !1);
        return t
    },
    getAmountOfNeighbours: function(e, i) {
        var t = this._getNeighboursLeft(e, 2, tileLayerEnum.FOREGROUND, i),
            r = this._getNeighboursRight(e, 2, tileLayerEnum.FOREGROUND, i),
            a = this._getNeighboursUp(e, 2, tileLayerEnum.FOREGROUND, i),
            n = this._getNeighboursDown(e, 2, tileLayerEnum.FOREGROUND, i);
        return pc.math.clamp(t.length - 1, 0, Number.POSITIVE_INFINITY) + pc.math.clamp(r.length - 1, 0, Number.POSITIVE_INFINITY) + pc.math.clamp(a.length - 1, 0, Number.POSITIVE_INFINITY) + pc.math.clamp(n.length - 1, 0, Number.POSITIVE_INFINITY)
    }
}), MatchLogic.initialize(), pc.extend(Array.prototype, {
    hasDuplicate: function() {
        for (var e = 0; e &lt; this.length; e++)
            for (var i = 0; i &lt; this.length; i++)
                if (e !== i &amp;&amp; this[e] === this[i]) return !0;
        return !1
    }
});
var Application = {};
pc.extend(Application, {
    app: null,
    loadedLevelName: null,
    dontDestroyOnLoad: null,
    loadLevelAsync: function(e, n, o) {
        this.app || (this.app = pc.Application.getApplication());
        var a = this.app.scenes.find(e);
        if (this.sceneName = e, a) {
            var i = this.app.root.findByName("Root"),
                t = this.app.root.findByTag("dontdestroyonload")[0];
            this.dontDestroyOnLoad = t, i.removeChild(t), this.app.fire("Application:destroyScene"), this.loadedLevelName = e, i.destroy(), this._loadScene(a.url, (function(e) {
                e.addChild(t), n.call(o)
            }))
        } else console.error("Scene with the name", e, "does not exists. Available scenes are: ", this.app.scenes.list().map((function(e) {
            return e.name
        })))
    },
    _loadScene: function(e, n) {
        this.app.scenes.loadSceneHierarchy(e, (function(e, o) {
            e ? console.error(e) : (Application.app.fire("Application:loadScene"), n(o))
        }))
    }
});
var Camera = pc.createScript("camera");
Object.defineProperty(Camera.prototype, "cameraPosition", {
    get: function() {
        return void 0 === this._cameraPosition &amp;&amp; (this._cameraPosition = this.entity.getPosition()), this._cameraPosition
    }
}), Object.defineProperty(Camera.prototype, "camera", {
    get: function() {
        return void 0 === this._camera &amp;&amp; (this._camera = this.entity.camera), this._camera
    }
}), Object.defineProperty(Camera, "main", {
    get: function() {
        for (var t = pc.Application.getApplication().root.findComponents("camera"), e = 0; e &lt; t.length; e++)
            if (!t[e].entity.tags.has("ui")) return t[e].entity;
        console.error("No camera found")
    }
}), pc.extend(Camera.prototype, {
    initialize: function() {
        Camera.instance = this
    }
});
var UICamera = pc.createScript("uicamera");
pc.extend(UICamera.prototype, {
    initialize: function() {
        UICamera.instance = this, this.camera = this.entity.camera
    },
    screenToWorld: function(e, a, t) {
        return this.entity.camera.screenToWorld(e, a, t)
    }
});
var PlayerData = function(t) {
    this.initialize(t)
};
Object.defineProperty(PlayerData, "instance", {
    get: function() {
        return PlayerData._instance || (PlayerData._instance = PlayerData.load()), PlayerData._instance
    }
}), Object.defineProperty(PlayerData, "doingTutorial", {
    get: function() {
        return this._doingTutorial
    },
    set: function(t) {
        this._doingTutorial = t
    }
}), Object.defineProperty(PlayerData, "tutorialCameraLocked", {
    get: function() {
        return this._tutorialCameraLocked
    },
    set: function(t) {
        this._tutorialCameraLocked = t
    }
}), Object.defineProperty(PlayerData, "inputBetweenGames", {
    get: function() {
        return this._inputBetweenGames
    },
    set: function(t) {
        this._inputBetweenGames = t
    }
}), pc.extend(PlayerData.prototype, {
    initialize: function(t) {
        PlayerData._instance = this, this._doingTutorial = !1, this._tutorialCameraLocked = !1, this._inputBetweenGames = !1
    }
}), pc.extend(PlayerData, {
    load: function() {
        return new PlayerData(!1)
    }
});
var SkyboxLoader = pc.createScript("skyboxLoader");
SkyboxLoader.attributes.add("skybox", {
    type: "asset"
}), pc.extend(SkyboxLoader.prototype, {
    postInitialize: function() {
        this.skybox &amp;&amp; LazyLoader.instance.lazyLoad(this.skybox, this._showSkybox, this), this.on("destroy", this._hideSkybox, this)
    },
    _showSkybox: function(o) {
        this.app.scene.setSkybox(o.resources)
    },
    _hideSkybox: function() {
        this.app.scene.setSkybox(null)
    }
});
var HouseKeeper = pc.createScript("houseKeeper");
HouseKeeper.IsKindle = !0, HouseKeeper.disableAd = !1, pc.extend(HouseKeeper.prototype, {
    initialize: function() {},
    postInitialize: function() {
        GameManager.startUp()
    },
    _onApplicationPause: function(e) {
        e &amp;&amp; (GameController.isInstanced &amp;&amp; GameController.instance.PauseIfPlaying(), PlayerData.instance.dirty &amp;&amp; PlayerData.instance.save())
    }
});
var ObjectHandler = pc.createScript("objectHandler");
ObjectHandler.startStage = 0, ObjectHandler.attributes.add("holdingStages", {
    type: "asset",
    assetType: "texture",
    array: !0,
    title: "The images that you see when you hold an object"
}), ObjectHandler.attributes.add("totalAnimationSeconds", {
    type: "number",
    default: 2,
    title: "Animation time",
    description: "Amount of seconds the animation takes"
}), ObjectHandler.attributes.add("holdingHeightAddition", {
    type: "number",
    default: 1,
    title: "How much higher does the holding animation need to be"
}), ObjectHandler.attributes.add("optionImages", {
    type: "entity"
}), ObjectHandler.attributes.add("screen", {
    type: "entity"
}), ObjectHandler.attributes.add("popup", {
    type: "entity"
}), pc.extend(ObjectHandler.prototype, {
    initialize: function() {
        this.inEditMode = !1, this.checkingEntity = this.selectedEntity = this.defaultAsset = void 0, this.boundingBox = void 0, this.gardenManager = this.app.root.findByName("Garden Manager").script.gardenManager, this.gardenCamera = this.app.root.findByName("Camera").script.gardenCamera, this.holdingImage = this.screen.findOne((function(t) {
            return t.element
        })), this.currentStage = ObjectHandler.startStage, this.maxStage = this.holdingStages.length + 1, this.stageDuration = this.totalAnimationSeconds / this.maxStage, this.showingPopup = !1
    },
    checkEntity: function(t) {
        t &amp;&amp; t != this.checkingEntity &amp;&amp; (this.checkingEntity = t, this.boundingBox = this.checkingEntity.script.objectOptions.boundingbox, this.screen.enabled = !0, this.screen.setPosition(this.boundingBox.center.x, this.boundingBox.center.y + (this.boundingBox.halfExtents.y + this.holdingHeightAddition), this.boundingBox.center.z)), this._tick()
    },
    _tick: function() {
        this.currentStage = this.inEditMode ? this.maxStage : this.currentStage + 1, this.updateStage(this.currentStage - 1), this.currentStage != this.maxStage || this.selectedEntity &amp;&amp; 2 == this.selectedEntity.script.objectOptions.objectState || (this.checkingEntity.script.objectOptions.objectState &gt;= 1 ? (this.selectedEntity &amp;&amp; this._deselectObject(!0), this.selectedEntity = this.checkingEntity, this.gardenCamera.focusObject(this.selectedEntity), this.initSelector()) : this.inEditMode || this._showPopup(), this.checkingEntity = null, this.removeStageAnimation(), this.resetStageCounter())
    },
    updateStage: function(t) {
        this.holdingStages[t] ? this.holdingImage.element.textureAsset = this.holdingStages[t] : this.removeStageAnimation()
    },
    removeStageAnimation: function() {
        this.screen.enabled = !1
    },
    reset: function() {
        this.checkingEntity = this.selectedEntity = void 0, this.removeStageAnimation(), this.resetStageCounter()
    },
    resetStageCounter: function() {
        this.currentStage = ObjectHandler.startStage
    },
    initSelector: function(t) {
        this.inEditMode = !0, this.optionImages.enabled = !0, this.defaultAsset = this.selectedEntity.model.asset, this._highlightObject(!0);
        for (var e = 0; e &lt; this.optionImages._children.length; e++) {
            var i = this.optionImages._children[e];
            i.script &amp;&amp; i.script.uibuttonMessage &amp;&amp; "changeSelectedObject" === i.script.uibuttonMessage.functionName ? i.element.textureAsset = this.selectedEntity.script.objectOptions.objectImages[e] : i.enabled = !t
        }
    },
    changeSelectedObject: function(t, e) {
        if (this.selectedEntity.script.objectOptions.objectOptions.length &gt; 0) this.selectedEntity.model.asset = this.selectedEntity.script.objectOptions.objectOptions[e], this.selectedEntity.collision.asset = this.selectedEntity.script.objectOptions.objectOptions[e];
        else
            for (var i = this.selectedEntity.model.meshInstances, s = 0; s &lt; i.length; ++s) i[s].material = this.selectedEntity.script.objectOptions.materialOptions[e].resource;
        this.selectedEntity.script.objectOptions.selectedOption = e, t.element.entity.parent.findByName("Accept").enabled = !0, this.gardenCamera.focusObject(this.selectedEntity), this._highlightObject(!0)
    },
    cancelObject: function() {
        this.gardenCamera.blockCamera = !1, this._deselectObject(!0), this.reset()
    },
    acceptObject: function() {
        this.gardenManager.updateSpecificOption(this.selectedEntity), this.selectedEntity.script.objectOptions.objectState = 1, this.gardenCamera.blockCamera = !1, this._deselectObject(!1), this.reset(), this.gardenManager.handleObjectQueue()
    },
    _deselectObject: function(t) {
        !0 === t &amp;&amp; (this.selectedEntity.model.asset = this.defaultAsset, this.selectedEntity.collision.asset = this.defaultAsset), this.selectedEntity.script.objectOptions.updateBoundingBox(), this._highlightObject(!1), this.optionImages.enabled = this.inEditMode = !1
    },
    _highlightObject: function(t) {
        for (var e = this.selectedEntity.model.meshInstances, i = 0; i &lt; e.length; ++i) {
            var s = e[i],
                n = s.material.name;
            n.includes(" Highlighted") &amp;&amp; mmeshName.replace(" Highlighted", "");
            var a = this.app.assets.find(t ? n + " Highlighted" : n, "material");
            a &amp;&amp; (s.material = a.resource)
        }
    },
    _showPopup: function() {
        this.showingPopup = !0, this.popup.enabled = !0
    },
    closePopup: function() {
        this.showingPopup = !1, this.popup.enabled = !1
    }
});
var CameraManager = pc.createScript("cameraManager"),
    cameraNames = Object.freeze({
        ui: "UICamera",
        worldSelect: "WorldSelectCamera",
        game: "Camera"
    });
pc.extend(CameraManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (CameraManager.instance = this)
    },
    activateCamera: function(a) {
        this.findCamera(a).enabled = !0
    },
    findCamera: function(a) {
        return this.app.root.findByName(a)
    },
    deactivateCamera: function(a) {
        this.findCamera(a).enabled = !1
    }
});
var BackgroundTile = pc.createScript("backgroundTile");
BackgroundTile.backgroundType = [{
    WALL: backgroundTileEnum.WALL
}, {
    PANEL: backgroundTileEnum.PANEL
}, {
    BLOCKER: backgroundTileEnum.BLOCKER
}, {
    LOCKER: backgroundTileEnum.LOCKER
}, {
    VIRUS: backgroundTileEnum.VIRUS
}, {
    COAT: backgroundTileEnum.COAT
}, {
    SINKER: backgroundTileEnum.SINKER
}, {
    CHEST: backgroundTileEnum.CHEST
}, {
    STICKER: backgroundTileEnum.STICKER
}, {
    POPPER: backgroundTileEnum.POPPER
}], BackgroundTile.ExplodeMethodEnum = Object.freeze({
    CANNOT_EXPLODE: 0,
    EXPLODES_IF_HIT: 1,
    EXPLODES_IF_ADJACENT: 2
}), BackgroundTile.attributes.add("scriptName", {
    type: "string"
}), BackgroundTile.attributes.add("backgroundType", {
    type: "number",
    enum: BackgroundTile.backgroundType,
    title: "Type"
}), BackgroundTile.attributes.add("explodeMethod", {
    type: "number",
    enum: [{
        CANNOT_EXPLODE: 0
    }, {
        EXPLODES_IF_HIT: 1
    }, {
        EXPLODES_IF_ADJACENT: 2
    }],
    title: "Explode Method"
}), BackgroundTile.attributes.add("backgroundSwappable", {
    type: "boolean",
    title: "Background Swappable"
}), BackgroundTile.attributes.add("foregroundSwappable", {
    type: "boolean",
    title: "Foreground Swappable"
}), BackgroundTile.attributes.add("hasForeground", {
    type: "boolean",
    default: !0,
    title: "Has Foreground"
}), BackgroundTile.attributes.add("maxLayers", {
    type: "number",
    default: 1,
    title: "Max Layers"
}), BackgroundTile.attributes.add("onlyBackgroundExplodes", {
    type: "boolean",
    title: "Only Background Explodes"
}), BackgroundTile.attributes.add("hasGravity", {
    type: "boolean",
    title: "Has Gravity"
}), BackgroundTile.attributes.add("regrow", {
    type: "boolean",
    title: "Regrow"
}), BackgroundTile.attributes.add("customScoreColor", {
    type: "boolean"
}), BackgroundTile.attributes.add("scoreColorId", {
    type: "rgb"
}), BackgroundTile.attributes.add("scoreOutlineColorId", {
    type: "rgb"
}), pc.extend(BackgroundTile.prototype, {
    initialize: function() {
        this.subClass = this.entity.script.get(this.scriptName), this.recycled = !0, this.typeID = backgroundTileEnum.EMPTY, this.colorID = tileColorEnum.NONE, this.isDestroyed = !1, this.currentLayer = this.maxLayers, this.hasExploded = !1, this.scoreValue = 0, this._isObjective = null, this._model = this.entity.findByName("ModelEntity"), this._modelComponent = this.entity.findComponent("model"), this._startModelScale = pc.Vec3.ONE, null !== this._modelComponent &amp;&amp; (this._startModelScale = this._modelComponent.entity.getLocalScale().clone()), this.app.on("ObjectiveManager:onObjectiveSet", this._onObjectiveSet, this), this.subClass &amp;&amp; !this.entity.script.has("impulseHandler") &amp;&amp; this.entity.script.create("impulseHandler")
    },
    isDefault: function() {
        return 0 === this.scriptName.length
    },
    postInitialize: function() {
        this.subClass &amp;&amp; this.subClass.init(this)
    },
    awake: function(t, e, i) {
        this.entity.reparent(e.entity), this.stopAllTweens(), this.recycled = !1, t instanceof pc.Vec3 &amp;&amp; this.entity.setLocalPosition(t), this.isDestroyed = !1, this.setLayers(i || this.maxLayers), this.entity.setLocalScale(pc.Vec3.ONE), this.parent = e, null !== this._modelComponent &amp;&amp; this._modelComponent.entity.setLocalScale(this._startModelScale.x, this._startModelScale.y, this._startModelScale.y), null === this._isObjective &amp;&amp; this._onObjectiveSet(), this.subClass &amp;&amp; "function" == typeof this.subClass.awake &amp;&amp; this.subClass.awake(this)
    },
    _onObjectiveSet: function() {
        this._isObjective = ObjectiveManager.instance.isTileOneOfObjectives(tileLayerEnum.BACKGROUND, this.typeID, this.colorID)
    },
    setProperties: function(t, e) {
        this.x = t, this.y = e
    },
    despawnInstant: function() {
        if (this.subClass &amp;&amp; "function" == typeof this.subClass.despawnInstant) return this.subClass.despawnInstant();
        this.recycled = !0
    },
    explode: function(t) {
        if ("function" == typeof this.subClass.explode) return this.subClass.explode(t);
        this.explodeMethod === BackgroundTile.ExplodeMethodEnum.CANNOT_EXPLODE &amp;&amp; console.error("This tile should not explode"), this.hasExploded = !0, this.currentLayer--, this.subClass.explode(), this._onExplode();
        var e = 0 === this.currentLayer;
        return e &amp;&amp; (this.stopAllTweens(), this.isDestroyed = !0), e
    },
    _onExplode: function(t, e, i) {
        var s = this.entity.findComponent("model").entity;
        if (s) {
            var n, o = s.tween(s.getLocalScale()).to(this._startModelScale.clone().scale(1.2), .1, pc.SineInOut);
            t ? (this.app.fire("BackgroundTile:onExplode", tileLayerEnum.BACKGROUND, this.typeID), this._isObjective &amp;&amp; (ObjectiveManager.instance.isObjectiveCompleted(tileLayerEnum.BACKGROUND, this.typeID, this.colorID) || this.app.fire("ModelToUIManager:showAnimation", this.entity.getLocalPosition(), {
                layerID: tileLayerEnum.BACKGROUND,
                typeID: this.typeID,
                colorID: this.colorID
            }, e)), i || (n = s.tween(s.getLocalScale()).to(pc.Vec3.ZERO, .15, pc.SineInOut))) : n = s.tween(s.getLocalScale()).to(this._startModelScale.clone(), .1, pc.SineInOut), this.scoreValue &amp;&amp; (GridManager.instance.showScore(this, this.scoreValue), this.scoreValue = 0), o.chain(n), o.start()
        }
    },
    _onLayerExplode: function() {
        var t = null,
            e = this.getForegroundTile();
        t = null === e || 0 === e || this.onlyBackgroundExplodes ? this : e, this.app.fire("ScoreManager:scoreBackgroundTile", this.typeID, this._isObjective, t)
    },
    getForegroundTile: function() {
        return GridManager.instance.getTile(this.x, this.y)
    },
    setLayers: function(t) {
        this.maxLayers = t, this.currentLayer = this.maxLayers
    },
    canExplode: function() {
        return this.explodeMethod !== BackgroundTile.ExplodeMethodEnum.CANNOT_EXPLODE
    },
    setScoreAfterDelay: function(t) {
        this.scoreValue += t
    },
    stopAllTweens: function() {
        this.subClass &amp;&amp; "function" == typeof this.subClass.stopAllTweens &amp;&amp; this.subClass.stopAllTweens()
    },
    doHintAnimation: function() {
        if (this.subClass) return "function" == typeof this.subClass.doHintAnimation ? this.subClass.doHintAnimation() : void 0
    },
    stopHintAnimation: function() {
        if (this.subClass) return "function" == typeof this.subClass.stopHintAnimation ? this.subClass.stopHintAnimation() : void 0
    },
    shakeTile: function() {
        if (this.subClass) return "function" == typeof this.subClass.shakeTile ? this.subClass.shakeTile() : void 0
    },
    getDespawnDelay: function() {
        return this.subClass &amp;&amp; "function" == typeof this.subClass.getDespawnDelay ? this.subClass.getDespawnDelay() : 0
    },
    pulse: function(t, e, i, s, n) {
        this._model &amp;&amp; this.entity.script.impulseHandler.impulse(t, e, i, s, n)
    },
    playAnimation: function(t, e, i, s) {
        if ("function" == typeof this.subClass.playAnimation) return this.subClass.playAnimation(t, e, i, s)
    }
});
var Billboard = pc.createScript("billboard");
pc.extend(Billboard.prototype, {
    initialize: function() {
        this.camera = this.app.root.findByName("Camera")
    },
    update: function(t) {
        this.entity.setRotation(this.camera.getRotation())
    }
});
var GardenMouseInput = pc.createScript("gardenMouseInput");
GardenMouseInput.attributes.add("moveSensitivity", {
    type: "number",
    default: .5,
    title: "Move Sensitivity",
    description: "How fast the camera moves around the orbit. Higher is faster"
}), GardenMouseInput.attributes.add("scrollSensitivity", {
    type: "number",
    default: .3,
    title: "Scroll Sensitivity",
    description: "How fast the camera moves in and out. Higher is faster"
}), pc.extend(GardenMouseInput.prototype, {
    initialize: function() {
        this.gardenCamera = this.entity.script.gardenCamera, this.velocity = new pc.Vec3(0, 0, 0);
        var t = this,
            onMouseOut = function(e) {
                t.onMouseOut(e)
            };
        this.gardenCamera &amp;&amp; (this.app.mouse.on(pc.EVENT_MOUSEDOWN, this.onMouseDown, this), this.app.mouse.on(pc.EVENT_MOUSEUP, this.onMouseUp, this), this.app.mouse.on(pc.EVENT_MOUSEMOVE, this.onMouseMove, this), this.app.mouse.on(pc.EVENT_MOUSEWHEEL, this.onMouseWheel, this), window.addEventListener("mouseout", onMouseOut, !1), this.on("destroy", (function() {
            this.app.mouse.off(pc.EVENT_MOUSEDOWN, this.onMouseDown, this), this.app.mouse.off(pc.EVENT_MOUSEUP, this.onMouseUp, this), this.app.mouse.off(pc.EVENT_MOUSEMOVE, this.onMouseMove, this), this.app.mouse.off(pc.EVENT_MOUSEWHEEL, this.onMouseWheel, this), window.removeEventListener("mouseout", onMouseOut, !1)
        })), this.lastPoint = new pc.Vec2), this.app.mouse.disableContextMenu(), this.lookButtonDown = !1, this.lastPoint = new pc.Vec2
    },
    update: function(t) {
        this.lookButtonDown &amp;&amp; this.gardenCamera.checkHold(this.lastPoint, t)
    },
    onMouseDown: function(t) {
        this.lookButtonDown = t.button == pc.MOUSEBUTTON_LEFT || pc.MOUSEBUTTON_LEFT, this.gardenCamera.checkSelection(t)
    },
    onMouseUp: function(t) {
        this.lookButtonDown = t.button != pc.MOUSEBUTTON_LEFT &amp;&amp; pc.MOUSEBUTTON_LEFT, this.gardenCamera.stopHold()
    },
    onMouseMove: function(t) {
        pc.app.mouse;
        this.lookButtonDown &amp;&amp; (this.velocity.x = t.dx * this.moveSensitivity, this.velocity.y = t.dy * this.moveSensitivity, this.gardenCamera.updateVelocity(this.velocity)), this.lastPoint.set(t.x, t.y)
    },
    onMouseOut: function(t) {
        this.lookButtonDown = !1
    },
    onMouseWheel: function(t) {
        this.distance = t.wheel * this.scrollSensitivity, this.gardenCamera.zoom(this.distance)
    }
});
var GardenTouchInput = pc.createScript("GardenTouchInput");
GardenTouchInput.attributes.add("moveSensitivity", {
    type: "number",
    default: 1,
    title: "Move Sensitivity",
    description: "How fast the camera moves around the orbit. Higher is faster"
}), GardenTouchInput.attributes.add("distanceSensitivity", {
    type: "number",
    default: .5,
    title: "Distance Sensitivity",
    description: "How fast the camera moves in and out. Higher is faster"
}), pc.extend(GardenTouchInput.prototype, {
    initialize: function() {
        this.gardenCamera = this.entity.script.gardenCamera, this.velocity = new pc.Vec3(0, 0, 0), this.lastTouchPoint = new pc.Vec2, this.lastPinchDistance = 0, this.gardenCamera &amp;&amp; this.app.touch &amp;&amp; (this.app.touch.on(pc.EVENT_TOUCHSTART, this.onTouchStartEndCancel, this), this.app.touch.on(pc.EVENT_TOUCHEND, this.onTouchStartEndCancel, this), this.app.touch.on(pc.EVENT_TOUCHCANCEL, this.onTouchStartEndCancel, this), this.app.touch.on(pc.EVENT_TOUCHMOVE, this.onTouchMove, this), this.on("destroy", (function() {
            this.app.touch.off(pc.EVENT_TOUCHSTART, this.onTouchStartEndCancel, this), this.app.touch.off(pc.EVENT_TOUCHEND, this.onTouchStartEndCancel, this), this.app.touch.off(pc.EVENT_TOUCHCANCEL, this.onTouchStartEndCancel, this), this.app.touch.off(pc.EVENT_TOUCHMOVE, this.onTouchMove, this)
        }))), this.lookButtonDown = !1
    },
    update: function(t) {
        this.lookButtonDown &amp;&amp; this.gardenCamera.checkHold(this.lastTouchPoint, t)
    },
    onTouchStartEndCancel: function(t) {
        var i = t.touches;
        this.lookButtonDown = !0, 1 == i.length ? this.lastTouchPoint.set(i[0].x, i[0].y) : 2 == i.length ? this.lastPinchDistance = this._getPinchDistance(i[0], i[1]) : this.lookButtonDown = !1, this.gardenCamera.stopHold(), t.event.preventDefault()
    },
    onTouchMove: function(t) {
        var i = t.touches;
        if (1 == i.length) {
            var e = i[0];
            this.velocity.x = (e.x - this.lastTouchPoint.x) * this.moveSensitivity, this.velocity.y = (e.y - this.lastTouchPoint.y) * this.moveSensitivity, this.gardenCamera.updateVelocity(this.velocity), this.lastTouchPoint.set(e.x, e.y)
        } else if (2 == i.length) {
            var n = this._getPinchDistance(i[0], i[1]) - this.lastPinchDistance;
            this.gardenCamera.zoom(n * this.distanceSensitivity * .1)
        }
        t.event.preventDefault()
    },
    _getPinchDistance: function(t, i) {
        var e = t.x - i.x,
            n = t.y - i.y;
        return Math.sqrt(e * e + n * n)
    }
});
var MovesManager = pc.createScript("movesManager");
pc.extend(MovesManager.prototype, {
    initialize: function() {
        MovesManager.instance = this, this._currentMoves = 0, this._startMoves = 1, this.app.on("SwapMode:onMoveStart", this._onMove, this)
    },
    _onMove: function() {
        this._currentMoves -= 1, this.app.fire("MovesManager:setMoves", this._currentMoves)
    },
    setMoveAmount: function(e) {
        this._startMoves = e, this._currentMoves = this._startMoves, this.app.fire("MovesManager:setMoves", this._currentMoves)
    },
    addMoves: function(e) {
        this._currentMoves += e, this.app.fire("MovesManager:setMoves", this._currentMoves)
    },
    getMoves: function() {
        return this._currentMoves
    },
    getStartMoves: function() {
        return this._startMoves
    }
});
var ForegroundTile = pc.createScript("foregroundTile");
ForegroundTile.attributes.add("scriptName", {
    type: "string",
    default: "colorTile"
}), ForegroundTile.attributes.add("hasColor", {
    type: "boolean",
    default: !0
}), ForegroundTile.attributes.add("swappable", {
    type: "boolean",
    default: !0
}), ForegroundTile.attributes.add("canExplode", {
    type: "boolean",
    default: !0
}), ForegroundTile.attributes.add("countDown", {
    type: "boolean",
    default: !1
}), ForegroundTile.attributes.add("bounceHeightPerCell", {
    type: "number",
    default: .1,
    min: 0,
    max: 1
}), ForegroundTile.attributes.add("maxBounceDeltaCell", {
    type: "number",
    default: 3,
    step: 1,
    min: 1,
    max: 10,
    precision: 0
}), ForegroundTile.attributes.add("bounceDuration", {
    type: "number",
    default: .5,
    min: 0,
    max: 1
}), ForegroundTile.attributes.add("scoreColorId", {
    type: "rgb"
}), ForegroundTile.attributes.add("scoreOutlineColorId", {
    type: "rgb"
}), ForegroundTile.attributes.add("shineAnimationObjectPool", {
    type: "entity"
}), ForegroundTile._States = Object.freeze({
    INACTIVE: 0,
    ACTIVE: 1
}), ForegroundTile._PowerStates = Object.freeze({
    ACTIVE: 0,
    IMMUNE: 1,
    TRIGGERED: 2
}), pc.extend(ForegroundTile.prototype, {
    initialize: function() {
        var t = this.entity.script.get(this.scriptName);
        this._aabb = new pc.BoundingBox(new pc.Vec3, new pc.Vec3(.6, .6, .6)), t ? (this._defaultRotation = this.entity.getLocalEulerAngles().clone(), this.typeID = 0, this.colorID = 0, this.subClass = t, this.subClass.init(this), this.x = null, this.y = null, this._state = ForegroundTile._States.INACTIVE, this._powerState = ForegroundTile._PowerStates.INACTIVE, this.hasMoved = !1, this.falling = !1, this.moving = !1, this.isMovedTile = !1, this._preventDelay = !1, this._hitByPower = !1, this._ignoreDespawnStats = !1, this._recycled = !0, this.hintMoveLoops = 2, this._moveTween = null, this._fallTweens = [], this._deltaY = 0, this.shineAnimationObjectPool &amp;&amp; (this.shinePool = this.shineAnimationObjectPool.script.objectPool), this._model = this.entity.findByName("ModelEntity"), this._hightLightModel = this.entity.findByName("Highlight"), this._hightLightModel.enabled = !1, this._isCountingDelay = !1, this.scoreValue = 0, this._isObjective = null, this._predefined = !1, this.tileParticle = this.entity.script.get("tileParticle"), this.app.on("ObjectiveManager:onObjectiveSet", this._onObjectiveSet, this), this.entity.script.has("impulseHandler") || this.entity.script.create("impulseHandler")) : console.warn("No script is found with the name", this.scriptName, "Could be a default script")
    },
    update: function(t) {
        this._isCountingDelay &amp;&amp; (this._delayCounter += t, this._delayCounter &gt;= this.despawnDelay &amp;&amp; (this._isCountingDelay = !1, this._onDelayDone()))
    },
    _onDelayDone: function() {
        this._ignoreDespawnStats || (this.scoreValue &amp;&amp; (GridManager.instance.showScore(this, this.scoreValue), this.scoreValue = 0), this._isObjective &amp;&amp; (ObjectiveManager.instance.isObjectiveCompleted(tileLayerEnum.FOREGROUND, this.typeID, this.colorID) || (this.app.fire("ModelToUIManager:showAnimation", this.entity.getLocalPosition(), {
            layerID: tileLayerEnum.FOREGROUND,
            typeID: this.typeID,
            colorID: this.colorID
        }, this.despawnDelay), this.app.fire("ForegroundTile:onExplode", tileLayerEnum.FOREGROUND, this.typeID, this.colorID)))), this.despawnAnimation(), this.tileParticle &amp;&amp; GridManager.instance.showParticle(this.x, this.y, this.tileParticle.getTexture(), this.tileParticle.getColor())
    },
    explode: function() {
        return !!GridManager.instance.canExplode(this.x, this.y) &amp;&amp; ("function" == typeof this.subClass.explode ? this.subClass.explode() : this.canExplode ? (this.app.fire("ScoreManager:scoreForegroundTile", this.typeID, this._isObjective, this), this.despawn(), !0) : void 0)
    },
    intersectsRay: function(t) {
        return this.setBoundingBox(), !!this.swappable &amp;&amp; this._aabb.intersectsRay(t)
    },
    setBoundingBox: function() {
        this._aabb.center.copy(this.entity.getPosition())
    },
    _onObjectiveSet: function() {
        this._isObjective = ObjectiveManager.instance.isTileOneOfObjectives(tileLayerEnum.FOREGROUND, this.typeID, this.colorID)
    },
    awake: function(t, e) {
        this.subClass &amp;&amp; "function" == typeof this.subClass.awake &amp;&amp; this.subClass.awake(), t instanceof pc.Vec3 &amp;&amp; (this.entity.setLocalPosition(t), this._aabb.center.copy(t), this.setBoundingBox()), this.despawnDelay = 0, this._powerState = ForegroundTile._PowerStates.ACTIVE, this.entity.setLocalScale(pc.Vec3.ONE), this.parent = e, this._preventDelay = !1, this.despawnCause = null, this._hitByPower = !1, this._ignoreDespawnStats = !1, this._model.setLocalPosition(0, 0, 0), this._recycled = !1, null === this._isObjective &amp;&amp; this._onObjectiveSet(), this._predefined = !1, this.setHighlight(!1), "function" != typeof this.subClass.onAwake ? this.entity.script.impulseHandler.reset() : this.subClass.onAwake()
    },
    setProperties: function(t, e) {
        this.x = t, this.y = e, this._state = ForegroundTile._States.ACTIVE, this.entity.setLocalScale(1, 1, 1)
    },
    isSwappable: function() {
        return this.swappable &amp;&amp; GridManager.instance.getBackgroundTile(this.x, this.y).foregroundSwappable
    },
    setHighlight: function(t) {
        this._hightLightModel.enabled = t
    },
    spawnAnimation: function(t, e, i) {
        i = i || !1, e = e || 0, void 0 === t &amp;&amp; (t = GridManager.instance.despawnDuration), this.entity.setLocalScale(pc.Vec3.ZERO), this.stopHintAnimation(), [foregroundTileEnum.LINE_H, foregroundTileEnum.LINE_V, foregroundTileEnum.BOMB, foregroundTileEnum.COLORBOMB].includes(this.typeID) &amp;&amp; i &amp;&amp; this.shineAnimation(t, e), this.appearTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1,
            y: 1,
            z: 1
        }, t, pc.BounceOut, e).start()
    },
    shineAnimation: function(t, e) {
        this.shine = this.shinePool.use(), this.shine.enabled = !0, this.shine.reparent(this.entity), this.shine.setPosition(0, 0, 0), this.shine.tween(this.shine.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.BounceOut, 1).start().on("complete", function() {
            this.stopShine()
        }.bind(this))
    },
    stopShine: function() {
        this.shine &amp;&amp; (this.shine.reparent(null), this.shine.enabled = !1, this.shine.setLocalScale(.01, .01, .01), this.shinePool.recycle(this.shine), this.shine = null)
    },
    despawnAnimation: function(t) {
        void 0 === t &amp;&amp; (t = GridManager.instance.despawnDuration), this.despawnEndPosition &amp;&amp; (t = GridManager.instance.powerTileCreationDuration), this.disappearTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, t, pc.BackIn).start(), this.stopHintAnimation(), this.despawnEndPosition &amp;&amp; (this.move(this.despawnEndPosition.x, this.despawnEndPosition.y, t), this.despawnEndPosition = null), GridManager.instance.playSFX("flower_destroy.mp3"), this.disappearTween.on("complete", this._recycle, this)
    },
    appear: function(t, e, i, n) {
        "function" == typeof this.subClass.appear &amp;&amp; this.subClass.appear(), this._deltaY += e - this.y;
        var s = GridManager.instance.calculatePosition(t, e, this.entity.getLocalPosition().z);
        return this.entity.setLocalPosition(s), this.isMovedTile = !0, this.applyGravity(this.x, this.y, this.x, this.y, i, n), this._getFallTweenDuration() + this._calculateBounceDuration()
    },
    move: function(t, e, i, n) {
        "function" == typeof this.subClass.move &amp;&amp; this.subClass.move(t, e, i), i || (i = GridManager.instance.moveDuration), this.x = t, this.y = e;
        var s = GridManager.instance.calculatePosition(t, e, this.entity.getLocalPosition().z);
        this._moveTween &amp;&amp; this._moveTween.stop(), this.moving = !0, this.moveTween = this.entity.tween(this.entity.getLocalPosition()).to({
            x: s.x,
            y: s.y,
            z: s.z
        }, i, pc.QuadraticInOut, n || 0).on("complete", function() {
            this.moving = !1
        }.bind(this), this).start()
    },
    applyGravity: function(t, e, i, n, s, o) {
        o = o || 0, "function" == typeof this.subClass.applyGravity &amp;&amp; this.subClass.applyGravity(t, e, i, n, s, o);
        var a = this.parent.calculatePosition(i, n, this.entity.getLocalPosition().z);
        this.isMovedTile = !0, this._deltaY += e - n;
        var h = 0 === this._fallTweens.length ? GridManager.instance.startFallDuration : 0,
            l = this.entity.tween(this.entity.getLocalPosition()).to({
                x: a.x,
                y: a.y,
                z: a.z
            }, s + h, pc.QuadraticIn, o);
        return this.x = i, this.y = n, 0 === this._fallTweens.length ? l.start() : this._fallTweens[this._fallTweens.length - 1].chain(l).off("complete", this._onFallComplete, this), l.on("complete", this._onFallComplete, this), this._fallTweens.push(l), this.falling = !0, this._getFallTweenDuration()
    },
    stopHintAnimation: function() {
        this._isPlayingHint &amp;&amp; (this._isPlayingHint = !1, this.hintTween.stop(), this.entity.setLocalScale(pc.Vec3.ONE), this.hintMoveTween &amp;&amp; (this.hintMoveTween.stop(), this.hintMoveTween = null))
    },
    isFlower: function() {
        return this.typeID === foregroundTileEnum.DEFAULT
    },
    isPowerTile: function() {
        return PowerTileManager.instance.isPowerTile(this.typeID)
    },
    isActive: function() {
        return this._state === ForegroundTile._States.ACTIVE
    },
    isPowerActive: function() {
        return this._powerState === ForegroundTile._PowerStates.ACTIVE
    },
    setHitByPower: function() {
        return GridManager.instance.canExplode(this.x, this.y) &amp;&amp; (this._hitByPower = !0), this._hitByPower
    },
    isHitByPower: function() {
        return this._hitByPower
    },
    doHintAnimation: function() {
        this.stopHintAnimation(), this._isPlayingHint = !0;
        var t = 0;
        this.hintTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1.1,
            y: 1,
            z: 1.1
        }, .5, pc.SineInOut).loop(!0).yoyo(!0).start().on("loop", function() {
            this.hintMoveTween &amp;&amp; ++t % (2 * this.hintMoveLoops) == 0 &amp;&amp; this.repeatHintMove(), this._isPlayingHint || (this.hintTween.stop(), this.hintMoveTween &amp;&amp; (this.hintMoveTween.stop(), this.hintMoveTween = null))
        }.bind(this))
    },
    repeatHintMove: function() {
        this.hintMoveTween.start()
    },
    makeHintMoveAnimation: function(t, e) {
        var i = .1 * t,
            n = .1 * e,
            s = this.entity.getLocalPosition();
        this.hintMoveTween = this.entity.tween(this.entity.getLocalPosition()).to({
            x: s.x - i,
            y: s.y - n,
            z: s.z
        }, .2, pc.SineInOut).yoyo(!0).repeat(4).delay(.1).start()
    },
    setDespawnDelay: function(t) {
        GridManager.instance.canExplode(this.x, this.y) ? this._preventDelay || (this._preventDelay = !0, this.despawnDelay = t, ("number" != typeof this.despawnDelay || isNaN(this.despawnDelay)) &amp;&amp; (console.warn("Despawn delay is not a number", this.despawnDelay), this.despawnDelay = 0)) : this.despawnDelay = t
    },
    setDespawnCause: function(t) {
        this.despawnCause = t
    },
    getDespawnCause: function() {
        return this.despawnCause
    },
    setScoreAfterDelay: function(t) {
        this.scoreValue += t
    },
    getDespawnDelay: function(t) {
        return this.despawnDelay
    },
    despawn: function() {
        this._state = ForegroundTile._States.INACTIVE, this._startDelayCountdown(), null !== this.despawnCause &amp;&amp; (this.despawnCause = null)
    },
    resetTileOrientation: function() {
        this.entity.setLocalEulerAngles(this._defaultRotation)
    },
    shakeTile: function(t) {
        t = t || 0;
        var e = this.entity.getLocalEulerAngles().clone();
        this.entity.setLocalEulerAngles(e.x, e.y, e.z - 5), this.shakeTween = this.entity.tween(this.entity.getLocalRotation()).rotate({
            x: e.x,
            y: e.y,
            z: e.z + 5
        }, .1, pc.SineInOut).loop(!0).yoyo(!0).delay(t).start()
    },
    enlargeTile: function() {
        this.enlargeTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1.2,
            y: 1.2,
            z: 1.2
        }, .2, pc.SineInOut).start().yoyo().repeat(2)
    },
    _startDelayCountdown: function() {
        this._isCountingDelay = !0, this._delayCounter = 0
    },
    ignoreDespawnStats: function() {
        this._ignoreDespawnStats = !0
    },
    updateFlowerStatistics: function() {
        "function" != typeof this.subClass.updateFlowerStatistics || this.subClass.updateFlowerStatistics()
    },
    _getFallTweenDuration: function() {
        if (0 === this._fallTweens.length) return 0;
        for (var t = this._calculateBounceDuration(), e = 0; e &lt; this._fallTweens.length; e++) t += this._fallTweens[e].duration + this._fallTweens[e]._delay;
        return t
    },
    _onFallComplete: function() {
        this._bounce()
    },
    _bounce: function() {
        var t = this.entity.getLocalPosition(),
            e = this._calculateBounceDuration();
        this.bounceTween = this.entity.tween(this.entity.getLocalPosition()).to({
            x: t.x,
            y: t.y + this._calculateBounceHeight(),
            z: t.z
        }, e, pc.Bounce), this.bounceTween.start(), this.bounceTween.on("complete", (function() {
            this.falling = !1, this._deltaY = 0
        }), this), this._fallTweens.length = 0
    },
    _calculateBounceHeight: function() {
        return Math.min(this._deltaY, this.maxBounceDeltaCell) * this.bounceHeightPerCell || this.bounceHeightPerCell
    },
    _calculateBounceDuration: function() {
        return this.bounceDuration
    },
    setDespawnEndPosition: function(t, e) {
        this.despawnEndPosition = {
            x: t,
            y: e
        }
    },
    _recycle: function() {
        this.stopAllTweens(), this.entity.reparent(null), this._recycled = !0, "function" == typeof this.subClass.recycle &amp;&amp; this.subClass.recycle(), TileLibrary.instance.returnObject(this.entity, tileLayerEnum.FOREGROUND, this.typeID, this.colorID)
    },
    stopAllTweens: function() {
        this._stopDelayCountdown(), this.hintMoveTween &amp;&amp; (this.hintMoveTween.stop(), this.hintMoveTween = null), this.shine &amp;&amp; this.stopShine(), this.fallTween &amp;&amp; this.fallTween.stop(), this.appearTween &amp;&amp; this.appearTween.stop(), this.moveTween &amp;&amp; this.moveTween.stop(), this.rotateTween &amp;&amp; this.rotateTween.stop(), this.fallOutOfLevelTween &amp;&amp; this.fallOutOfLevelTween.stop(), this._pulseTween &amp;&amp; this._pulseTween.stop(), this.stopAffectedTweens();
        for (var t = 0; t &lt; this._fallTweens.length; t++) this._fallTweens[t].stop();
        this._fallTweens.length = 0, this.bounceTween &amp;&amp; this.bounceTween.stop(), this.stopHintAnimation()
    },
    stopAffectedTweens: function() {
        this.shakeTween &amp;&amp; (this.resetTileOrientation(), this.shakeTween.stop()), this.enlargeTween &amp;&amp; (this.enlargeTween.stop(), this.entity.setLocalScale(1, 1, 1))
    },
    _stopDelayCountdown: function() {
        this._isCountingDelay = !1, this._delayCounter = 0
    },
    pulse: function(t, e, i, n, s) {
        this._model ? this._state !== ForegroundTile._States.INACTIVE &amp;&amp; this.entity.script.impulseHandler.impulse(t, e, i, n, s) : console.warn(this)
    },
    isColorPowerTile: function() {
        return this.typeID === foregroundTileEnum.COLORBOMB
    },
    setPowerState: function(t) {
        this._powerState = t
    },
    isPowerState: function(t) {
        return this._powerState === t
    },
    setPredefined: function() {
        this._predefined = !0
    },
    isPredefined: function() {
        return this._predefined
    }
});
var LoadScreenController = pc.createScript("loadScreenController");
pc.extend(LoadScreenController.prototype, {
    initialize: function() {
        this._loading = !1, this._scene = null, this._currentState = -1, this._sceneLoaded = !1, this._noInitialFade = !1
    },
    startLoadCoroutine: function(e, t, a, o) {
        this._loading = !0, this._sceneLoaded = !1, this._currentState = LoadScreenController._States.START, this._scene = e, this._noInitialFade = t, this._goToNextState()
    },
    _goToNextState: function() {
        switch (this._currentState++, this._currentState) {
            case LoadScreenController._States.FADEOUT:
                break;
            case LoadScreenController._States.LOADSCREEN:
                this._startLoadScreen();
                break;
            case LoadScreenController._States.PRELOADSCENE:
                this._startPreLoadScene();
                break;
            case LoadScreenController._States.LOADSCENE:
                this._startLoadScene();
                break;
            case LoadScreenController._States.POSTLOADSCENE:
                this._startPostLoadScene();
                break;
            case LoadScreenController._States.FINISH:
                this._startFinish()
        }
    },
    update: function() {
        if (this._loading) switch (this._currentState) {
            case LoadScreenController._States.FADEOUT:
                this._waitForFadeIsDone();
                break;
            case LoadScreenController._States.PRELOADSCENE:
                this._wait(2);
                break;
            case LoadScreenController._States.POSTLOADSCENE:
                this._waitForFadeIsDone()
        }
    },
    _waitForFadeIsDone: function() {
        this._goToNextState()
    },
    _wait: function(e) {
        this._goToNextState()
    },
    _startLoadScreen: function() {
        this._goToNextState()
    },
    _startPreLoadScene: function() {
        this._timer = 0
    },
    _startLoadScene: function() {
        Application.loadLevelAsync(this._scene, this._onSceneLoaded, this)
    },
    _onSceneLoaded: function() {
        this._sceneLoaded = !0;
        var e = this.app.assets._assets.filter((function(e) {
            return e.loading
        }));
        this._totalAssetsToLoad = e.length, this._assetsLoaded = 0;
        for (var t = 0; t &lt; e.length; t++) e[t].ready(this._updateProgress, this);
        0 === this._totalAssetsToLoad &amp;&amp; this._goToNextState()
    },
    _updateProgress: function() {
        this._assetsLoaded++;
        this.app.assets._assets.filter((function(e) {
            return e.loading
        }));
        this._assetsLoaded &gt;= this._totalAssetsToLoad &amp;&amp; this._goToNextState()
    },
    _startPostLoadScene: function() {
        this.app.lightmapper.bake()
    },
    _startFinish: function() {
        this.app.fire("switchedScene"), this.app.fire("UIManager:hideAll"), GameManager.instance &amp;&amp; GameManager.instance.loadScreenDone(), this.entity.destroy(), LoadScreenController.isLoading = !1
    }
}), pc.extend(LoadScreenController, {
    isLoading: !1,
    _States: Object.freeze({
        START: 0,
        FADEOUT: 1,
        LOADSCREEN: 2,
        PRELOADSCENE: 3,
        LOADSCENE: 4,
        POSTLOADSCENE: 5,
        FINISH: 6
    }),
    load: function(e, t) {
        if (LoadScreenController.isLoading) console.error("Already loading, please wait.");
        else {
            LoadScreenController.isLoading = !0;
            var a = new pc.Entity("LoadScreenController");
            a.reparent(pc.Application.getApplication().root), a.addComponent("script"), a.script.create("loadScreenController").startLoadCoroutine(e, t)
        }
    }
});
var ColorTile = pc.createScript("colorTile");
ColorTile.colorEnum = [{
    NONE: tileColorEnum.NONE
}, {
    BLUE: tileColorEnum.BLUE
}, {
    YELLOW: tileColorEnum.YELLOW
}, {
    RED: tileColorEnum.RED
}, {
    PURPLE: tileColorEnum.PURPLE
}, {
    GREEN: tileColorEnum.GREEN
}, {
    ORANGE: tileColorEnum.ORANGE
}], ColorTile.attributes.add("colorId", {
    type: "number",
    enum: ColorTile.colorEnum
}), pc.extend(ColorTile.prototype, {
    initialize: function() {
        this._fallTweens = []
    },
    init: function(t) {
        this.superClass = t, this.superClass.typeID = foregroundTileEnum.DEFAULT, this.superClass.colorID = this.colorId
    },
    updateFlowerStatistics: function() {
        this.app.fire("EndScreen:addFlower"), StatisticsManager.instance.incrementStatistic("flowers_destroyed", 1), this.superClass.colorID === tileColorEnum.BLUE &amp;&amp; StatisticsManager.instance.incrementStatistic("blue_flowers_destroyed", 1), this.superClass.colorID === tileColorEnum.YELLOW &amp;&amp; StatisticsManager.instance.incrementStatistic("yellow_flowers_destroyed", 1), this.superClass.colorID === tileColorEnum.RED &amp;&amp; StatisticsManager.instance.incrementStatistic("red_flowers_destroyed", 1), this.superClass.colorID === tileColorEnum.PURPLE &amp;&amp; StatisticsManager.instance.incrementStatistic("purple_flowers_destroyed", 1), this.superClass.colorID === tileColorEnum.GREEN &amp;&amp; StatisticsManager.instance.incrementStatistic("green_flowers_destroyed", 1), this.superClass.colorID === tileColorEnum.ORANGE &amp;&amp; StatisticsManager.instance.incrementStatistic("orange_flowers_destroyed", 1)
    }
});
var CenterShapeFlat = pc.createScript("centerShapeFlat");
CenterShapeFlat.attributes.add("offset", {
    type: "vec2"
}), pc.extend(CenterShapeFlat.prototype, {
    initialize: function() {
        this.app.on("GridManager:onLevelSpawn", this.setShape, this), this.app.on("GridManager:onDespawn", this.disableShape, this), this.material = this.entity.model.material, this.disableShape(), this.on("attr:offset", (function() {
            this.setGridMaterial()
        }), this)
    },
    setShape: function() {
        this.setShapeSize(), this.setGridMaterial(), this.enableShape()
    },
    setShapeSize: function() {
        this.entity.setLocalScale(GridManager.instance.columns, 1, GridManager.instance.rows)
    },
    setCaps: function() {
        this.topEntity.setLocalScale(1, 2 * GridManager.instance.radius / GridManager.instance.height, 1), this.bottomEntity.setLocalScale(1, 2 * GridManager.instance.radius / GridManager.instance.height, 1)
    },
    setProps: function() {
        var t = 1 / (2 * GridManager.instance.radius) * this.propSize,
            e = 2 * GridManager.instance.radius / GridManager.instance.height * t;
        this.topPropEntity.setLocalScale(t, e, t), this.bottomPropEntity.setLocalScale(t, e, t)
    },
    setGridMaterial: function() {
        this.material.diffuseMapTiling = new pc.Vec2(GridManager.instance.columns / 2, GridManager.instance.rows / 2), this.material.diffuseMapOffset = this.offset, this.material.update()
    },
    disableShape: function() {
        this.entity.enabled = !1
    },
    enableShape: function() {
        this.entity.enabled = !0
    }
});
var ObjectOptions = pc.createScript("objectOptions");
ObjectOptions.selectedOption = void 0, ObjectOptions.attributes.add("objectOptions", {
    type: "asset",
    array: !0,
    title: "The objects that can be placed here"
}), ObjectOptions.attributes.add("materialOptions", {
    type: "asset",
    assetType: "material",
    array: !0,
    title: "Instead of objects you can also use materials"
}), ObjectOptions.attributes.add("objectImages", {
    type: "asset",
    assetType: "texture",
    array: !0,
    title: "Images of the buildings"
}), ObjectOptions.attributes.add("objectState", {
    type: "number",
    enum: [{
        Locked: 0
    }, {
        Unlocked: 1
    }, {
        ToSelect: 2
    }],
    default: 0
}), ObjectOptions.attributes.add("world", {
    type: "number",
    default: 0,
    title: "Which world does this item exist in"
}), ObjectOptions.attributes.add("amountOfStars", {
    type: "number",
    default: 0,
    title: "How many stars does this object need to be unlocked"
}), pc.extend(ObjectOptions.prototype, {
    initialize: function() {
        this.boundingbox = !1, this.updateBoundingBox()
    },
    updateBoundingBox: function() {
        var t = this.entity.model.meshInstances;
        if (this.boundingbox = new pc.BoundingBox, t.length &gt; 0) {
            this.boundingbox.copy(t[0].aabb);
            for (var e = 1; e &lt; t.length; e++) this.boundingbox.add(t[e].aabb)
        }
    },
    getBoundingBox: function() {
        return this.boundingbox
    }
});
var CircleFill = pc.createScript("circleFill");
CircleFill.attributes.add("vs", {
    type: "asset",
    assetType: "shader",
    title: "Vertex Shader"
}), CircleFill.attributes.add("fs", {
    type: "asset",
    assetType: "shader",
    title: "Fragment Shader"
}), CircleFill.attributes.add("cutoutMap", {
    type: "asset",
    assetType: "texture",
    title: "Cutout Map"
}), CircleFill.attributes.add("circleColor", {
    type: "rgba",
    title: "Circle Color"
}), pc.extend(CircleFill.prototype, {
    initialize: function() {
        this.onAttributeChange(), this.time = 0;
        var t = this.app.graphicsDevice,
            e = this.cutoutMap.resource,
            i = this.vs.resource,
            r = "precision " + t.precision + " float;\n";
        r += this.fs.resource;
        var a = {
            attributes: {
                aPosition: pc.SEMANTIC_POSITION,
                aUv0: pc.SEMANTIC_TEXCOORD0
            },
            vshader: i,
            fshader: r
        };
        this.shader = new pc.Shader(t, a), this.material = new pc.Material, this.material.blendType = pc.BLEND_PREMULTIPLIED, this.entity.element.material = this.material, this.material.shader = this.shader, this.material.setParameter("uTime", 0), this.material.setParameter("cutoutMap", e), this.material.setParameter("baseColor", [this.circleColor.r, this.circleColor.g, this.circleColor.b, 1])
    },
    onAttributeChange: function() {
        this.on("attr:circleColor", (function(t, e) {
            this.material.setParameter("baseColor", [this.circleColor.r, this.circleColor.g, this.circleColor.b, 1])
        }))
    },
    updateValue: function(t) {
        this.material.setParameter("uTime", t)
    },
    updateColor: function(t) {
        this.material.setParameter("baseColor", [t.r, t.g, t.b, 1])
    }
});
var Wall = pc.createScript("wall");
pc.extend(Wall.prototype, {
    initialize: function() {},
    init: function(i) {
        this.superClass = i, this.superClass.colorID = tileColorEnum.NONE, this.superClass.typeID = backgroundTileEnum.WALL
    },
    explode: function() {}
});
var MovesInterface = pc.createScript("movesInterface");
MovesInterface.attributes.add("movesText", {
    type: "entity"
}), pc.extend(MovesInterface.prototype, {
    initialize: function() {
        this.app.on("MovesManager:setMoves", this.setMoves, this), this.app.on("PowerTileManager:onEndModePowerSpawn", this.reduceCounter, this)
    },
    setMoves: function(e) {
        this.currentValue = e, this.movesText.element.text = e, this.movesText.script.tweenScale.startTween();
        MovesManager.instance.getStartMoves()
    },
    reduceCounter: function() {
        this.currentValue = (this.currentValue ? this.currentValue : MovesManager.instance.getMoves()) - 1, this.setMoves(this.currentValue)
    }
});
var GardenManager = pc.createScript("gardenManager");
GardenManager.attributes.add("amountOfWorlds", {
    type: "number",
    default: 5,
    title: "Amount of worlds that exist"
}), GardenManager.attributes.add("camera", {
    type: "entity"
}), GardenManager.attributes.add("objectManager", {
    type: "entity"
}), pc.extend(GardenManager.prototype, {
    initialize: function() {
        GardenManager.instance = this, this.stars = [], this.areaSaveData = {}, this.objectSaveData = {}, this._unlockedItems = [], this.totalAmountOfStars = 0, this.objects = this.app.root.findByTag("object"), this.areas = this.app.root.findByTag("area"), this.gardenCamera = this.camera.script.gardenCamera, this.objectHandler = this.objectManager.script.objectHandler
    },
    intersectRay: function(t) {
        for (var e = [], a = 0; a &lt; this.objects.length; a++) {
            var s = this.objects[a];
            new pc.BoundingBox(s.getPosition(), new pc.Vec3(3, 3, 3)).intersectsRay(t) &amp;&amp; e.push(s)
        }
        return 0 === e.length ? (console.log("no hit"), null) : (e.length &gt; 1 &amp;&amp; console.warn("Two hits found", e, t), e[0])
    },
    postInitialize: function() {
        UIManager.instance._hideAll(), this._getStarData(), this._getAreaData(), this._getObjectData()
    },
    unlockArea: function(t) {
        for (var e = 0; e &lt; this.areas.length; e++) this.areas[e].script.areaManager.areaNumber === t &amp;&amp; (this.areas[e].script.areaManager.changeAreaState(1), this.areaSaveData[this.areas[e].name].state = 1);
        this._updateAreaData()
    },
    _getAreaData: function() {
        if (this.areaSaveData = StorageManager.instance.get("areaData"), void 0 !== this.areaSaveData &amp;&amp; Object.keys(this.areaSaveData).length &gt; 0)
            for (var t = 0; t &lt; this.areas.length; t++) this.areas[t].script.areaManager.regionState = this.areaSaveData[this.areas[t].name].state;
        else this._generateAreaData()
    },
    _generateAreaData: function() {
        this.areaSaveData = {};
        for (var t = 0; t &lt; this.areas.length; t++) this.areaSaveData[this.areas[t].name] = {}, this.areaSaveData[this.areas[t].name].state = this.areas[t].script.areaManager.regionState, this.areaSaveData[this.areas[t].name].area = this.areas[t].script.areaManager.areaNumber;
        this._updateAreaData()
    },
    _updateAreaData: function() {
        StorageManager.instance.set("areaData", this.areaSaveData)
    },
    updateSpecificOption: function(t) {
        var e = this.objectSaveData[t.name];
        if (void 0 !== e) {
            var a = t.script.objectOptions;
            e.selectedOption = a.selectedOption, e.objectState = 1, this._updateObjectData()
        }
    },
    _getObjectData: function() {
        if (this.objectSaveData = StorageManager.instance.get("objectData"), void 0 !== this.objectSaveData &amp;&amp; Object.keys(this.objectSaveData).length &gt; 0 &amp;&amp; this.objects.length == Object.keys(this.objectSaveData).length)
            for (var t = 0; t &lt; this.objects.length; t++) {
                var e = this.objects[t].script.objectOptions,
                    a = this.objectSaveData[this.objects[t].name];
                if (null !== a.selectedOption &amp;&amp; void 0 !== a.selectedOption)
                    if (e.selectedOption = a.selectedOption, e.objectOptions.length &gt; 0) this.objects[t].model.asset = e.objectOptions[e.selectedOption], this.objects[t].collision.asset = e.objectOptions[e.selectedOption];
                    else
                        for (var s = this.objects[t].model.meshInstances, i = 0; i &lt; s.length; ++i) s[i].material = e.materialOptions[e.selectedOption].resource;
                e.objectState = a.objectState, this._checkObject(t)
            } else this._generateObjectData();
        this.handleObjectQueue()
    },
    _checkObject: function(t) {
        var e = this.objects[t].script.objectOptions;
        0 !== this.objects[t].parent.script.areaManager.regionState &amp;&amp; (this.stars[e.world] &gt;= e.amountOfStars &amp;&amp; 0 === e.objectState || 2 === e.objectState) &amp;&amp; (e.objectState = 2, this._unlockedItems.push(t))
    },
    handleObjectQueue: function() {
        if (this._unlockedItems.length &gt; 0) {
            var t = this._unlockedItems.shift();
            this.gardenCamera.focusObject(this.objects[t]), this.objectHandler.selectedEntity = this.objects[t], this.objectHandler.initSelector(!0)
        }
    },
    _generateObjectData: function() {
        this.objectSaveData = {};
        for (var t = 0; t &lt; this.objects.length; t++) {
            var e = this.objects[t],
                a = e.script.objectOptions;
            this.objectSaveData[e.name] = {}, this.objectSaveData[e.name].selectedOption = a.selectedOption, this.objectSaveData[e.name].objectState = a.objectState, this._checkObject(t)
        }
        this._updateObjectData()
    },
    _updateObjectData: function() {
        StorageManager.instance.set("objectData", this.objectSaveData)
    },
    _getStarData: function() {
        for (var t = 0; t &lt; this.amountOfWorlds; t++) this.stars[t] = StorageManager.instance.get("star_amount_world_" + (t + 1)), this.totalAmountOfStars += this.stars[t]
    },
    _findInArray: function(t, e) {
        return t.filter((function(t) {
            return t[0] == e
        }))
    }
});
var StarBar = pc.createScript("starBar");
StarBar.attributes.add("barShader", {
    type: "entity"
}), StarBar.attributes.add("barRounder", {
    type: "entity"
}), StarBar.attributes.add("startValue", {
    type: "number"
}), StarBar.attributes.add("endValue", {
    type: "number"
}), StarBar.attributes.add("maxStarValue", {
    type: "number"
}), StarBar.attributes.add("starTemplate", {
    type: "asset",
    assetType: "template"
}), StarBar.attributes.add("nStars", {
    type: "number"
}), StarBar.attributes.add("lerpTime", {
    type: "number",
    default: 1
}), pc.extend(StarBar.prototype, {
    initialize: function() {
        this.currentValue = this.startValue, this.createStars(), this.app.on("ScoreManager:setStarValues", this.setStarPositions, this), this.app.on("AsyncScoreManager:showScore", this.setFillValue, this), this.currentScore = 0, this._lerpValue = this.lerpTime, this._multipleLerp = !1
    },
    update: function(t) {
        this.lerpValue &lt; this.lerpTime &amp;&amp; this.lerpBarValue(t)
    },
    createStars: function() {
        this.stars = [];
        for (var t = 0; t &lt; this.nStars; t += 1) {
            var a = this.starTemplate.resource.instantiate();
            this.entity.addChild(a), this.stars.push(a)
        }
    },
    setStarPositions: function(t, a, e) {
        this.setFillValue(this.startValue), this.currentValue = this.startValue;
        this.endValue, this.startValue;
        var r = this._calculateValue(e),
            s = this._calculateValue(a),
            i = this._calculateValue(t);
        this.stars[0].script.starBarStar.setRotation(i), this.stars[1].script.starBarStar.setRotation(s), this.stars[2].script.starBarStar.setRotation(r), this.resetStars(), this._multipleLerp = !1, this.lerpBarValue(1)
    },
    setFillValue: function(t) {
        var a = this._calculateValue(t);
        this.startCurrentValue = this.currentValue, this.lerpValue &lt; this.lerpTime &amp;&amp; (this._multipleLerp = !0), this.lerpValue = 0, this.goalValue = a
    },
    _calculateValue: function(t) {
        return this.startValue + t / ScoreManager.instance.star3Value * (this.endValue - this.startValue) * this.maxStarValue
    },
    lerpBarValue: function(t) {
        this.lerpValue += t, this.currentValue = pc.math.lerp(this.startCurrentValue, this.goalValue, this._multipleLerp ? pc.CubicOut(this.lerpValue) : pc.CubicInOut(this.lerpValue)), this.barShader.script.circleFill.updateValue(this.currentValue), this.barRounder.setLocalEulerAngles(0, 0, -360 * this.currentValue), this.checkStarActive(this.currentValue), this.lerpValue &gt;= this.lerpTime &amp;&amp; (this._multipleLerp = !1)
    },
    checkStarActive: function(t) {
        for (var a = 0; a &lt; this.stars.length; a += 1) this.stars[a].script.starBarStar.checkActivate(t)
    },
    resetStars: function() {
        for (var t = 0; t &lt; this.stars.length; t += 1) this.stars[t].script.starBarStar.setInactive()
    }
});
var AreaManager = pc.createScript("areaManager");
AreaManager.attributes.add("regionState", {
    type: "number",
    enum: [{
        Locked: 0
    }, {
        Unlocked: 1
    }, {
        current: 2
    }],
    default: 0
}), AreaManager.attributes.add("areaNumber", {
    type: "number",
    default: 1
}), pc.extend(AreaManager.prototype, {
    initialize: function() {
        this.objects = this.entity.children, this.lockedLayer = this.app.scene.layers.getLayerByName("Locked").id, this.unlockedLayer = this.app.scene.layers.getLayerByName("Unlocked").id, this.updateState()
    },
    changeAreaState: function(e) {
        this.regionState = e, this.updateState()
    },
    updateState: function() {
        for (var e = 0; e &lt; this.objects.length; e++) this.objects[e].model.layers = 0 === this.regionState ? [this.lockedLayer] : [this.unlockedLayer]
    }
});
var ObjectiveManager = pc.createScript("objectiveManager");
objectiveTypesEnum = Object.freeze({
    SCORE: 0,
    ORDER: 1,
    COAT: 2
}), objectiveStatesEnum = Object.freeze({
    ACTIVE: 0,
    COMPLETED: 1
}), ObjectiveManager.attributes.add("objectiveSlots", {
    type: "number"
}), pc.extend(ObjectiveManager.prototype, {
    initialize: function() {
        ObjectiveManager.instance = this, this._objectiveSlots = [], this._defaultObjective = Object.freeze({
            objectiveType: objectiveTypesEnum.ORDER,
            orderTypeObject: {
                layerID: 0,
                typeID: 0,
                colorID: 0
            },
            values: {
                current: 0,
                goal: 0,
                currentVisible: 0
            },
            state: objectiveStatesEnum.ACTIVE
        }), this.app.on("GameManager:quit", this.removeObjectives, this), this.app.on("ScoreManager:setScore", this.onScoreAdd, this), this.app.on("ForegroundTile:onExplode", this.onTileDestroy, this), this.app.on("BackgroundTile:onExplode", this.onTileDestroy, this)
    },
    getObjectives: function() {
        return this._objectiveSlots
    },
    setObjectives: function(e) {
        for (var t = 0; t &lt; e.length; t += 1) ObjectiveManager.instance.addObjective(e[t].objectiveType, e[t].goal, e[t].orderTypeObject);
        this.app.fire("ObjectiveManager:onObjectiveSet")
    },
    removeObjectives: function() {
        this._objectiveSlots.length = 0
    },
    addObjective: function(e, t, i) {
        if (!(this._objectiveSlots.length &gt;= this.objectiveSlots)) {
            var r = JSON.parse(JSON.stringify(this._defaultObjective));
            r.objectiveType = e, r.values.goal = t, r.values.current = 0, r.values.currentVisible = 0, r.state = objectiveStatesEnum.ACTIVE, e === objectiveTypesEnum.ORDER &amp;&amp; (r.orderTypeObject.layerID = i.layerID, r.orderTypeObject.typeID = i.typeID, r.orderTypeObject.colorID = i.colorID), this._objectiveSlots.push(Object.assign({}, r)), this.app.fire("ObjectiveManager:onObjectiveAdd", r)
        }
    },
    onTileDestroy: function(e, t, i) {
        if (LevelManager.instance.playing)
            for (var r = 0; r &lt; this._objectiveSlots.length; r += 1) {
                var s = this._objectiveSlots[r];
                this._objectiveSlots[r].objectiveType === objectiveTypesEnum.ORDER &amp;&amp; this._isCorrectOrderTile(s.orderTypeObject, e, t, i) &amp;&amp; (s.values.current += 1, s.values.current &gt;= s.values.goal &amp;&amp; (s.state = objectiveStatesEnum.COMPLETED))
            }
    },
    onTileRegrow: function(e, t, i) {
        for (var r = 0; r &lt; this._objectiveSlots.length; r += 1) {
            var s = this._objectiveSlots[r];
            this._objectiveSlots[r].objectiveType === objectiveTypesEnum.ORDER &amp;&amp; this._isCorrectOrderTile(s.orderTypeObject, e, t, i) &amp;&amp; (s.values.current -= 1, this.app.fire("ObjectiveManager:onObjectiveChange", r, s))
        }
    },
    onScoreAdd: function() {
        for (var e = 0; e &lt; this._objectiveSlots.length; e += 1) {
            var t = this._objectiveSlots[e];
            t.objectiveType === objectiveTypesEnum.SCORE &amp;&amp; (t.values.current = ScoreManager.instance.getScore(), t.values.currentVisible = t.values.current, this.app.fire("ObjectiveManager:onObjectiveChange", e, t), t.values.current &gt;= t.values.goal &amp;&amp; t.state !== objectiveStatesEnum.COMPLETED &amp;&amp; (this.app.fire("ObjectiveManager:onObjectiveComplete", e), t.state = objectiveStatesEnum.COMPLETED))
        }
    },
    _isCorrectOrderTile: function(e, t, i, r) {
        var s = e.layerID === t &amp;&amp; e.typeID === i;
        return TileLibrary.instance.isTileColored(t, i) &amp;&amp; (s = s &amp;&amp; e.colorID === r), s
    },
    _updateOrderStatistics: function(e, t, i) {
        if (StatisticsManager.instance.incrementStatistic("orders_completed", 1), e === tileLayerEnum.FOREGROUND &amp;&amp; i === foregroundTileEnum.SWITCHER) StatisticsManager.instance.incrementStatistic("switcher_orders_completed", 1);
        else if (e === tileLayerEnum.FOREGROUND) switch (StatisticsManager.instance.incrementStatistic("flower_orders_completed", 1), t) {
            case tileColorEnum.BLUE:
                StatisticsManager.instance.incrementStatistic("blue_flower_orders_completed", 1);
                break;
            case tileColorEnum.YELLOW:
                StatisticsManager.instance.incrementStatistic("yellow_flower_orders_completed", 1);
                break;
            case tileColorEnum.RED:
                StatisticsManager.instance.incrementStatistic("red_flower_orders_completed", 1);
                break;
            case tileColorEnum.PURPLE:
                StatisticsManager.instance.incrementStatistic("purple_flower_orders_completed", 1);
                break;
            case tileColorEnum.GREEN:
                StatisticsManager.instance.incrementStatistic("green_flower_orders_completed", 1);
                break;
            case tileColorEnum.ORANGE:
                StatisticsManager.instance.incrementStatistic("orange_flower_orders_completed", 1)
        } else if (e === tileLayerEnum.BACKGROUND) switch (i) {
            case backgroundTileEnum.PANEL:
                StatisticsManager.instance.incrementStatistic("panels_orders_completed", 1);
                break;
            case backgroundTileEnum.BLOCKER:
                StatisticsManager.instance.incrementStatistic("blocker_orders_completed", 1);
                break;
            case backgroundTileEnum.LOCKER:
                StatisticsManager.instance.incrementStatistic("locker_orders_completed", 1);
                break;
            case backgroundTileEnum.VIRUS:
                StatisticsManager.instance.incrementStatistic("virus_orders_completed", 1);
                break;
            case backgroundTileEnum.SINKER:
                StatisticsManager.instance.incrementStatistic("sinker_orders_completed", 1);
                break;
            case backgroundTileEnum.STICKER:
                StatisticsManager.instance.incrementStatistic("sticker_orders_completed", 1);
                break;
            case backgroundTileEnum.POPPER:
                StatisticsManager.instance.incrementStatistic("popper_orders_completed", 1)
        }
    },
    isTileOneOfObjectives: function(e, t, i) {
        for (var r = 0; r &lt; this._objectiveSlots.length; r += 1)
            if (this._isCorrectOrderTile(this._objectiveSlots[r].orderTypeObject, e, t, i)) return !0;
        return !1
    },
    isObjectiveCompleted: function(e, t, i) {
        for (var r = 0; r &lt; this._objectiveSlots.length; r += 1) {
            var s = this._objectiveSlots[r];
            if (this._isCorrectOrderTile(s.orderTypeObject, e, t, i)) return this._updateOrderStatistics(e, i, t), s.values.goal &lt;= s.values.currentVisible
        }
        return null
    },
    onObjectiveAdd: function(e, t, i) {
        if (LevelManager.instance.playing)
            for (var r = 0; r &lt; this._objectiveSlots.length; r += 1) {
                var s = this._objectiveSlots[r];
                this._isCorrectOrderTile(s.orderTypeObject, e, t, i) &amp;&amp; (s.values.currentVisible++, s.values.currentVisible &gt; s.values.current &amp;&amp; console.warn("something went wrong", s), s.values.currentVisible &gt;= s.values.goal ? (this.app.fire("ObjectiveManager:onObjectiveComplete", r), s.values.currentVisible === s.values.goal &amp;&amp; this.app.fire("Audio:sfx", "goal_completed.mp3")) : this.app.fire("ObjectiveManager:onObjectiveChange", r, s))
            }
    },
    isObjectivesCompleted: function() {
        for (var e = 0; e &lt; this._objectiveSlots.length; e += 1) {
            var t = this._objectiveSlots[e];
            if (t.state !== objectiveStatesEnum.COMPLETED)
                if (t.values.current &lt; t.values.goal) {
                    if (t.values.currentVisible &lt; t.values.goal) return !1;
                    console.error("Something went wrong", t)
                } else console.error("Something went wrong", t)
        }
        return !0
    },
    reset: function() {
        this._objectiveSlots.length = 0, this.app.fire("ObjectiveManager:onReset")
    },
    increaseVirusObjective: function() {
        for (var e = 0; e &lt; this._objectiveSlots.length; e += 1) {
            var t = this._objectiveSlots[e];
            1 === t.orderTypeObject.layerID &amp;&amp; 5 === t.orderTypeObject.typeID &amp;&amp; (t.values.goal++, this.app.fire("ObjectiveManager:onObjectiveChange", e, t))
        }
    }
});
var Inventory = pc.createScript("inventory");
pc.extend(Inventory.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (Inventory.instance = this), this.storageKey = "inventory", this.items = Object.freeze(["COINS", "PREBOOSTER_1", "PREBOOSTER_2", "PREBOOSTER_3", "BOOSTER_1", "BOOSTER_2", "BOOSTER_3"]), this.inventory = this._getSaveData()
    },
    getItem: function(t) {
        if (this.inventory.hasOwnProperty(t)) return this.inventory[t];
        console.error("No inventory found with the key", t)
    },
    addItem: function(t, e) {
        isNaN(e) &amp;&amp; (e = 1), this.inventory.hasOwnProperty(t) ? (this.inventory[t] += e, this._saveInventory()) : console.error("No inventory found with the key", t)
    },
    tryPayItem: function(t, e) {
        return isNaN(e) &amp;&amp; (e = 1), this.inventory.hasOwnProperty(t) ? !(this.inventory[t] &lt; e) &amp;&amp; (this.inventory[t] -= e, StatisticsManager.instance.incrementStatistic("bees_pre_booster_bought", 1), this._saveInventory(), !0) : (console.error("No inventory found with the key", t), !1)
    },
    _saveInventory: function() {
        StorageManager.instance.set(this.storageKey, this.inventory)
    },
    _getSaveData: function() {
        var t = StorageManager.instance.get(this.storageKey);
        return t = this._validateData(t)
    },
    _validateData: function(t) {
        Array.isArray(t) &amp;&amp; (t = {}), "object" != typeof t &amp;&amp; (t = {});
        for (var e = Object.keys(t), n = 0; n &lt; e.length; n++) {
            var r = e[n];
            this.items.includes(r) || delete t[r]
        }
        for (var i = !1, a = 0; a &lt; this.items.length; a++) {
            var s = this.items[a];
            t.hasOwnProperty(s) || (t[s] = this._createInventoryData(s), i = !0)
        }
        return i &amp;&amp; StorageManager.instance.set(this.storageKey, t), t
    },
    _createInventoryData: function(t) {
        switch (t) {
            case "COINS":
                return 100;
            case "PREBOOSTER_1":
            case "PREBOOSTER_2":
            case "PREBOOSTER_3":
            case "BOOSTER_1":
            case "BOOSTER_2":
            case "BOOSTER_3":
                return 3;
            default:
                return 0
        }
    }
});
var GardenCamera = pc.createScript("gardenCamera");
GardenCamera.attributes.add("distanceMax", {
    type: "number",
    default: 20,
    title: "Distance Max",
    description: "Maximum distance your camera can zoom out"
}), GardenCamera.attributes.add("distanceMin", {
    type: "number",
    default: 5,
    title: "Distance Min",
    description: "Minimum distance your camera can zoom out"
}), GardenCamera.attributes.add("maxDistanceInterupt", {
    type: "number",
    default: 400,
    title: "The maximum distance your mouse travels before you deselect (in screen pixels)"
}), GardenCamera.attributes.add("movementSpeed", {
    type: "number",
    default: .5,
    title: "Movement Multiplier",
    description: "Multiply the touch and mouse movement by this much"
}), GardenCamera.attributes.add("focusSpeed", {
    type: "number",
    default: 1,
    title: "focus speed",
    description: "The speed at which an object get focussed"
}), pc.extend(GardenCamera.prototype, {
    initialize: function() {
        this.velocity = new pc.Vec3(0, 0, 0), this.hundredPercent = 100, this.tempEntity = new pc.Entity, this.objectHandler = this.app.root.findByName("Object Manager").script.objectHandler, this.blockCamera = !1, this.holdingTimer = 0, this.selectedLocation = void 0, this.lerpedPosition = new pc.Vec3(0, 0, 0), this.targetPosition = new pc.Vec3(0, 0, 0)
    },
    update: function(t) {
        0 === this.velocity.x &amp;&amp; 0 === this.velocity.z || this._moveCamera(t), this.blockCamera &amp;&amp; (this.lerpedPosition.lerp(this.entity.getPosition(), this.targetPosition, this.focusSpeed * t), this.entity.setPosition(this.lerpedPosition))
    },
    updateVelocity: function(t) {
        this.blockCamera || (this.velocity.x += t.x, this.velocity.z += t.y)
    },
    checkHold: function(t, e) {
        if (this.holdingTimer += e, this.holdingTimer &gt; this.objectHandler.stageDuration &amp;&amp; !1 === this.objectHandler.showingPopup &amp;&amp; !this.objectHandler.selectedEntity) {
            if (this.objectHandler.checkingEntity) this._checkDistance(this.selectedLocation, t) &gt;= this.maxDistanceInterupt ? this.stopHold() : this.objectHandler.checkEntity();
            else {
                var i = this.raycast(t);
                i &amp;&amp; i.tags.has("object") &amp;&amp; this.objectHandler.selectedEntity !== i &amp;&amp; 0 !== i.parent.script.areaManager.regionState &amp;&amp; (this.selectedLocation = t.clone(), this.objectHandler.checkEntity(i))
            }
            this.holdingTimer = 0
        }
    },
    checkSelection: function(t) {
        if (!0 === this.objectHandler.inEditMode) {
            var e = this.raycast(t);
            e &amp;&amp; e.tags.has("object") &amp;&amp; this.objectHandler.selectedEntity != e &amp;&amp; this.objectHandler.checkEntity(e)
        }
    },
    raycast: function(t) {
        var e = this.entity.camera.screenToWorld(t.x, t.y, this.entity.camera.nearClip),
            i = this.entity.camera.screenToWorld(t.x, t.y, this.entity.camera.farClip),
            n = new pc.Ray(e, i.sub(e).normalize());
        return GardenManager.instance.intersectRay(n)
    },
    stopHold: function() {
        this.objectHandler.checkingEntity &amp;&amp; !this.objectHandler.selectedEntity &amp;&amp; (this.objectHandler.reset(), this.holdingTimer = 0)
    },
    zoom: function(t) {
        !1 === this.blockCamera &amp;&amp; (this.tempEntity.setPosition(this.entity.getPosition()), this.tempEntity.setRotation(this.entity.getRotation()), this.tempEntity.translateLocal(0, 0, -t), this.tempEntity.getPosition().y &gt;= this.distanceMin &amp;&amp; this.tempEntity.getPosition().y &lt;= this.distanceMax &amp;&amp; this.entity.setPosition(this.tempEntity.getPosition()))
    },
    focusObject: function(t) {
        t.script.objectOptions.updateBoundingBox();
        var e = t.script.objectOptions.boundingbox,
            i = e.center.x,
            n = this.entity.getPosition().y,
            s = e.center.z,
            a = -1 * this.entity.getLocalEulerAngles().x,
            o = n - e.center.y,
            c = Math.cos(a * (Math.PI / 180));
        s += Math.sqrt(o / c * (o / c) + o * o), this.targetPosition.set(i, n, s), this.blockCamera = !0
    },
    _moveCamera: function(t) {
        this.velocity.x *= -this.movementSpeed * t * (this.entity.position.y / this.distanceMin), this.velocity.z *= -this.movementSpeed * t * (this.entity.position.y / this.distanceMin), this.entity.translate(this.velocity), this.velocity.x = 0, this.velocity.z = 0
    },
    _checkDistance: function(t, e) {
        return t.distance(e)
    }
});
var BackgroundMeshHandler = pc.createScript("backgroundMeshHandler");
BackgroundMeshHandler.attributes.add("material", {
    type: "asset",
    assetType: "material"
}), BackgroundMeshHandler.attributes.add("tileMaterial", {
    type: "asset",
    assetType: "material"
}), BackgroundMeshHandler.attributes.add("cellWidth", {
    type: "number",
    default: 2
}), BackgroundMeshHandler.attributes.add("cellHeight", {
    type: "number",
    default: 2
}), BackgroundMeshHandler.attributes.add("backgroundMeshTileTemplate", {
    type: "asset",
    assetType: "template"
}), BackgroundMeshHandler.attributes.add("colors", {
    type: "json",
    array: !0,
    schema: [{
        name: "backgroundColor",
        type: "rgb"
    }, {
        name: "tileColor",
        type: "rgb"
    }]
}), pc.extend(BackgroundMeshHandler.prototype, {
    initialize: function() {
        BackgroundMeshHandler.instance = this, this._grid = null, this._vertices = [], this._triangles = [], this._uvs = [], this._mesh = new pc.Mesh, this._backgroundMeshTiles = [], this.index = pc.math.clamp(WorldManager.instance.getWorldIndex() - 1, 0, this.colors.length - 1), this._switchColors(), this.app.on("WorldManager:setWorld", this.setIndex, this)
    },
    generateMesh: function(e) {
        this._resetMesh(), this._grid = e, this._columns = e.length, this._rows = e[0].length, this._createUVs(), this._createVertices(), this._createTriangles(), this._generateMesh(), this._placeBackgroundMeshTile()
    },
    reset: function() {
        this._resetMesh(), this._mesh.clear(), this.entity.model &amp;&amp; (this.entity.model.model = null, this.entity.removeComponent("model"))
    },
    _resetMesh: function() {
        this._grid = null, this._vertices.length = 0, this._triangles.length = 0, this._uvs.length = 0, this._disableBackgroundMeshTiles()
    },
    _createUVs: function() {
        for (var e = 0; e &lt; this._columns + 1; e++)
            for (var t = 0; t &lt; this._rows + 1; t++) this._uvs.push(e / 2, t / 2)
    },
    _createVertices: function() {
        for (var e = this._columns / 2, t = this._rows / 2, s = 0; s &lt; this._columns + 1; s++)
            for (var i = 0; i &lt; this._rows + 1; i++) {
                var r = (s - e) * this.cellWidth,
                    h = (i - t) * this.cellHeight;
                this._vertices.push(new pc.Vec3(r, h, 0))
            }
    },
    _createTriangles: function() {
        this._squares = 0;
        for (var e = 0; e &lt; this._columns; e++)
            for (var t = 0; t &lt; this._rows; t++)
                if (!this._grid[e][t].entity.script.get("wall")) {
                    var s = e * (this._rows + 1) + t,
                        i = e * (this._rows + 1) + t + 1,
                        r = (e + 1) * (this._rows + 1) + t,
                        h = (e + 1) * (this._rows + 1) + t + 1;
                    this._triangles.push(i), this._triangles.push(s), this._triangles.push(r), this._triangles.push(h), this._triangles.push(i), this._triangles.push(r), this._squares++
                }
    },
    _placeBackgroundMeshTile: function() {
        this._instantiateBackgroundMeshTiles(this._squares);
        for (var e = 0, t = (this._columns - 1) / 2, s = (this._rows - 1) / 2, i = 0; i &lt; this._columns; i++)
            for (var r = 0; r &lt; this._rows; r++)
                if (!this._grid[i][r].entity.script.get("wall")) {
                    var h = (i - t) * this.cellWidth,
                        a = (r - s) * this.cellHeight,
                        n = this._backgroundMeshTiles[e];
                    n.setLocalPosition(h, a, .1), n.setLocalScale(.67 * this.cellHeight, .67 * this.cellHeight, .67 * this.cellWidth), n.enabled = !0, e++
                }
    },
    _generateMesh: function() {
        for (var e = [], t = 0; t &lt; this._vertices.length; t++) e.push(this._vertices[t].x, this._vertices[t].y, this._vertices[t].z);
        var s = pc.calculateNormals(e, this._triangles);
        this._mesh.setPositions(e), this._mesh.setUvs(0, this._uvs), this._mesh.setIndices(this._triangles), this._mesh.setNormals(s), this._mesh.update();
        var i = new pc.GraphNode;
        this._material = this.material;
        var r = new pc.MeshInstance(i, this._mesh, this.material.resource);
        r.cull = !1;
        var h = new pc.Model;
        h.graph = i, h.meshInstances = [r], h.castShadows = !1, h.receiveShadows = !1, this.entity.addComponent("model", {
            type: "asset"
        }), this.entity.model.model = h
    },
    _disableBackgroundMeshTiles: function() {
        for (var e = 0; e &lt; this._backgroundMeshTiles.length; e++) this._backgroundMeshTiles[e].enabled = !1
    },
    _instantiateBackgroundMeshTiles: function(e) {
        for (var t = this._backgroundMeshTiles.length - 1; t &lt; e + 1; t++) {
            var s = this.backgroundMeshTileTemplate.resource.instantiate();
            s.reparent(this.entity), s.enabled = !1, this._backgroundMeshTiles.push(s)
        }
        this.app.batcher.markGroupDirty(this.backgroundMeshTileTemplate.resource._templateRoot.model.batchGroupId)
    },
    getAABB: function() {
        return this._mesh.aabb
    },
    setIndex: function(e) {
        this.index = e - 1, this.index &gt;= this.colors.length &amp;&amp; (this.index = pc.math.clamp(e, 0, this.colors.length - 1)), this._switchColors()
    },
    _switchColors: function() {
        var e = this.colors[this.index].backgroundColor;
        this.material.resource.diffuse.set(e.r, e.g, e.b), this.material.resource.update();
        var t = this.colors[this.index].tileColor;
        this.tileMaterial.resource.diffuse.set(t.r, t.g, t.b), this.tileMaterial.resource.update()
    }
});
var BasicFill = pc.createScript("basicFill");
BasicFill.attributes.add("vs", {
    type: "asset",
    assetType: "shader",
    title: "Vertex Shader"
}), BasicFill.attributes.add("fs", {
    type: "asset",
    assetType: "shader",
    title: "Fragment Shader"
}), BasicFill.attributes.add("difuseMap", {
    type: "asset",
    assetType: "texture",
    title: "Difuse Map"
}), BasicFill.attributes.add("vDirection", {
    type: "number",
    enum: [{
        none: 0
    }, {
        bottomToTop: 1
    }, {
        topToBottom: 2
    }],
    title: "Vertical Direction",
    default: 1
}), BasicFill.attributes.add("hDirection", {
    type: "number",
    enum: [{
        none: 0
    }, {
        leftToRight: 1
    }, {
        rightToLeft: 2
    }],
    title: "Horizontal Direction",
    default: 0
}), BasicFill.attributes.add("useDiffuseColor", {
    type: "boolean",
    default: !1
}), BasicFill.attributes.add("fillPercentage", {
    type: "number",
    default: .5,
    min: 0,
    max: 1
}), BasicFill.attributes.add("silhouetteColor", {
    type: "rgba",
    title: "Silhouette Color"
}), BasicFill.attributes.add("fillColor", {
    type: "rgba",
    title: "Fill Color"
}), BasicFill.attributes.add("addColor", {
    type: "rgba",
    title: "Add Color"
}), BasicFill.attributes.add("addColorCurve", {
    type: "curve",
    curves: ["value"]
}), BasicFill.attributes.add("fillSpeed", {
    type: "number",
    default: 500,
    min: 0,
    max: 1e3
}), pc.extend(BasicFill.prototype, {
    initialize: function(t) {
        this.onAttributeChange(), this.time = 0;
        var e = this.app.graphicsDevice,
            i = this.difuseMap.resource,
            l = this.vs.resource,
            a = "precision " + e.precision + " float;\n";
        a += this.fs.resource;
        var s = {
            attributes: {
                aPosition: pc.SEMANTIC_POSITION,
                aUv0: pc.SEMANTIC_TEXCOORD0
            },
            vshader: l,
            fshader: a
        };
        this.shader = new pc.Shader(e, s), this.material = new pc.Material, this.material.blendType = pc.BLEND_PREMULTIPLIED, this.entity.element.material = this.material, this.material.shader = this.shader, this.setFillValues(), this.material.setParameter("silhouetteColor", [this.silhouetteColor.r, this.silhouetteColor.g, this.silhouetteColor.b, 1]), this.material.setParameter("fillColor", [this.fillColor.r, this.fillColor.g, this.fillColor.b, 1]), this.material.setParameter("fillPercentage", t), this.material.setParameter("vDirection", this.vDirection), this.material.setParameter("hDirection", this.hDirection), this.material.setParameter("useDiffuseColor", this.useDiffuseColor), this.material.setParameter("difuseMap", i)
    },
    setFillValues: function() {
        this.startFillValue = this.currentValue, this.endFillValue = this.currentValue, this.startFillTime = 0, this.endFillTime = 0, this.isFilling = !1, this.currentLerpColor = new pc.Color
    },
    update: function() {
        if (this.isFilling) {
            var t = (pc.now() - this.startFillTime) / (this.endFillTime - this.startFillTime);
            t &gt; 1 &amp;&amp; (t = 1, this.isFilling = !1);
            var e = pc.math.lerp(this.startFillValue, this.endFillValue, t);
            this.setValue(e), this.colorFact = this.addColorCurve.value(t), this.currentLerpColor.lerp(this.fillColor, this.addColor, this.colorFact), this.updateFillColor(this.currentLerpColor)
        }
    },
    onAttributeChange: function() {
        this.on("attr:silhouetteColor", (function(t, e) {
            this.material.setParameter("silhouetteColor", [this.silhouetteColor.r, this.silhouetteColor.g, this.silhouetteColor.b, 1])
        })), this.on("attr:fillColor", (function(t, e) {
            this.material.setParameter("fillColor", [this.fillColor.r, this.fillColor.g, this.fillColor.b, 1])
        })), this.on("attr:fillPercentage", (function(t, e) {
            this.updateValue(t)
        }))
    },
    updateValue: function(t) {
        this.fillSpeed &lt;= 0 ? this.setValue(t) : (this.startFillValue = this.currentValue || 0, this.endFillValue = t, this.startFillTime = pc.now(), this.endFillTime = this.startFillTime + this.fillSpeed, this.isFilling = !0)
    },
    setValue: function(t) {
        this.material &amp;&amp; (this.currentValue = t, this.material.setParameter("fillPercentage", t))
    },
    updateFillColor: function(t) {
        this.material &amp;&amp; this.material.setParameter("fillColor", [t.r, t.g, t.b, 1])
    },
    setNewTexture: function(t) {
        var e = t.resource;
        this.material.setParameter("difuseMap", e), this.material.update()
    }
});
var UibuttonMessage = pc.createScript("uibuttonMessage"),
    _Trigger = Object.freeze([{
        OnClick: 0
    }, {
        OnMouseOver: 1
    }, {
        OnMouseOut: 2
    }, {
        OnPress: 3
    }, {
        OnRelease: 4
    }, {
        OnDoubleClick: 5
    }]),
    Trigger = Object.freeze({
        OnClick: 0,
        OnMouseOver: 1,
        OnMouseOut: 2,
        OnPress: 3,
        OnRelease: 4,
        OnDoubleClick: 5
    });
UibuttonMessage.attributes.add("_target", {
    type: "entity"
}), UibuttonMessage.attributes.add("functionName", {
    type: "string"
}), UibuttonMessage.attributes.add("trigger", {
    type: "number",
    enum: _Trigger
}), UibuttonMessage.attributes.add("includeChildren", {
    type: "boolean",
    default: !1
}), UibuttonMessage.attributes.add("parameters", {
    type: "number"
}), pc.extend(UibuttonMessage.prototype, {
    initialize: function() {
        this.target = this._target, this._mStarted = !0, this.entity.script.elementInput || this.entity.script.create("elementInput"), this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onPress: function() {
        this.entity.enabled &amp;&amp; this.trigger === Trigger.OnPress &amp;&amp; this._send()
    },
    _onRelease: function() {
        this.entity.enabled &amp;&amp; this.trigger === Trigger.OnRelease &amp;&amp; this._send()
    },
    _onClick: function() {
        this.entity.enabled &amp;&amp; this.trigger === Trigger.OnClick &amp;&amp; this._send()
    },
    _send: function() {
        if (this.functionName)
            if (this.target || (this.target = this.entity), this.includeChildren);
            else
                for (var t = 0; t &lt; this.target.script.scripts.length; t++) "function" == typeof this.target.script.scripts[t][this.functionName] &amp;&amp; this.target.script.scripts[t][this.functionName](this.entity, this.parameters)
    }
});
var CrossBombBehaviour = function() {
    this.initialize()
};
CrossBombBehaviour.duration = new pc.Vec2(.5, .1), pc.extend(CrossBombBehaviour.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication(), this.firstNineDelay = .5, this.gridOvershoot = 2, this.lineStartDistance = 1
    },
    getAffectedTiles: function(e) {
        for (var a = [], o = e.x - 1; o &lt;= e.x + 1; o += 1)
            for (var i = e.y - 1; i &lt;= e.y + 1; i += 1) {
                if (n = GridManager.instance.getBackgroundTile(o, i)) {
                    if (n.canExplode() &amp;&amp; n.explode(PowerTileManager.instance.calculateDespawnDelay(0, this.firstNineDelay, 0) + e.getDespawnDelay()), !n.onlyBackgroundExplodes)(t = GridManager.instance.getTile(o, i)) &amp;&amp; t.canExplode &amp;&amp; (t.isHitByPower() || (a.push(t), t.setHitByPower(), t.setDespawnDelay(this.firstNineDelay)))
                }
            }
        for (o = 0; o &lt; MatchLogic.columns; o += 1) {
            var n = GridManager.instance.getBackgroundTile(o, e.y),
                r = Math.abs(o - e.x) - this.lineStartDistance;
            if (n.canExplode() &amp;&amp; n.explode(PowerTileManager.instance.calculateDespawnDelay(r, CrossBombBehaviour.duration.x, CrossBombBehaviour.duration.y)), !n.onlyBackgroundExplodes)(t = GridManager.instance.getTile(o, e.y)) &amp;&amp; t.canExplode &amp;&amp; (t.isHitByPower() || (a.push(t), t.setHitByPower(), t.typeID !== foregroundTileEnum.NONE &amp;&amp; t.typeID !== foregroundTileEnum.DEFAULT &amp;&amp; t.setDespawnCause(foregroundTileEnum.LINE_H), t.setDespawnDelay(CrossBombBehaviour.duration.x + r * CrossBombBehaviour.duration.y)))
        }
        for (i = 0; i &lt; MatchLogic.rows; i += 1) {
            n = GridManager.instance.getBackgroundTile(e.x, i);
            var t, s = Math.abs(i - e.y) - this.lineStartDistance;
            if (n.canExplode() &amp;&amp; n.explode(PowerTileManager.instance.calculateDespawnDelay(s, CrossBombBehaviour.duration.x, CrossBombBehaviour.duration.y)), !n.onlyBackgroundExplodes)(t = GridManager.instance.getTile(e.x, i)) &amp;&amp; t.canExplode &amp;&amp; (t.isHitByPower() || (a.push(t), t.setHitByPower(), t.typeID !== foregroundTileEnum.NONE &amp;&amp; t.typeID !== foregroundTileEnum.DEFAULT &amp;&amp; t.setDespawnCause(foregroundTileEnum.LINE_V), t.setDespawnDelay(CrossBombBehaviour.duration.x + s * CrossBombBehaviour.duration.y)))
        }
        return ImpulseManager.applyPulse(e.x, e.y, 5, .5, .05 + e.despawnDelay, .2), a
    },
    doActivateAnimation: function(e) {
        GridManager.instance.playSFX("bomb_detonate_flowers.mp3");
        var a = 0 - this.gridOvershoot,
            o = MatchLogic.rows - 1 + this.gridOvershoot;
        PowerAnimationManager.instance.createLineAnimationCrossbomb(e.x, e.y - this.lineStartDistance, CrossBombBehaviour.duration, !0, !0, e.x, a, 180, e.colorID, CrossBombBehaviour.duration.x), PowerAnimationManager.instance.createLineAnimationCrossbomb(e.x, e.y + this.lineStartDistance, CrossBombBehaviour.duration, !0, !0, e.x, o, 0, e.colorID, CrossBombBehaviour.duration.x);
        var i = 0 - this.gridOvershoot,
            n = MatchLogic.columns - 1 + this.gridOvershoot;
        GridManager.instance.playSFX("line_flowers.mp3"), PowerAnimationManager.instance.createLineAnimationCrossbomb(e.x - this.lineStartDistance, e.y, CrossBombBehaviour.duration, !1, !0, i, e.y, 270, e.colorID, CrossBombBehaviour.duration.x), PowerAnimationManager.instance.createLineAnimationCrossbomb(e.x + this.lineStartDistance, e.y, CrossBombBehaviour.duration, !1, !1, n, e.y, 90, e.colorID, CrossBombBehaviour.duration.x)
    },
    calculateAngle: function(e, a, o, i) {
        var n = e - o,
            r = a - i;
        return -1 * (180 * Math.atan2(r, n) / Math.PI) + 90
    }
});
var BackgroundBorderHandler = pc.createScript("backgroundBorderHandler");
BackgroundBorderHandler.attributes.add("material", {
    type: "asset",
    assetType: "material"
}), BackgroundBorderHandler.attributes.add("cellWidth", {
    type: "number",
    default: 1
}), BackgroundBorderHandler.attributes.add("cellHeight", {
    type: "number",
    default: 1
}), BackgroundBorderHandler.attributes.add("radius", {
    type: "number",
    default: .1
}), BackgroundBorderHandler.attributes.add("colors", {
    type: "json",
    array: !0,
    schema: [{
        name: "borderColor",
        type: "rgb"
    }]
}), pc.extend(BackgroundBorderHandler.prototype, {
    initialize: function() {
        BackgroundBorderHandler.instance = this, this._grid = null, this._vertices = [], this._triangles = [], this._uvs = [], this._mesh = new pc.Mesh(this.app.graphicsDevice), this.index = pc.math.clamp(WorldManager.instance.getWorldIndex() - 1, 0, this.colors.length - 1), this._switchColors(), this.app.on("WorldManager:setWorld", this.setIndex, this)
    },
    generateMesh: function(t) {
        this._resetMesh(), this._grid = t, this._columns = t.length, this._rows = t[0].length, this._calculateGridBorderEdges(), this._generateBorders(), this._generateMesh()
    },
    reset: function() {
        this._resetMesh(), this._mesh.clear(), this.entity.model &amp;&amp; (this.entity.model.model = null, this.entity.removeComponent("model"))
    },
    _resetMesh: function() {
        this._grid = null, this._vertices.length = 0, this._triangles.length = 0, this._uvs.length = 0
    },
    _generateBorders: function() {
        for (var t = this._getAllWallGroups(), e = this._calculateGridBorderEdges(), s = [], i = 0; i &lt; t.length; i++) {
            this._isGroupAtBorder(t[i]) ? s = s.concat(t[i]) : this._generateBorder(t[i])
        }
        this._generateBorder(s, e)
    },
    _calculateGridBorderEdges: function() {
        var t = [],
            e = 0,
            s = 0;
        for (e = 0; e &lt; this._columns; e++) {
            if (s = 0, !this._grid[e][s].entity.script.get("wall")) {
                var i = e * (this._rows + 1) + s,
                    r = (e + 1) * (this._rows + 1) + s;
                t.push({
                    node1: i,
                    node2: r
                })
            }
            if (s = this._rows - 1, !this._grid[e][s].entity.script.get("wall")) {
                var h = e * (this._rows + 1) + s + 1,
                    n = (e + 1) * (this._rows + 1) + s + 1;
                t.push({
                    node1: h,
                    node2: n
                })
            }
        }
        for (s = 0; s &lt; this._rows; s++) {
            if (e = 0, !this._grid[e][s].entity.script.get("wall")) {
                h = e * (this._rows + 1) + s + 1, i = e * (this._rows + 1) + s;
                t.push({
                    node1: h,
                    node2: i
                })
            }
            if (e = this._columns - 1, !this._grid[e][s].entity.script.get("wall")) {
                r = (e + 1) * (this._rows + 1) + s, n = (e + 1) * (this._rows + 1) + s + 1;
                t.push({
                    node1: r,
                    node2: n
                })
            }
        }
        return t
    },
    _getEdgesFromWalls: function(t, e) {
        for (var s = e || [], i = 0; i &lt; t.length; i++) {
            var r = t[i].x,
                h = t[i].y;
            this._getEdges(r, h, s)
        }
        return s
    },
    _sortEdges: function(t) {
        for (var e = [t.shift()]; 0 !== t.length;) {
            for (var s = t.length, i = e[e.length - 1].node2, r = t.length - 1; r &gt;= 0; r--) {
                var h = t[r];
                if (h.node1 === i) {
                    e.push(t.splice(r, 1)[0]);
                    break
                }
                if (h.node2 === i) {
                    var n = t.splice(r, 1)[0];
                    e.push({
                        node1: n.node2,
                        node2: n.node1
                    });
                    break
                }
            }
            if (s === t.length) {
                this._generateBorder([], t);
                break
            }
        }
        return e
    },
    _generateBorder: function(t, e) {
        for (var s = this._getEdgesFromWalls(t, e), i = this._sortEdges(s), r = 0; r &lt; i.length; r++) {
            e = i[r];
            var h = this._numberToPosition(e.node1),
                n = this._numberToPosition(e.node2),
                o = (new pc.Vec3).sub2(h, n),
                a = this.radius,
                l = this._vertices.length;
            o.x &lt; 0 &amp;&amp; 0 === o.y ? (this._vertices.push(new pc.Vec3(h.x - a, h.y + a, h.z)), this._vertices.push(new pc.Vec3(h.x - a, h.y - a, h.z)), this._vertices.push(new pc.Vec3(n.x + a, n.y + a, h.z)), this._vertices.push(new pc.Vec3(n.x + a, n.y - a, h.z))) : o.x &gt; 0 &amp;&amp; 0 === o.y ? (this._vertices.push(new pc.Vec3(h.x + a, h.y - a, h.z)), this._vertices.push(new pc.Vec3(h.x + a, h.y + a, h.z)), this._vertices.push(new pc.Vec3(n.x - a, n.y - a, h.z)), this._vertices.push(new pc.Vec3(n.x - a, n.y + a, h.z))) : o.y &gt; 0 &amp;&amp; 0 === o.x ? (this._vertices.push(new pc.Vec3(h.x + a, h.y + a, h.z)), this._vertices.push(new pc.Vec3(h.x - a, h.y + a, h.z)), this._vertices.push(new pc.Vec3(n.x + a, n.y - a, h.z)), this._vertices.push(new pc.Vec3(n.x - a, n.y - a, h.z))) : o.y &lt; 0 &amp;&amp; 0 === o.x ? (this._vertices.push(new pc.Vec3(h.x - a, h.y - a, h.z)), this._vertices.push(new pc.Vec3(h.x + a, h.y - a, h.z)), this._vertices.push(new pc.Vec3(n.x - a, n.y + a, h.z)), this._vertices.push(new pc.Vec3(n.x + a, n.y + a, h.z))) : console.log("something went wrong", o), this._triangles.push(l + 0), this._triangles.push(l + 1), this._triangles.push(l + 2), this._triangles.push(l + 1), this._triangles.push(l + 3), this._triangles.push(l + 2), this._uvs.push(0, 0, 0, 0, 0, 0, 0, 0)
        }
    },
    _generateMesh: function() {
        for (var t = [], e = 0; e &lt; this._vertices.length; e++) t.push(this._vertices[e].x, this._vertices[e].y, this._vertices[e].z);
        var s = pc.calculateNormals(t, this._triangles);
        this._mesh.clear(), this._mesh.setPositions(t), this._mesh.setUvs(0, this._uvs), this._mesh.setIndices(this._triangles), this._mesh.setNormals(s), this._mesh.update();
        var i = new pc.GraphNode;
        this._material = this.material;
        var r = new pc.MeshInstance(i, this._mesh, this.material.resource);
        r.cull = !1;
        var h = new pc.Model;
        h.graph = i, h.meshInstances = [r], this.entity.addComponent("model", {
            type: "asset"
        }), this.entity.model.model = h
    },
    _getEdges: function(t, e, s) {
        var i = t * (this._rows + 1) + e,
            r = t * (this._rows + 1) + e + 1,
            h = (t + 1) * (this._rows + 1) + e,
            n = (t + 1) * (this._rows + 1) + e + 1;
        this._grid[t - 1] &amp;&amp; (this._grid[t - 1][e].entity.script.get("wall") || s.push({
            node1: i,
            node2: r
        }));
        this._grid[t + 1] &amp;&amp; (this._grid[t + 1][e].entity.script.get("wall") || s.push({
            node1: h,
            node2: n
        }));
        this._grid[t][e + 1] &amp;&amp; (this._grid[t][e + 1].entity.script.get("wall") || s.push({
            node1: r,
            node2: n
        }));
        this._grid[t][e - 1] &amp;&amp; (this._grid[t][e - 1].entity.script.get("wall") || s.push({
            node1: i,
            node2: h
        }))
    },
    _getNeighbours: function(t, e) {
        var s = t - 1,
            i = t + 1,
            r = e + 1,
            h = e - 1;
        return [this._grid[s][e], this._grid[i][e], this._grid[t][r], this._grid[t][h]]
    },
    _getAllWallGroups: function() {
        for (var t = [], e = 0; e &lt; this._columns; e++)
            for (var s = 0; s &lt; this._rows; s++)
                if (this._grid[e][s].entity.script.get("wall")) {
                    for (var i = !1, r = 0; r &lt; t.length; r++)
                        if (pc.utils.isElementInArray(this._grid[e][s], t[r])) {
                            i = !0;
                            break
                        }
                    if (!i) {
                        var h = [this._grid[e][s]];
                        this._getWallNeighbours(e, s, h), t.push(h)
                    }
                }
        return t
    },
    _isGroupAtBorder: function(t) {
        for (var e = 0; e &lt; t.length; e++) {
            var s = t[e];
            if (0 === s.x || s.x === this._columns - 1 || 0 === s.y || s.y === this._rows - 1) return !0
        }
        return !1
    },
    _getWallNeighbours: function(t, e, s) {
        var i = t - 1,
            r = t + 1,
            h = e + 1,
            n = e - 1;
        if (this._grid[i] &amp;&amp; this._grid[i][e]) {
            var o = this._grid[i][e];
            o.entity.script.get("wall") &amp;&amp; (pc.utils.isElementInArray(o, s) || (s.push(o), this._getWallNeighbours(i, e, s)))
        }
        if (this._grid[r] &amp;&amp; this._grid[r][e]) {
            var a = this._grid[r][e];
            a.entity.script.get("wall") &amp;&amp; (pc.utils.isElementInArray(a, s) || (s.push(a), this._getWallNeighbours(r, e, s)))
        }
        if (this._grid[t][h]) {
            var l = this._grid[t][h];
            l.entity.script.get("wall") &amp;&amp; (pc.utils.isElementInArray(l, s) || (s.push(l), this._getWallNeighbours(t, h, s)))
        }
        if (this._grid[t][n]) {
            var c = this._grid[t][n];
            c.entity.script.get("wall") &amp;&amp; (pc.utils.isElementInArray(c, s) || (s.push(c), this._getWallNeighbours(t, n, s)))
        }
    },
    _numberToPosition: function(t) {
        var e = t % (this._rows + 1),
            s = Math.floor(t / (this._rows + 1)),
            i = this._columns / 2,
            r = this._rows / 2,
            h = (s - i) * this.cellWidth,
            n = (e - r) * this.cellHeight;
        return new pc.Vec3(h, n, -.01)
    },
    getAABB: function() {
        return this._mesh.aabb
    },
    setIndex: function(t) {
        this.index = t - 1, this.index &gt;= this.colors.length &amp;&amp; (this.index = pc.math.clamp(t, 0, this.colors.length - 1)), this._switchColors()
    },
    _switchColors: function() {
        var t = this.colors[this.index].borderColor;
        this.material.resource.diffuse.set(t.r, t.g, t.b), this.material.resource.update()
    }
});
var ObjectiveInterface = pc.createScript("objectiveInterface");
ObjectiveInterface.attributes.add("objectivePrefab", {
    type: "entity"
}), ObjectiveInterface.attributes.add("objectiveDividerPrefab", {
    type: "entity"
}), pc.extend(ObjectiveInterface.prototype, {
    initialize: function() {
        this.objectives = [], this.objectivesAndDividers = [], this.app.on("ObjectiveManager:onObjectiveAdd", this.onObjectiveAdd, this), this.app.on("ObjectiveManager:onObjectiveChange", this.onObjectiveChange, this), this.app.on("ObjectiveManager:onObjectiveComplete", this.onObjectiveComplete, this), this.app.on("ObjectiveManager:onReset", this.onReset, this)
    },
    onObjectiveAdd: function(e) {
        if (this.objectives.length &gt; 0) {
            var t = this.objectiveDividerPrefab.clone();
            t.enabled = !0, t.reparent(this.entity), this.objectivesAndDividers.push(t)
        }
        var i = this.objectivePrefab.clone();
        i.enabled = !0, i.reparent(this.entity), this.objectives.push(i), this.objectivesAndDividers.push(i);
        var s = TileLibrary.instance.getTileSprite(e.orderTypeObject);
        i.script.objectivePrefab.setObjectiveImage(s), this.onObjectiveChange(this.objectives.length - 1, e)
    },
    onObjectiveChange: function(e, t) {
        var i = t.values.goal - t.values.currentVisible;
        i &lt; 0 &amp;&amp; (i = 0);
        var s = t.values.currentVisible &lt; t.values.goal &amp;&amp; t.values.currentVisible &gt; 0;
        this.objectives[e].script.objectivePrefab.changeValueText(i, s)
    },
    onObjectiveComplete: function(e) {
        this.objectives[e].script.objectivePrefab.setObjectiveCompleted()
    },
    onReset: function() {
        for (var e = 0; e &lt; this.objectivesAndDividers.length; e += 1) this.objectivesAndDividers[e].destroy();
        this.objectivesAndDividers.length = 0, this.objectives.length = 0
    }
});
var ParticleHandler = pc.createScript("particleHandler");
pc.extend(ParticleHandler.prototype, {
    initialize: function() {
        this._sprite = this.entity.sprite, this._clip = this.entity.sprite.clip("particle"), this._active = !1
    },
    update: function() {
        this._active &amp;&amp; !this._clip.isPlaying &amp;&amp; this._recycle()
    },
    awake: function(t, i, e, c, r) {
        c &amp;&amp; r ? (this._active = !0, this.entity.setPosition(t), this.entity.reparent(e), this._sprite.play("particle"), this._clip.sprite = c, this._sprite.color = r) : this._recycle()
    },
    _recycle: function() {
        GridManager.instance.recycleParticle(this.entity), this._active = !1
    }
});
var ObjectivePrefab = pc.createScript("objectivePrefab");
ObjectivePrefab.attributes.add("objectiveIcon", {
    type: "entity"
}), ObjectivePrefab.attributes.add("valueText", {
    type: "entity"
}), ObjectivePrefab.attributes.add("checkIcon", {
    type: "entity"
}), pc.extend(ObjectivePrefab.prototype, {
    initialize: function() {
        this.checkIcon.enabled = !1
    },
    setObjectiveImage: function(e) {
        this.objectiveIcon.element.spriteAsset = e
    },
    changeValueText: function(e, t) {
        this.valueText.element.text = e, t &amp;&amp; this.bubbleTween(this.objectiveIcon)
    },
    setObjectiveCompleted: function() {
        this.checkIcon.setLocalScale(0, 0, 0), this.checkIcon.enabled = !0, this.bubbleTween(this.checkIcon), this.valueText.enabled = !1
    },
    bubbleTween: function(e) {
        if (!this._despawning &amp;&amp; !this._spawning) {
            var t = e.tween(e.getLocalScale()).to({
                    x: 1.5,
                    y: 1.5,
                    z: 1.5
                }, .08, pc.SineInOut),
                c = e.tween(e.getLocalScale()).to({
                    x: .8,
                    y: .8,
                    z: .8
                }, .15, pc.SineInOut),
                n = e.tween(e.getLocalScale()).to({
                    x: 1.1,
                    y: 1.1,
                    z: 1.1
                }, .05, pc.SineInOut),
                i = e.tween(e.getLocalScale()).to({
                    x: 1,
                    y: 1,
                    z: 1
                }, .05, pc.SineInOut);
            t.chain(c), c.chain(n), n.chain(i), t.start()
        }
    }
});
var GardenButton = pc.createScript("gardenButton");
pc.extend(GardenButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onClick: function() {
        LoadScreenController.load("Garden", !1, "loading world", null)
    }
});
var BombTile = pc.createScript("bombTile");
BombTile.tileColorEnumCopy = Object.freeze({
    NONE: 0,
    BLUE: 1,
    YELLOW: 2,
    RED: 3,
    PURPLE: 4,
    GREEN: 5,
    ORANGE: 6
}), BombTile.colorEnum = [{
    NONE: BombTile.tileColorEnumCopy.NONE
}, {
    BLUE: BombTile.tileColorEnumCopy.BLUE
}, {
    YELLOW: BombTile.tileColorEnumCopy.YELLOW
}, {
    RED: BombTile.tileColorEnumCopy.RED
}, {
    PURPLE: BombTile.tileColorEnumCopy.PURPLE
}, {
    GREEN: BombTile.tileColorEnumCopy.GREEN
}, {
    ORANGE: BombTile.tileColorEnumCopy.ORANGE
}], BombTile.attributes.add("colorId", {
    type: "number",
    enum: BombTile.colorEnum
}), pc.extend(BombTile.prototype, {
    initialize: function() {},
    init: function(o) {
        this.superClass = o, this.superClass.colorID = this.colorId, this.superClass.typeID = foregroundTileEnum.BOMB
    }
});
var PowerTileManager = pc.createScript("powerTileManager");
pc.extend(PowerTileManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(PowerTileManager) &amp;&amp; (PowerTileManager.instance = this), this.powerBehaviourScripts = {
            [foregroundTileEnum.LINE_H]: new LineHBehaviour,
            [foregroundTileEnum.LINE_V]: new LineVBehaviour,
            [foregroundTileEnum.COLORBOMB]: new ColorBombBehaviour,
            [foregroundTileEnum.BOMB]: new BombBehaviour
        }, this._delayedActionQueue = [], this.powerStrengthOrder = {
            [foregroundTileEnum.COLORBOMB]: 4,
            [foregroundTileEnum.BOMB]: 3,
            [foregroundTileEnum.LINE_H]: 2,
            [foregroundTileEnum.LINE_V]: 1
        }
    },
    update: function(e) {
        for (var t = this._delayedActionQueue.length - 1; t &gt;= 0; t -= 1) this._delayedActionQueue[t].timer += e, this._delayedActionQueue[t].timer &gt;= this._delayedActionQueue[t].delay &amp;&amp; (this._delayedActionQueue[t].action(), this._delayedActionQueue.splice(t, 1))
    },
    onTileSwap: function(e, t) {
        var i = [];
        return (i = t.typeID === foregroundTileEnum.COLORBOMB &amp;&amp; e.typeID !== foregroundTileEnum.COLORBOMB ? this.checkPowerCombination(t, e) : this.checkPowerCombination(e, t)).length &gt; 0 ? (this.app.fire("ScoreManager:scoreEachPowerTile", i), i) : e.typeID === foregroundTileEnum.COLORBOMB ? this.activatePower(e, t) : t.typeID === foregroundTileEnum.COLORBOMB ? this.activatePower(t, e) : []
    },
    checkPowerCombination: function(e, t) {
        if (!this.isPowerTile(t.typeID) || !this.isPowerTile(e.typeID)) return [];
        var i = this.powerBehaviourScripts[e.typeID];
        this._updatePowerStatistics(e.typeID), this._updatePowerStatistics(t.typeID);
        var r = i.getCombinationScript(t.typeID);
        if (null === r) return [];
        e.setPowerState(ForegroundTile._PowerStates.TRIGGERED), t.setPowerState(ForegroundTile._PowerStates.TRIGGERED);
        var n = r.getAffectedTiles(e, t, e.colorID &gt; 0 ? e.colorID : t.colorID);
        return this.startAnimation(e, r, n, t), this.app.fire("Audio:sfx", "power_combination_fuse.mp3"), n
    },
    isPowerTile: function(e) {
        return e === foregroundTileEnum.LINE_H || e === foregroundTileEnum.LINE_V || e === foregroundTileEnum.BOMB || e === foregroundTileEnum.COLORBOMB
    },
    activatePower: function(e, t) {
        var i = e.typeID;
        e.getDespawnCause() !== e.typeID || e.typeID !== foregroundTileEnum.LINE_V &amp;&amp; e.typeID !== foregroundTileEnum.LINE_H || (i = e.typeID === foregroundTileEnum.LINE_V ? foregroundTileEnum.LINE_H : foregroundTileEnum.LINE_V);
        var r = this.powerBehaviourScripts[i];
        if (!r) return console.warn("No power behaviour script for power: ", i), [];
        var n = r.getAffectedTiles(e, t);
        return 0 === n.length &amp;&amp; i === foregroundTileEnum.COLORBOMB || (e.setPowerState(ForegroundTile._PowerStates.TRIGGERED), this.startAnimation(e, r, n, t), this.app.fire("ScoreManager:scoreEachPowerTile", n), this._updatePowerStatistics(i)), n
    },
    isPowerStronger: function(e, t) {
        return !(!this.isPowerTile(e) || !this.isPowerTile(t)) &amp;&amp; this.powerStrengthOrder[e.typeID] &gt; this.powerStrengthOrder[t.typeID]
    },
    checkPowerTileSpawn: function(e, t) {
        return e &gt;= 5 || t &gt;= 5 ? (GridManager.instance.playSFX("power_create.mp3"), foregroundTileEnum.COLORBOMB) : e &gt;= 3 &amp;&amp; t &gt;= 3 ? (GridManager.instance.playSFX("power_create.mp3"), foregroundTileEnum.BOMB) : t &gt;= 4 ? (GridManager.instance.playSFX("power_create.mp3"), foregroundTileEnum.LINE_H) : e &gt;= 4 ? (GridManager.instance.playSFX("power_create.mp3"), foregroundTileEnum.LINE_V) : foregroundTileEnum.EMPTY
    },
    onTileMatch: function(e) {
        if (!this.isPowerTile(e.typeID) || !e.isPowerActive()) return [];
        var t = GridManager.instance.getBackgroundTile(e.x, e.y);
        return t.onlyBackgroundExplodes &amp;&amp; !t.isDestroyed ? [] : this.activatePower(e)
    },
    calculateDespawnDelay: function(e, t, i) {
        return t + e * i
    },
    setTileDespawnDelay: function(e, t, i, r, n) {
        var o = r + i * n,
            a = e.getDespawnDelay();
        t.setDespawnDelay(a + o)
    },
    startAnimation: function(e, t, i, r) {
        e.despawnDelay &lt;= 0 ? t.doActivateAnimation(e, i, r) : this._addDelayedAction(e.despawnDelay, function() {
            t.doActivateAnimation(e, i, r)
        }.bind(this))
    },
    _addDelayedAction: function(e, t) {
        this._delayedActionQueue.push({
            timer: 0,
            delay: e,
            action: t
        })
    },
    _updatePowerStatistics: function(e) {
        StatisticsManager.instance.incrementStatistic("power_tiles_activated", 1), e !== foregroundTileEnum.LINE_V &amp;&amp; e !== foregroundTileEnum.LINE_H || StatisticsManager.instance.incrementStatistic("bees_activated", 1), e === foregroundTileEnum.COLORBOMB &amp;&amp; StatisticsManager.instance.incrementStatistic("butterflies_activated", 1), e === foregroundTileEnum.BOMB &amp;&amp; StatisticsManager.instance.incrementStatistic("ladybugs_activated", 1)
    },
    switchTilePower: function(e, t, i) {
        var r = e.x,
            n = e.y,
            o = e.colorID,
            a = GridManager.instance._spawnForegroundTile(r, n, !1, 0, o, t, !1, 0, !0);
        return GridManager.instance._tileArrayForeground[r][n] = a, this.setTileState(a, ForegroundTile._PowerStates.IMMUNE), a.isMovedTile = !0, !i || i &lt;= 0 ? (a.spawnAnimation(void 0, 0, !0), SwapMode.instance.currentState !== matchStates.ENDSPAWN &amp;&amp; SwapMode.instance.currentState !== matchStates.END || this.app.fire("PowerTileManager:onEndModePowerSpawn", this.currentMove)) : (e.setDespawnDelay(i), a.entity.setLocalScale(pc.Vec3.ZERO), this._addDelayedAction(i, function() {
            GridManager.instance.playSFX("power_create.mp3"), a.spawnAnimation(void 0, 0, !0), SwapMode.instance.currentState !== matchStates.ENDSPAWN &amp;&amp; SwapMode.instance.currentState !== matchStates.END || this.app.fire("PowerTileManager:onEndModePowerSpawn", this.currentMove)
        }.bind(this))), e.despawn(), a
    },
    setTileState: function(e, t) {
        e.isPowerState(ForegroundTile._PowerStates.TRIGGERED) || e.setPowerState(t)
    }
});
var PowerHorizontalTile = pc.createScript("powerHorizontalTile");
PowerHorizontalTile.tileColorEnumCopy = Object.freeze({
    NONE: 0,
    BLUE: 1,
    YELLOW: 2,
    RED: 3,
    PURPLE: 4,
    GREEN: 5,
    ORANGE: 6
}), PowerHorizontalTile.colorEnum = [{
    NONE: PowerHorizontalTile.tileColorEnumCopy.NONE
}, {
    BLUE: PowerHorizontalTile.tileColorEnumCopy.BLUE
}, {
    YELLOW: PowerHorizontalTile.tileColorEnumCopy.YELLOW
}, {
    RED: PowerHorizontalTile.tileColorEnumCopy.RED
}, {
    PURPLE: PowerHorizontalTile.tileColorEnumCopy.PURPLE
}, {
    GREEN: PowerHorizontalTile.tileColorEnumCopy.GREEN
}, {
    ORANGE: PowerHorizontalTile.tileColorEnumCopy.ORANGE
}], PowerHorizontalTile.attributes.add("colorId", {
    type: "number",
    enum: PowerHorizontalTile.colorEnum
}), pc.extend(PowerHorizontalTile.prototype, {
    initialize: function() {},
    init: function(o) {
        this.superClass = o, this.superClass.colorID = this.colorId, this.superClass.typeID = foregroundTileEnum.LINE_H
    }
});
var PowerVerticalTile = pc.createScript("powerVerticalTile");
PowerVerticalTile.tileColorEnumCopy = Object.freeze({
    NONE: 0,
    BLUE: 1,
    YELLOW: 2,
    RED: 3,
    PURPLE: 4,
    GREEN: 5,
    ORANGE: 6
}), PowerVerticalTile.colorEnum = [{
    NONE: PowerVerticalTile.tileColorEnumCopy.NONE
}, {
    BLUE: PowerVerticalTile.tileColorEnumCopy.BLUE
}, {
    YELLOW: PowerVerticalTile.tileColorEnumCopy.YELLOW
}, {
    RED: PowerVerticalTile.tileColorEnumCopy.RED
}, {
    PURPLE: PowerVerticalTile.tileColorEnumCopy.PURPLE
}, {
    GREEN: PowerVerticalTile.tileColorEnumCopy.GREEN
}, {
    ORANGE: PowerVerticalTile.tileColorEnumCopy.ORANGE
}], PowerVerticalTile.attributes.add("colorId", {
    type: "number",
    enum: PowerVerticalTile.colorEnum
}), pc.extend(PowerVerticalTile.prototype, {
    initialize: function() {},
    init: function(e) {
        this.superClass = e, this.superClass.colorID = this.colorId, this.superClass.typeID = foregroundTileEnum.LINE_V
    }
});
var ColorBombTile = pc.createScript("colorBombTile");
pc.extend(ColorBombTile.prototype, {
    initialize: function() {},
    init: function(o) {
        this.superClass = o, this.superClass.colorID = tileColorEnum.NONE, this.superClass.typeID = foregroundTileEnum.COLORBOMB
    }
});
var BackgroundSpriteHandler = pc.createScript("backgroundSpriteHandler");
BackgroundSpriteHandler.attributes.add("sprites", {
    type: "asset",
    array: !0
}), BackgroundSpriteHandler.attributes.add("atlas", {
    type: "asset",
    array: !0
}), pc.extend(BackgroundSpriteHandler.prototype, {
    initialize: function() {
        BackgroundSpriteHandler.instance = this, this.sprite = this.entity.sprite, this.index = pc.math.clamp(WorldManager.instance.getWorldIndex() - 1, 0, this.sprites.length - 1), this._switchSprite(), this.app.on("ViewportManager:onResize", this._onResize, this), this.app.on("PerspectiveView:onCameraChange", this._onCameraChange, this), this.app.on("WorldManager:setWorld", this.setIndex, this), this.on("destroy", this._onDestroy, this)
    },
    postInitialize: function() {
        this._onResize(null, innerWidth, innerHeight)
    },
    _onDestroy: function() {
        this.app.off("ViewportManager:onResize", this._onResize, this), this.app.off("PerspectiveView:onCameraChange", this._onCameraChange, this), this.app.off("WorldManager:setWorld", this.setIndex, this)
    },
    setIndex: function(t) {
        this.index = t - 1, this.index &gt;= this.sprites.length &amp;&amp; (this.index = pc.math.clamp(t, 0, this.sprites.length - 1)), this._switchSprite()
    },
    _switchSprite: function() {
        var t = this.sprites[this.index],
            e = this.atlas[this.index];
        t.resource || LazyLoader.instance.lazyLoad(t, this._onResize, this), e.resource || LazyLoader.instance.lazyLoad(e, this._onResize, this), t.resource &amp;&amp; e.resource &amp;&amp; this._onResize()
    },
    isLoaded: function() {
        return this.sprites[this.index].resource &amp;&amp; this.atlas[this.index].resource
    },
    _onResize: function(t, e, i) {
        if (this.isLoaded()) {
            e || (e = innerWidth), i || (i = innerHeight), this.sprite.sprite !== this.sprites[this.index].resource &amp;&amp; (this.sprite.sprite = this.sprites[this.index].resource);
            var s = this.sprite.sprite.atlas.frames[1].rect,
                n = s.z / 100 / 2,
                a = s.w / 100 / 2,
                r = PerspectiveView.instance.entity.getLocalPosition().z - this.entity.getLocalPosition().z,
                h = PerspectiveView.instance.camera.fov,
                o = UIManager.instance.getReferenceResolution().y,
                p = (e = e * o / i) / (i = o),
                c = r * Math.tan(h / 2 * Math.PI / 180) * p / n,
                d = r * Math.tan(h / 2 * Math.PI / 180) / a,
                l = Math.max(c, d);
            this.entity.setLocalScale(l, l, l), this.entity.setLocalPosition(0, 0, this.entity.getLocalPosition().z)
        }
    },
    _onCameraChange: function(t) {
        this._onResize(null, innerWidth, innerHeight)
    }
});
var WorldManager = pc.createScript("worldManager");
WorldManager.attributes.add("worldBackgroundImages", {
    type: "asset",
    assetType: "sprite",
    array: !0
}), WorldManager.attributes.add("blurredWorldBackgroundImages", {
    type: "asset",
    assetType: "sprite",
    array: !0
}), WorldManager.attributes.add("unlockablePartAssets", {
    type: "json",
    schema: [{
        name: "completedModel",
        type: "asset",
        assetType: "model"
    }, {
        name: "partModel",
        type: "asset",
        assetType: "model"
    }, {
        name: "partSprite",
        type: "asset",
        assetType: "sprite"
    }],
    array: !0
}), WorldManager.attributes.add("worldTextColors", {
    type: "rgb",
    array: !0
}), pc.extend(WorldManager.prototype, {
    initialize: function() {
        WorldManager.instance = this, this._worldIndex = 0, this._worldList = {
            1: {
                name: "WORLD_1",
                nLevels: 100,
                nParts: 4,
                isUnlocked: !0,
                comics: [],
                index: 0,
                minLevel: 1,
                maxLevel: 100
            },
            2: {
                name: "WORLD_2",
                nLevels: 150,
                nParts: 6,
                isUnlocked: !0,
                comics: [],
                index: 1,
                minLevel: 101,
                maxLevel: 250
            },
            3: {
                name: "WORLD_3",
                nLevels: 150,
                nParts: 6,
                isUnlocked: !0,
                comics: [],
                index: 2,
                minLevel: 251,
                maxLevel: 400
            },
            4: {
                name: "WORLD_4",
                nLevels: 200,
                nParts: 8,
                isUnlocked: !1,
                comics: [],
                index: 3,
                minLevel: 401,
                maxLevel: 600
            },
            5: {
                name: "WORLD_5",
                nLevels: 200,
                nParts: 8,
                isUnlocked: !1,
                comics: [],
                index: 4,
                minLevel: 601,
                maxLevel: 800
            },
            6: {
                name: "WORLD_6",
                nLevels: 200,
                nParts: 8,
                isUnlocked: !1,
                comics: [],
                index: 5,
                minLevel: 801,
                maxLevel: 1e3
            },
            7: {
                name: "WORLD_7",
                nLevels: 250,
                nParts: 10,
                isUnlocked: !1,
                comics: [],
                index: 6,
                minLevel: 1001,
                maxLevel: 1250
            },
            8: {
                name: "WORLD_8",
                nLevels: 250,
                nParts: 10,
                isUnlocked: !1,
                comics: [],
                index: 7,
                minLevel: 1251,
                maxLevel: 1500
            },
            9: {
                name: "WORLD_9",
                nLevels: 250,
                nParts: 10,
                isUnlocked: !1,
                comics: [],
                index: 8,
                minLevel: 1501,
                maxLevel: 1750
            },
            10: {
                name: "WORLD_10",
                nLevels: 250,
                nParts: 10,
                isUnlocked: !1,
                comics: [],
                index: 9,
                minLevel: 1701,
                maxLevel: 2e3
            }
        }, this.maxLevel = 0;
        for (var e = 1; e &lt;= 10 &amp;&amp; this._worldList[e].isUnlocked; e++) this.maxLevel += this._worldList[e].nLevels;
        this.app.on("LevelManager:unlockNewPage", this.unlockNewPage, this)
    },
    postInitialize: function() {
        this._worldIndex = StorageManager.instance.get("lastPlayedWorld"), this.findComicAssets()
    },
    switchWorld: function(e) {
        e !== this._worldIndex &amp;&amp; (this._worldIndex = e, StorageManager.instance.set("lastPlayedWorld", this._worldIndex), this.app.fire("WorldManager:setWorld", this._worldIndex))
    },
    getWorldIndex: function() {
        return this._worldIndex
    },
    getWorldList: function() {
        return this._worldList
    },
    getWorldData: function(e) {
        if (this._worldList.hasOwnProperty(e)) return this._worldList[e];
        console.error("World " + e + " does not exist")
    },
    getWorldIDByIndex: function(e) {
        return Object.keys(this._worldList)[e]
    },
    setWorldIndex: function(e) {
        this._worldIndex = e, this.app.fire("WorldManager:setWorld", this._worldIndex)
    },
    getWorldIndexByID: function(e) {
        return Object.keys(this._worldList).indexOf(String(e))
    },
    getCurrentWorld: function(e) {
        return this.getWorldByLevel(e || LevelDataManager.instance.getCurrentLevel())
    },
    isNextWorldExisting: function(e) {
        var t = WorldManager.instance.getWorldIndexByID(e) + 1;
        return !(t &gt; this._worldList.length - 1) &amp;&amp; !1 !== this.getWorldData(this.getWorldIDByIndex(t)).isUnlocked
    },
    getWorldByLevel: function(e) {
        var t = 0,
            r = 0;
        for (var n in this._worldList) {
            if (t = r + 1, r += this._worldList[n].nLevels, e &gt;= t &amp;&amp; e &lt;= r) return this._worldList[n].index + 1;
            r
        }
    },
    getPageInWorld: function(e, t) {
        var r = this.getWorldData(e);
        return t = Math.min(this.getMaxLevels(e), t), levelNumber = this._getCurrentWorldLevel(t), Math.floor((t - r.minLevel) / (r.nLevels / r.nParts))
    },
    getMaxLevels: function(e) {
        for (var t = 0, r = 1; r &lt;= e; r++) t += this._worldList[r].nLevels;
        return t
    },
    getNumberOfParts: function(e) {
        return this.getWorldData(e).nParts
    },
    getLevelNumberinPage: function(e) {
        for (var t in this._worldList)
            if (minLevel = this._worldList[t].minLevel, maxLevel = this._worldList[t].maxLevel, e &gt;= minLevel &amp;&amp; e &lt;= maxLevel) return (e - minLevel) % (this._worldList[t].nLevels / this._worldList[t].nParts) + 1
    },
    isEndOfPage: function(e) {
        var t = this.getCurrentWorld(e);
        return (e = this._getCurrentWorldLevel(e)) % (this._worldList[t].nLevels / this._worldList[t].nParts) == 0
    },
    isEndOfWorld: function(e) {
        this.getCurrentWorld();
        return (e = this._getCurrentWorldLevel(e)) === this._worldList[this.getCurrentWorld()].nLevels
    },
    findComicAssets: function() {
        for (var e in this._worldList)
            for (var t = this._worldList[e], r = 1; r &lt;= t.nParts; r += 1) t.comics[r - 1] = this.app.assets.find("w" + e + "_p" + r + ".png")
    },
    _getCurrentWorldLevel: function(e, t) {
        for (var r in this._worldList) r &lt; this.getCurrentWorld(e) &amp;&amp; (e -= this._worldList[r].nLevels);
        return e
    },
    getWorldBackgroundImage: function(e) {
        var t = this.getWorldIndexByID(e);
        return this.worldBackgroundImages[t]
    },
    getBlurredWorldBackgroundImage: function(e) {
        return this.blurredWorldBackgroundImages[e - 1]
    },
    getPartAssets: function(e) {
        var t = this.getWorldIndexByID(e);
        return this.unlockablePartAssets[t]
    },
    getWorldTextColor: function(e) {
        var t = this.getWorldIndexByID(e);
        return this.worldTextColors[t]
    }
});
var WorldSelectButton = pc.createScript("worldSelectButton"),
    _worldIndexEnum = [{
        "World 1": 0
    }, {
        "World 2": 1
    }, {
        "World 3": 2
    }, {
        "World 4": 3
    }, {
        "World 5": 4
    }, {
        "World 6": 5
    }];
WorldSelectButton.attributes.add("worldIndex", {
    type: "number",
    enum: _worldIndexEnum
}), pc.extend(WorldSelectButton.prototype, {
    initialize: function() {
        this._elementInput || (this._elementInput = this.entity.script.create("elementInput"), console.warn("Add the script elementInput to this entity:", this.entity.name)), this.entity.script.elementInput.on("click", this._onClick, this)
    },
    _onClick: function() {
        WorldManager.instance.switchWorld(this.worldIndex)
    }
});
var LevelDataManager = pc.createScript("levelDataManager");
pc.extend(LevelDataManager.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (LevelDataManager.instance = this), this.storageKey = "levelData", this._levelData = this._getSaveData(), this._calculateTotalStars(), this._calculatePartsCollected()
    },
    postInitialize: function() {},
    getCurrentLevel: function() {
        return pc.math.clamp(this._levelData.currentLevel, 0, WorldManager.instance.maxLevel)
    },
    getLevelData: function(t, a) {
        return this._levelData.hasOwnProperty(t) &amp;&amp; this._levelData[t].hasOwnProperty(a) ? this._levelData[t][a] : null
    },
    getTotalStarData: function(t) {
        return this._starData.hasOwnProperty(t) ? this._starData[t] : null
    },
    getPartsData: function(t) {
        return this._partsData.hasOwnProperty(t) ? this._partsData[t] : null
    },
    completedLevelsInWorld: function(t) {
        return this._partsData.hasOwnProperty(t) ? Object.keys(this._levelData[t]).length : null
    },
    _getSaveData: function() {
        var t = StorageManager.instance.get(this.storageKey);
        return t = this._validateData(t)
    },
    _validateData: function(t) {
        var a = WorldManager.instance.getWorldList();
        Array.isArray(t) &amp;&amp; (t = {}), "object" != typeof t &amp;&amp; (t = {});
        var e = t.currentLevel || 1;
        for (var r in t) a.hasOwnProperty(r) || (console.warn("World exists in data, but not in world list. Deleting world."), delete t[r]);
        var s = !1;
        for (var r in a) t.hasOwnProperty(r) || (t[r] = this._createWorldData(), s = !0), Array.isArray(t[r]) &amp;&amp; (t[r] = {}), "object" != typeof t[r] &amp;&amp; (t[r] = {});
        return t.currentLevel = e, t.hasOwnProperty("currentLevel") || (t.currentLevel = 1, s = !0), s &amp;&amp; StorageManager.instance.set(this.storageKey, t), t
    },
    _createWorldData: function() {
        return {}
    },
    _createLevelData: function(t, a) {
        return {
            score: t,
            stars: a
        }
    },
    saveLevelData: function(t, a, e, r) {
        if (this._levelData.hasOwnProperty(t) &amp;&amp; WorldManager.instance.getWorldList().hasOwnProperty(t)) {
            var s = this._levelData[t];
            s.hasOwnProperty(a) ? (e &gt; s[a].score &amp;&amp; (s[a].score = e), r &gt; s[a].stars &amp;&amp; (s[a].stars = r)) : s[a] = this._createLevelData(e, r), a &gt; this._levelData.currentLevel - 1 &amp;&amp; (this._levelData.currentLevel = a + 1), StorageManager.instance.set(this.storageKey, this._levelData), this._calculateTotalStars(t), this._calculatePartsCollected(t)
        } else console.error("World " + t + " does not exist")
    },
    _resetData: function(t) {
        for (var a in this._levelData) delete this._levelData[a]
    },
    _calculateTotalStars: function(t) {
        if (this._starData = {}, this._starData.hasOwnProperty(t)) {
            for (var a in this._starData[t] = 0, this._levelData[t]) this._starData[t] += this._levelData[t][a].stars;
            this.app.fire("LevelDataManager:onSpecificTotalStarsChange", t, this._starData[t])
        } else {
            var e = WorldManager.instance.getWorldList();
            for (var r in e)
                for (var a in this._starData[r] = 0, this._levelData[r]) this._starData[r] += this._levelData[r][a].stars
        }
    },
    _calculatePartsCollected: function(t) {
        this._partsData = {};
        var a = WorldManager.instance.getWorldList();
        if (this._partsData.hasOwnProperty(t)) {
            r = Object.keys(this._levelData[t]).length, s = a[t].nLevels / a[t].nParts;
            this._partsData[t] = Math.floor(r / s), this.app.fire("LevelDataManager:onSpecificPartsChange", t, this._partsData[t])
        } else
            for (var e in a) {
                var r = Object.keys(this._levelData[e]).length,
                    s = a[e].nLevels / a[e].nParts;
                this._partsData[e] = Math.floor(r / s)
            }
    },
    cheat: function(t) {
        for (var a = 1, e = WorldManager.instance.getWorldList()[a].nLevels, r = 1; r &lt;= t; r++) r &gt; e &amp;&amp; (a++, e += WorldManager.instance.getWorldList()[a].nLevels), this.saveLevelData(a, r, 1e4, 3)
    }
});
var CameraSettings = pc.createScript("cameraSettings"),
    defaultString = "------------------------------------------------------";
CameraSettings.attributes.add("desktopClamp", {
    type: "number",
    default: 1600
}), CameraSettings.attributes.add("paddingPercentage", {
    type: "number",
    default: 1.1
}), CameraSettings.attributes.add("a", {
    type: "string",
    title: "Desktop Landscape",
    default: defaultString
}), CameraSettings.attributes.add("landscapeWidthDesktopPercentage", {
    type: "number",
    default: .75,
    max: 1,
    min: 0
}), CameraSettings.attributes.add("landscapeHeightDesktopPercentage", {
    type: "number",
    default: .8,
    max: 1,
    min: 0
}), CameraSettings.attributes.add("b", {
    type: "string",
    title: "Desktop Portrait",
    default: defaultString
}), CameraSettings.attributes.add("portraitWidthDesktopPercentage", {
    type: "number",
    default: 1,
    max: 1,
    min: 0
}), CameraSettings.attributes.add("portraitHeightDesktopPercentage", {
    type: "number",
    default: .67,
    max: 1,
    min: 0
}), CameraSettings.attributes.add("c", {
    type: "string",
    title: "Mobile Landscape",
    default: defaultString
}), CameraSettings.attributes.add("landscapeWidthMobilePercentage", {
    type: "number",
    default: .5,
    max: 1,
    min: 0
}), CameraSettings.attributes.add("landscapeHeightMobilePercentage", {
    type: "number",
    default: 1,
    max: 1,
    min: 0
}), CameraSettings.attributes.add("d", {
    type: "string",
    title: "Mobile Portrait",
    default: defaultString
}), CameraSettings.attributes.add("portraitWidthMobilePercentage", {
    type: "number",
    default: 1,
    max: 1,
    min: 0
}), CameraSettings.attributes.add("portraitHeightMobilePercentage", {
    type: "number",
    default: .8,
    max: 1,
    min: 0
}), pc.extend(CameraSettings.prototype, {
    initialize: function() {
        CameraSettings.instance = this, this._camera = this.entity.camera, this.orthoHeight = this._camera.orthoHeight, this.app.on("ViewportManager:onResize", this._onResize, this), this._onResize(Wrapper.instance.getOrientation(), innerWidth, innerHeight, ViewportManager.instance.getDevice()), this.on("destroy", this._onDestroy, this)
    },
    setAABB: function(t) {
        this._aabb = t, this.setNewOrthoHeight()
    },
    _onDestroy: function() {
        this.app.off("ViewportManager:onResize", this._onResize, this)
    },
    _onResize: function(t, e, i, a) {
        this._orientation = t || "portrait", this._device = a;
        var s = UIManager.instance.getReferenceResolution().y;
        switch (e = e * s / i, i = s, a) {
            case deviceEnum.DESKTOP:
                e = Math.min(e, this.desktopClamp)
        }
        switch (this._scale = e / i, t) {
            case "portrait":
                this._device === deviceEnum.DESKTOP ? this._idealRatio = e * this.portraitWidthDesktopPercentage / (i * this.portraitHeightDesktopPercentage) : this._idealRatio = e * this.portraitWidthMobilePercentage / (i * this.portraitHeightMobilePercentage);
                break;
            case "landscape":
                this._device === deviceEnum.DESKTOP ? this._idealRatio = e * this.landscapeWidthDesktopPercentage / (i * this.landscapeHeightDesktopPercentage) : this._idealRatio = e * this.landscapeWidthMobilePercentage / (i * this.landscapeHeightMobilePercentage)
        }
        this.setNewOrthoHeight()
    },
    setNewOrthoHeight: function() {
        var t = 1;
        if (this._aabb) {
            t = this._aabb.halfExtents.x / this._aabb.halfExtents.y;
            var e = 0;
            switch (this._orientation) {
                case "portrait":
                    var i = this._device === deviceEnum.DESKTOP ? this.portraitWidthDesktopPercentage : this.portraitWidthMobilePercentage,
                        a = this._device === deviceEnum.DESKTOP ? this.portraitHeightDesktopPercentage : this.portraitHeightMobilePercentage;
                    e = t &gt; this._idealRatio ? this._aabb.halfExtents.x / this._scale / i : this._aabb.halfExtents.y / a;
                    break;
                case "landscape":
                    i = this._device === deviceEnum.DESKTOP ? this.landscapeWidthDesktopPercentage : this.landscapeWidthMobilePercentage, a = this._device === deviceEnum.DESKTOP ? this.landscapeHeightDesktopPercentage : this.landscapeHeightMobilePercentage;
                    e = t &gt; this._idealRatio ? this._aabb.halfExtents.x / this._scale / i : this._aabb.halfExtents.y / a
            }
            this.orthoHeight = e * this.paddingPercentage, this._camera.orthoHeight = this.orthoHeight, this.app.fire("CameraSettings.onOrthoHeightChange", this.orthoHeight)
        }
    }
});
var Blocker = pc.createScript("blocker");
pc.extend(Blocker.prototype, {
    initialize: function() {
        this.parent = null, this._explode = !1, this.animationController = this.entity.script.tileAnimationController, this.animationController.on("explode", this._onExplodeAnimation, this), this.animationController.on("complete", this._onCompleteAnimation, this)
    },
    despawnInstant: function() {
        this._explode = !0
    },
    recycle: function() {
        this._explode ? console.warn("already recycled") : (this._explode = !0, this.entity.objectPool.recycle(this.entity))
    },
    init: function(t) {
        this.parent = t, this.parent.typeID = backgroundTileEnum.BLOCKER
    },
    awake: function() {
        this.parent.hasExploded = !1, this._explode = !1, this.parent._modelComponent.entity.enabled = !0, this.animationController.setLayer(this.parent.currentLayer - 1)
    },
    explode: function(t) {
        return this.parent.hasExploded ? (this.animationController.playExplode(this.parent.currentLayer, t, !0), !0) : (this.parent._onLayerExplode(), this.parent.currentLayer--, this.animationController.playExplode(this.parent.currentLayer, t), this.parent.hasExploded = !0, 0 === this.parent.currentLayer &amp;&amp; (this.parent.isDestroyed = !0), !0)
    },
    _onExplodeAnimation: function(t) {
        var e = 0 === this.parent.currentLayer;
        this.parent._onExplode(e, t.delay, !0), e ? GridManager.instance.playSFX("blocker_destroy.mp3") : GridManager.instance.playSFX("blocker_hit.mp3")
    },
    _onCompleteAnimation: function() {
        this.recycle()
    },
    getDespawnDelay: function() {
        this.animationController.getDespawnDelay()
    }
});
var DialogInterface = pc.createScript("dialogInterface");
DialogInterface.attributes.add("leftPersonContainer", {
    type: "entity"
}), DialogInterface.attributes.add("rightPersonContainer", {
    type: "entity"
}), DialogInterface.attributes.add("leftPersonNameTag", {
    type: "entity"
}), DialogInterface.attributes.add("rightPersonNameTag", {
    type: "entity"
}), DialogInterface.attributes.add("dialogText", {
    type: "entity"
}), DialogInterface.attributes.add("overlay", {
    type: "entity"
}), DialogInterface.attributes.add("skipButton", {
    type: "entity"
}), pc.extend(DialogInterface.prototype, {
    initialize: function() {
        this.leftPersonText = this.leftPersonNameTag.findByName("Text"), this.rightPersonText = this.rightPersonNameTag.findByName("Text")
    },
    initializeSingleSentence: function() {
        this._enableLeftPerson(!1), this._enableRightPerson(!1)
    },
    converstation: function(e, t) {
        var i = "left" === e.side;
        t ? (this._enableLeftPerson(i), this._enableRightPerson(!i), i ? (this.leftPersonContainer.element.spriteAsset = t.images[e.image], this.leftPersonNameTag.element.spriteAsset = t.nameContainer, this.leftPersonText.element.text = t.name) : (this.rightPersonContainer.element.spriteAsset = t.images[e.image], this.rightPersonNameTag.element.spriteAsset = t.nameContainer, this.rightPersonText.element.text = t.name)) : (this._enableLeftPerson(!1), this._enableRightPerson(!1)), this.displaySentence(e.text)
    },
    setPosition: function(e, t) {
        isFinite(e) &amp;&amp; isFinite(t) &amp;&amp; this.entity.setLocalPosition(e, t, 0)
    },
    _enableLeftPerson: function(e) {
        this.leftPersonContainer.enabled = e, this.leftPersonNameTag.enabled = e
    },
    _enableRightPerson: function(e) {
        this.rightPersonContainer.enabled = e, this.rightPersonNameTag.enabled = e
    },
    displaySentence: function(e) {
        LocalizationManager.instance.setText(this.dialogText, e)
    },
    hideDialogBox: function() {
        this.app.fire("UIManager:hideUI", UIManager.SCREEN_DIALOG), this.app.fire("DialogManager:dialogDone")
    },
    displayDialogBox: function() {
        this.app.fire("UIManager:showUI", UIManager.SCREEN_DIALOG)
    },
    enableOverlay: function(e) {
        this.overlay.enabled = e, this.skipButton.enabled = e
    },
    toggleSkip: function(e) {}
});
var DialogManager = pc.createScript("dialogManager"),
    dialogTypes = Object.freeze({
        CONVERSATION: 0,
        GAMETUTORIAL: 1,
        PREBOOSTERTUTORIAL: 2
    });
DialogManager.attributes.add("dialogScript", {
    type: "asset",
    assetType: "json"
}), DialogManager.attributes.add("dialogInterface", {
    type: "entity"
}), DialogManager.attributes.add("gameTutorialInterface", {
    type: "entity"
}), DialogManager.attributes.add("preBoosterTutorialInterface", {
    type: "entity"
}), DialogManager.attributes.add("characters", {
    type: "json",
    schema: [{
        name: "name",
        type: "string"
    }, {
        name: "images",
        type: "asset",
        assetType: "sprite",
        array: !0
    }, {
        name: "nameContainer",
        type: "asset",
        assetType: "sprite"
    }],
    array: !0
}), pc.extend(DialogManager.prototype, {
    initialize: function() {
        DialogManager.instance = this, this.gameTutorialInterface.enabled = !1, this.dialogInterface.enabled = !1, this.preBoosterTutorialInterface.enabled = !1, this._interface = null, this.dialog = this.dialogScript.resource, this.currentDialogIndex = 0, this.dialogCharacters = {}
    },
    setInterface: function(e) {
        switch (e) {
            case dialogTypes.GAMETUTORIAL:
                this._interface = this.gameTutorialInterface.script.tutorialInterface;
                break;
            case dialogTypes.PREBOOSTERTUTORIAL:
                this._interface = this.preBoosterTutorialInterface.script.tutorialInterface;
                break;
            case dialogTypes.CONVERSATION:
                this._interface = this.dialogInterface.script.dialogInterface
        }
    },
    showDialog: function(e, t, i, a, n) {
        this.setInterface(a), this._interface.displayDialogBox(), this.functionAfter = t, this.functionScope = i, this.currentDialogIndex = 0, this.currentDialog = this._getDialog(e), this._getPeopleFromDialog(this.currentDialog), this._handleDialog(this.currentDialog[this.currentDialogIndex]), this._interface.toggleSkip(n), this.fire("step", this.currentDialogIndex)
    },
    hideDialog: function() {
        this._interface &amp;&amp; (this._interface.hideDialogBox(), this._interface = null)
    },
    skipDialog: function() {
        this._closeDialog()
    },
    nextDialog: function() {
        this.currentDialogIndex &lt; this.currentDialog.length - 1 ? this._handleDialog(this.currentDialog[++this.currentDialogIndex]) : (this._closeDialog(), "function" == typeof this.functionAfter &amp;&amp; this.functionAfter.call(this.functionScope), this.fire("finish")), this.fire("step", this.currentDialogIndex)
    },
    previousDialog: function() {
        this._handleDialog(this.currentDialog[--this.currentDialogIndex]), this.fire("step", this.currentDialogIndex)
    },
    _getDialog: function(e) {
        var t = [],
            i = this.dialog[e];
        if (Array.isArray(i))
            for (var a = 0; a &lt; i.length; a++) t[a] = i[a];
        else t[0] = i, this._interface.initializeSingleSentence();
        return t
    },
    _handleDialog: function(e) {
        "object" == typeof e ? (this._interface.converstation(e, this.dialogCharacters[e.person]), e.textBubble &amp;&amp; this._interface.setTopOrBottomBubble(e.textBubble)) : this._interface.displaySentence(e)
    },
    _getPeopleFromDialog: function(e) {
        for (var t = 0; t &lt; e.length; t++) this.dialogCharacters[e[t].person] || (this.dialogCharacters[e[t].person] = this._getCharacterInfo(e[t].person))
    },
    _getCharacterInfo: function(e) {
        for (var t = 0; t &lt; this.characters.length; t++)
            if (this.characters[t].name == e) return this.characters[t]
    },
    _closeDialog: function() {
        this._interface.hideDialogBox(), this._resetDialogIndex()
    },
    _pauseGame: function() {
        this.app.timeScale = 0, PlayerData.instance.inputBetweenGames = !1
    },
    _resumeGame: function() {
        this.app.timeScale = 1, PlayerData.instance.inputBetweenGames = !0
    },
    _resetDialogIndex: function() {
        this.currentDialogIndex = 0
    },
    enableOverlay: function(e) {
        this._interface.enableOverlay(e)
    }
});
var Panel = pc.createScript("panel");
pc.extend(Panel.prototype, {
    initialize: function() {
        this.parent = null, this._explode = !1, this.animationController = this.entity.script.tileAnimationController, this.animationController.on("explode", this._onExplodeAnimation, this), this.animationController.on("complete", this._onCompleteAnimation, this)
    },
    despawnInstant: function() {
        this._explode = !0
    },
    init: function(t) {
        this.parent = t, this.parent.typeID = backgroundTileEnum.PANEL
    },
    recycle: function() {
        this._explode ? console.warn("already recycled") : (this._explode = !0, this.entity.objectPool.recycle(this.entity))
    },
    awake: function() {
        this.parent.hasExploded = !1, this._explode = !1, this.parent._modelComponent.entity.enabled = !0, this.animationController.setLayer(this.parent.currentLayer - 1)
    },
    explode: function(t) {
        return this.parent.hasExploded ? (this.animationController.playExplode(this.parent.currentLayer, t, !0), !0) : (this.parent._onLayerExplode(), this.parent.currentLayer--, this.animationController.playExplode(this.parent.currentLayer, t), this.parent.hasExploded = !0, 0 === this.parent.currentLayer &amp;&amp; (this.parent.isDestroyed = !0), !0)
    },
    _onExplodeAnimation: function(t) {
        var e = 0 === this.parent.currentLayer;
        this.parent._onExplode(e, t.delay, !0), e ? GridManager.instance.playSFX("panel_destroy.mp3") : GridManager.instance.playSFX("panel_hit.mp3")
    },
    _onCompleteAnimation: function() {
        this.recycle()
    },
    getDespawnDelay: function() {
        this.animationController.getDespawnDelay()
    }
});
var Dropper = pc.createScript("dropper");
pc.extend(Dropper.prototype, {
    initialize: function() {
        this.doIdleCountdown = !1, this.active = !1, this.app.on("SwapMode:onCascadeDone", this.startIdleCountdown, this)
    },
    update: function(t) {
        this.doIdleCountdown &amp;&amp; (this.superClass._recycled &amp;&amp; (this.stopIdleCountdown(), this.stopIdleTween()), this.idleCountdown += t, this.idleCountdown &gt;= this.idleCountdownDuration &amp;&amp; (this.startIdleAnimation(), this.stopIdleCountdown()))
    },
    init: function(t) {
        this.superClass = t, this.superClass.typeID = foregroundTileEnum.DROPPER
    },
    explode: function() {
        return this.stopIdleCountdown(), GridManager.instance.removeDropper(this), this.app.fire("ScoreManager:scoreForegroundTile", this.superClass.typeID, !0, this.superClass), GridManager.instance.playSFX("dropper_deliver.mp3"), this.superClass.despawn(), StatisticsManager.instance.incrementStatistic("droppers_collected", 1), !0
    },
    onAwake: function() {
        this.active = !0, this.startIdleCountdown()
    },
    appear: function() {
        this.stopTween()
    },
    move: function() {
        this.stopTween()
    },
    applyGravity: function() {
        this.stopTween()
    },
    stopTween: function() {
        this.stopIdleCountdown(), this.stopIdleTween()
    },
    startIdleAnimation: function() {
        var t = GridManager.instance.calculatePosition(this.superClass.x, this.superClass.y, .2);
        this.idleTween = this.entity.tween(this.entity.getLocalPosition()).to({
            x: t.x,
            y: t.y - .1,
            z: t.z
        }, .2, pc.SineInOut).yoyo(!0).repeat(4).on("complete", function() {
            this.startIdleCountdown(), this.idleTween = null
        }.bind(this), this).start()
    },
    startIdleCountdown: function() {
        if (this.active) {
            this.idleCountdown = 0;
            this.idleCountdownDuration = 5 * Math.random() + 5, this.doIdleCountdown = !0
        }
    },
    stopIdleCountdown: function() {
        this.doIdleCountdown = !1
    },
    stopIdleTween: function() {
        this.idleTween &amp;&amp; (this.idleTween.stop(), this.idleTween = null, this.resetPosition())
    },
    resetPosition: function() {
        var t = GridManager.instance.calculatePosition(this.superClass.x, this.superClass.y, 0);
        this.entity.setLocalPosition(t)
    },
    recycle: function() {
        this.stopIdleCountdown(), this.stopIdleTween(), this.active = !1
    }
});
var BookUI = pc.createScript("bookUI");
BookUI.attributes.add("chapterSelectPageEntity", {
    type: "entity"
}), BookUI.attributes.add("levelSelectPageEntity", {
    type: "entity"
}), BookUI.attributes.add("pageGroup", {
    type: "entity"
}), BookUI.attributes.add("pageFlipEntity", {
    type: "entity"
}), BookUI.attributes.add("bookOpenEntity", {
    type: "entity"
}), pc.extend(BookUI.prototype, {
    initialize: function() {
        this._createPageList(), this._closeAllPages(), this.app.on("BookUI:chapterIntro", this.openFirstPageOfChapter, this), this.app.on("BookUI:previousPage", this.previousPage, this), this.app.on("BookUI:nextPage", this.nextPage, this), this.app.on("BookUI:chapterSelect", this.openChapterSelect, this), this.app.on("BookUI:levelSelect", this.openSpecificLevelPage, this), this.app.on("BookUI:currentLevel", this.openCurrentLevelPage, this)
    },
    onUIEntityOpen: function(e) {
        switch (e) {
            case "nextLevel":
                this.openAndMoveToCurrentLevel();
                break;
            case "currentLevel":
            case "currentLevel":
                break;
            case "lastLevel":
                this.openAndMoveToLastPlayedLevel();
                break;
            case "nextLevelUnlockAnim":
                this.openNextLevelOrPage();
                break;
            default:
                this.openAndMoveToCurrentLevel()
        }
    },
    nextPage: function() {
        var e = this.currentPage + 1;
        e &lt; this.pages.length &amp;&amp; this._switchPage(e)
    },
    previousPage: function() {
        var e = this.currentPage - 1;
        e &gt;= 0 &amp;&amp; this._switchPage(e)
    },
    openChapterSelect: function() {
        UnlockLevelAnimation.instance.stopAllAnimations(), this._switchPage(this.pageTracker.chapterSelect.pageIndex)
    },
    openFirstPageOfChapter: function(e) {
        if (this.pageTracker.hasOwnProperty(e)) this._switchPage(this.pageTracker[e][0].pageIndex);
        else {
            var t = this._getCurrentChapter();
            null !== t &amp;&amp; this._switchPage(this.pageTracker[t][0].pageIndex)
        }
        this.getCurrentPageScript().scrollToValue(0)
    },
    openSpecificLevelPage: function(e, t) {
        this._switchPage(this.pageTracker[e][t].pageIndex)
    },
    openCurrentLevelPage: function() {
        var e = 0,
            t = 0,
            a = LevelDataManager.instance.getCurrentLevel(),
            n = WorldManager.instance.getWorldList();
        for (var r in n) {
            if (!1 === n[r].isUnlocked) return void this.openSpecificLevelPage(t, n[r].nParts - 1);
            var i = e + 1,
                s = i + n[r].nLevels - 1;
            if (t = r, a &gt;= i &amp;&amp; a &lt;= s)
                for (var g = 0; g &lt; n[r].nParts; g += 1) {
                    var o = i + g * (n[r].nLevels / n[r].nParts),
                        p = i + (g + 1) * (n[r].nLevels / n[r].nParts) - 1;
                    if (a &gt;= o &amp;&amp; a &lt;= p) return void this.openSpecificLevelPage(r, g)
                }
            e = s
        }
    },
    openAndMoveToCurrentLevel: function() {
        this.openCurrentLevelPage(), this.getCurrentPageScript().scrollToLevel(LevelDataManager.instance.getCurrentLevel())
    },
    openNextLevelOrPage: function() {
        var e = LevelManager.instance.getCurrentChapterNumber();
        if (!WorldManager.instance.isNextWorldExisting(e) &amp;&amp; WorldManager.instance.isEndOfWorld(LevelManager.instance.getCurrentLevelNumber())) this.openAndMoveToLastPlayedLevel();
        else if (WorldManager.instance.isEndOfPage(LevelManager.instance.getCurrentLevelNumber())) {
            this.openAndMoveToLastPlayedLevel(), this.getCurrentPageScript().unlockNextPageButton()
        } else {
            this.openAndMoveToCurrentLevel(), this.getCurrentPageScript().unlockLatestLevel(!1)
        }
    },
    openAndMoveToLastPlayedLevel: function() {
        var e = LevelManager.instance.getCurrentChapterNumber(),
            t = LevelManager.instance.getCurrentLevelNumber();
        if (null !== e &amp;&amp; null !== t) {
            var a = this._getPage(e, t);
            this._switchPage(this._getPageNumber(e, t)), a.scrollToLevel(t)
        } else this.openAndMoveToCurrentLevel()
    },
    _createPageList: function() {
        this.pages = [], this.pageTracker = {};
        var e = WorldManager.instance.getWorldList();
        for (var t in this._setPageOrderData(this.pageTracker, "chapterSelect", this.chapterSelectPageEntity, {
                pageScript: "chapterSelectPage"
            }), e) {
            this.pageTracker[t] = {};
            for (var a = 0; a &lt; e[t].nParts; a += 1) this._setPageOrderData(this.pageTracker[t], a, this.levelSelectPageEntity, {
                pageScript: "levelSelectPage",
                chapterID: t,
                pageID: a
            })
        }
    },
    _closeAllPages: function() {
        for (var e = 0; e &lt; this.pages.length; e += 1) this.pages[e].entity.enabled = !1
    },
    _setPageOrderData: function(e, t, a, n) {
        this.pages.push({
            entity: a,
            pageInfo: n
        }), e[t] = {}, e[t].pageIndex = this.pages.length - 1, e[t].page = a
    },
    _switchPage: function(e) {
        isNaN(this.currentPage) || e !== this.currentPage ? e &gt;= 0 &amp;&amp; e &lt; this.pages.length &amp;&amp; (isNaN(this.currentPage) || (this.pages[this.currentPage].entity.enabled = !1, this._onPageClose(this.pages[this.currentPage])), this.currentPage = e, this.pages[e].entity.enabled = !0, this._onPageOpen(this.pages[e]), this.app.fire("BookUI:switchPage", this.currentPage, this.pages.length, this.pages[e]), this._startPageFlipAnim()) : this._onPageOpen(this.pages[e])
    },
    getCurrentPageScript: function() {
        var e = this.pages[this.currentPage];
        return e.entity.script.get(e.pageInfo.pageScript)
    },
    _onPageOpen: function(e) {
        var t = e.entity.script.get(e.pageInfo.pageScript);
        t &amp;&amp; t._onPageOpen(e.pageInfo)
    },
    _onPageClose: function(e) {
        var t = e.entity.script.get(e.pageInfo.pageScript);
        t &amp;&amp; t._onPageClose(e.pageInfo)
    },
    _getCurrentChapter: function() {
        for (var e = WorldManager.instance.getWorldList(), t = Object.keys(e), a = 0; a &lt; t.length; a += 1) {
            if (a === t.length - 1 &amp;&amp; this.currentPage &gt; this.pageTracker[t[a]].chapterIntro.pageIndex) return t[a];
            if (this.currentPage &gt; this.pageTracker[t[a]].chapterIntro.pageIndex &amp;&amp; this.currentPage &lt; this.pageTracker[t[a + 1]].chapterIntro.pageIndex) return t[a]
        }
        return null
    },
    _getPage: function(e, t) {
        var a = WorldManager.instance.getPageInWorld(e, t);
        return this.pages[this.pageTracker[e][a].pageIndex].entity.script.levelSelectPage
    },
    _getPageNumber: function(e, t) {
        var a = WorldManager.instance.getPageInWorld(e, t);
        return this.pageTracker[e][a].pageIndex
    },
    _startPageFlipAnim: function() {
        this.bookOpenEntity.enabled = this.currentPage &gt; 0, !0 === this.pageFlipEntity.enabled &amp;&amp; this.pageFlipEntity.script.tweenRotation.startTween()
    }
});
var CharacterOptions = pc.createScript("characterOptions");
CharacterOptions.attributes.add("talkingTexture", {
    type: "asset",
    assetType: "texture"
}), CharacterOptions.attributes.add("idleTexture", {
    type: "asset",
    assetType: "texture"
});
var RotateFlower = pc.createScript("rotateFlower");
var BookButton = pc.createScript("bookButton"),
    bookOptions = Object.freeze({
        HOME: 0,
        NEXTREPLAY: 1,
        NEXTCURRENT: 2,
        RESETLEVEL: 3
    }),
    typeOptions = [{
        HOME: bookOptions.HOME
    }, {
        NEXTREPLAY: bookOptions.NEXTREPLAY
    }, {
        NEXTCURRENT: bookOptions.NEXTCURRENT
    }, {
        RESETLEVEL: bookOptions.RESETLEVEL
    }];
BookButton.attributes.add("goTo", {
    type: "number",
    enum: typeOptions
}), BookButton.attributes.add("currentLevelText", {
    type: "entity"
}), pc.extend(BookButton.prototype, {
    initialize: function() {
        this.bookOptions = bookOptions, this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.setCurrentLevelText(LevelDataManager.instance.getCurrentLevel())
    },
    _onClick: function() {
        switch (this.app.fire("UIManager:hideAll"), this.goTo) {
            case bookOptions.NEXTREPLAY:
                this.app.fire("Audio:bgm", "main_ost.mp3"), this.app.fire("UIManager:showUI", "Book", "lastLevel");
                break;
            case bookOptions.NEXTCURRENT:
                this.app.fire("UIManager:showUI", "Book", "nextLevelUnlockAnim");
                break;
            case bookOptions.HOME:
            default:
                this.app.fire("UIManager:showUI", "Book", "nextLevel")
        }
    },
    setCurrentLevelText: function(t) {
        null !== this.currentLevelText &amp;&amp; (this.currentLevelText.element.text = t)
    },
    setType: function(t) {
        this.goTo = t
    }
});
var BoosterShopInterface = pc.createScript("boosterShopInterface");
BoosterShopInterface.attributes.add("shopItemTemplate", {
    type: "asset",
    assetType: "template"
}), BoosterShopInterface.attributes.add("shopItemGroup", {
    type: "entity"
}), BoosterShopInterface.attributes.add("watchAdButtonEntity", {
    type: "entity"
}), BoosterShopInterface.attributes.add("watchAdIcon", {
    type: "entity"
}), pc.extend(BoosterShopInterface.prototype, {
    initialize: function() {
        this.createShopItems(), this.watchAdButtonEntity.script.elementInput.on(inputEvents.CLICK, BoosterShopManager.instance.watchAd, BoosterShopManager.instance)
    },
    onUIEntityOpen: function() {
        this.app.fire("UIManager:showUI", "Coins"), this.updateItems(), this.app.on("Wrapper:checkHasRewardedAd", this.checkHasRewarded, this), this.app.on("FamobiAPI:cooldown", this.checkHasRewarded, this), this.checkHasRewarded()
    },
    onUIEntityClose: function() {
        this.app.fire("UIManager:hideUI", "Coins"), this.app.off("Wrapper:checkHasRewardedAd", this.checkHasRewarded, this), this.app.off("FamobiAPI:cooldown", this.checkHasRewarded, this)
    },
    createShopItems: function() {
        var t = BoosterShopManager.instance.getStock();
        this.shopItems = [];
        for (var e = 0; e &lt; t.length; e += 1) {
            var o = this.shopItemTemplate.resource.instantiate();
            this.shopItemGroup.addChild(o), o.script.boosterShopItem.setItem(t[e]), this.shopItems.push(o)
        }
    },
    updateItems: function() {
        for (var t = 0; t &lt; this.shopItems.length; t += 1) this.shopItems[t].script.boosterShopItem.updateItem()
    },
    checkHasRewarded: function() {
        var t = Wrapper.instance.hasRewardedAd();
        this.watchAdButtonEntity.button.active = t, this.watchAdButtonEntity.element.useInput = t, this.watchAdIcon.element.color = t ? new pc.Color(1, 1, 1) : new pc.Color(.5, .5, .5)
    }
});
var LimitFps = pc.createScript("limitFps");
LimitFps.attributes.add("targetFps", {
    type: "number",
    default: 30
}), LimitFps.prototype.initialize = function() {
    this.app;
    this.limit(this.targetFps), this.on("attr:targetFps", (function(t, i) {
        this.limit(t)
    }))
}, LimitFps.prototype.limit = function(t) {
    var i = this.app;
    this.intervalId &amp;&amp; (clearInterval(this.intervalId), this.intervalId = null), t &gt;= 60 ? i.autoRender = !0 : (i.autoRender = !1, this.intervalId = setInterval((function() {
        i.renderNextFrame = !0
    }), 1e3 / t))
};
var CollectibleUnlockInterface = pc.createScript("collectibleUnlockInterface "),
    animationStates = Object.freeze({
        IDLE: 0,
        ANIMATE: 1,
        LEAVE: 3,
        ADDTOCOLLECTION: 4,
        FUSE: 5,
        READYFORFUSE: 6
    });
CollectibleUnlockInterface.attributes.add("unlockContainer", {
    type: "entity"
}), CollectibleUnlockInterface.attributes.add("pivotPoint", {
    type: "entity"
}), CollectibleUnlockInterface.attributes.add("shineEffect", {
    type: "entity"
}), CollectibleUnlockInterface.attributes.add("completedObjectEntity", {
    type: "entity"
}), CollectibleUnlockInterface.attributes.add("completedObjectShine", {
    type: "entity"
}), CollectibleUnlockInterface.attributes.add("unlockText", {
    type: "entity"
}), CollectibleUnlockInterface.attributes.add("popupTime", {
    type: "number",
    default: 1
}), CollectibleUnlockInterface.attributes.add("popupScale", {
    type: "number",
    default: 2
}), CollectibleUnlockInterface.attributes.add("popupAnimation", {
    type: "string",
    default: "BackOut"
}), CollectibleUnlockInterface.attributes.add("spinSeparator", {
    type: "string",
    default: "------------------------------------",
    title: "separator",
    description: "separator for options"
}), CollectibleUnlockInterface.attributes.add("fullDuration", {
    type: "number",
    default: 6
}), CollectibleUnlockInterface.attributes.add("speedyFullDuration", {
    type: "number",
    default: 5
}), CollectibleUnlockInterface.attributes.add("durationUntilMoveOut", {
    type: "number",
    default: 4
}), CollectibleUnlockInterface.attributes.add("yOffset", {
    type: "number",
    default: 1
}), CollectibleUnlockInterface.attributes.add("flashImage", {
    type: "entity"
}), CollectibleUnlockInterface.attributes.add("viginette", {
    type: "entity"
}), CollectibleUnlockInterface.attributes.add("backdrop", {
    type: "entity"
}), pc.extend(CollectibleUnlockInterface.prototype, {
    initialize: function() {
        CollectibleUnlockInterface.instance = this, this.unlockContainerDesktopScale = {
            x: 2,
            y: 2,
            z: 2
        }, this.unlockContainerMobilePortraitScale = {
            x: 1,
            y: 1,
            z: 1
        }, this.unlockContainerMobileLandscapeScale = {
            x: 2.5,
            y: 2.5,
            z: 2.5
        }, this.state = animationStates.IDLE, this.queuedObject = null, this.callback = null, this.uiScreen = this.entity.script.uiEntity.name, this.circleDegrees = 360, this.yOffsetStart = this.yOffset, this.containerPos = this.unlockContainer.getLocalPosition().clone(), this.pivotPointStartPos = this.pivotPoint.getLocalPosition().clone(), this.petalStartRotation = {
            x: 90,
            y: 0,
            z: 0
        }, this.startRot = this.pivotPoint.getLocalEulerAngles().z, this.endRot = this.startRot + 2 * this.circleDegrees, this.speedyEndRot = this.startRot + 3 * this.circleDegrees, this.animateStateDuration = 1, this.addtocollectionStateDuration = 7, this.fuseStateDuration = 5, this.leaveStateDuration = 1.5, this.readyForFuseStateDuration = 2.5, this.circleStartSpeed = 60, this.circleEndSpeed = 300, this.circleCurrentSpeed = this.circleStartSpeed, this.acceleration = 3, this.deceleration = 7, this.completedObjectiveSpeed = 40, this.shineEffectStartScale = new pc.Vec3(.02, .02, .02), this.completedObjectShineScale = new pc.Vec3(.03, .03, .03), this.unlockTextStartScale = new pc.Vec3(.5, .5, .5), this.unlockObjectiveEntityStartScale = new pc.Vec3(.5, .5, .5), this.newUnlockedObjectiveEntityStartScale = new pc.Vec3(.8, .8, .8), this.unlockObjectiveEntitystartPos = new pc.Vec3(0, -.25, 0), this.zeroVector = new pc.Vec3(0, 0, 0), this.completedObjectAngleUpright = new pc.Vec3(0, 270, 0)
    },
    unlockObject: function(t, e, i, a, n) {
        this.state = animationStates.ANIMATE, this.viginette.enabled = !0, this.backdrop.enabled = !0, this.flashImage.element.opacity = 1, this.unlockText.enabled = !0, this.yOffset = this.yOffsetStart, this.amountOfParts = i, this.amountOfPartsBefore = this.amountOfParts - 1, this.totalParts = a, this.changeAngle = this.circleDegrees / this.amountOfParts, this.app.fire("Audio:sfx", "new_discovery.mp3"), this.partAsset = e, this.completedAsset = n, this.callback = t, this.app.fire("UIManager:showUI", this.uiScreen), this.unlockContainer.enabled = !0, this.unlockContainer.setLocalPosition(this.containerPos), this.shineEffect.setLocalScale(this.shineEffectStartScale);
        for (var o = 0; o &lt; this.amountOfParts; o++) {
            var s = this.unlockContainer.children[o],
                c = this.changeAngle * o,
                l = s.children[0],
                r = s.children[0].children[0];
            s.enabled = !0, s.setLocalPosition(this.zeroVector), r.model.asset = this.partAsset, r.setLocalPosition(this.unlockObjectiveEntitystartPos), s.setLocalEulerAngles(0, 0, c), o === this.amountOfPartsBefore ? (l.setLocalPosition(this.zeroVector), r.setLocalScale(this.newUnlockedObjectiveEntityStartScale), this.shineEffect.enabled = !0, this.shineEffect.setLocalPosition(l.getLocalPosition())) : (r.setLocalScale(this.unlockObjectiveEntityStartScale), l.setLocalPosition(0, 15, 0))
        }
        this.unlockText.setLocalScale(this.unlockTextStartScale), this.unlockText.element.text = this.amountOfPartsBefore + "/" + this.totalParts, this.changeState(animationStates.ANIMATE)
    },
    animationDone: function() {
        this.unlockTextTween.stop(), this.unlockText.setLocalScale(this.unlockTextStartScale), this.unlockText.enabled = !1, this.flashImage.enabled = !1, this.circleCurrentSpeed = this.circleStartSpeed, this.completedObjectEntity.enabled = !1, this.flashImage.enabled = !1, this.unlockContainer.enabled = !1, this.completedObjectShine.enabled = !1, this.angle = 0, this.callback ? (this.callback(), this.callback = null) : this.app.fire("UIManager:hideUI", this.uiScreen)
    },
    update: function(t) {
        switch (this.state !== animationStates.IDLE &amp;&amp; (this._counter += t, this._counter &gt;= this.currentStateDuration &amp;&amp; this.onStateEnd(this.state)), this.state) {
            case animationStates.IDLE:
                break;
            case animationStates.ANIMATE:
                this.wiggleUnlockedParts(t), this.rotateCircleOfParts(t);
                break;
            case animationStates.LEAVE:
                break;
            case animationStates.ADDTOCOLLECTION:
                this.wiggleUnlockedParts(t), this.rotateCircleOfParts(t);
                break;
            case animationStates.FUSE:
                this.rotateCompletedObject(t), this.wiggleUnlockedParts(t), this.rotateCircleOfParts(t), this.speedDownRotationOfParts();
                break;
            case animationStates.READYFORFUSE:
                this.wiggleUnlockedParts(t), this.rotateCircleOfParts(t), this.speedUpRotationOfParts()
        }
        this.timeSinceStartRotation += t, this.timeSinceStartRotation = Math.min(this.timeSinceStartRotation, this.fullDuration)
    },
    rotateCircleOfParts: function(t) {
        this.completedObjectEntity.enabled || this.unlockContainer.setLocalEulerAngles(this.unlockContainer.getLocalEulerAngles().x, this.unlockContainer.getLocalEulerAngles().y, this.unlockContainer.getLocalEulerAngles().z + this.circleCurrentSpeed * t)
    },
    speedUpRotationOfParts: function() {
        this._counter &lt;= this.currentStateDuration &amp;&amp; this.circleCurrentSpeed &lt;= this.circleEndSpeed &amp;&amp; (this.circleCurrentSpeed += this.acceleration)
    },
    speedDownRotationOfParts: function() {
        this.circleCurrentSpeed &gt;= 0 &amp;&amp; (this.circleCurrentSpeed -= this.deceleration, this.circleCurrentSpeed &lt; 0 &amp;&amp; (this.circleCurrentSpeed = 0))
    },
    wiggleUnlockedParts: function(t) {
        for (var e = 0; e &lt; this.amountOfParts; e++) {
            var i = this.unlockContainer.children[e];
            i.children[0].setLocalEulerAngles(this.petalStartRotation.x, -15 * Math.sin(5 * (this.unlockContainer.getLocalEulerAngles().z + this.circleCurrentSpeed * t - i.getLocalEulerAngles().z) * (Math.PI / 180)), this.petalStartRotation.z - i.getLocalEulerAngles().z - this.unlockContainer.getLocalEulerAngles().z + this.circleCurrentSpeed * t)
        }
    },
    rotateCompletedObject: function(t) {
        this.completedObjectEntity.enabled &amp;&amp; this.completedObjectEntity.rotateLocal(0, -this.completedObjectiveSpeed * t, 0)
    },
    _resetTimers: function() {
        this._counter = 0, this.secsSinceStart = 0, this.timeSinceStartRotation = 0
    },
    _scaleObject: function() {
        var t = this.unlockContainerDesktopScale;
        ViewportManager.instance.getDevice() === deviceEnum.MOBILE &amp;&amp; (t = ViewportManager.instance.getOrientation() === orientationEnum.PORTRAIT ? this.unlockContainerMobilePortraitScale : this.unlockContainerMobileLandscapeScale), this.unlockContainer.tween(this.unlockContainer.getLocalScale()).to(t, this.popupTime, pc[this.popupAnimation]).start()
    },
    changeState: function(t) {
        this.state = t, this.onStateSwitch()
    },
    moveOut: function() {
        this.completedObjectShine.tween(this.completedObjectShine.getLocalScale()).to({
            x: 0,
            y: 0,
            z: 0
        }, .2, pc.SineOut).start();
        if (this.amountOfParts === this.totalParts) this.completedObjectEntity.tween(this.completedObjectEntity.getLocalPosition()).to({
            x: this.completedObjectEntity.getLocalPosition().x + 15,
            y: this.completedObjectEntity.getLocalPosition().y,
            z: this.completedObjectEntity.getLocalPosition().z
        }, this.leaveStateDuration, pc.Linear).start();
        else
            for (var t = 0; t &lt; this.amountOfParts; t++) {
                var e = this.unlockContainer.children[t].children[0],
                    i = {
                        x: e.getLocalPosition().x,
                        y: e.getLocalPosition().y + 15,
                        z: e.getLocalPosition().z
                    };
                e.tween(e.getLocalPosition()).to(i, this.leaveStateDuration, pc.Linear).start()
            }
    },
    onStateSwitch: function() {
        switch (this.state) {
            case animationStates.IDLE:
                this.unlockContainer.enabled = !1, this.animationDone();
                break;
            case animationStates.ANIMATE:
                this._counter = 0, this.unlockContainer.enabled = !0, this.currentStateDuration = this.animateStateDuration, this._resetTimers(), this._scaleObject();
                break;
            case animationStates.LEAVE:
                this.currentStateDuration = this.leaveStateDuration, this.moveOut(), this._counter = 0;
                break;
            case animationStates.ADDTOCOLLECTION:
                this._counter = 0, this.currentStateDuration = this.addtocollectionStateDuration, this.doCircleAnimation();
                break;
            case animationStates.FUSE:
                this.currentStateDuration = this.fuseStateDuration, this.timeSinceStartRotation = 0, this._counter = 0, this.fuseParts();
                break;
            case animationStates.READYFORFUSE:
                this.currentStateDuration = this.readyForFuseStateDuration, this._counter = 0
        }
    },
    doCircleAnimation: function() {
        for (var t = 0; t &lt; this.amountOfParts; t++) {
            var e = this.addtocollectionStateDuration / 20 * t,
                i = this.unlockContainer.children[t],
                a = i.children[0],
                n = i.children[0].children[0];
            t === this.amountOfParts - 1 ? (n.tween(n.getLocalScale()).to({
                x: .5,
                y: .5,
                z: .5
            }, 2, pc.Linear, e + 3).start(), this.shineEffect.tween(this.shineEffect.getLocalScale()).to({
                x: 0,
                y: 0,
                z: 0
            }, .1, pc.Linear, e + 3).start(), a.tween(a.getLocalPosition()).to({
                x: 0,
                y: 0 + this.yOffset,
                z: 0
            }, 2, pc.QuadraticOut, e + 3).start().on("complete", (function() {}), this)) : a.tween(a.getLocalPosition()).to({
                x: 0,
                y: 0 + this.yOffset,
                z: 0
            }, 3, pc.QuadraticOut, e).start(), this.unlockTextTween = this.unlockText.tween(this.unlockText.getLocalScale()).to(new pc.Vec3(1, 1, 1), .15, pc.SineInOut, 5.6).on("complete", (function() {
                this.unlockText.element.text = this.amountOfParts + "/" + this.totalParts
            }), this).yoyo(!0).repeat(2).start()
        }
    },
    onStateEnd: function(t) {
        switch (t) {
            case animationStates.ANIMATE:
                this.changeState(animationStates.ADDTOCOLLECTION);
                break;
            case animationStates.ADDTOCOLLECTION:
                this.amountOfParts === this.totalParts ? this.changeState(animationStates.READYFORFUSE) : this.changeState(animationStates.LEAVE);
                break;
            case animationStates.FUSE:
                this.changeState(animationStates.LEAVE);
                break;
            case animationStates.LEAVE:
                this.changeState(animationStates.IDLE);
                break;
            case animationStates.READYFORFUSE:
                this.changeState(animationStates.FUSE)
        }
    },
    fuseParts: function() {
        for (var t = 0; t &lt; this.amountOfParts; t++) {
            var e = this.unlockContainer.children[t].children[0],
                i = e.tween(e.getLocalPosition()).to(this.unlockContainer.getLocalPosition(), .5, pc.BackIn, .35).start();
            t === this.amountOfParts - 1 &amp;&amp; i.on("complete", (function() {
                for (var t = 0; t &lt; this.amountOfParts; t++) {
                    this.unlockContainer.children[t].enabled = !1, this.unlockText.enabled = !1
                }
                this.screenFlash()
            }), this)
        }
    },
    screenFlash: function() {
        this.flashImage.enabled = !0, setTimeout(function() {
            this.completedObjectEntity.enabled = !0, this.completedObjectEntity.model.asset = this.completedAsset, this.completedObjectEntity.setLocalPosition(this.unlockContainer.getLocalPosition().x, this.unlockContainer.getLocalPosition().y, this.unlockContainer.getLocalPosition().z), this.completedObjectEntity.setLocalEulerAngles(this.completedObjectAngleUpright), this.completedObjectShine.enabled = !0, this.completedObjectShine.setLocalScale(this.completedObjectShineScale), this.completedObjectShine.setLocalPosition(this.completedObjectEntity.getLocalPosition()), this.unlockContainer.setLocalEulerAngles(this.unlockContainer.getLocalEulerAngles().x, this.unlockContainer.getLocalEulerAngles().y, 0)
        }.bind(this), 100), this.flashImage.tween(this.flashImage.element).to({
            opacity: 0
        }, 1.5, pc.Linear).start(), this.backdrop.enabled = !0, this.viginette.enabled = !0
    }
});
var BoosterShopManager = pc.createScript("BoosterShopManager");
BoosterShopManager.storeEnum = [{
    PREBOOSTER_1: "PREBOOSTER_1"
}, {
    PREBOOSTER_2: "PREBOOSTER_2"
}, {
    PREBOOSTER_3: "PREBOOSTER_3"
}, {
    BOOSTER_1: "BOOSTER_1"
}, {
    BOOSTER_2: "BOOSTER_2"
}, {
    BOOSTER_3: "BOOSTER_3"
}], BoosterShopManager.attributes.add("stock", {
    type: "json",
    schema: [{
        name: "inventoryKey",
        type: "string",
        enum: BoosterShopManager.storeEnum
    }, {
        name: "image",
        type: "asset",
        assetType: "sprite"
    }, {
        name: "price",
        type: "number"
    }],
    array: !0
}), BoosterShopManager.attributes.add("coinReward", {
    type: "number"
}), pc.extend(BoosterShopManager.prototype, {
    initialize: function() {
        BoosterShopManager.instance = this
    },
    getStock: function() {
        return this.stock
    },
    purchase: function(t) {
        var e = Inventory.instance.tryPayItem("COINS", t.price);
        return e &amp;&amp; (StatisticsManager.instance.incrementStatistic("coins_used", t.price), this._updatePurchaseStatistics(t.inventoryKey), this.app.fire("CoinInterface:updateCoins"), Inventory.instance.addItem(t.inventoryKey, 1), this.app.fire("BoosterShopManager:onItemBought"), this.app.fire("Audio:sfx", "coin_pay.mp3")), e
    },
    changeBoosterPrice: function(t, e) {
        this._getStockByinventoryKey(t).price = e
    },
    watchAd: function() {
        Wrapper.instance.rewardedAd(this.rewardAd, this)
    },
    rewardAd: function(t) {
        t.rewardGranted &amp;&amp; (this.app.fire("Audio:sfx", "coin_gain_single.mp3"), StatisticsManager.instance.incrementStatistic("coins_redeemed", this.coinReward), Inventory.instance.addItem("COINS", this.coinReward), this.app.fire("CoinInterface:updateCoins"))
    },
    _getStockByinventoryKey: function(t) {
        for (var e = 0; e &lt; this.stock.length; e++)
            if (this.stock[e].inventoryKey === t) return this.stock[e];
        return !1
    },
    _updatePurchaseStatistics: function(t) {
        switch (StatisticsManager.instance.incrementStatistic("total_bought", 1), t) {
            case boosterEnum.PREBOOSTER_1:
                StatisticsManager.instance.incrementStatistic("bees_pre_booster_bought", 1);
                break;
            case boosterEnum.PREBOOSTER_2:
                StatisticsManager.instance.incrementStatistic("ladybugs_pre_booster_bought", 1);
                break;
            case boosterEnum.PREBOOSTER_3:
                StatisticsManager.instance.incrementStatistic("butterflies_pre_booster_bought", 1);
                break;
            case boosterEnum.BOOSTER_1:
                StatisticsManager.instance.incrementStatistic("free_swap_booster_bought", 1);
                break;
            case boosterEnum.BOOSTER_2:
                StatisticsManager.instance.incrementStatistic("breaker_booster_bought", 1);
                break;
            case boosterEnum.BOOSTER_3:
                StatisticsManager.instance.incrementStatistic("crossbomb_booster_bought", 1)
        }
    }
});
var BookNavigationButton = pc.createScript("bookNavigationButton"),
    bookButtonTypes = {
        PREVIOUSPAGE: 0,
        NEXTPAGE: 1,
        CHAPTERSELECT: 2,
        LEVELSELECT: 3,
        CLOSE: 4
    },
    bookButtonTypeAttribute = [{
        PREVIOUSPAGE: bookButtonTypes.PREVIOUSPAGE
    }, {
        NEXTPAGE: bookButtonTypes.NEXTPAGE
    }, {
        CHAPTERSELECT: bookButtonTypes.CHAPTERSELECT
    }, {
        LEVELSELECT: bookButtonTypes.LEVELSELECT
    }, {
        CLOSE: bookButtonTypes.CLOSE
    }];
BookNavigationButton.attributes.add("type", {
    type: "number",
    enum: bookButtonTypeAttribute
}), BookNavigationButton.attributes.add("worldID", {
    type: "number"
}), BookNavigationButton.attributes.add("pageID", {
    type: "number"
}), pc.extend(BookNavigationButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.app.on("BookUI:switchPage", this._onPageSwitch, this)
    },
    _onPageSwitch: function(t, e, o) {
        switch (this.type) {
            case bookButtonTypes.PREVIOUSPAGE:
                this.entity.enabled = t &gt; 1;
                break;
            case bookButtonTypes.NEXTPAGE:
                var a = o.entity.script.get(o.pageInfo.pageScript),
                    i = !1;
                if (a &amp;&amp; (i = a.containsCurrentLevel), this.entity.enabled = t &lt; e - 1 &amp;&amp; !i, o.pageInfo.chapterID) {
                    var n = WorldManager.instance.getWorldData(o.pageInfo.chapterID);
                    n &amp;&amp; o.pageInfo.pageID === n.nParts - 1 &amp;&amp; (this.entity.enabled = !1)
                }
                break;
            case bookButtonTypes.CHAPTERSELECT:
                this.entity.enabled = "chapterSelectPage" !== o.pageInfo.pageScript;
                break;
            case bookButtonTypes.LEVELSELECT:
                this.entity.enabled = "levelSelectPage" === o.pageInfo.pageScript || "chapterSelectPage" === o.pageInfo.pageScript &amp;&amp; this.worldID &gt;= 0;
                break;
            case bookButtonTypes.CLOSE:
        }
    },
    _onClick: function() {
        switch (this.app.fire("Audio:sfx", "page_flip.mp3"), this.type) {
            case bookButtonTypes.PREVIOUSPAGE:
                this.app.fire("BookUI:previousPage");
                break;
            case bookButtonTypes.NEXTPAGE:
                this.app.fire("BookUI:nextPage");
                break;
            case bookButtonTypes.CHAPTERSELECT:
                this.app.fire("BookUI:chapterSelect");
                break;
            case bookButtonTypes.LEVELSELECT:
                this.app.fire("BookUI:levelSelect", this.worldID, this.pageID);
                break;
            case bookButtonTypes.CLOSE:
                this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "Menu")
        }
    }
});
var ChapterSelectPage = pc.createScript("chapterSelectPage");
ChapterSelectPage.attributes.add("chapterButtonTemplate", {
    type: "asset",
    assetType: "template"
}), ChapterSelectPage.attributes.add("buttonGroup", {
    type: "entity"
}), ChapterSelectPage.attributes.add("buttonSprites", {
    type: "asset",
    assetType: "sprite",
    array: !0
}), pc.extend(ChapterSelectPage.prototype, {
    initialize: function() {
        this.createButtons()
    },
    _onPageOpen: function(t) {
        this.setCurrentChapter(this.findCurrentChapter())
    },
    _onPageClose: function(t) {},
    createButtons: function() {
        this.chapterButtons = [];
        for (var t = WorldManager.instance.getWorldList(), e = Object.keys(t), a = 0; a &lt; e.length; a += 1) {
            var r = this.chapterButtonTemplate.resource.instantiate();
            this.buttonGroup.addChild(r);
            var n = -360 / e.length * a;
            r.setLocalEulerAngles(0, 0, n), r.script.chapterSelectButton.setCounterRotation(-n), r.script.chapterSelectButton.setButtonInformation(e[a], this.buttonSprites[a]), this.chapterButtons.push(r)
        }
    },
    findCurrentChapter: function() {
        var t = 0,
            e = 0,
            a = LevelDataManager.instance.getCurrentLevel(),
            r = WorldManager.instance.getWorldList();
        for (var n in r) {
            var s = t + 1,
                o = s + r[n].nLevels - 1;
            if (e = n, a &gt;= s &amp;&amp; a &lt;= o) return n;
            t = o
        }
        return e
    },
    setCurrentChapter: function(t) {
        for (var e = !0, a = 0; a &lt; this.chapterButtons.length; a += 1) {
            var r = this.chapterButtons[a].script.chapterSelectButton;
            !1 === WorldManager.instance.getWorldData(r.chapterID).isUnlocked ? r.setState(ChapterSelectButton.buttonStates.UNAVAILABLE) : r.chapterID === t ? (r.setState(ChapterSelectButton.buttonStates.CURRENT), e = !1) : r.setState(e ? ChapterSelectButton.buttonStates.UNLOCKED : ChapterSelectButton.buttonStates.LOCKED)
        }
    }
});
var ChapterIntroPage = pc.createScript("chapterIntroPage");
ChapterIntroPage.attributes.add("chapterNumberText", {
    type: "entity"
}), ChapterIntroPage.attributes.add("chapterTitleText", {
    type: "entity"
}), ChapterIntroPage.attributes.add("chapterStarsText", {
    type: "entity"
}), ChapterIntroPage.attributes.add("chapterPartsText", {
    type: "entity"
}), ChapterIntroPage.attributes.add("chapterPartsImage", {
    type: "entity"
}), ChapterIntroPage.attributes.add("pageButtonTemplate", {
    type: "asset",
    assetType: "template"
}), ChapterIntroPage.attributes.add("pageButtonGroup", {
    type: "entity"
}), ChapterIntroPage.attributes.add("petalImage", {
    type: "entity"
}), pc.extend(ChapterIntroPage.prototype, {
    initialize: function() {
        this.createPageButtons(), this.app.on("ViewportManager:onResize", this._onResize, this), this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.currentTime = 0
    },
    _onResize: function(t, e, a, n) {
        t === orientationEnum.PORTRAIT ? this.pageButtonGroup.element.width = 580 : this.pageButtonGroup.element.width = 350, this.nParts &amp;&amp; (this.pageButtonGroup.element.height = 120 * this.nParts)
    },
    _onPageOpen: function(t) {
        var e = WorldManager.instance.getWorldData(t.chapterID);
        this.setPageInformation(t.chapterID, e), this.setCurrentPage(this.findCurrentPage(this.chapterID)), this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), WorldManager.instance.isNewPageUnlocked() &amp;&amp; (this.app.fire("ComicInterface:queueComic"), this.unlockPage(), WorldManager.instance.emptyPageUnlock())
    },
    _onPageClose: function(t) {},
    setPageInformation: function(t, e) {
        this.chapterID = t, LocalizationManager.instance.setText(this.chapterNumberText, "CHAPTER_NUMBER", t), LocalizationManager.instance.setText(this.chapterTitleText, e.name);
        var a = LevelDataManager.instance.getTotalStarData(t);
        this.chapterStarsText.element.text = a + "/" + 3 * e.nLevels;
        var n = LevelDataManager.instance.getPartsData(t);
        this.setPartsInfo(n, e.nParts), this.nParts = e.nParts, this.pageButtonGroup.element.height = 150 * this.nParts;
        for (var r = 0; r &lt; this.pageButtons.length; r += 1) r &gt;= e.nParts ? this.pageButtons[r].enabled = !1 : (this.pageButtons[r].enabled = !0, this.pageButtons[r].script.chapterPageButton.setButtonInformation(t, r))
    },
    setCurrentPage: function(t) {
        for (var e = t &gt; 0, a = 0; a &lt; this.pageButtons.length; a += 1) {
            var n = this.pageButtons[a].script.chapterPageButton;
            n.pageID === t ? (n.setState(ChapterPageButton.buttonStates.CURRENT), e = !1) : n.setState(e ? ChapterPageButton.buttonStates.UNLOCKED : ChapterPageButton.buttonStates.LOCKED)
        }
    },
    findCurrentPage: function(t) {
        var e = 0,
            a = !1,
            n = !1,
            r = LevelDataManager.instance.getCurrentLevel(),
            i = WorldManager.instance.getWorldList();
        for (var s in i) {
            var o = e + 1,
                h = o + i[s].nLevels - 1;
            if (r &gt;= o &amp;&amp; r &lt;= h ? (a = !0, n = !0) : n = !1, e = h, s === t) {
                if (!a) return i[s].nParts + 1;
                if (n)
                    for (var p = 0; p &lt; i[s].nParts; p += 1) {
                        var g = o + p * (i[s].nLevels / i[s].nParts),
                            c = o + (p + 1) * (i[s].nLevels / i[s].nParts) - 1;
                        if (r &gt;= g &amp;&amp; r &lt;= c) return p
                    } else if (!n) return -1
            }
        }
    },
    unlockPage: function() {
        var t = LevelDataManager.instance.getPartsData(LevelManager.instance.getCurrentChapterNumber()),
            e = WorldManager.instance.getWorldData(this.chapterID).nParts,
            a = this.findCurrentPage(this.chapterID),
            n = null;
        if (t === e) {
            this.setPartsInfo(t - 1, e), this.petalImage.enabled = !0, this.petalImage.element.spriteAsset = WorldManager.instance.unlockableFlowers[LevelManager.instance.getCurrentChapterNumber() - 1].partSprite;
            for (var r = 0; r &lt; this.pageButtons.length; r += 1) void 0 !== this.pageButtons[r].script.chapterPageButton.pageID &amp;&amp; (n = this.pageButtons[r].script.chapterPageButton);
            this.app.fire("UitoUimanager:showAnimation", n.entity, this.showFlowerAnimation.bind(this))
        } else
            for (var i = 0; i &lt; this.pageButtons.length; i += 1)
                if (n = this.pageButtons[i].script.chapterPageButton, this.chapterPartsText.element.text = t - 1 + "/" + e, n.pageID === a) {
                    this.currentButton = n;
                    var s = this.pageButtons[i - 1];
                    n.setState(ChapterPageButton.buttonStates.LOCKED), this.petalImage.enabled = !0, this.petalImage.element.spriteAsset = WorldManager.instance.unlockableFlowers[LevelManager.instance.getCurrentChapterNumber() - 1].partSprite, this.app.fire("UitoUimanager:showAnimation", s.script.chapterPageButton.entity, this.unlockPageButton.bind(this))
                }
    },
    unlockPageButton: function() {
        var t = LevelDataManager.instance.getPartsData(LevelManager.instance.getCurrentChapterNumber()),
            e = WorldManager.instance.getWorldData(this.chapterID).nParts;
        this.currentButton.unlockItem(), this.setPartsInfo(t, e)
    },
    showFlowerAnimation: function() {
        var t = LevelDataManager.instance.getPartsData(LevelManager.instance.getCurrentChapterNumber()),
            e = WorldManager.instance.getWorldData(this.chapterID).nParts;
        this.setPartsInfo(t, e), CollectibleUnlockInterface.instance.showQueuedUnlock()
    },
    setPartsInfo: function(t, e) {
        var a = t &gt;= e;
        this.chapterPartsText.element.text = t + "/" + e, this.chapterPartsImage.element.opacity = a ? 1 : .5, this.chapterPartsImage.element.color = a ? pc.Color.WHITE : pc.Color.BLACK, this.chapterPartsText.enabled = !a
    },
    createPageButtons: function() {
        var t = 0,
            e = WorldManager.instance.getWorldList();
        for (var a in e) e[a].nParts &gt; t &amp;&amp; (t = e[a].nParts);
        this.pageButtons = [];
        for (var n = 0; n &lt; t; n += 1) {
            var r = this.pageButtonTemplate.resource.instantiate();
            this.pageButtonGroup.addChild(r), this.pageButtons.push(r)
        }
    }
});
var SwitchPageOrChapterButton = pc.createScript("switchPageOrChapterButton");
SwitchPageOrChapterButton.attributes.add("isNext", {
    type: "boolean"
}), SwitchPageOrChapterButton.attributes.add("chapterButton", {
    type: "entity"
}), SwitchPageOrChapterButton.attributes.add("pageButton", {
    type: "entity"
}), SwitchPageOrChapterButton.attributes.add("lockEntity", {
    type: "entity"
}), SwitchPageOrChapterButton.attributes.add("disableOnInactiveEntities", {
    type: "entity",
    array: !0
}), SwitchPageOrChapterButton.attributes.add("comingSoonTextEntity", {
    type: "entity"
}), SwitchPageOrChapterButton.attributes.add("chapterNumberTextEntity", {
    type: "entity"
}), SwitchPageOrChapterButton.attributes.add("chapterImageEntity", {
    type: "entity"
}), pc.extend(SwitchPageOrChapterButton.prototype, {
    initialize: function() {
        this.chapterButton.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.pageButton.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.goToComic = !0, this.isNewUnlock = !1
    },
    onPageSwitch: function(t, e) {
        if (t.chapterID) {
            this.chapterID = t.chapterID, this.pageID = t.pageID;
            var i = WorldManager.instance.getWorldList(),
                n = 0 === t.pageID,
                a = t.pageID === i[t.chapterID].nParts - 1,
                s = n &amp;&amp; !this.isNext || a &amp;&amp; this.isNext;
            if (this.isNext) {
                if (i[t.chapterID].index === i.length - 1 &amp;&amp; a) return void this.setButton(null);
                if (!1 === WorldManager.instance.getWorldData(parseInt(t.chapterID) + 1).isUnlocked &amp;&amp; a) this.setButtonsLocked(!0, !0);
                else {
                    var r = e.containsCurrentLevel;
                    this.setButtonsLocked(r, !1)
                }
                this.setButton(s ? this.chapterButton : this.pageButton)
            } else {
                if (0 === i[t.chapterID].index &amp;&amp; n) return void this.setButton(null);
                this.setButtonsLocked(!1, !1), this.setButton(s ? this.chapterButton : this.pageButton)
            }
            if (this.chapterButton.enabled) {
                var o = this.isNext ? parseInt(t.chapterID) + 1 : parseInt(t.chapterID) - 1;
                this.chapterNumberTextEntity.element.text = o;
                var h = WorldManager.instance.getWorldBackgroundImage(o);
                void 0 !== h &amp;&amp; (this.chapterImageEntity.element.sprite = h.resource)
            }
        } else this.setButton(null)
    },
    _onClick: function() {
        if (this.isNext &amp;&amp; !0 === this.isNewUnlock) {
            var t = WorldManager.instance.getWorldList(),
                e = this.pageID === t[this.chapterID].nParts - 1,
                i = WorldManager.instance.getWorldIDByIndex(WorldManager.instance.getWorldIndexByID(this.chapterID) + 1);
            this.app.fire("ComicInterface:showUnlockedComic", e ? i : this.chapterID, e ? 0 : this.pageID + 1), this.isNewUnlock = !1
        }
        this.isNext ? (this.app.fire("BookUI:nextPage"), this.app.fire("LevelSelectPage:scrollTo", 0)) : (this.app.fire("BookUI:previousPage"), this.app.fire("LevelSelectPage:scrollTo", 1))
    },
    setButton: function(t) {
        this.entity.enabled = !0;
        var e = t === this.chapterButton,
            i = t === this.pageButton;
        this.chapterButton.enabled = e, this.pageButton.enabled = i, this.entity.enabled = this.chapterButton.enabled || this.pageButton.enabled
    },
    setButtonsLocked: function(t, e) {
        this.chapterButton.script.elementInput.setActive(!t), this.pageButton.script.elementInput.setActive(!t);
        for (var i = 0; i &lt; this.disableOnInactiveEntities.length; i += 1) this.disableOnInactiveEntities[i].enabled = !t;
        this.lockEntity.enabled = t &amp;&amp; !e, this.comingSoonTextEntity.enabled = t &amp;&amp; e
    },
    unlockAnimation: function() {
        UnlockLevelAnimation.instance.startAnim(this.entity, this.lockEntity, function() {
            this.setButtonsLocked(!1, !1), this.isNewUnlock = !0
        }.bind(this)), this.setButtonsLocked(!0, !1)
    }
});
var LevelSelectPage = pc.createScript("levelSelectPage");
LevelSelectPage.attributes.add("chapterNumberText", {
    type: "entity"
}), LevelSelectPage.attributes.add("chapterImageEntity", {
    type: "entity"
}), LevelSelectPage.attributes.add("storyImage", {
    type: "entity"
}), LevelSelectPage.attributes.add("scrollviewBackgroundEntity", {
    type: "entity"
}), LevelSelectPage.attributes.add("backgroundImageEntity", {
    type: "entity"
}), LevelSelectPage.attributes.add("levelTemplate", {
    type: "asset",
    assetType: "template"
}), LevelSelectPage.attributes.add("levelGroup", {
    type: "entity"
}), LevelSelectPage.attributes.add("scrollBar", {
    type: "entity"
}), LevelSelectPage.attributes.add("previousPageButtonGroup", {
    type: "entity"
}), LevelSelectPage.attributes.add("nextPageButtonGroup", {
    type: "entity"
}), LevelSelectPage.attributes.add("viewport", {
    type: "entity"
}), LevelSelectPage.attributes.add("nextChapterButton", {
    type: "entity"
}), LevelSelectPage.MARGIN = 50, pc.extend(LevelSelectPage.prototype, {
    initialize: function() {
        this.createLevelList(), LevelSelectPage.instance = this, this.app.on("LevelSelectPage:scrollTo", this.scrollToValue, this), this.app.on("ViewportManager:onResize", this._onResize, this), this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.shownFirstComic = !1, this.app.mouse.on(pc.EVENT_MOUSEWHEEL, this.onMouseWheel, this)
    },
    _onResize: function(e, t, n, a) {
        this.levelGroup.element.height = this.getScrollViewHeight()
    },
    getScrollViewHeight: function() {
        for (var e = 0, t = 0; t &lt; this.levelGroup.children.length; t += 1) this.levelGroup.children[t].enabled &amp;&amp; (e += this.levelGroup.children[t].element.height, e += this.levelGroup.layoutgroup.spacing.y);
        return e += this.levelGroup.layoutgroup.padding.w + this.levelGroup.layoutgroup.padding.y
    },
    _onPageOpen: function(e) {
        WorldManager.instance.setWorldIndex(e.chapterID);
        var t = WorldManager.instance.getWorldData(e.chapterID);
        this.setPageInformation(e.chapterID, e.pageID, t), this.previousPageButtonGroup.script.switchPageOrChapterButton.onPageSwitch(e, this), this.nextPageButtonGroup.script.switchPageOrChapterButton.onPageSwitch(e, this), this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), setTimeout(function() {
            this.fire("onPageLoadDone")
        }.bind(this), 100), 0 === LevelDataManager.instance.completedLevelsInWorld(e.chapterID) &amp;&amp; !1 === this.shownFirstComic &amp;&amp; (this.app.fire("ComicInterface:showUnlockedComic", e.chapterID, e.pageID), this.shownFirstComic = !0)
    },
    _onPageClose: function(e) {},
    setPageInformation: function(e, t, n) {
        LocalizationManager.instance.setText(this.chapterNumberText, n.name), this.chapterImageEntity.element.sprite = WorldManager.instance.getWorldBackgroundImage(e).resource, this.scrollviewBackgroundEntity.element.sprite = WorldManager.instance.getWorldBackgroundImage(e).resource, this.backgroundImageEntity.element.sprite = WorldManager.instance.getBlurredWorldBackgroundImage(e).resource, this.containsCurrentLevel = !1;
        for (var a = 0; a &lt; this.levelButtons.length; a += 1)
            if (a &gt; n.nLevels / n.nParts) this.levelButtons[a].enabled = !1;
            else {
                this.levelButtons[a].enabled = !0;
                var i = this.getLevelID(e, t, a);
                this.levelButtons[a].script.levelButton.setButtonInformation(e, i), i &lt; LevelDataManager.instance.getCurrentLevel() ? this.levelButtons[a].script.levelButton.setState(LevelButton.buttonStates.UNLOCKED) : i === LevelDataManager.instance.getCurrentLevel() ? (this.levelButtons[a].script.levelButton.setState(LevelButton.buttonStates.CURRENT), this.containsCurrentLevel = !0) : this.levelButtons[a].script.levelButton.setState(LevelButton.buttonStates.LOCKED)
            }
        var r = n.comics[t];
        if (r) {
            if (!r.resource) return void LazyLoader.instance.lazyLoad(r, this.setPageInformation.bind(this, e, t, n), this);
            this.storyImage.element.sprite = r.resource
        }
        var l = LevelDataManager.instance.getTotalStarData(e),
            o = LevelDataManager.instance.getPartsData(e);
        this.app.fire("ChapterInformationBar:updateStats", l, 3 * n.nLevels, o, n.nParts, e)
    },
    createLevelList: function() {
        this.previousPageButtonGroup.reparent(this.levelGroup), this.previousPageButtonGroup.enabled = !0;
        var e = 0,
            t = WorldManager.instance.getWorldList();
        for (var n in t) {
            var a = t[n].nLevels / t[n].nParts;
            a &gt; e &amp;&amp; (e = a)
        }
        this.levelButtons = [];
        for (var i = 0; i &lt; e; i += 1) {
            var r = this.levelTemplate.resource.instantiate();
            this.levelGroup.addChild(r), this.levelButtons.push(r)
        }
        this.nextPageButtonGroup.reparent(this.levelGroup), this.nextPageButtonGroup.enabled = !0
    },
    getLevelID: function(e, t, n) {
        var a = 0,
            i = WorldManager.instance.getWorldList();
        for (var r in i)
            if (r !== e) a += i[r].nLevels;
            else
                for (var l = 0; l &lt; i[r].nParts; l += 1) {
                    if (l === t) return a + n + 1;
                    a += i[r].nLevels / i[r].nParts
                }
    },
    scrollToLevel: function(e) {
        var t = WorldManager.instance.getWorldByLevel(e),
            n = WorldManager.instance.getWorldList(),
            a = WorldManager.instance.getLevelNumberinPage(e),
            i = (n[t].nLevels, n[t].nParts, this.levelGroup.children[1].element.height + this.levelGroup.layoutgroup.spacing.y),
            r = 0;
        this.previousPageButtonGroup.enabled &amp;&amp; (r = this.previousPageButtonGroup.element.height + this.levelGroup.layoutgroup.spacing.y);
        var l = this.viewport.element.height,
            o = this.levelGroup.layoutgroup.padding.w + r + a * i,
            s = l / 2 + i / 2,
            u = pc.math.clamp((o - s) / (this.getScrollViewHeight() - l), 0, 1);
        this.scrollBar.scrollbar.value = u
    },
    scrollToValue: function(e) {
        this.scrollBar.scrollbar.value = e
    },
    unlockLatestLevel: function(e) {
        var t = this._getButton(LevelDataManager.instance.getCurrentLevel());
        e &amp;&amp; t.script.levelButton.triggerPopup(), t.script.levelButton.unlockAnimation(), this.containsCurrentLevel = !0
    },
    openLevel: function() {
        this._getButton(LevelDataManager.instance.getCurrentLevel()).script.levelButton.click()
    },
    _isLevelInPage: function(e) {
        return !!this._getButton(e)
    },
    _getButton: function(e) {
        for (var t = 0; t &lt; this.levelButtons.length; t++)
            if (this.levelButtons[t].script.levelButton.levelID === e) return this.levelButtons[t];
        return null
    },
    onMouseWheel: function(e) {
        if (!ComicInterface.instance.panelContainer.enabled) {
            this.scrollBar.scrollbar.value += .05 * e.wheelDelta
        }
    },
    unlockNextPageButton: function() {
        this.nextChapterButton.script.switchPageOrChapterButton.unlockAnimation()
    }
});
var ChapterSelectButton = pc.createScript("chapterSelectButton");
ChapterSelectButton.buttonStates = Object.freeze({
    LOCKED: 0,
    UNLOCKED: 1,
    CURRENT: 2,
    UNAVAILABLE: 3
}), ChapterSelectButton.attributes.add("buttonEntity", {
    type: "entity"
}), ChapterSelectButton.attributes.add("chapterIDText", {
    type: "entity"
}), ChapterSelectButton.attributes.add("counterRotateEntities", {
    type: "entity",
    array: !0
}), ChapterSelectButton.attributes.add("lockedImage", {
    type: "entity"
}), ChapterSelectButton.attributes.add("commingSoonText", {
    type: "entity"
}), ChapterSelectButton.attributes.add("worldSelectButton", {
    type: "entity"
}), ChapterSelectButton.attributes.add("worldImageEntity", {
    type: "entity"
}), pc.extend(ChapterSelectButton.prototype, {
    setButtonInformation: function(t, e) {
        this.chapterID = t, this.chapterIDText.element.text = t, this.buttonEntity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.worldImageEntity.element.sprite = e.resource
    },
    setCounterRotation: function(t) {
        for (var e = 0; e &lt; this.counterRotateEntities.length; e += 1) this.counterRotateEntities[e].setLocalEulerAngles(0, 0, t)
    },
    setState: function(t) {
        this.currentState !== ChapterSelectButton.buttonStates.UNAVAILABLE &amp;&amp; (this.currentState = t, this.worldSelectButton.enabled = this.currentState !== ChapterSelectButton.buttonStates.UNAVAILABLE, this.lockedImage.enabled = this.currentState === ChapterSelectButton.buttonStates.LOCKED, this.commingSoonText.enabled = this.currentState === ChapterSelectButton.buttonStates.UNAVAILABLE)
    },
    _onClick: function() {
        this.currentState !== ChapterSelectButton.buttonStates.LOCKED &amp;&amp; this.currentState !== ChapterSelectButton.buttonStates.UNAVAILABLE &amp;&amp; (this.app.fire("BookUI:chapterIntro", this.chapterID), this.app.fire("Audio:sfx", "page_flip.mp3"))
    }
});
var ChapterPageButton = pc.createScript("chapterPageButton");
ChapterPageButton.buttonStates = Object.freeze({
    LOCKED: 0,
    UNLOCKED: 1,
    CURRENT: 2
}), ChapterPageButton.attributes.add("pageIDText", {
    type: "entity"
}), ChapterPageButton.attributes.add("buttonSpriteEntity", {
    type: "entity"
}), ChapterPageButton.attributes.add("lockEntity", {
    type: "entity"
}), ChapterPageButton.attributes.add("unlockedBgImage", {
    type: "asset",
    assetType: "sprite"
}), ChapterPageButton.attributes.add("lockedBgImage", {
    type: "asset",
    assetType: "sprite"
}), ChapterPageButton.attributes.add("buttonUnlockScale", {
    type: "vec3",
    default: [.1, .1, .1]
}), ChapterPageButton.attributes.add("buttonUnlockAnimationTime", {
    type: "number",
    default: 1
}), ChapterPageButton.attributes.add("buttonUnlockAnimationDelay", {
    type: "number",
    default: 1
}), pc.extend(ChapterPageButton.prototype, {
    setButtonInformation: function(t, e) {
        this.chapterID = t, this.pageID = e, LocalizationManager.instance.setText(this.pageIDText, "PAGE_NUMBER", e + 1), this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.entity.script.dynamicElementSize._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice())
    },
    unlockItem: function() {
        var t = this,
            e = 0;
        this.entity.tween(this.entity.getLocalScale()).to(this.buttonUnlockScale, this.buttonUnlockAnimationTime / 2, pc.BackOut).delay(this.buttonUnlockAnimationDelay).yoyo(!0).repeat(2).start().on("update", (function(n) {
            (e += n) &gt; t.buttonUnlockAnimationTime / 2 &amp;&amp; t.buttonSpriteEntity.element.sprite !== t.unlockedBgImage.resource &amp;&amp; (t.buttonSpriteEntity.element.sprite = t.unlockedBgImage.resource, t.pageIDText.enabled = !0, t.lockEntity.enabled = !1)
        })).on("complete", (function() {
            t.currentState = ChapterPageButton.buttonStates.CURRENT, t._pulse()
        }))
    },
    setState: function(t) {
        this.pulseTween &amp;&amp; this._cancelPulse(), this.currentState = t, this.pageIDText.enabled = this.currentState !== ChapterPageButton.buttonStates.LOCKED, this.lockEntity.enabled = this.currentState === ChapterPageButton.buttonStates.LOCKED, this.buttonSpriteEntity.element.sprite = this.currentState === ChapterPageButton.buttonStates.LOCKED ? this.lockedBgImage.resource : this.unlockedBgImage.resource, this.currentState === LevelButton.buttonStates.CURRENT &amp;&amp; this._pulse()
    },
    _onClick: function() {
        this.currentState !== ChapterSelectButton.buttonStates.LOCKED &amp;&amp; (this.app.fire("BookUI:levelSelect", this.chapterID, this.pageID), this.app.fire("Audio:sfx", "page_flip.mp3"))
    },
    _pulse: function() {
        this.pulseTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1.1,
            y: 1.1,
            z: 1.1
        }, 1, pc.SineOut).loop(!0).yoyo(!0).start()
    },
    _cancelPulse: function() {
        this.pulseTween.stop(), this.entity.setLocalScale(1, 1, 1), this.pulseTween = null
    }
});
var LevelButton = pc.createScript("levelButton");
LevelButton.buttonStates = Object.freeze({
    LOCKED: 0,
    UNLOCKED: 1,
    CURRENT: 2
}), LevelButton.attributes.add("buttonBorderEntity", {
    type: "entity"
}), LevelButton.attributes.add("levelNumberText", {
    type: "entity"
}), LevelButton.attributes.add("starImages", {
    type: "entity",
    array: !0
}), LevelButton.attributes.add("objectiveImages", {
    type: "entity",
    array: !0
}), LevelButton.attributes.add("backgrounds", {
    type: "asset",
    array: !0
}), LevelButton.attributes.add("unlockedBorderEntity", {
    type: "entity"
}), LevelButton.attributes.add("lockedGroupEntity", {
    type: "entity"
}), LevelButton.attributes.add("currentGroupEntity", {
    type: "entity"
}), LevelButton.attributes.add("totalAnimationTime", {
    type: "number",
    default: 5
}), LevelButton.attributes.add("animationDelay", {
    type: "number",
    default: .2
}), LevelButton.attributes.add("popupDelay", {
    type: "number",
    default: 2
}), pc.extend(LevelButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.popupTimer = 0, this.openPopup = !1, this.pulseTween = null, this.startScale = this.entity.getLocalScale().clone(), this.startPosition = this.entity.getLocalPosition().clone(), this.app.on("ViewportManager:onResize", this._onResize.bind(this), this), this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.app.on("LevelButton:cancelPopup", this._cancelPopup, this), LevelSelectPage.instance.on("onPageLoadDone", this._pulse, this)
    },
    update: function(t) {
        this.openPopup &amp;&amp; (this.popupTimer += t, this.popupTimer &gt; this.popupDelay &amp;&amp; (this.openPopup = !1, this.popupTimer = 0, this.currentState != LevelButton.buttonStates.UNLOCKED &amp;&amp; this.setState(LevelButton.buttonStates.UNLOCKED), this._onClick()))
    },
    _onResize: function(t, e, n, i) {
        this._cancelPulse(), setTimeout(function() {
            this.currentState === LevelButton.buttonStates.CURRENT &amp;&amp; this._pulse()
        }.bind(this), 300)
    },
    setButtonInformation: function(t, e, n) {
        this.levelNumberText.element.text = e, this.levelID = e, this.levelInfo = n, this.chapterID = t, this.setImage();
        for (var i = LevelDataManager.instance.getLevelData(t, e), s = null === i ? 0 : i.stars, o = 0; o &lt; this.starImages.length; o += 1) this.starImages[o].enabled = s &gt; o;
        if (this.data = LevelManager.instance.getLevelData(this.levelID), this.data) {
            for (var a = Object.keys(this.data), l = 0, u = 0; u &lt; a.length; u++) {
                var r = a[u];
                if ("turns" !== r) {
                    var c = TileLibrary.instance.getTileSprite(r);
                    c ? (this.objectiveImages[l].enabled = !0, this.objectiveImages[l].element.spriteAsset = c, l++) : console.warn("No asset found for key:", r)
                }
            }
            1 === l &amp;&amp; (this.objectiveImages[l].enabled = !1)
        } else console.warn("No data found for level", e)
    },
    setImage: function() {
        this.entity.element.sprite = this.backgrounds[this.chapterID - 1].resource
    },
    setState: function(t) {
        this._cancelPulse(), this.currentState = t, this.lockedGroupEntity.enabled = this.currentState === LevelButton.buttonStates.LOCKED, this.unlockedBorderEntity.enabled = this.currentState !== LevelButton.buttonStates.LOCKED, this.currentGroupEntity.enabled = this.currentState === LevelButton.buttonStates.CURRENT;
        for (var e = 0; e &lt; this.objectiveImages.length; e++) this.objectiveImages[e].element.color = this.currentState === LevelButton.buttonStates.LOCKED ? new pc.Color(.2, .2, .2) : pc.Color.WHITE, this.objectiveImages[e].element.opacity = this.currentState === LevelButton.buttonStates.LOCKED ? .7 : 1
    },
    _onClick: function() {
        this.currentState !== LevelButton.buttonStates.LOCKED &amp;&amp; (this.app.fire("LevelButton:cancelPopup"), this.app.fire("UIManager:showUI", "LevelInfo"), UIManager.instance.getScreen("LevelInfo").script.levelInfoScreen.setInformation(this.chapterID, this.levelID, this.levelInfo, this.data))
    },
    _cancelPopup: function() {
        !0 === this.openPopup &amp;&amp; (this.openPopup = !1, this.popupTimer = 0)
    },
    _pulse: function() {
        if (this.currentState === LevelButton.buttonStates.CURRENT &amp;&amp; null === this.pulseTween) {
            var t = this.entity.getLocalPosition().clone();
            this.pulseTween = this.entity.tween(this.entity.getLocalPosition()).to({
                x: t.x,
                y: t.y - 5,
                z: t.z
            }, .15, pc.SineInOut).delay(2).repeat(4).yoyo(!0).on("complete", function() {
                this.pulseTween.start()
            }.bind(this)).start()
        }
    },
    _cancelPulse: function() {
        this.pulseTween &amp;&amp; (this.pulseTween.stop(), this.pulseTween = null, this.entity.setLocalScale(this.startScale.x, this.startScale.y, this.startScale.z))
    },
    triggerPopup: function() {
        this.openPopup = !0
    },
    unlockAnimation: function() {
        this.lock = this.lockedGroupEntity.findByName("Lock"), UnlockLevelAnimation.instance.startAnim(this.entity, this.lock, function() {
            this.setState(LevelButton.buttonStates.CURRENT)
        }.bind(this)), this.setState(LevelButton.buttonStates.LOCKED)
    },
    click: function() {
        this._onClick()
    }
});
var PreBoosterButton = pc.createScript("preBoosterButton");
PreBoosterButton.buttonStates = Object.freeze({
    ACTIVE: 0,
    INACTIVE: 1,
    EMPTY: 2
}), PreBoosterButton.attributes.add("inventoryKey", {
    type: "string"
}), PreBoosterButton.attributes.add("activeBubble", {
    type: "entity"
}), PreBoosterButton.attributes.add("inactiveBubble", {
    type: "entity"
}), PreBoosterButton.attributes.add("emptyBubble", {
    type: "entity"
}), PreBoosterButton.attributes.add("amountText", {
    type: "entity"
}), PreBoosterButton.DISABLE_OPACITY = .5, pc.extend(PreBoosterButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.app.on("BoosterShopManager:onItemBought", this.getInventoryAmount, this), this._hand = this.entity.findByTag("tutorial")[0]
    },
    getInventoryAmount: function() {
        var t = Inventory.instance.getItem(this.inventoryKey);
        this._tutorial &amp;&amp; 0 === t &amp;&amp; (t = 1), t &gt; 0 ? this.setState(PreBoosterButton.buttonStates.INACTIVE) : this.setState(PreBoosterButton.buttonStates.EMPTY), this.amountText.element.text = t
    },
    setState: function(t) {
        this.currentState = t, this.activeBubble.enabled = this.currentState === PreBoosterButton.buttonStates.ACTIVE, this.inactiveBubble.enabled = this.currentState === PreBoosterButton.buttonStates.INACTIVE, this.emptyBubble.enabled = this.currentState === PreBoosterButton.buttonStates.EMPTY
    },
    _onClick: function() {
        switch (this.currentState) {
            case PreBoosterButton.buttonStates.ACTIVE:
                this.setState(PreBoosterButton.buttonStates.INACTIVE);
                break;
            case PreBoosterButton.buttonStates.INACTIVE:
                this.app.fire("PreBoosterButton:active", this.inventoryKey), this.setState(PreBoosterButton.buttonStates.ACTIVE);
                break;
            case PreBoosterButton.buttonStates.EMPTY:
                this.app.fire("UIManager:showUI", "BoosterShop")
        }
    },
    activate: function(t) {
        if (this._active = t, t) {
            this.entity.element.useInput = !0;
            for (var e = this.entity.findComponents("element"), n = 0; n &lt; e.length; n++) e[n].opacity = 1, e[n].color = (new pc.Color).fromString("#FFFFFF")
        } else {
            this.entity.element.useInput = !1;
            for (e = this.entity.findComponents("element"), n = 0; n &lt; e.length; n++) e[n].opacity = PreBoosterButton.DISABLE_OPACITY, e[n].color = (new pc.Color).fromString("#3E3E3E")
        }
    },
    activateBooster: function() {
        if (this.currentState === PreBoosterButton.buttonStates.ACTIVE &amp;&amp; (!!this._tutorial || Inventory.instance.tryPayItem(this.inventoryKey, 1))) switch (StatisticsManager.instance.incrementStatistic("pre_boosters_used", 1), this.inventoryKey) {
            case "PREBOOSTER_1":
                BoosterManager.instance.addPreBoosterToQueue(preGameBoosters.LINECLEAR, 2), StatisticsManager.instance.incrementStatistic("bees_pre_booster_used", 1);
                break;
            case "PREBOOSTER_2":
                BoosterManager.instance.addPreBoosterToQueue(preGameBoosters.BOMB, 2), StatisticsManager.instance.incrementStatistic("ladybugs_pre_booster_used", 1);
                break;
            case "PREBOOSTER_3":
                BoosterManager.instance.addPreBoosterToQueue(preGameBoosters.COLORBOMB, 1), StatisticsManager.instance.incrementStatistic("butterflies_pre_booster_used", 1)
        }
    },
    useInput: function(t) {
        var e = !t || this.entity.tags.has(t);
        e &amp;&amp; t &amp;&amp; this.setTutorial(!0), this.entity.element.useInput = e &amp;&amp; this._active
    },
    setTutorial: function(t) {
        this._tutorial = t, t &amp;&amp; (this.currentState === PreBoosterButton.buttonStates.EMPTY ? (this.amountText.element.text = 1, this.setState(PreBoosterButton.buttonStates.INACTIVE)) : this.amountText.element.text = Inventory.instance.getItem(this.inventoryKey)), this.enableTutorial(t)
    },
    enableTutorial: function(t) {
        this._hand.enabled = t
    }
});
var LevelInfoScreen = pc.createScript("levelInfoScreen");
LevelInfoScreen.attributes.add("levelNumberText", {
    type: "entity"
}), LevelInfoScreen.attributes.add("movesAmountText", {
    type: "entity"
}), LevelInfoScreen.attributes.add("objectiveEntities", {
    type: "entity",
    array: !0
}), LevelInfoScreen.attributes.add("boosterButtonEntities", {
    type: "entity",
    array: !0
}), LevelInfoScreen.attributes.add("startLevelButton", {
    type: "entity"
}), LevelInfoScreen.attributes.add("closeButton", {
    type: "entity"
}), pc.extend(LevelInfoScreen.prototype, {
    initialize: function() {
        LevelInfoScreen.instance = this, this._allButtons = this.entity.findScripts("elementInput"), this.startLevelButton.script.elementInput.on(inputEvents.CLICK, this._startLevel, this)
    },
    onUIEntityOpen: function() {
        for (var t = 0; t &lt; this._allButtons.length; t++) {
            var e = this._allButtons[t].entity;
            e.script.preBoosterButton &amp;&amp; e.script.preBoosterButton.setTutorial(!1)
        }
    },
    setInformation: function(t, e, n, s) {
        WorldManager.instance.switchWorld(t), this.levelID = e, this.chapterID = t, LocalizationManager.instance.setText(this.levelNumberText, "LEVEL_NUMBER", e);
        for (var i = 0; i &lt; this.boosterButtonEntities.length; i += 1) this.boosterButtonEntities[i].script.preBoosterButton.getInventoryAmount();
        this.movesAmountText.element.text = s.turns;
        for (var o = Object.keys(s), r = 0, a = 0; a &lt; o.length; a++) {
            var l = o[a];
            if ("turns" !== l) {
                var u = s[l];
                this.objectiveEntities[r].enabled = !0, this.objectiveEntities[r].script.popupObjectiveUI.setGoal(l, u), r++
            }
        }
        1 === r &amp;&amp; (this.objectiveEntities[r].enabled = !1), TutorialManager.instance.preGameBooster(this.levelID)
    },
    _startLevel: function() {
        this.fire("start");
        for (var t = 0; t &lt; this.boosterButtonEntities.length; t += 1) this.boosterButtonEntities[t].script.preBoosterButton.activateBooster();
        LevelManager.instance.startLevel(this.levelID, this.chapterID)
    },
    enableOneButton: function(t) {
        for (var e = 0; e &lt; this._allButtons.length; e++) {
            var n = this._allButtons[e].entity;
            n.script.preBoosterButton ? n.script.preBoosterButton.useInput(t) : n.element.useInput = n.tags.has(t)
        }
    },
    enableAll: function(t) {
        this.startLevelButton.element.useInput = t, this.closeButton.element.useInput = t;
        for (var e = 0; e &lt; this._allButtons.length; e++) {
            var n = this._allButtons[e].entity;
            n.script.preBoosterButton &amp;&amp; (n.script.preBoosterButton.useInput(), n.script.preBoosterButton.enableTutorial(!1))
        }
    }
});
var PlankBackgroundResize = pc.createScript("plankBackgroundResize");
PlankBackgroundResize.attributes.add("sizeDifference", {
    type: "number"
}), pc.extend(PlankBackgroundResize.prototype, {
    initialize: function() {
        this.app.on("ViewportManager:onResize", this._onResize, this), this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice())
    },
    _onResize: function(e, i, n, t) {
        t === deviceEnum.MOBILE &amp;&amp; e === orientationEnum.PORTRAIT ? this.entity.element.width = n * this.sizeDifference : this.entity.element.width = i * this.sizeDifference
    }
});
var ConfirmLeaveGameButton = pc.createScript("confirmLeaveGameButton");
ConfirmLeaveGameButton.attributes.add("clickSFX", {
    type: "string",
    default: "button_click.mp3"
}), pc.extend(ConfirmLeaveGameButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onClick: function() {
        this.app.fire("Audio:sfx", this.clickSFX), GameManager.instance.trackEventLevelQuit().then(function() {
            BoosterManager.instance.reset(), this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "Book", "lastLevel"), LevelManager.instance.reset(), TutorialManager.instance.endTutorial(!0), this.app.fire("ConfirmLeaveGameButton:leave")
        }.bind(this))
    }
});
var SettingsToggleUI = pc.createScript("settingsToggleUI");
SettingsToggleUI.attributes.add("uiToDisable", {
    type: "entity",
    array: !0
}), pc.extend(SettingsToggleUI.prototype, {
    initialize: function() {
        this.hamburgerButton = this.entity.script.hamburgerMenu, this.hamburgerButton.on("MenuToggle", this.onMenuToggle, this)
    },
    onMenuToggle: function(t) {
        for (var e = 0; e &lt; this.uiToDisable.length; e++) this.uiToDisable[e].enabled = !t
    }
});
var StarBarStar = pc.createScript("starBarStar");
StarBarStar.attributes.add("starImageEntity", {
    type: "entity"
}), StarBarStar.attributes.add("inactiveStarEntity", {
    type: "entity"
}), pc.extend(StarBarStar.prototype, {
    setRotation: function(t) {
        this.barValue = t, this.entity.setLocalEulerAngles(0, 0, -360 * t), this.starImageEntity.setLocalEulerAngles(0, 0, 360 * t), this.inactiveStarEntity.setLocalEulerAngles(0, 0, 360 * t)
    },
    setActive: function() {
        this.isActive || (this.app.fire("Audio:sfx", "star_ingame.mp3"), this.isActive = !0, this.starImageEntity.enabled = !0, this.starImageEntity.script.tweenScale.startTween())
    },
    setInactive: function() {
        this.starImageEntity.script.tweenScale.stopTween(), this.starImageEntity.script.tweenScale.reset(), this.isActive = !1, this.starImageEntity.enabled = !1
    },
    checkActivate: function(t) {
        t &gt; this.barValue ? this.setActive() : this.setInactive()
    }
});
var PopupObjectiveUI = pc.createScript("popupObjectiveUI");
PopupObjectiveUI.attributes.add("hasResult", {
    type: "boolean"
}), PopupObjectiveUI.attributes.add("objectiveIconEntity", {
    type: "entity"
}), PopupObjectiveUI.attributes.add("goalTextEntity", {
    type: "entity"
}), PopupObjectiveUI.attributes.add("resultTextEntity", {
    type: "entity"
}), PopupObjectiveUI.attributes.add("resultIconEntity", {
    type: "entity"
}), PopupObjectiveUI.attributes.add("completeIcon", {
    type: "asset",
    assetType: "sprite"
}), PopupObjectiveUI.attributes.add("failedIcon", {
    type: "asset",
    assetType: "sprite"
}), PopupObjectiveUI.attributes.add("completeColor", {
    type: "rgb"
}), PopupObjectiveUI.attributes.add("failedColor", {
    type: "rgb"
}), pc.extend(PopupObjectiveUI.prototype, {
    initialize: function() {
        this.resultTextEntity.enabled = this.hasResult, this.resultIconEntity.enabled = this.hasResult, this.goalTextEntity.enabled = !this.hasResult
    },
    setGoal: function(t, e) {
        this.goal = e, this.objectiveIconEntity.element.spriteAsset = TileLibrary.instance.getTileSprite(t), this.goalTextEntity.element.text = (this.hasResult ? "/" : "") + e, this.setTextWidth()
    },
    setResult: function(t) {
        if (this.hasResult) {
            var e = this.goal - t;
            if (e &lt; 0) console.warn("Remaining value is lower than 0", e);
            else {
                this.resultTextEntity.element.text = e;
                var i = e &lt;= 0;
                this.resultTextEntity.element.color = i ? this.completeColor : this.failedColor, this.resultIconEntity.element.sprite = i ? this.completeIcon.resource : this.failedIcon.resource, this.setTextWidth()
            }
        }
    },
    setTextWidth: function() {
        this.goalTextEntity.parent.element.width = this.hasResult ? this.resultTextEntity.element.width : this.goalTextEntity.element.width, this.entity.element.width = this.goalTextEntity.parent.element.width + this.objectiveIconEntity.element.width
    }
});
var TutorialManager = pc.createScript("tutorialManager");
TutorialManager.attributes.add("focusOverlay", {
    type: "entity"
}), TutorialManager.attributes.add("overlay", {
    type: "entity"
}), TutorialManager.attributes.add("objectiveEntity", {
    type: "entity"
}), TutorialManager.attributes.add("moveEntity", {
    type: "entity"
}), TutorialManager.attributes.add("scaleCurve", {
    type: "curve"
}), TutorialManager.attributes.add("pregameBoosters", {
    type: "json",
    array: !0,
    schema: [{
        name: "level",
        type: "number"
    }, {
        name: "data",
        type: "asset"
    }]
}), TutorialManager.attributes.add("tutorials", {
    type: "json",
    array: !0,
    schema: [{
        name: "level",
        type: "number"
    }, {
        name: "data",
        type: "asset"
    }]
}), pc.extend(TutorialManager.prototype, {
    initialize: function() {
        TutorialManager.instance = this, this.focusOverlay.enabled = !1, this.overlay.enabled = !1, this.active = !1, this._currentStep = -1, this._currentTutorialSteps = null, this.app.on("ViewportManager:onResize", this._onResize, this), this.app.on("PerspectiveView:onCameraChange", this._onResize, this)
    },
    _onResize: function() {
        setTimeout(function() {
            if (this._currentTutorialStep) switch (this._currentTutorialStep.type) {
                case "dialog":
                    this._currentTutorialStep.focus &amp;&amp; this.focus(this._currentTutorialStep.focus)
            }
        }.bind(this), 100)
    },
    preGameBooster: function(t) {
        LevelDataManager.instance.getCurrentLevel();
        var e = this.pregameBoosters.findIndex((function(e) {
            return e.level === t
        })); - 1 !== e &amp;&amp; this._setTutorial(this.pregameBoosters[e].data.resources)
    },
    startLevel: function(t) {
        var e = this.tutorials.findIndex((function(e) {
            return e.level === t
        })); - 1 !== e &amp;&amp; this._setTutorial(this.tutorials[e].data.resources)
    },
    _checkActionStep: function(t) {
        if (this._dialogStep = t, this._canDoAction = this._isActionStep(this._dialogStep), this.app.fire("GameInput:toggleGameInput", this._canDoAction), this._canDoAction) {
            if ("booster" === this._currentTutorialStep.type &amp;&amp; 0 !== this._currentTutorialStep.index.indexOf(this._dialogStep)) return;
            this._showAction()
        }
    },
    _setTutorial: function(t) {
        this.active = !0, this._currentStep = 0, this._currentTutorial = t, this._currentTutorialStep = this._currentTutorial[this._currentStep], this._showTutorial(), this._checkActionStep(0)
    },
    _showTutorial: function() {
        if (this._currentTutorialStep.dialog) {
            var t = "prebooster" === this._currentTutorialStep.type,
                e = "booster" !== this._currentTutorialStep.type &amp;&amp; !t;
            DialogManager.instance.showDialog(this._currentTutorialStep.dialog, null, null, t ? dialogTypes.PREBOOSTERTUTORIAL : dialogTypes.GAMETUTORIAL, e)
        }
        switch (this._currentTutorialStep.type) {
            case "prebooster":
                this.app.on("PreBoosterButton:active", this._onPreboosterClick, this), DialogManager.instance.on("step", this._checkActionStep, this), LevelInfoScreen.instance.enableAll(!1);
                break;
            case "booster":
                DialogManager.instance.on("step", this._checkActionStep, this), DialogManager.instance.on("finish", this._nextTutorialStep, this), this._currentTutorialStep.dialog || this._showAction();
                break;
            case "dialog":
                DialogManager.instance.on("finish", this._nextTutorialStep, this), this.overlay.enabled = !0, this.focus(this._currentTutorialStep.focus);
                break;
            case "swap":
                DialogManager.instance.on("step", this._checkActionStep, this), DialogManager.instance.on("finish", this._nextTutorialStep, this), this._currentTutorialStep.dialog || this._showAction();
                break;
            case "randomMatch":
                DialogManager.instance.on("step", this._checkActionStep, this), this.app.on("SwapMode:onMoveStart", this._nextTutorialStep, this), this._currentTutorialStep.dialog || this._showAction();
                break;
            case "waitForCascade":
                this.app.on("SwapMode:onCascadeDone", this._onCascadeFinish, this), this._currentTutorialStep.enableOverlay &amp;&amp; this.enableOverlay(!0);
                break;
            default:
                console.warn("Type is not recognized: ", this._currentTutorialStep.type)
        }
    },
    _hideTutorial: function() {
        switch (this._resetHand(), this._currentTutorialStep.type) {
            case "prebooster":
                this.app.off("PreBoosterButton:active", this._onPreboosterClick, this), DialogManager.instance.off("step", this._checkActionStep, this), LevelInfoScreen.instance.enableAll(!0);
                break;
            case "booster":
                var t = this._currentTutorialStep.boosterIndex;
                setTimeout(function() {
                    this.app.fire("TutorialManager:enableBoosters", t)
                }.bind(this)), this.enableOverlay(!1), DialogManager.instance.off("finish", this._nextTutorialStep, this), DialogManager.instance.off("step", this._checkActionStep, this), this._boosterEntity.script.boosterButton.off("cancel", this._onBoosterCancel, this), this._boosterEntity.script.boosterButton.off("use", this._onBoosterUse, this), this._boosterEntity = null;
                break;
            case "dialog":
                DialogManager.instance.off("finish", this._nextTutorialStep, this), this.enableOverlay(!1);
                break;
            case "swap":
                DialogManager.instance.off("step", this._checkActionStep, this), DialogManager.instance.off("finish", this._nextTutorialStep, this), this.enableOverlay(!1);
                break;
            case "randomMatch":
                DialogManager.instance.off("step", this._checkActionStep, this), DialogManager.instance.nextDialog(), this.app.off("SwapMode:onMoveStart", this._nextTutorialStep, this);
                break;
            case "waitForCascade":
                this.app.off("SwapMode:onCascadeDone", this._onCascadeFinish, this), this._currentTutorialStep.enableOverlay &amp;&amp; this.enableOverlay(!1);
                break;
            default:
                console.warn("Type is not recognized: ", this._currentTutorialStep.type)
        }
    },
    _showAction: function() {
        switch (this._currentTutorialStep.type) {
            case "prebooster":
                LevelInfoScreen.instance.enableOneButton(this._currentTutorialStep.tag);
                break;
            case "booster":
                this.app.fire("TutorialManager:enableBooster", this._currentTutorialStep.boosterIndex);
                break;
            case "dialog":
                break;
            case "swap":
                this._showTutorialHand(), this.setOverlayWorldPosition(), GridManager.instance.showTutorialMatch([GridManager.instance.getTile(this._currentTutorialStep.tile1.x, this._currentTutorialStep.tile1.y), GridManager.instance.getTile(this._currentTutorialStep.tile2.x, this._currentTutorialStep.tile2.y)]);
                break;
            case "randomMatch":
            case "waitForCascade":
                break;
            default:
                console.warn("Type is not recognized: ", this._currentTutorialStep.type)
        }
    },
    _onPreboosterClick: function() {
        this._nextTutorialStep()
    },
    _onStartClick: function() {
        this._nextTutorialStep()
    },
    _onCascadeFinish: function() {
        this._nextTutorialStep()
    },
    _nextTutorialStep: function() {
        this._hideTutorial(), this._currentStep++, this._currentTutorialStep = this._currentTutorial[this._currentStep], this._currentTutorialStep ? (this._showTutorial(), this._checkActionStep(0), "waitForCascade" !== this._currentTutorialStep.type &amp;&amp; this.app.fire("BoosterButton:disableAll")) : this.endTutorial()
    },
    _isActionStep: function(t) {
        return !("randomMatch" !== this._currentTutorialStep.type || "number" == typeof this._currentTutorialStep.index &amp;&amp; Array.isArray(this._currentTutorialStep.index)) || (Array.isArray(this._currentTutorialStep.index) ? -1 !== this._currentTutorialStep.index.indexOf(t) : t === this._currentTutorialStep.index)
    },
    _resetHand: function() {
        this._tween &amp;&amp; this._tween.stop();
        var t = GridManager.instance.tutorialHand;
        t.enabled = !1, t.setLocalScale(1, 1, 1)
    },
    _showTutorialHand: function() {
        this._resetHand();
        var t = GridManager.instance.tutorialHand;
        t.enabled = !0;
        var e = this._currentTutorialStep.tile1,
            i = this._currentTutorialStep.tile2,
            a = GridManager.instance.calculatePosition(e.x, e.y, 1),
            r = GridManager.instance.calculatePosition(i.x, i.y, 1);
        t.setLocalPosition(a), this._tween = t.tween(t.getLocalPosition()).to({
            x: r.x,
            y: r.y,
            z: r.z
        }, 1, pc.Linear).loop(!0).yoyo(!0).start()
    },
    _showTutorialHandClick: function(t) {
        this._resetHand();
        var e = GridManager.instance.tutorialHand;
        e.enabled = !0;
        var i = GridManager.instance.calculatePosition(t.x, t.y, 1);
        e.setLocalPosition(i);
        this._tween = e.tween(e.getLocalScale()).to({
            x: 1.5,
            y: 1.5,
            z: 1.5
        }, 1, pc.Linear).loop(!0).yoyo(!0).start()
    },
    checkAllowedSwap: function(t, e) {
        if (!this.active) return !0;
        if ("randomMatch" === this._currentTutorialStep.type) return !0;
        if ("swap" !== this._currentTutorialStep.type) {
            if ("booster" !== this._currentTutorialStep.type) return !1;
            if (0 !== this._currentTutorialStep.boosterIndex) return !1
        }
        if (!BoosterManager.instance.isBoosterActive(boosterEnum.FREESWAP) || 0 === this._currentTutorialStep.boosterIndex) {
            var i = this._currentTutorialStep.tile1,
                a = this._currentTutorialStep.tile2;
            if (!t || !e) return console.warn("No tile 1 or tile 2"), console.log(t), console.log(e), !1;
            var r = GridManager.instance.getTile(i.x, i.y),
                n = GridManager.instance.getTile(a.x, a.y),
                o = t === r || t === n,
                s = e === r || e === n;
            return o &amp;&amp; s &amp;&amp; (this._resetHand(), DialogManager.instance.nextDialog()), o &amp;&amp; s
        }
    },
    setBoosterEntity: function(t) {
        this._boosterEntity = t, this._boosterEntity.script.boosterButton.off("use", this._onBoosterUse, this), this._boosterEntity.script.boosterButton.on("use", this._onBoosterUse, this), this.app.fire("GameInput:toggleGameInput", !1)
    },
    _onBoosterUse: function() {
        this.enableOverlay(!1), this.app.fire("GameInput:toggleGameInput", !0), this._boosterEntity.script.boosterButton.off("use", this._onBoosterUse, this), this._boosterEntity.script.boosterButton.on("cancel", this._onBoosterCancel, this), DialogManager.instance.nextDialog(), this._currentTutorialStep.tile ? this._showTutorialHandClick(this._currentTutorialStep.tile) : this._currentTutorialStep.tile1 &amp;&amp; this._currentTutorialStep.tile2 &amp;&amp; this._showTutorialHand(), this.setOverlayWorldPosition()
    },
    _onBoosterCancel: function() {
        DialogManager.instance.previousDialog(), this._boosterEntity.script.boosterButton.off("cancel", this._onBoosterCancel, this), this._resetHand()
    },
    canUseBooster: function(t) {
        var e = this._currentTutorialStep.tile;
        if (!e) return !1;
        var i = t.x === e.x &amp;&amp; t.y === e.y;
        return i &amp;&amp; DialogManager.instance.nextDialog(), i
    },
    endTutorial: function(t) {
        this.active &amp;&amp; (this._currentTutorialStep &amp;&amp; this._hideTutorial(), this.active = !1, DialogManager.instance.hideDialog(), t || this.app.fire("TutorialManager:stopTutorial"))
    },
    enableOverlay: function(t) {
        this.focusOverlay.enabled = t, this.overlay.enabled = !1, this._targetEntity = null, this._follow = !1
    },
    setOverlayPosition: function(t) {
        this.focusOverlay.setPosition(t.getPosition()), this._targetEntity = t, this._follow = !0, this._setScale(1)
    },
    setOverlayWorldPosition: function() {
        var t = new pc.Vec3,
            e = null;
        this._currentTutorialStep.tile ? e = GridManager.instance.calculatePosition(this._currentTutorialStep.tile.x, this._currentTutorialStep.tile.y, 0) : this._currentTutorialStep.tile1 &amp;&amp; this._currentTutorialStep.tile2 &amp;&amp; (e = GridManager.instance.calculatePosition((this._currentTutorialStep.tile1.x + this._currentTutorialStep.tile2.x) / 2, (this._currentTutorialStep.tile1.y + this._currentTutorialStep.tile2.y) / 2, 0)), PerspectiveView.instance.entity.camera.worldToScreen(e, t), t.mul(new pc.Vec3(1, window.devicePixelRatio, 0));
        var i = UIManager.instance.getScale(),
            a = innerWidth;
        this.focusOverlay.setLocalPosition((t.x - a / 2) / i * devicePixelRatio, -t.y / i + 640, 0);
        var r = this.scaleCurve.value(this._getRadius() / 100);
        this._setScale(r)
    },
    update: function() {
        this._follow &amp;&amp; this.focusOverlay.setPosition(this._targetEntity.getPosition())
    },
    focus: function(t) {
        switch (t) {
            case "objective":
                this.enableOverlay(!0), this.setOverlayPosition(this.objectiveEntity);
                break;
            case "move":
                this.setOverlayPosition(this.moveEntity)
        }
    },
    _getRadius: function() {
        return Math.abs(PerspectiveView.instance.entity.parent.getLocalPosition().z)
    },
    _setScale: function(t) {
        this.focusOverlay.setLocalScale(t, t, t)
    }
});
var PyzomathDataReader = {};
PyzomathDataReader.objectiveTypeLink = Object.freeze({
    0: objectiveTypesEnum.ORDER,
    1: objectiveTypesEnum.ORDER,
    2: objectiveTypesEnum.ORDER,
    3: objectiveTypesEnum.ORDER,
    4: objectiveTypesEnum.SCORE
}), pc.extend(PyzomathDataReader, {
    getColumns: function(e) {
        return e.levelSettings.maxHorSize
    },
    getRows: function(e) {
        return e.levelSettings.maxVertSize
    },
    getColors: function(e) {
        return e.levelSettings.maxNrOfColors
    },
    getMoves: function(e) {
        return e.levelSettings.triggers.find((function(e) {
            return 1 === e.consequence
        })).conditions[0].maxSetting
    },
    getObjectives: function(e) {
        for (var t = e.levelSettings.triggers.find((function(e) {
                return 0 === e.consequence
            })).conditions, n = [], r = 0; r &lt; t.length; r += 1) {
            var o = t[r],
                i = PyzomathDataReader.objectiveTypeLink[o.conditionType];
            switch (i) {
                case objectiveTypesEnum.ORDER:
                    var a = o.elements[0].hasOwnProperty("background") ? tileLayerEnum.BACKGROUND : tileLayerEnum.FOREGROUND,
                        c = a === tileLayerEnum.BACKGROUND ? o.elements[0].background : o.elements[0].foreground;
                    n.push({
                        objectiveType: i,
                        goal: o.maxSetting,
                        orderTypeObject: {
                            layerID: a,
                            typeID: TileLibrary.instance.getOriginalTypeID(a, c),
                            colorID: o.elements[0].hasOwnProperty("color") ? ColorManager.instance.getColorInOrder(o.elements[0].color) : 0
                        }
                    });
                    break;
                case objectiveTypesEnum.SCORE:
                    n.push({
                        objectiveType: i,
                        goal: o.maxSetting,
                        orderTypeObject: {}
                    });
                    break;
                default:
                    console.warn("Type is not recognized:", i, PyzomathDataReader.objectiveTypeLink)
            }
        }
        return n
    },
    getTiles: function(e) {
        return e.grid.startingState
    },
    getStarValues: function(e) {
        return e.starValues
    }
});
var BoosterShopItem = pc.createScript("boosterShopItem");
BoosterShopItem.attributes.add("buyButtonEntity", {
    type: "entity"
}), BoosterShopItem.attributes.add("boosterButtonEntity", {
    type: "entity"
}), BoosterShopItem.attributes.add("priceTextEntity", {
    type: "entity"
}), BoosterShopItem.attributes.add("inventoryAmountEntity", {
    type: "entity"
}), BoosterShopItem.attributes.add("imageEntity", {
    type: "entity"
}), pc.extend(BoosterShopItem.prototype, {
    initialize: function() {
        this.buyButtonEntity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.boosterButtonEntity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onClick: function() {
        BoosterShopManager.instance.purchase(this.stockItem), this.updateItem()
    },
    updateItem: function() {
        this.priceTextEntity.element.text = this.stockItem.price, this.inventoryAmountEntity.element.text = Inventory.instance.getItem(this.stockItem.inventoryKey), this.imageEntity.element.sprite = this.stockItem.image.resource
    },
    setItem: function(t) {
        this.stockItem = t, this.updateItem()
    },
    activate: function(t) {
        if (this._active = t, t) {
            this.entity.element.useInput = !0;
            for (var e = this.entity.findComponents("element"), n = 0; n &lt; e.length; n++) e[n].opacity = 1, e[n].color = (new pc.Color).fromString("#FFFFFF")
        } else {
            this.entity.element.useInput = !1;
            for (e = this.entity.findComponents("element"), n = 0; n &lt; e.length; n++) e[n].opacity = PreBoosterButton.DISABLE_OPACITY, e[n].color = (new pc.Color).fromString("#3E3E3E")
        }
    }
});
var NavigationMenu = pc.createScript("navigationMenu");
NavigationMenu.attributes.add("menuButton", {
    type: "entity"
}), NavigationMenu.attributes.add("content", {
    type: "entity",
    array: !0
}), NavigationMenu.attributes.add("contentOffset", {
    type: "number",
    default: 200
}), NavigationMenu.attributes.add("contentStartOffset", {
    type: "number",
    default: 100
}), NavigationMenu.attributes.add("unfoldDuration", {
    type: "number",
    default: 1
}), NavigationMenu.attributes.add("animationDistance", {
    type: "number",
    default: 100
}), NavigationMenu.attributes.add("overlay", {
    type: "entity"
}), NavigationMenu.attributes.add("toggleEnabledEntities", {
    type: "entity",
    array: !0
}), pc.extend(NavigationMenu.prototype, {
    initialize: function() {
        this.menuButton.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.overlay.script.elementInput.on(inputEvents.CLICK, this._onClick, this);
        for (var t = 0; t &lt; this.content.length; t += 1) this.content[t].script.elementInput.on(inputEvents.CLICK, this._onClick, this);
        this.isOpen = !1, this.toggleMenu(!0, !1), this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _onClick: function() {
        this.toggleMenu(), this.app.fire("Audio:playSFX", "button.mp3")
    },
    toggleMenu: function(t, n) {
        this.isOpen = void 0 === n ? !this.isOpen : n;
        for (var e = ViewportManager.instance.getOrientation(), i = e === orientationEnum.PORTRAIT ? new pc.Vec2(0, this.contentOffset) : new pc.Vec2(-this.contentOffset, 0), a = e === orientationEnum.PORTRAIT ? new pc.Vec2(1, 0) : new pc.Vec2(0, -1), s = e === orientationEnum.PORTRAIT ? new pc.Vec2(0, this.contentStartOffset) : new pc.Vec2(-this.contentStartOffset, 0), o = 0; o &lt; this.content.length; o += 1) this._setItemPosition(this.content[o], o, i, a, s, t);
        this.overlay.enabled = this.isOpen;
        for (o = 0; o &lt; this.toggleEnabledEntities.length; o += 1) this.toggleEnabledEntities[o].enabled = this.isOpen
    },
    _setItemPosition: function(t, n, e, i, a, s) {
        var o = new pc.Vec2(e.x * n + i.x * this.animationDistance + a.x, e.y * n + i.y * this.animationDistance + a.y),
            u = new pc.Vec2(e.x * n + a.x, e.y * n + a.y),
            c = this.isOpen ? u : o;
        s ? (t.setLocalPosition(c.x, c.y, 0), t.enabled = this.isOpen) : (this.isOpen &amp;&amp; (t.enabled = !0), t.tween(t.getLocalPosition()).to({
            x: c.x,
            y: c.y,
            z: 0
        }, this.unfoldDuration, this.isOpen ? pc.BackOut : pc.BackIn).delay(.2 * n).start().on("complete", function() {
            this.isOpen || (t.enabled = !1)
        }.bind(this)))
    },
    _onResize: function(t, n, e, i) {
        this.toggleMenu(!0, this.isOpen)
    }
});
var CoinInterface = pc.createScript("coinInterface");
CoinInterface.attributes.add("addCoinsButton", {
    type: "entity"
}), CoinInterface.attributes.add("coinTextEntity", {
    type: "entity"
}), pc.extend(CoinInterface.prototype, {
    initialize: function() {
        this.addCoinsButton.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.app.on("CoinInterface:updateCoins", this.setCoinAmount, this)
    },
    onUIEntityOpen: function() {
        this.setCoinAmount()
    },
    setCoinAmount: function() {
        var t = Inventory.instance.getItem("COINS");
        this.coinTextEntity.element.text = t
    },
    _onClick: function() {
        this.app.fire("UIManager:showUI", "BoosterShop")
    }
});
var PerspectiveView = pc.createScript("perspectiveView"),
    defaultString = "------------------------------------------------------";
PerspectiveView.attributes.add("padding", {
    type: "number",
    min: 0,
    max: .3,
    precision: 2
}), PerspectiveView.attributes.add("desktopClamp", {
    type: "number",
    default: 1600
}), PerspectiveView.attributes.add("a", {
    type: "string",
    title: "Desktop Landscape",
    default: defaultString
}), PerspectiveView.attributes.add("landscapeWidthDesktop", {
    type: "number",
    default: .75,
    max: 1,
    min: 0
}), PerspectiveView.attributes.add("landscapeHeightDesktop", {
    type: "number",
    default: .8,
    max: 1,
    min: 0
}), PerspectiveView.attributes.add("b", {
    type: "string",
    title: "Desktop Portrait",
    default: defaultString
}), PerspectiveView.attributes.add("portraitWidthDesktop", {
    type: "number",
    default: 1,
    max: 1,
    min: 0
}), PerspectiveView.attributes.add("portraitHeightDesktop", {
    type: "number",
    default: .67,
    max: 1,
    min: 0
}), PerspectiveView.attributes.add("c", {
    type: "string",
    title: "Mobile Landscape",
    default: defaultString
}), PerspectiveView.attributes.add("landscapeWidthMobile", {
    type: "curve"
}), PerspectiveView.attributes.add("landscapeHeightMobile", {
    type: "number",
    default: 1,
    max: 1,
    min: 0
}), PerspectiveView.attributes.add("d", {
    type: "string",
    title: "Mobile Portrait",
    default: defaultString
}), PerspectiveView.attributes.add("portraitWidthMobile", {
    type: "number",
    default: 1,
    max: 1,
    min: 0
}), PerspectiveView.attributes.add("portraitHeightMobile", {
    type: "number",
    default: .8,
    max: 1,
    min: 0
}), PerspectiveView.attributes.add("tweenEntity", {
    type: "entity"
}), Object.defineProperty(PerspectiveView.prototype, "camera", {
    get: function() {
        return this._camera
    }
}), pc.extend(PerspectiveView.prototype, {
    initialize: function() {
        PerspectiveView.instance = this, this._radius = this.entity.getLocalPosition().z, this._camera = this.entity.camera, this.app.on("ViewportManager:onResize", this._onResize, this), this._referenceResolution = UIManager.instance.getReferenceResolution(), this._onResize(Wrapper.instance.getOrientation(), innerWidth, innerHeight, ViewportManager.instance.getDevice())
    },
    _onResize: function(t, e, i, s) {
        this._orientation = t, this._device = s, this._heightWidthRatio = i / e;
        var a = e * this._referenceResolution.y / i;
        this._device === deviceEnum.DESKTOP &amp;&amp; (a = Math.min(a, this.desktopClamp)), this._widthRatio = a / this._referenceResolution.y, this._heightRatio = 1, this.focus()
    },
    setAABB: function(t) {
        this._aabb = t, this.focus()
    },
    focus: function() {
        if (this._aabb) {
            var t = this._camera.fov,
                e = 0,
                i = 0;
            switch (this._orientation) {
                case "portrait":
                    e = this._aabb.halfExtents.x / this._widthRatio / (1 - this.padding) / (1 - (this._device === deviceEnum.DESKTOP ? this.portraitWidthDesktop : this.portraitWidthMobile)), i = this._aabb.halfExtents.y / this._heightRatio / (1 - this.padding) / (1 - (this._device === deviceEnum.DESKTOP ? this.portraitHeightDesktop : this.portraitHeightMobile));
                    break;
                case "":
                case "landscape":
                    e = this._aabb.halfExtents.x / this._widthRatio / (1 - this.padding) / (1 - (this._device === deviceEnum.DESKTOP ? this.landscapeWidthDesktop : this.landscapeWidthMobile.value(this._heightWidthRatio))), i = this._aabb.halfExtents.y / this._heightRatio / (1 - this.padding) / (1 - (this._device === deviceEnum.DESKTOP ? this.landscapeHeightDesktop : this.landscapeHeightMobile));
                    break;
                default:
                    console.warn("Something went wrong with the orientation", this._orientation)
            }
            var s = e / Math.tan(t / 2 * Math.PI / 180),
                a = i / Math.tan(t / 2 * Math.PI / 180);
            this._radius = Math.max(s, a), this._stopTweens(), this.entity.setLocalEulerAngles(0, 0, 0), this.app.fire("PerspectiveView:onCameraChange", this._radius), this.fire("complete")
        }
    },
    getRadius: function() {
        return this._radius
    },
    getOffset: function() {
        return {
            x: this._aabb.center.x,
            y: this._aabb.center.y,
            z: this._radius
        }
    },
    tweenAngle: function(t, e) {
        if ("number" == typeof t) {
            var i = this._calculatePosition(t),
                s = this.entity.getLocalEulerAngles().x,
                a = Math.abs(s - t);
            if (0 !== a) {
                this._stopTweens(), this._positionTween = this.entity.tween(this.entity.getLocalPosition()).to({
                    x: i.x,
                    y: i.y,
                    z: i.z
                }, a / e, pc.CubicInOut).start();
                var n = this;
                this._rotationTween = this.entity.tween(this.entity.getLocalRotation()).rotate(new pc.Vec3(t, 0, 0), a / e, pc.CubicInOut).start().on("complete", (function() {
                    n.fire("complete")
                }))
            }
        }
    },
    tweenEndAnimation: function() {
        var t = this._calculatePosition(50);
        this._stopTweens();
        var e = this;
        this._positionTween = this.entity.tween(this.entity.getLocalPosition()).to({
            x: t.x,
            y: t.y,
            z: t.z
        }, 2, pc.CubicInOut).start(), this._rotationTween = this.entity.tween(this.entity.getLocalRotation()).rotate(new pc.Vec3(50, 0, 0), 2, pc.CubicInOut).start(), this._parentPositionTween = this.tweenEntity.tween(this.tweenEntity.getLocalPosition()).to({
            x: 0,
            y: this.entity.getLocalPosition().z / 2,
            z: 0
        }, 2, pc.CubicInOut, 1).start().on("complete", (function() {
            e.fire("complete")
        }))
    },
    resetParentPosition: function() {
        this.tweenEntity.setLocalPosition(0, 0, 0)
    },
    _stopTweens: function() {
        this._positionTween &amp;&amp; this._positionTween.stop(), this._rotationTween &amp;&amp; this._rotationTween.stop(), this._parentPositionTween &amp;&amp; this._parentPositionTween.stop()
    },
    setAngle: function(t) {
        this._calculatePosition(t);
        this.entity.setLocalEulerAngles(t, 0, 0)
    },
    _calculatePosition: function(t) {
        var e = new pc.Vec3(this._aabb.center.x, this._aabb.center.y, 0),
            i = this._radius * Math.cos(t * Math.PI / 180),
            s = this._radius * Math.sin(t * Math.PI / 180);
        return e.set(e.x, e.y - s, i), e
    }
});
var LoseScreen = pc.createScript("loseScreen");
LoseScreen.attributes.add("objectiveEntities", {
    type: "entity",
    array: !0
}), LoseScreen.attributes.add("boosterButtonEntities", {
    type: "entity",
    array: !0
}), LoseScreen.attributes.add("retryLevelButton", {
    type: "entity"
}), LoseScreen.attributes.add("buttons", {
    type: "entity"
}), pc.extend(LoseScreen.prototype, {
    initialize: function() {
        this.retryLevelButton.script.elementInput.on(inputEvents.CLICK, this._startLevel, this), this.app.on("StartLevelButton:onLevelStart", this._onLevelStart, this)
    },
    onUIEntityOpen: function() {
        this.buttons.enabled = !1, this.getObjectiveData(), this.getBoosters();
        var t = this;
        this.app.fire("Audio:sfx", "level_lose.mp3"), this.app.fire("AudioManager:stopBgm"), TrackingManager.instance.levelEnd(!1), setTimeout((function() {
            GameManager.instance.trackEventLevelFail(!0).then((function() {
                t.buttons.enabled = !0
            }))
        }), 1e3)
    },
    getBoosters: function() {
        for (var t = 0; t &lt; this.boosterButtonEntities.length; t += 1) this.boosterButtonEntities[t].script.preBoosterButton.getInventoryAmount()
    },
    getObjectiveData: function() {
        for (var t = ObjectiveManager.instance.getObjectives(), e = 0; e &lt; this.objectiveEntities.length; e += 1) {
            if (e &gt;= t.length) return void(this.objectiveEntities[e].enabled = !1);
            this.objectiveEntities[e].enabled = !0, this.objectiveEntities[e].script.popupObjectiveUI.setGoal(t[e].orderTypeObject, t[e].values.goal), this.objectiveEntities[e].script.popupObjectiveUI.setResult(t[e].values.current)
        }
    },
    _startLevel: function() {
        for (var t = 0; t &lt; this.boosterButtonEntities.length; t += 1) this.boosterButtonEntities[t].script.preBoosterButton.activateBooster();
        this.app.fire("Audio:bgm", "ingame_ost_world" + LevelManager.instance.currentChapter + ".mp3"), LevelManager.instance.startLevel(LevelManager.instance.currentLevel, LevelManager.instance.currentChapter, !0)
    }
});
var WinScreen = pc.createScript("winScreen");
WinScreen.attributes.add("nextLevelButton", {
    type: "entity"
}), WinScreen.attributes.add("scoreTextEntity", {
    type: "entity"
}), WinScreen.attributes.add("starsEntities", {
    type: "entity",
    array: !0
}), WinScreen.attributes.add("levelNumberEntity", {
    type: "entity"
}), WinScreen.attributes.add("highscoreTextEntity", {
    type: "entity"
}), WinScreen.attributes.add("buttons", {
    type: "entity"
}), pc.extend(WinScreen.prototype, {
    onUIEntityOpen: function(t) {
        this.app.fire("AudioManager:stopBgm"), this.winSound = AudioManager.instance.playSFX("level_win.mp3"), this.winSound ? this.winSound.once("end", this._playWinBGM, this) : this._playWinBGM();
        var e = this.nextLevelButton.script.bookButton;
        t ? e.setType(e.bookOptions.NEXTCURRENT) : e.setType(e.bookOptions.NEXTREPLAY);
        var n = ScoreManager.instance.getScore();
        this.scoreTextEntity.element.text = n, this.buttons.enabled = !1;
        var i = LevelDataManager.instance.getLevelData(WorldManager.instance.getCurrentWorld(LevelManager.instance.currentLevel), LevelManager.instance.currentLevel),
            s = i ? i.score : 0;
        this.highscoreTextEntity.element.text = null === s ? n : s, this.levelNumberEntity.element.text = "Level " + LevelManager.instance.currentLevel;
        var a = ScoreManager.instance.getStars();
        n &gt; s &amp;&amp; setTimeout(function() {
            this.highscoreTextEntity.element.text = n, this.highscoreTextEntity.parent.script.tweenScale.startTween()
        }.bind(this), 300 + 500 * a);
        a = ScoreManager.instance.getStars();
        for (var r = 0; r &lt; this.starsEntities.length; r += 1) this.starsEntities[r].enabled = a &gt; r, this.starsEntities[r].enabled &amp;&amp; (this.starsEntities[r].script.tweenScale.once("finish", this._playStarSound(r, a), this));
        var o = this;
        TrackingManager.instance.levelEnd(!0), setTimeout((function() {
            GameManager.instance.trackEventLevelSuccess(!0).then((function() {
                o.buttons.enabled = !0
            }))
        }), 500 + 500 * a)
    },
    onUIEntityClose: function() {
        this.winSound &amp;&amp; this.winSound.off("end", this._playWinBGM, this), this.app.fire("WinScreen:close"), this.app.fire("Audio:bgm", "main_ost.mp3")
    },
    _playStarSound: function(t) {
        setTimeout(function() {
            this.app.fire("Audio:sfx", "win_star_" + (t + 1) + ".mp3")
        }.bind(this), 1e3 * this.starsEntities[t].script.tweenScale.startDelay + 300)
    },
    _playWinBGM: function() {
        this.app.fire("Audio:bgm", "level_win_ost.mp3")
    }
});
var MouseInput = pc.createScript("mouseInput");
MouseInput.attributes.add("orbitSensitivity", {
    type: "number",
    default: .3,
    title: "Orbit Sensitivity",
    description: "How fast the camera moves around the orbit. Higher is faster"
}), MouseInput.attributes.add("distanceSensitivity", {
    type: "number",
    default: .15,
    title: "Distance Sensitivity",
    description: "How fast the camera moves in and out. Higher is faster"
}), MouseInput.prototype.initialize = function() {
    if (this.orbitCamera = this.entity.script.orbitCamera, this.orbitCamera) {
        var t = this,
            onMouseOut = function(o) {
                t.onMouseOut(o)
            };
        this.app.mouse.on(pc.EVENT_MOUSEDOWN, this.onMouseDown, this), this.app.mouse.on(pc.EVENT_MOUSEUP, this.onMouseUp, this), this.app.mouse.on(pc.EVENT_MOUSEMOVE, this.onMouseMove, this), this.app.mouse.on(pc.EVENT_MOUSEWHEEL, this.onMouseWheel, this), window.addEventListener("mouseout", onMouseOut, !1), this.on("destroy", (function() {
            this.app.mouse.off(pc.EVENT_MOUSEDOWN, this.onMouseDown, this), this.app.mouse.off(pc.EVENT_MOUSEUP, this.onMouseUp, this), this.app.mouse.off(pc.EVENT_MOUSEMOVE, this.onMouseMove, this), this.app.mouse.off(pc.EVENT_MOUSEWHEEL, this.onMouseWheel, this), window.removeEventListener("mouseout", onMouseOut, !1)
        }))
    }
    this.app.mouse.disableContextMenu(), this.panButtonDown = !1, this.lastPoint = new pc.Vec2
}, MouseInput.fromWorldPoint = new pc.Vec3, MouseInput.toWorldPoint = new pc.Vec3, MouseInput.worldDiff = new pc.Vec3, MouseInput.prototype.pan = function(t) {
    var o = MouseInput.fromWorldPoint,
        e = MouseInput.toWorldPoint,
        s = MouseInput.worldDiff,
        i = this.entity.camera,
        n = this.orbitCamera.distance;
    i.screenToWorld(t.x, t.y, n, o), i.screenToWorld(this.lastPoint.x, this.lastPoint.y, n, e), s.sub2(e, o), this.orbitCamera.pivotPoint.add(s)
}, MouseInput.prototype.onMouseDown = function(t) {
    switch (t.button) {
        case pc.MOUSEBUTTON_MIDDLE:
        case pc.MOUSEBUTTON_RIGHT:
            this.panButtonDown = !0
    }
}, MouseInput.prototype.onMouseUp = function(t) {
    switch (t.button) {
        case pc.MOUSEBUTTON_MIDDLE:
        case pc.MOUSEBUTTON_RIGHT:
            this.panButtonDown = !1
    }
}, MouseInput.prototype.onMouseMove = function(t) {
    pc.app.mouse;
    this.panButtonDown &amp;&amp; this.pan(t), this.lastPoint.set(t.x, t.y)
}, MouseInput.prototype.onMouseWheel = function(t) {
    this.orbitCamera.distance -= t.wheel * this.distanceSensitivity * (.1 * this.orbitCamera.distance), t.event.preventDefault()
}, MouseInput.prototype.onMouseOut = function(t) {
    this.panButtonDown = !1
};
var OutOfMovesScreen = pc.createScript("outOfMovesScreen");
OutOfMovesScreen.attributes.add("objectiveEntities", {
    type: "entity",
    array: !0
}), OutOfMovesScreen.attributes.add("addMovesButton", {
    type: "entity"
}), OutOfMovesScreen.attributes.add("addMovesPriceText", {
    type: "entity"
}), OutOfMovesScreen.attributes.add("addMovesPrice", {
    type: "number"
}), pc.extend(OutOfMovesScreen.prototype, {
    initialize: function() {
        this.addMovesButton.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    onUIEntityOpen: function() {
        GridManager.instance.active(!1), this.getObjectiveData(), this.app.fire("UIManager:showUI", "Coins"), this.addMovesPriceText.element.text = this.addMovesPrice
    },
    onUIEntityClose: function() {
        this.app.fire("UIManager:hideUI", "Coins")
    },
    getObjectiveData: function() {
        for (var e = ObjectiveManager.instance.getObjectives(), t = 0; t &lt; this.objectiveEntities.length; t += 1) {
            if (t &gt;= e.length) return void(this.objectiveEntities[t].enabled = !1);
            this.objectiveEntities[t].enabled = !0, this.objectiveEntities[t].script.popupObjectiveUI.setGoal(e[t].orderTypeObject, e[t].values.goal), this.objectiveEntities[t].script.popupObjectiveUI.setResult(e[t].values.current)
        }
    },
    _onClick: function() {
        Inventory.instance.tryPayItem("COINS", this.addMovesPrice) ? (this.app.fire("Audio:sfx", "coin_pay.mp3"), MovesManager.instance.addMoves(5), this.app.fire("UIManager:hideAll"), this.app.fire("UIManager:showUI", "Game"), this.app.fire("CoinInterface:updateCoins"), this.app.fire("GameInput:toggleGameInput", !0)) : this.app.fire("UIManager:showUI", "BoosterShop")
    }
});
var LevelDataExporter = function() {
    this.initialize()
};
pc.extend(LevelDataExporter.prototype, {
    initialize: function() {
        this.app = pc.Application.getApplication(), this.app.on("LevelLoader:levelsLoaded", this.getAllAssets, this)
    },
    getAllAssets: function() {
        for (var e = this.app.assets.findByTag("level"), t = {}, n = 0; n &lt; e.length; n++) {
            var o = e[n],
                r = {};
            if (o.resource) {
                for (var a = o.resource.levelSettings.triggers, i = 0; i &lt; a.length; i++) {
                    var l = a[i];
                    if (1 === l.consequence)
                        for (var s = 0; s &lt; l.conditions.length; s++) {
                            for (var c = (v = l.conditions[s]).name.split(" "), p = ""; !p &amp;&amp; c.length &gt; 0;) p = c.pop();
                            r[p || "turns"] = v.maxSetting
                        } else
                            for (var g = 0; g &lt; l.conditions.length; g++) {
                                var v;
                                for (c = (v = l.conditions[g]).name.split(" "), p = ""; !p &amp;&amp; c.length &gt; 0;) p = c.pop();
                                switch (p) {
                                    case "default":
                                        for (var f = 0; f &lt; v.elements.length; f++) {
                                            var h = v.elements[f];
                                            r["default_" + ColorManager.instance.getColorInOrder(h.color)] = v.maxSetting
                                        }
                                        break;
                                    default:
                                        r[p || "turns"] = v.maxSetting
                                }
                            }
                }
                var d = o.name.replace("level_", "").replace(".json", "");
                t[d] = r
            }
        }
        var u = {};
        Object.keys(t).sort().forEach((function(e) {
            u[e] = t[e]
        })), console.log(u), console.log(JSON.stringify(u))
    }
});
var DynamicElementSize = pc.createScript("dynamicElementSize"),
    defaultString = "------------------------------------------------------";
DynamicElementSize.attributes.add("a", {
    type: "string",
    title: "Desktop Landscape",
    default: defaultString
}), DynamicElementSize.attributes.add("desktopLandscapeSize", {
    type: "vec2",
    title: "Size"
}), DynamicElementSize.attributes.add("b", {
    type: "string",
    title: "Desktop Portrait",
    default: defaultString
}), DynamicElementSize.attributes.add("desktopPortraitSize", {
    type: "vec2",
    title: "Size"
}), DynamicElementSize.attributes.add("c", {
    type: "string",
    title: "Mobile Landscape",
    default: defaultString
}), DynamicElementSize.attributes.add("mobileLandscapeSize", {
    type: "vec2",
    title: "Size"
}), DynamicElementSize.attributes.add("d", {
    type: "string",
    title: "Mobile Portrait",
    default: defaultString
}), DynamicElementSize.attributes.add("mobilePortraitSize", {
    type: "vec2",
    title: "Size"
}), pc.extend(DynamicElementSize.prototype, {
    initialize: function() {
        this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _onResize: function(t, e, i, n) {
        return n === deviceEnum.DESKTOP ? t === orientationEnum.LANDSCAPE ? void this._applyOrientation(this.desktopLandscapeSize) : t === orientationEnum.PORTRAIT ? void this._applyOrientation(this.desktopPortraitSize) : void console.warn("Orientation", this._orientation, "is not recognized!") : n === deviceEnum.MOBILE ? t === orientationEnum.LANDSCAPE ? void this._applyOrientation(this.mobileLandscapeSize) : t === orientationEnum.PORTRAIT ? void this._applyOrientation(this.mobilePortraitSize) : void console.warn("Orientation", this._orientation, "is not recognized!") : void 0
    },
    _applyOrientation: function(t) {
        this.entity.element.width = t.x, this.entity.element.height = t.y
    }
});
var TutorialInterface = pc.createScript("tutorialInterface");
TutorialInterface.attributes.add("picture", {
    type: "entity"
}), TutorialInterface.attributes.add("topBubble", {
    type: "json",
    schema: [{
        name: "bubbleEntity",
        type: "entity"
    }, {
        name: "textEntity",
        type: "entity"
    }]
}), TutorialInterface.attributes.add("bottomBubble", {
    type: "json",
    schema: [{
        name: "bubbleEntity",
        type: "entity"
    }, {
        name: "textEntity",
        type: "entity"
    }]
}), pc.extend(TutorialInterface.prototype, {
    initialize: function() {},
    initializeSingleSentence: function() {},
    converstation: function(t, e) {
        var i = e.images[t.image],
            n = i.resource.atlas.frames[i.resource.frameKeys[0]].rect;
        this.picture.element.spriteAsset = i, this.picture.element.width = n.z, this.picture.element.height = n.w, this.displaySentence(t.text)
    },
    displaySentence: function(t) {
        this._textAvailable = "string" != typeof LocalizationManager.instance.get(t) || "" !== LocalizationManager.instance.get(t), LocalizationManager.instance.setText(this.topBubble.textEntity, t), LocalizationManager.instance.setText(this.bottomBubble.textEntity, t)
    },
    hideDialogBox: function() {
        var t = this.picture.getLocalPosition().clone();
        if (this.entity.enabled) {
            var e = UIManager.instance.getReferenceResolution().y / window.innerHeight,
                i = window.innerWidth * e / 2;
            this.picture.tween(this.picture.getLocalPosition()).to({
                x: t.x + i,
                y: t.y,
                z: t.z
            }, .5, pc.SineOut).start().on("complete", function() {
                this.entity.enabled = !1, this.picture.setLocalPosition(t.x, t.y, t.z)
            }.bind(this)), this.topBubble.bubbleEntity.tween(this.topBubble.bubbleEntity.getLocalScale()).to({
                x: 0,
                y: 0,
                z: 0
            }, .2, pc.BackIn).start(), this.bottomBubble.bubbleEntity.tween(this.bottomBubble.bubbleEntity.getLocalScale()).to({
                x: 0,
                y: 0,
                z: 0
            }, .2, pc.BackIn).start()
        } else this.entity.enabled = !1
    },
    displayDialogBox: function() {
        var t = UIManager.instance.getReferenceResolution().y / window.innerHeight,
            e = window.innerWidth * t / 2,
            i = this.picture.getLocalPosition().clone();
        this.picture.setLocalPosition(i.x + e, i.y, i.z);
        this.picture.tween(this.picture.getLocalPosition()).to({
            x: i.x,
            y: i.y,
            z: i.z
        }, .5, pc.SineOut).start();
        this.topBubble.bubbleEntity.setLocalScale(0, 0, 0), this.bottomBubble.bubbleEntity.setLocalScale(0, 0, 0);
        this.topBubble.bubbleEntity.tween(this.topBubble.bubbleEntity.getLocalScale()).to({
            x: 1,
            y: 1,
            z: 1
        }, .3, pc.BackOut, .5).start(), this.bottomBubble.bubbleEntity.tween(this.bottomBubble.bubbleEntity.getLocalScale()).to({
            x: 1,
            y: 1,
            z: 1
        }, .3, pc.BackOut, .5).start();
        this.entity.enabled = !0
    },
    enableOverlay: function(t) {},
    setTopOrBottomBubble: function(t) {
        this.topBubble.bubbleEntity.enabled = "top" === t &amp;&amp; this._textAvailable, this.bottomBubble.bubbleEntity.enabled = "bottom" === t &amp;&amp; this._textAvailable
    },
    toggleSkip: function(t) {}
});
var FirstTimeUserManager = pc.createScript("firstTimeUserManager"),
    disableEnum = {
        disableButton: 0,
        disappear: 1
    },
    disableOptions = [{
        disableButton: disableEnum.disableButton
    }, {
        disappear: disableEnum.disappear
    }];
FirstTimeUserManager.attributes.add("lockableEntities", {
    type: "json",
    schema: [{
        name: "entity",
        type: "entity",
        array: !0
    }, {
        name: "unlockLevel",
        type: "number",
        default: 0,
        description: "Unlock when you are on this specific level"
    }, {
        name: "key",
        type: "string"
    }, {
        name: "type",
        type: "number",
        enum: disableOptions
    }],
    array: !0
}), FirstTimeUserManager.attributes.add("disableOpacity", {
    type: "number",
    default: .5
}), pc.extend(FirstTimeUserManager.prototype, {
    postInitialize: function() {
        FirstTimeUserManager.instance = this, this.checkEntities()
    },
    checkEntities: function() {
        for (var t in this.lockableEntities) switch (this.lockableEntities[t].type) {
            case disableEnum.disableButton:
                this._checkButton(this.lockableEntities[t]);
                break;
            case disableEnum.disappear:
                this._checkAppearance(this.lockableEntities[t])
        }
    },
    checkItem: function(t) {
        for (var e in this.lockableEntities)
            if (this.lockableEntities[e].key === t) switch (this.lockableEntities[e].type) {
                case disableEnum.disableButton:
                    this._checkButton(this.lockableEntities[e]);
                    break;
                case disableEnum.disappear:
                    this._checkAppearance(this.lockableEntities[e])
            }
    },
    unlockItem: function(t) {
        for (var e in this.lockableEntities)
            if (this.lockableEntities[e].key === t) switch (this.lockableEntities[e].type) {
                case disableEnum.disableButton:
                    this._enableButton(this.lockableEntities[e]);
                    break;
                case disableEnum.disappear:
                    this._appear(this.lockableEntities[e])
            }
    },
    lockItem: function(t) {
        for (var e in this.lockableEntities)
            if (this.lockableEntities[e].key === t) switch (this.lockableEntities[e].type) {
                case disableEnum.disableButton:
                    this._disableButton(this.lockableEntities[e]);
                    break;
                case disableEnum.disappear:
                    this._disappear(this.lockableEntities[e])
            }
    },
    checkDisappear: function() {
        for (var t in this.lockableEntities) this.lockableEntities[t].type === disableEnum.disappear &amp;&amp; this._checkAppearance(this.lockableEntities[t])
    },
    _checkButton: function(t) {
        t.unlockLevel &lt;= LevelDataManager.instance.getCurrentLevel() ? this._enableButton(t) : this._disableButton(t)
    },
    _disableButton: function(t) {
        for (var e = 0; e &lt; t.entity.length; e++) t.entity[e].script.preBoosterButton ? t.entity[e].script.preBoosterButton.activate(!1) : t.entity[e].script.boosterButton ? t.entity[e].script.boosterButton.activate(!1) : t.entity[e].script.boosterShopItem &amp;&amp; t.entity[e].script.boosterShopItem.activate(!1)
    },
    _enableButton: function(t) {
        for (var e = 0; e &lt; t.entity.length; e++) t.entity[e].script.preBoosterButton ? t.entity[e].script.preBoosterButton.activate(!0) : t.entity[e].script.boosterButton ? t.entity[e].script.boosterButton.activate(!0) : t.entity[e].script.boosterShopItem &amp;&amp; t.entity[e].script.boosterShopItem.activate(!0)
    },
    _checkAppearance: function(t) {
        t.unlockLevel &lt;= LevelDataManager.instance.getCurrentLevel() ? this._appear(t) : this._disappear(t)
    },
    _disappear: function(t) {
        for (var e = 0; e &lt; t.entity.length; e++) t.entity[e].enabled = !1
    },
    _appear: function(t) {
        for (var e = 0; e &lt; t.entity.length; e++) t.entity[e].enabled = !0
    }
});
var SettingsBackground = pc.createScript("settingsBackground");
pc.extend(SettingsBackground.prototype, {
    initialize: function() {
        this.hamburgerButton = this.entity.parent.script.hamburgerMenu, this.hamburgerButton.on("MenuToggle", this.onMenuToggle, this), this.entity.element.width = 0
    },
    onMenuToggle: function(t) {
        for (var n = 1, e = 0; e &lt; this.hamburgerButton.content.length; e += 1) null !== this.hamburgerButton.content[e].parent &amp;&amp; (n += 1);
        var i = t ? n * this.hamburgerButton.unfoldDistance - 20 : 0;
        this.app.tween(this.entity.element).to({
            width: i
        }, this.hamburgerButton.unfoldDuration, pc.SineOut).start()
    }
});
var AsyncScoreManager = pc.createScript("asyncScoreManager");
pc.extend(AsyncScoreManager.prototype, {
    initialize: function() {
        this.app.on("AsyncScoreManager:setScore", this._setScore, this), this.app.on("AsyncScoreManager:reset", this._resetScore, this), this.app.on("LevelManager:onLevelStart", this._resetScore, this), this.app.on("SwapMode:onWait", this._checkScore, this), this._resetScore()
    },
    _resetScore: function() {
        this.currentScore = 0
    },
    _setScore: function(e) {
        LevelManager.instance.playing &amp;&amp; (this.currentScore += e, this.app.fire("AsyncScoreManager:showScore", this.currentScore))
    },
    _checkScore: function() {
        var e = ScoreManager.instance.getScore();
        e !== this.currentScore &amp;&amp; LevelManager.instance.playing &amp;&amp; (console.warn("Missing score visual! ScoreManager:" + e + " AsyncScoreManager: " + this.currentScore), this.currentScore = e)
    }
});
var UnlockLevelsButton = pc.createScript("unlockLevelsButton");
UnlockLevelsButton.attributes.add("newCurrentLevel", {
    type: "number"
}), pc.extend(UnlockLevelsButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onClick: function() {
        LevelDataManager.instance.cheat(this.newCurrentLevel - 1), Inventory.instance.addItem("COINS", 1e6)
    }
});
var GameScreen = pc.createScript("gameScreen");
GameScreen.attributes.add("endMode", {
    type: "entity"
}), pc.extend(GameScreen.prototype, {
    initialize: function() {},
    onUIEntityOpen: function() {
        GridManager.instance &amp;&amp; GridManager.instance.active(!0), this.endMode.script.endModeVisuals.hideAll()
    },
    onUIEntityClose: function() {
        GridManager.instance &amp;&amp; GridManager.instance.active(!1)
    }
});
var ModelToUIManager = pc.createScript("modelToUimanager");
ModelToUIManager.attributes.add("screen", {
    type: "entity"
}), ModelToUIManager.attributes.add("elementFollower", {
    type: "entity"
}), ModelToUIManager.attributes.add("size", {
    type: "curve"
}), ModelToUIManager.attributes.add("sizeMultiplier", {
    type: "number",
    default: .5
}), ModelToUIManager.attributes.add("speed", {
    type: "number",
    default: 1600
}), ModelToUIManager.attributes.add("startTime", {
    type: "number",
    default: .1
}), ModelToUIManager.attributes.add("deltaDuration", {
    type: "number",
    default: .05
}), pc.extend(ModelToUIManager.prototype, {
    initialize: function() {
        this.app.on("ModelToUIManager:showAnimation", this._showAnimation, this), this.app.on("PerspectiveView:onCameraChange", this._onCameraChange, this), this._objectPool = this.entity.script.objectPool, this._delay = 0, this.app.on("SwapMode:onCascadeDone", this._resetDuration, this), this.app.on("SwapMode:onTileMatch", this._resetDuration, this), this.app.on("ConfirmLeaveGameButton:leave", this._resetDuration, this), this.on("destroy", this._onDestroy, this), this._array = []
    },
    _resetDuration: function() {
        this._delay = 0
    },
    _onDestroy: function() {
        this.app.off("ModelToUIManager:showAnimation", this._showAnimation, this), this.app.off("PerspectiveView:onCameraChange", this._onCameraChange, this), this.app.off("SwapMode:onCascadeDone", this._resetDuration, this), this.app.off("SwapMode:onTileMatch", this._resetDuration, this), this.app.off("ConfirmLeaveGameButton:leave", this._resetDuration, this)
    },
    _onCameraChange: function() {
        this._cameraPosition = PerspectiveView.instance.entity.parent.getLocalPosition()
    },
    _showAnimation: function(e, t, a) {
        if (LevelManager.instance.playing) {
            isNaN(a) &amp;&amp; (console.error("No delay is found:", a), a = this._delay);
            var i = this._objectPool.use(),
                o = new pc.Vec3,
                n = TileLibrary.instance.getTileSprite(t),
                s = this.size.value(this._cameraPosition.z / 100) * this.sizeMultiplier;
            i.element.spriteAsset = n, i.element.width = s, i.element.height = s, i.setLocalScale(1, 1, 1);
            var r = UIManager.instance.getScale(),
                l = (this.app.graphicsDevice, (this.screen.element.width - this.screen.parent.element.width) / 2);
            PerspectiveView.instance.entity.camera.worldToScreen(e, o), o.scale(window.devicePixelRatio), i.reparent(this.screen), i.setLocalPosition(o.x / r - l, -o.y / r, 0), i.enabled = !0;
            var h = this,
                c = this.elementFollower.script.elementFollower.getLocalPosition(),
                p = c.x - e.x,
                d = c.y - e.y,
                u = (Math.sqrt(p * p + d * d), this.startTime + .2),
                y = 0;
            a - this._delay &lt; this.deltaDuration &amp;&amp; (y = this.deltaDuration - (a - this._delay)), this._delay = a + y, u += y;
            var m = i.tween(i.getLocalScale()).to({
                x: 2,
                y: 2,
                z: 2
            }, u, pc.Linear).yoyo(!0).loop(!0).start();
            i.tween(i.getLocalPosition()).to({
                x: c.x,
                y: c.y,
                z: c.z
            }, 2 * u, pc.BackIn).start().on("complete", (function() {
                m.stop(), i.enabled = !1, h._objectPool.recycle(i), ObjectiveManager.instance.onObjectiveAdd(t.layerID, t.typeID, t.colorID)
            }))
        }
    }
});
var UitoUimanager = pc.createScript("uitoUimanager");
UitoUimanager.attributes.add("screen", {
    type: "entity"
}), UitoUimanager.attributes.add("elementFollower", {
    type: "entity"
}), UitoUimanager.attributes.add("elementFollower2", {
    type: "entity"
}), UitoUimanager.attributes.add("object", {
    type: "entity"
}), UitoUimanager.attributes.add("speed", {
    type: "number",
    default: 1600
}), UitoUimanager.attributes.add("delay", {
    type: "number",
    default: .2
});
var animationStages = Object.freeze({
    IDLE: 0,
    PREPERATION: 1,
    ANIMATE: 2,
    DONE: 3
});
pc.extend(UitoUimanager.prototype, {
    initialize: function() {
        this.app.on("UitoUimanager:showAnimation", this._showAnimation, this), this.setStart = !1, this.currentDelayTimer = 0, this.currentState = animationStages.IDLE, this.callback = null
    },
    update: function(t) {
        this.currentState === animationStages.PREPERATION &amp;&amp; this.currentDelayTimer &lt; this.delay ? (this.currentDelayTimer += t, this.startPosition = this.elementFollower2.script.elementFollower.getLocalPosition(), this.object.setLocalPosition(this.startPosition)) : this.currentState === animationStages.PREPERATION &amp;&amp; this._switchState(animationStages.ANIMATE), this.currentState, animationStages.ANIMATE
    },
    _showAnimation: function(t, e) {
        this.callback = e, this.elementFollower2.script.elementFollower.updateTarget(t), this._switchState(animationStages.PREPERATION)
    },
    _prepareAnimation: function() {
        this.object.enabled = !1, this.object.reparent(this.screen)
    },
    _animateObject: function() {
        this.object.enabled = !0, this.currentDelayTimer = 0, this.setStart = !1, this.endPosition = this.elementFollower.script.elementFollower.getLocalPosition();
        var t = this.endPosition.x - this.startPosition.x,
            e = this.endPosition.y - this.startPosition.y,
            i = Math.sqrt(t * t + e * e);
        this.duration = this.delay + i / this.speed, this._scaleObject(this.duration), this._moveObject(this.duration)
    },
    _animationDone: function() {
        this.scaleTween.stop(), this.object.enabled = !1, this.callback(), this.callback = null
    },
    _scaleObject: function(t) {
        this.scaleTween = this.object.tween(this.object.getLocalScale()).to({
            x: 1.5,
            y: 1.5,
            z: 1.5
        }, t, pc.Linear).yoyo(!0).loop(!0).start()
    },
    _moveObject: function(t) {
        var e = this;
        this.object.tween(this.object.getLocalPosition()).to({
            x: this.endPosition.x,
            y: this.endPosition.y,
            z: this.endPosition.z
        }, 2 * t, pc.BackIn).start().on("complete", (function() {
            e._switchState(animationStages.DONE)
        }))
    },
    _switchState: function(t) {
        switch (this.currentState = t, this.currentState) {
            case animationStages.PREPERATION:
                this._prepareAnimation();
                break;
            case animationStages.ANIMATE:
                this._animateObject();
                break;
            case animationStages.DONE:
                this._animationDone(), this._switchState(animationStages.IDLE)
        }
    }
});
var DropperExitManager = pc.createScript("dropperExitManager");
pc.extend(DropperExitManager.prototype, {
    initialize: function() {
        DropperExitManager.instance = this, this.dropperExitPool = TilePrefabManager.instance.getObjectPool("DropperExitObjectPool"), this.exitVisuals = []
    },
    setExits: function(e, i) {
        if (i)
            for (var t = 0; t &lt; e.length; t += 1) {
                var r = this.dropperExitPool.use();
                this.exitVisuals.push(r), r.enabled = !0, r.reparent(GridManager.instance.entity);
                var a = GridManager.instance.calculatePosition(e[t].x, e[t].y - .5, GridManager.instance.radius - .8);
                r.setLocalPosition(a)
            }
    },
    removeExits: function() {
        for (var e = 0; e &lt; this.exitVisuals.length; e += 1) this.dropperExitPool.recycle(this.exitVisuals[e]);
        this.exitVisuals.length = 0
    }
});
var ElementFollower = pc.createScript("elementFollower");
ElementFollower.attributes.add("target", {
    type: "entity"
}), pc.extend(ElementFollower.prototype, {
    initialize: function() {},
    updateTarget: function(t) {
        this.target = t
    },
    update: function() {
        this.target &amp;&amp; this.entity.setPosition(this.target.getPosition())
    },
    getLocalPosition: function() {
        return this.entity.setPosition(this.target.getPosition()), this.entity.getLocalPosition()
    }
});
var DropperCollection = pc.createScript("dropperCollection");
DropperCollection.attributes.add("droppers", {
    type: "json",
    schema: [{
        name: "petalModel",
        type: "asset"
    }, {
        name: "petalMaterial",
        type: "asset",
        assetType: "material"
    }],
    array: !0
}), pc.extend(DropperCollection.prototype, {
    initialize: function() {
        this.doIdleCountdown = !1, this.active = !1, this.app.on("SwapMode:onCascadeDone", this.startIdleCountdown, this)
    },
    update: function(t) {
        this.doIdleCountdown &amp;&amp; (this.superClass._recycled &amp;&amp; (this.stopIdleCountdown(), this.stopIdleTween()), this.idleCountdown += t, this.idleCountdown &gt;= this.idleCountdownDuration &amp;&amp; (this.startIdleAnimation(), this.stopIdleCountdown()))
    },
    init: function(t) {
        this.superClass = t, this.superClass.typeID = foregroundTileEnum.DROPPER_COLLECTION
    },
    awake: function() {
        this.worldIndex = pc.math.clamp(WorldManager.instance.getWorldIndex() - 1, 0, this.droppers.length - 1), this._changeDropper()
    },
    explode: function() {
        return this.stopIdleCountdown(), this.app.fire("ScoreManager:scoreForegroundTile", this.superClass.typeID, !0, this.superClass), GridManager.instance.playSFX("dropper_deliver.mp3"), this.superClass.despawn(), this.superClass.setDespawnEndPosition(this.superClass.x, this.superClass.y - 1), !0
    },
    onAwake: function() {
        this.startIdleCountdown()
    },
    appear: function() {
        this.stopTween()
    },
    move: function() {
        this.stopTween()
    },
    applyGravity: function() {
        this.stopTween()
    },
    stopTween: function() {
        this.stopIdleCountdown(), this.stopIdleTween()
    },
    startIdleAnimation: function() {
        var t = GridManager.instance.calculatePosition(this.superClass.x, this.superClass.y, .2);
        this.idleTween = this.entity.tween(this.entity.getLocalPosition()).to({
            x: t.x,
            y: t.y - .1,
            z: t.z
        }, .2, pc.SineInOut).yoyo(!0).repeat(4).on("complete", function() {
            this.startIdleCountdown(), this.idleTween = null
        }.bind(this), this).start()
    },
    startIdleCountdown: function() {
        this.idleCountdown = 0;
        this.idleCountdownDuration = 5 * Math.random() + 5, this.doIdleCountdown = !0
    },
    stopIdleCountdown: function() {
        this.doIdleCountdown = !1
    },
    stopIdleTween: function() {
        this.idleTween &amp;&amp; (this.idleTween.stop(), this.idleTween = null, this.resetPosition())
    },
    resetPosition: function() {
        var t = GridManager.instance.calculatePosition(this.superClass.x, this.superClass.y, 0);
        this.entity.setLocalPosition(t)
    },
    recycle: function() {
        this.stopIdleCountdown(), this.stopIdleTween(), this.active = !1
    },
    _changeDropper: function() {
        var t = this.worldIndex,
            e = this.droppers[t].petalModel,
            s = this.droppers[t].petalMaterial,
            n = this.superClass._hightLightModel;
        n.model.asset = e;
        for (var o = n.model.meshInstances, i = 0; i &lt; o.length; i++) {
            o[i].material = s.resource
        }
        this.superClass._model.model.asset = e
    }
});
Locker = pc.createScript("locker"), pc.extend(Locker.prototype, {
    initialize: function() {
        this.parent = null, this._explode = !1, this.animationController = this.entity.script.tileAnimationController, this.animationController.on("explode", this._onExplodeAnimation, this), this.animationController.on("complete", this._onCompleteAnimation, this)
    },
    despawnInstant: function() {
        this._explode = !0
    },
    init: function(t) {
        this.parent = t, this.parent.typeID = backgroundTileEnum.LOCKER
    },
    recycle: function() {
        this._explode ? console.warn("already recycled") : (this._explode = !0, this.entity.objectPool.recycle(this.entity))
    },
    awake: function() {
        this.parent.hasExploded = !1, this._explode = !1, this.parent._modelComponent.entity.enabled = !0, this.animationController.setLayer(this.parent.currentLayer - 1)
    },
    explode: function(t) {
        return this.parent.hasExploded ? (this.animationController.playExplode(this.parent.currentLayer, t, !0), !0) : (this.parent._onLayerExplode(), this.parent.currentLayer--, this.animationController.playExplode(this.parent.currentLayer, t), this.parent.hasExploded = !0, 0 === this.parent.currentLayer &amp;&amp; (this.parent.isDestroyed = !0), !0)
    },
    _onExplodeAnimation: function(t) {
        this.stopShakeTile();
        var e = 0 === this.parent.currentLayer;
        this.parent._onExplode(e, t.delay, !0), e ? GridManager.instance.playSFX("ice_destroy.mp3") : GridManager.instance.playSFX("ice_hit.mp3")
    },
    _onCompleteAnimation: function() {
        this.recycle()
    },
    getDespawnDelay: function() {
        this.animationController.getDespawnDelay()
    },
    doHintAnimation: function() {
        this.stopHintAnimation(), this._isPlayingHint = !0;
        var t = 0;
        this.hintTween = this.entity.tween(this.entity.getLocalScale()).to({
            x: 1.1,
            y: 1.1,
            z: 1
        }, .5, pc.SineInOut).loop(!0).yoyo(!0).start().on("loop", function() {
            this.hintMoveTween &amp;&amp; ++t % (2 * this.hintMoveLoops) == 0 &amp;&amp; this.repeatHintMove(), this._isPlayingHint || (this.hintTween.stop(), this.hintMoveTween &amp;&amp; (this.hintMoveTween.stop(), this.hintMoveTween = null))
        }.bind(this))
    },
    stopHintAnimation: function() {
        this._isPlayingHint &amp;&amp; (this._isPlayingHint = !1, this.hintTween.stop(), this.entity.setLocalScale(pc.Vec3.ONE), this.hintMoveTween &amp;&amp; (this.hintMoveTween.stop(), this.hintMoveTween = null))
    },
    shakeTile: function(t) {
        t = t || 0, this.rotation = this.entity.getLocalEulerAngles().clone(), this.entity.setLocalEulerAngles(this.rotation.x, this.rotation.y, -5), this.shakeTween = this.entity.tween(this.entity.getLocalRotation()).rotate({
            x: this.rotation.x,
            y: this.rotation.y,
            z: 5
        }, .1, pc.SineInOut).loop(!0).yoyo(!0).delay(t).start()
    },
    stopShakeTile: function() {
        this.shakeTween &amp;&amp; (this.entity.setLocalEulerAngles(this.rotation.x, this.rotation.y, this.rotation.z), this.shakeTween.stop())
    },
    stopAllTweens: function() {
        this.stopHintAnimation(), this.stopShakeTile()
    }
});
var ComicInterface = pc.createScript("comicInterface"),
    worldEnum = Object.freeze({
        WORLD_1: 0,
        WORLD_2: 1,
        WORLD_3: 2,
        WORLD_4: 3,
        WORLD_5: 4,
        WORLD_6: 5,
        WORLD_7: 6,
        WORLD_8: 7,
        WORLD_9: 8,
        WORLD_10: 9
    });
ComicInterface.attributes.add("scrollbar", {
    type: "entity"
}), ComicInterface.attributes.add("scrollView", {
    type: "entity"
}), ComicInterface.attributes.add("dotPrefab", {
    type: "entity"
}), ComicInterface.attributes.add("navigation", {
    type: "entity"
}), ComicInterface.attributes.add("panelContainer", {
    type: "entity"
}), ComicInterface.attributes.add("panel", {
    type: "asset",
    assetType: "template"
}), ComicInterface.attributes.add("content", {
    type: "entity"
}), ComicInterface.attributes.add("chapterText", {
    type: "entity"
}), ComicInterface.attributes.add("prevButton", {
    type: "entity"
}), ComicInterface.attributes.add("nextButton", {
    type: "entity"
}), pc.extend(ComicInterface.prototype, {
    initialize: function() {
        ComicInterface.instance = this, this.dots = [], this.scrollbar.scrollbar.value = 1, this.totalWidth = 0, this.nextButton.script.elementInput.on(inputEvents.CLICK, this.nextSlide, this), this.prevButton.script.elementInput.on(inputEvents.CLICK, this.previousSlide, this), this.scrollView.scrollview.on("set:scroll", this.scroll, this), this.app.on("ComicInterface:showUnlockedComic", this.showUnlockedComic, this), this.app.on("ComicInterface:showComic", this.showComic, this), this.scrollIItem = new pc.Entity, this.lastPosition = 0, this.isMoving = !1, this.app.mouse.on(pc.EVENT_MOUSEWHEEL, this.onMouseWheel, this)
    },
    update: function() {
        this.content.getLocalPosition().x - this.lastPosition &gt;= 1 || this.content.getLocalPosition().x - this.lastPosition &lt;= -1 &amp;&amp; this.isMoving ? this.lastPosition = this.content.getLocalPosition().x : this.isMoving &amp;&amp; (this.isMoving = !1, this.centerComic(this.currentPanel))
    },
    showUnlockedComic: function(t, i) {
        this.setComic(t), this.app.fire("UIManager:showUI", "Comic"), this.setStartLocation(i), this.centerComic(i, 1, this.showImage.bind(this)), this.lockLatestPanel(i)
    },
    showComic: function(t, i) {
        this.setComic(t), this.app.fire("UIManager:showUI", "Comic"), this.setStartLocation(i)
    },
    makePanel: function(t, i, e) {
        var n = this.panel.resource.instantiate();
        this.panelContainer.addChild(n), this.panels.push(n), n.element.spriteAsset = t, this.itemWidth = n.element.width, this.totalHeight = n.element.height, this.totalWidth = this.totalWidth ? this.totalWidth + this.itemWidth : this.itemWidth, n.script.backToPage.pageID = e, n.script.backToPage.worldID = this.worldID, n.script.backToPage.isUnlocked = i, n.button.active = i
    },
    setComic: function(t) {
        this.panels = [], this.worldID = t, this._resetContainer();
        for (var i = WorldManager.instance.getWorldData(t), e = 0; e &lt; i.comics.length; e++) {
            var n = LevelDataManager.instance.getPartsData(t);
            this.makePanel(i.comics[e], e &lt;= n, e)
        }
        this.chapterText.element.color = WorldManager.instance.getWorldTextColor(this.worldID), LocalizationManager.instance.setText(this.chapterText, i.name), this.comicLength = i.comics.length, this.calculateContentWidth(this.comicLength), this.generateDots(this.comicLength)
    },
    setStartLocation: function(t) {
        this.highLightDot(t), this.currentPanel = t;
        var i = this.content.element.width - this.scrollView.element.width,
            e = t * (this.panelContainer.layoutgroup.spacing.x + this.itemWidth) / (i / 100) / 100;
        this.scrollbar.scrollbar.value = e, this.scroll()
    },
    centerComic: function(t, i, e) {
        this.currentPanel = t;
        var n = this.content.element.width - this.scrollView.element.width,
            o = t * (this.panelContainer.layoutgroup.spacing.x + this.itemWidth) / (n / 100) / 100;
        this.tweenTo(o, i, e)
    },
    tweenTo: function(t, i, e) {
        i = i || 0, this.tweenAnimation = this.app.tween(this.scrollbar.scrollbar).to({
            value: t
        }, .3, pc.SineOut).delay(i).start().on("complete", function() {
            e &amp;&amp; e()
        }.bind(this))
    },
    calculateContentWidth: function(t) {
        this.panelContainer.element.width = this.totalWidth + this.panelContainer.layoutgroup.padding.x + this.panelContainer.layoutgroup.padding.z + this.panelContainer.layoutgroup.spacing.x * (t - 1), this.panelContainer.element.height = this.totalHeight + this.panelContainer.layoutgroup.padding.y + this.panelContainer.layoutgroup.padding.w, this.content.element.width = this.panelContainer.element.width, this.scrollView.element.width = this.itemWidth + 2 * this.panelContainer.layoutgroup.spacing.x
    },
    _resetContainer: function() {
        if (this.totalWidth = 0, this.panelContainer.children.length &gt; 0)
            for (var t = this.panelContainer.children.length - 1; t &gt;= 0; t--) "Untitled" !== this.panelContainer.children[t].name &amp;&amp; this.panelContainer.children[t].destroy();
        if (this.navigation.children.length &gt; 0) {
            this.dots = [];
            for (var i = this.navigation.children.length - 1; i &gt;= 0; i--) "Untitled" !== this.navigation.children[i].name &amp;&amp; this.navigation.children[i].destroy()
        }
    },
    lockLatestPanel: function(t) {
        this.panels[t].element.color = pc.Color.BLACK, this.lockedPanel = t
    },
    showImage: function() {
        var t = new pc.Color(0, 0, 0);
        this.app.tween(t).to(pc.Color.WHITE, 1, pc.Linear).on("update", function() {
            this.panels[this.lockedPanel].element.color = t
        }.bind(this)).start()
    },
    scroll: function() {
        for (var t = this.scrollbar.scrollbar.value, i = 0, e = 0; e &lt; this.comicLength; e++) {
            var n = this.content.element.width - this.scrollView.element.width;
            t &gt;= (e * (this.panelContainer.layoutgroup.spacing.x + this.itemWidth) - this.itemWidth / 2) / (n / 100) / 100 &amp;&amp; (i = e)
        }
        this.currentPanel !== i &amp;&amp; (this.currentPanel = i, this.highLightDot(this.currentPanel))
    },
    generateDots: function(t) {
        for (var i, e = 0; e &lt; t; e++)(i = this.dotPrefab.clone()).enabled = !0, this.changeOpacity(i, 0 !== e), this.navigation.addChild(i), this.dots.push(i);
        this.navigation.element.width = i.element.width * t + this.navigation.layoutgroup.spacing.x * t
    },
    changeOpacity: function(t, i) {
        t.element.opacity = i ? .5 : 1
    },
    highLightDot: function(t) {
        for (var i = 0; i &lt; this.dots.length; i++) this.changeOpacity(this.dots[i], i !== t)
    },
    nextSlide: function() {
        this.currentPanel &lt; this.comicLength - 1 &amp;&amp; this.centerComic(this.currentPanel + 1)
    },
    previousSlide: function() {
        this.currentPanel &gt; 0 &amp;&amp; this.centerComic(this.currentPanel - 1)
    },
    onMouseWheel: function(t) {
        if (this.panelContainer.enabled) {
            var i = this.content.element.width - this.scrollView.element.width,
                e = (this.panelContainer.layoutgroup.spacing.x + this.itemWidth) / (i / 100) / 100;
            this.scrollbar.scrollbar.value += t.wheelDelta * e
        }
    }
});
var ImpulseManager = {
    applyPulse: function(a, e, r, n, c, i) {
        for (var g = MatchLogic.columns, l = MatchLogic.rows, o = r * r, s = 0; s &lt; g; s++)
            for (var t = 0; t &lt; l; t++) {
                var u = GridManager.instance.getTile(s, t),
                    p = GridManager.instance.getBackgroundTile(s, t),
                    M = s - a,
                    v = t - e;
                M * M + v * v &gt; o || (p.pulse(M, v, n, c, i), u &amp;&amp; u.pulse(M, v, n, c, i))
            }
    }
};
var GameInput = pc.createScript("gameInput");
pc.extend(GameInput.prototype, {
    initialize: function() {
        this.app.on("GameInput:toggleGameInput", this.setInputEnabled, this), this._inputEnabled = !0
    },
    postInitialize: function() {
        this.entity.script.elementInput.on(inputEvents.DOWN, this._onDown, this), this.entity.script.elementInput.on(inputEvents.MOVE, this._onMove, this), this.entity.script.elementInput.on(inputEvents.UP, this._onUp, this)
    },
    _onDown: function(t) {
        this.app.fire("GameInput:forced" + inputEvents.DOWN), !0 === this._inputEnabled &amp;&amp; this.app.fire("GameInput:" + inputEvents.DOWN, t)
    },
    _onMove: function(t) {
        !0 === this._inputEnabled &amp;&amp; this.app.fire("GameInput:" + inputEvents.MOVE, t)
    },
    _onUp: function(t) {
        this.app.fire("GameInput:" + inputEvents.UP, t)
    },
    setInputEnabled: function(t) {
        this._inputEnabled = t
    }
});
var EndModeVisuals = pc.createScript("endModeVisuals");
EndModeVisuals.attributes.add("text", {
    type: "entity"
}), EndModeVisuals.attributes.add("icon", {
    type: "entity"
}), pc.extend(EndModeVisuals.prototype, {
    initialize: function() {
        this.app.on("SwapMode:onEndStart", this.showText, this), this.app.on("SwapMode:speedUp", this.showSpeedUp, this), this.app.on("SwapMode:onFinaleDone", this.hideAll, this), LocalizationManager.instance.setText(this.text, "END_MODE_TEXT")
    },
    hideAll: function() {
        this.text.enabled = !1, this.icon.enabled = !1
    },
    showText: function() {
        this.text.enabled = !0, this.icon.enabled = !1
    },
    showSpeedUp: function() {
        this.text.enabled = !1, this.icon.enabled = !0
    }
});
var ImpulseHandler = pc.createScript("impulseHandler");
pc.extend(ImpulseHandler.prototype, {
    initialize: function() {
        this._impulsesDelay = [], this._impulses = [], this._model = this.entity.findByName("ModelEntity"), this._impulseVector = new pc.Vec2
    },
    update: function(e) {
        for (var t = this._impulsesDelay.length - 1; t &gt;= 0; t--) {
            (i = this._impulsesDelay[t]).delay -= e, i.delay &lt;= 0 &amp;&amp; this._impulses.push(this._impulsesDelay.splice(t, 1)[0])
        }
        this._model.getLocalPosition();
        for (var s = this._impulses.length - 1; s &gt;= 0; s--) {
            var i, l = (i = this._impulses[s]).deltaX,
                n = i.deltaY,
                o = i.amplitude,
                a = Math.sqrt(l * l + n * n),
                h = 0 === l ? 0 : o * l / a / Math.abs(l),
                p = 0 === n ? 0 : o * -n / a / Math.abs(n);
            this._createTween(h, p, i.duration, !0), this._impulses.splice(s, 1)
        }
    },
    _createTween: function(e, t, s, i) {
        var l = this._model.getLocalPosition();
        this.stopTween();
        var n = this._model.parent.getLocalEulerAngles();
        n.x &gt; 89 &amp;&amp; n.x &lt; 91 ? this._tween = this._model.tween(this._model.getLocalPosition()).to({
            x: e,
            y: l.y,
            z: t
        }, s || ImpulseHandler.DURATION, pc.SineInOut).start() : this._tween = this._model.tween(this._model.getLocalPosition()).to({
            x: e,
            y: -t,
            z: l.z
        }, s || ImpulseHandler.DURATION, pc.SineInOut).start(), i &amp;&amp; this._tween.on("complete", this.moveToCenter.bind(this, s), this)
    },
    moveToCenter: function(e) {
        this._createTween(0, 0, e, !1)
    },
    impulse: function(e, t, s, i, l) {
        this._impulsesDelay.push({
            deltaX: e,
            deltaY: t,
            amplitude: s,
            delay: i,
            duration: l
        })
    },
    stopTween: function() {
        this._tween &amp;&amp; (this._tween.stop(), this._tween = null)
    },
    reset: function() {
        this.stopTween(), this._model.setLocalPosition(0, 0, 0), this._impulses.length = 0, this._impulsesDelay.length = 0
    }
}), ImpulseHandler.DEFAULT_DURATION = .3;
var ShakeCamera = pc.createScript("shakeCamera");
pc.extend(ShakeCamera.prototype, {
    initialize: function() {
        this.app.on("ShakeCamera:shake", this.shakeCamera, this), this.tweenTime = .1
    },
    shakeCamera: function(e, t) {
        e /= this.tweenTime, this.rotation = this.entity.getLocalEulerAngles().clone(), this.shakeOffset = .25;
        var s = this.shakeOffset;
        this.shakeDecrease = this.shakeOffset / e, this.entity.setLocalEulerAngles(this.rotation.x, -this.shakeOffset, this.rotation.z), this.shakeTween(e, s)
    },
    shakeTween: function(e, t) {
        e &gt; 0 ? this.entity.tween(this.entity.getLocalRotation()).rotate({
            y: t
        }, this.tweenTime, pc.SineInOut).yoyo(!0).on("complete", function() {
            this.shakeOffset = this.shakeOffset - this.shakeDecrease, t = t &lt; 0 ? this.shakeOffset : -1 * this.shakeOffset, this.shakeTween(e - 1, t)
        }.bind(this)).start() : this.entity.setLocalEulerAngles(this.rotation)
    }
});
var ElementInputFollower = pc.createScript("elementInputFollower");
ElementInputFollower.attributes.add("followButton", {
    type: "entity"
}), pc.extend(ElementInputFollower.prototype, {
    initialize: function() {
        this.followButton.script.elementInput.on("onButtonInputChange", this._onButtonInputChange.bind(this))
    },
    _onButtonInputChange: function(t, n, o) {
        this.entity.element.color = o ? t ? this.followButton.button.pressedTint : n ? this.followButton.button.hoverTint : this.followButton.button.defaultTint : this.followButton.button.inactiveTint
    }
});
var UnlockLevelAnimation = pc.createScript("unlockLevelAnimation");
UnlockLevelAnimation.attributes.add("keyEntity", {
    type: "entity",
    title: "Key Entity"
}), UnlockLevelAnimation.attributes.add("shadowKeyEntity", {
    type: "entity",
    title: "Shadow of Key"
}), UnlockLevelAnimation.attributes.add("openLockAnimationGroup", {
    type: "entity",
    title: "Open Lock Group"
}), UnlockLevelAnimation.attributes.add("openLock", {
    type: "entity",
    title: "lock Entity"
}), UnlockLevelAnimation.attributes.add("openLockShine", {
    type: "entity",
    title: "openLock Spark"
}), UnlockLevelAnimation.attributes.add("keySparkle", {
    type: "entity",
    title: "Key in lock Sparkle"
}), UnlockLevelAnimation.attributes.add("keyAppearEffect", {
    type: "entity",
    title: "key unlock effect"
}), UnlockLevelAnimation.attributes.add("keyMoveTweenDuration", {
    type: "number",
    default: 1.5
}), UnlockLevelAnimation.attributes.add("keyScaleDuration", {
    type: "number",
    default: 1,
    title: "Initial key scale"
}), UnlockLevelAnimation.attributes.add("keyScaleAnimationDur", {
    type: "number",
    default: 1.5,
    title: "Scale key huge"
}), UnlockLevelAnimation.attributes.add("openLockScaleTweenDuration", {
    type: "number",
    default: .5
}), UnlockLevelAnimation.attributes.add("fadeOutTweenDuration", {
    type: "number",
    default: .7
}), UnlockLevelAnimation.attributes.add("closedLockTweenDuration", {
    type: "number",
    default: .2
}), UnlockLevelAnimation.attributes.add("keySparkleDelay", {
    type: "number",
    default: .3
}), UnlockLevelAnimation.KEY_END_SCALE = new pc.Vec3(1, 1, 1), UnlockLevelAnimation.KEY_START_SCALE = new pc.Vec3(.9, .9, .9), UnlockLevelAnimation.SHADOW_ORIGINAL_SCALE = new pc.Vec3(.9, .9, .9), UnlockLevelAnimation.LOCK_END_ANGLE = new pc.Vec3(0, 0, 10), UnlockLevelAnimation.LOCK_START_ANGLE = new pc.Vec3(0, 0, -10), UnlockLevelAnimation.OPEN_LOCK_END_SCALE = new pc.Vec3(1, 1, 1), UnlockLevelAnimation.OPEN_LOCK_START_SCALE = new pc.Vec3(.2, .2, .2), UnlockLevelAnimation.EFFECT_END_SCALE = new pc.Vec3(.5, .5, .5), UnlockLevelAnimation.EFFECT_START_SCALE = new pc.Vec3(0, 0, 0), pc.extend(UnlockLevelAnimation.prototype, {
    initialize: function() {
        Singleton.instance.canCreateInstance(this) &amp;&amp; (UnlockLevelAnimation.instance = this), this.startParent = this.entity.parent, this.isAnimPlaying = !1, this.originalKeyPos = this.keyEntity.getLocalPosition().clone(), this.originalOpenLockPos = this.openLock.getLocalPosition().clone(), this.originalKeyRotation = this.keyEntity.getLocalRotation().clone(), this.shadowKeyStartPos = this.shadowKeyEntity.getLocalPosition().clone()
    },
    startAnim: function(e, t, i) {
        this.keySparkle.enabled = !1, this.keySparkle.element.opacity = 1, this.entity.reparent(e), this.lock = t, this.keyEntity.enabled = !0, this.keyEntity.setLocalScale(0, 0, 0), this.keyEntity.setLocalPosition(this.originalKeyPos), this.keyEntity.setLocalEulerAngles(0, 0, 60), this.keyEntity.element.opacity = 1, this.shadowKeyEntity.setLocalScale(0, 0, 0), this.shadowKeyEntity.setLocalEulerAngles(0, 0, 71.17), this.shadowKeyEntity.enabled = !0, this.shadowKeyEntity.element.opacity = 1, this.isAnimPlaying = !0;
        var n = this.entity.getLocalPosition();
        t.setLocalEulerAngles(UnlockLevelAnimation.LOCK_START_ANGLE), this.lockTween = this.tweenRotate(t, UnlockLevelAnimation.LOCK_END_ANGLE, this.closedLockTweenDuration, pc.Linear).yoyo(!0).loop(!0);
        var o = {
                x: .7,
                y: .7,
                z: .7
            },
            a = {
                x: 2,
                y: 2,
                z: 2
            },
            s = {
                x: 0,
                y: 0,
                z: -40
            },
            c = {
                x: this.originalKeyPos.x - .2 * this.keyEntity.element.width,
                y: this.originalKeyPos.y + .3 * this.keyEntity.element.height,
                z: 0
            };
        this.keyAppearEffect.setLocalPosition(c.x, c.y, c.z), this.keyAppearEffect.enabled = !0, this.keyAppearEffect.setLocalScale(UnlockLevelAnimation.EFFECT_START_SCALE), this.shadowKeyEntity.setLocalPosition(this.keyEntity.getLocalPosition().x, this.keyEntity.getLocalPosition().y, this.keyEntity.getLocalPosition().z), this.keyAppearEffectTween = this.tweenScale(this.keyAppearEffect, UnlockLevelAnimation.EFFECT_END_SCALE, this.keyScaleDuration, pc.ElasticOut), this.makeShadowAppearTween = this.tweenScale(this.shadowKeyEntity, UnlockLevelAnimation.KEY_START_SCALE, this.keyScaleDuration, pc.ElasticOut), this.makeKeyAppearTween = this.tweenScale(this.keyEntity, UnlockLevelAnimation.KEY_START_SCALE, this.keyScaleDuration, pc.ElasticOut).on("complete", (function() {
            this.keyAppearEffectDisappear = this.tweenScale(this.keyAppearEffect, UnlockLevelAnimation.EFFECT_START_SCALE, .5, pc.SineOut).on("complete", (function() {
                this.keyAppearEffect.enabled = !1
            }), this), this.shadowSmallTween = this.tweenScale(this.shadowKeyEntity, o, this.keyScaleAnimationDur, pc.SineIn).on("complete", (function() {
                this.tweenScale(this.shadowKeyEntity, UnlockLevelAnimation.SHADOW_ORIGINAL_SCALE, .5, pc.SineOut)
            }), this), this.makeKeyHugeTween = this.tweenScale(this.keyEntity, a, this.keyScaleAnimationDur, pc.SineIn).on("complete", (function() {
                this.scaleKeyBackNormalTween = this.tweenScale(this.keyEntity, UnlockLevelAnimation.KEY_START_SCALE, .5, pc.SineOut).on("complete", (function() {
                    n.x, n.y, n.z;
                    this.moveShadowInLockTween = this.tweenTo(this.shadowKeyEntity, n, .1, pc.QuarticOut), this.moveKeyInLockTween = this.tweenTo(this.keyEntity, n, .1, pc.QuarticOut).on("complete", (function() {
                        this.keySparkle.enabled = !0, this.stopAnim(), i &amp;&amp; i()
                    }), this)
                }), this)
            }), this);
            this.tweenRotate(this.shadowKeyEntity, s, .8, pc.CubicInOut, .5), this.tweenRotate(this.keyEntity, s, .8, pc.CubicInOut, .5);
            var e = this.entity.getLocalPosition(),
                t = {
                    x: e.x + 80,
                    y: e.y,
                    z: e.z
                };
            this.moveShadowNextToLockTween = this.tweenTo(this.shadowKeyEntity, t, 1, pc.Linear), this.moveKeyNextToLockTween = this.tweenTo(this.keyEntity, t, 1, pc.Linear)
        }), this)
    },
    stopAnim: function() {
        this.lockTween.stop(), this.app.fire("Audio:sfx", "level_unlock.mp3"), this.openLockAnimationGroup.enabled = !0, this.openLockAnimationGroup.setLocalPosition(this.originalOpenLockPos), this.openLock.element.opacity = 1, this.openLockShine.element.opacity = 1, this.openLock.setLocalScale(UnlockLevelAnimation.OPEN_LOCK_START_SCALE), this.openLockGrowTween = this.tweenScale(this.openLock, UnlockLevelAnimation.OPEN_LOCK_END_SCALE, this.openLockScaleTweenDuration, pc.ElasticOut).yoyo(!0).on("complete", (function() {
            this.openLockShineFadeAwayTween = this.tweenOpacity(this.openLockShine, 0, this.fadeOutTweenDuration, pc.Linear, .4).on("complete", this.disableEntities, this), this.openLockFadeAwayTween = this.tweenOpacity(this.openLock, 0, this.fadeOutTweenDuration, pc.Linear, .4), this.keyFadeAwayTween = this.tweenOpacity(this.keyEntity, 0, .4, pc.Linear), this.shadowFadeAwayTween = this.tweenOpacity(this.shadowKeyEntity, 0, .4, pc.Linear)
        }), this), this.keySparkleFadeAwayTween = this.tweenOpacity(this.keySparkle, 0, .4, pc.Linear, this.keySparkleDelay), this.isAnimPlaying = !1
    },
    disableEntities: function() {
        this.openLockAnimationGroup &amp;&amp; (this.openLockAnimationGroup.enabled = !1), this.keyEntity &amp;&amp; (this.keyEntity.enabled = !1), this.shadowKeyEntity &amp;&amp; (this.shadowKeyEntity.enabled = !1), this.keyAppearEffect &amp;&amp; (this.keyAppearEffect.enabled = !1), this.keySparkle &amp;&amp; (this.keySparkle.enabled = !1)
    },
    stopAllAnimations: function() {
        this.keyAppearEffectTween &amp;&amp; this.keyAppearEffectTween.stop(), this.makeShadowAppearTween &amp;&amp; this.makeShadowAppearTween.stop(), this.makeKeyAppearTween &amp;&amp; this.makeKeyAppearTween.stop(), this.keyAppearEffectDisappear &amp;&amp; this.keyAppearEffectDisappear.stop(), this.shadowSmallTween &amp;&amp; this.shadowSmallTween.stop(), this.makeKeyHugeTween &amp;&amp; this.makeKeyHugeTween.stop(), this.scaleKeyBackNormalTween &amp;&amp; this.scaleKeyBackNormalTween.stop(), this.moveShadowNextToLockTween &amp;&amp; this.moveShadowNextToLockTween.stop(), this.moveShadowInLockTween &amp;&amp; this.moveShadowInLockTween.stop(), this.moveKeyInLockTween &amp;&amp; this.moveKeyInLockTween.stop(), this.moveKeyNextToLockTween &amp;&amp; this.moveKeyNextToLockTween.stop(), this.openLockGrowTween &amp;&amp; this.openLockGrowTween.stop(), this.openLockFadeAwayTween &amp;&amp; this.openLockFadeAwayTween.stop(), this.keyFadeAwayTween &amp;&amp; this.keyFadeAwayTween.stop(), this.shadowFadeAwayTween &amp;&amp; this.shadowFadeAwayTween.stop(), this.openLockShineFadeAwayTween &amp;&amp; this.openLockShineFadeAwayTween.stop(), this.openLockGrowTween &amp;&amp; this.openLockGrowTween.stop(), this.keySparkleFadeAwayTween &amp;&amp; this.keySparkleFadeAwayTween.stop(), this.disableEntities()
    },
    tweenOpacity: function(e, t, i, n, o) {
        return e.tween(e.element).to({
            opacity: t
        }, i, n, o || 0).start()
    },
    tweenTo: function(e, t, i, n, o) {
        return e.tween(e.getLocalPosition()).to(t, i, n, o || 0).start()
    },
    tweenScale: function(e, t, i, n, o) {
        return e.tween(e.getLocalScale()).to(t, i, n, o || 0).start()
    },
    tweenRotate: function(e, t, i, n, o) {
        return e.tween(e.getLocalRotation()).rotate(t, i, n, o || 0).start()
    }
});
var CameraPath = pc.createScript("cameraPath");
CameraPath.CURVE_ENUM = [{
    Cardinal: "CURVE_CARDINAL"
}, {
    Catmull: "CURVE_CATMULL"
}, {
    Linear: "CURVE_LINEAR"
}, {
    SmoothStep: "CURVE_SMOOTHSTEP"
}, {
    Spline: "CURVE_SPLINE"
}, {
    Step: "CURVE_STEP"
}], CameraPath.attributes.add("pathRoot", {
    type: "entity",
    title: "Path Root"
}), CameraPath.attributes.add("duration", {
    type: "number",
    default: 10,
    title: "Duration Secs"
}), CameraPath.attributes.add("target", {
    type: "entity"
}), CameraPath.attributes.add("positionCurve", {
    type: "string",
    enum: CameraPath.CURVE_ENUM,
    default: "CURVE_CARDINAL"
}), CameraPath.attributes.add("rotationCurve", {
    type: "string",
    enum: CameraPath.CURVE_ENUM,
    default: "CURVE_CARDINAL"
}), CameraPath.attributes.add("upCurve", {
    type: "string",
    enum: CameraPath.CURVE_ENUM,
    default: "CURVE_CARDINAL"
}), CameraPath.attributes.add("slider", {
    type: "number",
    min: 0,
    max: 1,
    step: .001
}), CameraPath.attributes.add("playAnimation", {
    type: "boolean"
}), CameraPath.attributes.add("lookAtTarget", {
    type: "vec3"
}), CameraPath.attributes.add("useLookAtTarget", {
    type: "boolean"
}), CameraPath.attributes.add("useLength", {
    type: "boolean"
}), CameraPath.attributes.add("useOffsetAll", {
    type: "boolean"
}), CameraPath.attributes.add("useRotation", {
    type: "boolean"
}), pc.extend(CameraPath.prototype, {
    initialize: function() {
        this.createPath(), this._originalLookAtTarget = this.lookAtTarget.clone(), this._originalPositions = [], this.pathRoot.find((function(t) {
            return t.model
        })).forEach((function(t) {
            t.destroy()
        }));
        for (var t = 0; t &lt; this.pathRoot.children.length; t++) {
            var i = this.pathRoot.children[t];
            this._originalPositions[t] = i.getPosition().clone()
        }
        this.on("attr:playAnimation", this.play, this), this.on("attr:slider", (function(t) {
            this.time = this.duration * t, this.updateTransform()
        }), this), this.on("attr:pathRoot", (function(t, i) {
            t &amp;&amp; (this.createPath(), this.time = 0)
        })), this.time = 0, this.lookAt = new pc.Vec3, this.up = new pc.Vec3, this.flyingThrough = !1
    },
    update: function(t) {
        this.flyingThrough &amp;&amp; (this.time += t, this.updateTransform(), this.time &gt; this.duration &amp;&amp; (this.flyingThrough = !1, this.fire("complete")))
    },
    updateTransform: function() {
        var t = this.time / this.duration;
        if (this.target.setPosition(this.px.value(t), this.py.value(t), this.pz.value(t)), this.lookAt.set(this.tx.value(t), this.ty.value(t), this.tz.value(t)), this.up.set(this.ux.value(t), this.uy.value(t), this.uz.value(t)), this.useLookAtTarget) {
            this.target.lookAt(this.lookAtTarget, CameraPath.BACK);
            var i = this.target.getPosition();
            0 === i.x &amp;&amp; 0 === i.y &amp;&amp; this.target.setEulerAngles(0, 0, 0)
        } else this.useRotation ? this.target.setLocalEulerAngles(this.lookAt.x, this.lookAt.y, this.lookAt.z) : this.target.lookAt(this.lookAt, this.up)
    },
    createPath: function() {
        pc.CURVE_CARDINAL;
        this.px = new pc.Curve, this.px.type = pc[this.positionCurve], this.py = new pc.Curve, this.py.type = pc[this.positionCurve], this.pz = new pc.Curve, this.pz.type = pc[this.positionCurve], this.tx = new pc.Curve, this.tx.type = pc[this.rotationCurve], this.ty = new pc.Curve, this.ty.type = pc[this.rotationCurve], this.tz = new pc.Curve, this.tz.type = pc[this.rotationCurve], this.ux = new pc.Curve, this.ux.type = pc[this.upCurve], this.uy = new pc.Curve, this.uy.type = pc[this.upCurve], this.uz = new pc.Curve, this.uz.type = pc[this.upCurve];
        var t = this.pathRoot.children,
            e = 0,
            a = [],
            s = new pc.Vec3;
        for (a.push(0), i = 1; i &lt; t.length; i++) {
            var h = t[i - 1],
                o = t[i];
            s.sub2(h.getPosition(), o.getPosition()), e += s.length(), a.push(e)
        }
        for (i = 0; i &lt; t.length; i++) {
            var r = this.useLength ? a[i] / e : i / (t.length - 1),
                n = t[i],
                u = n.getPosition();
            if (this.px.add(r, u.x), this.py.add(r, u.y), this.pz.add(r, u.z), this.useRotation) {
                var p = n.getLocalEulerAngles();
                this.tx.add(r, p.x), this.ty.add(r, p.y), this.tz.add(r, p.z)
            } else {
                p = u.clone().add(n.forward);
                this.tx.add(r, p.x), this.ty.add(r, p.y), this.tz.add(r, p.z)
            }
            var l = n.up;
            this.ux.add(r, l.x), this.uy.add(r, l.y), this.uz.add(r, l.z)
        }
    },
    play: function() {
        return this.reset(), this.flyingThrough = !0, this
    },
    reset: function() {
        this.flyingThrough = !1, this.time = 0
    },
    stop: function() {
        this.flyingThrough = !1
    },
    setBeginPosition: function(t) {
        var i = this.pathRoot.children[0],
            e = this._originalPositions[0];
        return i.setPosition(e.x, e.y, t), this.createPath(), this
    },
    setEndPosition: function(t) {
        var i = this.pathRoot.children.length - 1,
            e = this.pathRoot.children[i],
            a = this._originalPositions[i];
        return e.setPosition(a.x, a.y, t), this.createPath(), this
    },
    addAllPositions: function(t) {
        for (var i = 0; i &lt; this.pathRoot.children.length; i++) {
            var e = this.pathRoot.children[i],
                a = this._originalPositions[i];
            e.setPosition(a.x, a.y, a.z + t)
        }
        return this.createPath(), this
    },
    addOffset: function(t) {
        for (var i = 0; i &lt; this.pathRoot.children.length; i++) {
            var e = this.pathRoot.children[i],
                a = this.pathRoot.children[i].getPosition();
            e.setPosition(a.x + t.x, a.y + t.y, a.z)
        }
        return this.createPath(), this.lookAtTarget.set(this._originalLookAtTarget.x + t.x, this._originalLookAtTarget.y + t.y, this._originalLookAtTarget.z), this
    },
    resetPositions: function() {
        for (var t = 0; t &lt; this.pathRoot.children.length; t++) {
            var i = this.pathRoot.children[t],
                e = this._originalPositions[t];
            i.setPosition(e.x, e.y, e.z)
        }
        return this
    }
}), CameraPath.BACK = new pc.Vec3(0, .01, 1);
var MaxElementScale = pc.createScript("maxElementScale");
MaxElementScale.attributes.add("fillPercentage", {
    type: "number",
    default: 1
}), MaxElementScale.attributes.add("maxDesktopScale", {
    type: "number",
    default: -1
}), MaxElementScale.attributes.add("fillSmallestSide", {
    type: "boolean"
}), MaxElementScale.attributes.add("debugScale", {
    type: "boolean"
}), pc.extend(MaxElementScale.prototype, {
    initialize: function() {
        this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _onResize: function(e, t, a, i) {
        var n = Math.abs(Math.round(this.entity.getLocalEulerAngles().z)),
            l = !1;
        if (90 === n || 270 === n) l = !0;
        else if (0 !== n &amp;&amp; 180 !== n) return void console.warn("Element is diagonal, can`t use max scale script");
        var s = UIManager.instance.getReferenceResolution().y / a,
            c = this.entity.element.width,
            o = this.entity.element.height,
            r = t * this.fillPercentage / (l ? o : c) * s,
            h = a * this.fillPercentage / (l ? c : o) * s,
            m = this.fillSmallestSide ? Math.min(r, h) : Math.max(r, h);
        this.debugScale &amp;&amp; console.log(m), this.maxDesktopScale &gt; 0 &amp;&amp; i === deviceEnum.DESKTOP &amp;&amp; (m = pc.math.clamp(m, 0, this.maxDesktopScale)), this.entity.setLocalScale(pc.Vec3.ONE.clone().scale(m))
    }
});
var CameraAnimations = pc.createScript("cameraAnimations");
CameraAnimations.attributes.add("introPaths", {
    type: "entity"
}), CameraAnimations.attributes.add("outroPaths", {
    type: "entity"
}), CameraAnimations.attributes.add("target", {
    type: "entity"
}), CameraAnimations.attributes.add("debugIndex", {
    type: "number"
}), CameraAnimations.attributes.add("delay", {
    type: "number",
    placeholder: "msec",
    default: 200
}), pc.extend(CameraAnimations.prototype, {
    initialize: function() {
        CameraAnimations.instance = this, this._introPaths = this.introPaths.findScripts("cameraPath").filter((function(t) {
            return t.entity.enabled
        })), this._outroPaths = this.outroPaths.findScripts("cameraPath").filter((function(t) {
            return t.entity.enabled
        })), this._currentAnimation = null, this.index = 0, this.app.on("PerspectiveView:onCameraChange", this._onRadiusChange, this)
    },
    _onRadiusChange: function() {
        this.stop();
        var t = PerspectiveView.instance.getOffset();
        this.entity.setLocalPosition(t.x, t.y, t.z), this.entity.setLocalEulerAngles(0, 0, 0)
    },
    getRandomIndex: function(t) {
        this.index = Math.floor(Math.random() * t.length), -1 !== this.debugIndex &amp;&amp; (this.index = pc.math.clamp(this.debugIndex, 0, t.length - 1))
    },
    playRandomOutro: function() {
        this.getRandomIndex(this._outroPaths);
        var t = this.play(this._outroPaths);
        return t.resetPositions(), t.useOffsetAll ? t.addAllPositions(PerspectiveView.instance.getRadius()) : t.setBeginPosition(PerspectiveView.instance.getRadius()), t.addOffset(PerspectiveView.instance.getOffset()), this
    },
    playRandomIntro: function() {
        return this.getRandomIndex(this._introPaths), this.play(this._introPaths).resetPositions().setEndPosition(PerspectiveView.instance.getRadius()).addOffset(PerspectiveView.instance.getOffset()), this
    },
    play: function(t, e) {
        var i = t[this.index];
        return i || console.warn("No path found", t), this._currentAnimation instanceof CameraPath &amp;&amp; this._currentAnimation.stop(), this._currentAnimation = i, i.play().once("complete", (function() {
            pc.utils.delay(this.delay).then(function() {
                this.onComplete()
            }.bind(this))
        }), this), i
    },
    stop: function() {
        this._currentAnimation &amp;&amp; (this._currentAnimation.stop(), this.onComplete())
    },
    onComplete: function() {
        this._currentAnimation = null;
        var t = PerspectiveView.instance.getOffset();
        this.target.setLocalEulerAngles(0, 0, 0), this.target.setLocalPosition(t.x, t.y, t.z), this.fire("complete")
    }
});
var ElementBar = pc.createScript("elementBar");
pc.extend(ElementBar.prototype, {
    initialize: function() {
        this._onResize(ViewportManager.instance.getOrientation(), window.innerWidth, window.innerHeight, ViewportManager.instance.getDevice()), this.app.on("ViewportManager:onResize", this._onResize, this)
    },
    _onResize: function(e, t, n, i) {
        var a = Math.abs(Math.round(this.entity.getLocalEulerAngles().z)),
            r = !1;
        if (90 === a || 270 === a) r = !0;
        else if (0 !== a &amp;&amp; 180 !== a) return void console.warn("Element is diagonal, can`t use max scale script");
        var o = UIManager.instance.getReferenceResolution().y / n,
            s = this.entity.getLocalScale().x;
        this.entity.element.width = (r ? n / s : t) * o
    }
});
var Disabler = pc.createScript("disabler");
Disabler.prototype.initialize = function() {
    this.entity.enabled = !1
};
var TileAnimationController = pc.createScript("tileAnimationController");
TileAnimationController.attributes.add("model", {
    type: "entity"
}), TileAnimationController.attributes.add("layerAnimations", {
    type: "string",
    array: !0
}), TileAnimationController.attributes.add("idleAnimations", {
    type: "string",
    array: !0
}), TileAnimationController.attributes.add("explodeAnimations", {
    type: "string",
    array: !0
}), TileAnimationController.attributes.add("playIdleAnimation", {
    type: "boolean",
    default: !1
}), TileAnimationController.attributes.add("idleDelay", {
    type: "vec2",
    placeholder: ["min", "max"]
}), pc.extend(TileAnimationController.prototype, {
    initialize: function() {
        this.queue = [], this.playing = !1, this._delay = 0, this._currentAnimationData = null, this.animationComponent = this.model.animation, this.backgroundTile = this.entity.script.backgroundTile
    },
    setLayer: function(t) {
        var i = new AnimationData(this.layerAnimations[t]);
        this.complete = !1, this.play(i)
    },
    playIdle: function() {
        if (this.playIdleAnimation) {
            var t = this.backgroundTile.currentLayer - 1;
            this._playIdle(t, pc.math.random(this.idleDelay.x, this.idleDelay.y))
        }
    },
    _playIdle: function(t, i) {
        var n = new AnimationData(this.idleAnimations[t], i, void 0, void 0, !0);
        this.play(n)
    },
    playExplode: function(t, i) {
        var n = this.explodeAnimations[t],
            a = this.getDuplicate(n);
        a ? a.delay = Math.min(a.delay, i) : (a = new AnimationData(n, i, "explode", 0 === t ? "complete" : null), this.play(a))
    },
    playAnimation: function(t, i, n, a) {
        var e = new AnimationData(t, i, n, a, !0);
        this.play(e)
    },
    update: function(t) {
        this.playing &amp;&amp; (this._currentAnimationData.playing ? this.animationComponent.currentTime &gt;= this.animationComponent.duration &amp;&amp; this.showNextAnimation() : (this._delay += t, this._delay &gt;= this._currentAnimationData.delay &amp;&amp; (this.animationComponent.play(this._currentAnimationData.name), this._currentAnimationData.animation = this.animationComponent.getAnimation(name), this._currentAnimationData.playing = !0, this.doEvent(this._currentAnimationData.eventStart, this._currentAnimationData))))
    },
    play: function(t) {
        this.backgroundTile.isDestroyed ? console.warn("Trying to play", t, "while destroyed") : this.playing ? this._currentAnimationData.canOverride ? (this.resetAnimation(), this._currentAnimationData = t) : this.queue.push(t) : (this._currentAnimationData = t, this.playing = !0)
    },
    showNextAnimation: function() {
        if (this.doEvent(this._currentAnimationData.eventEnd, this._currentAnimationData), this.resetAnimation(), this._currentAnimationData = this.queue.shift(), !this._currentAnimationData) return this.reset(), void(this.backgroundTile.isDestroyed || this.playIdle())
    },
    resetAnimation: function() {
        this._currentAnimationData = null, this._delay = 0
    },
    reset: function() {
        this.queue.length = 0, this.playing = !1, this.resetAnimation()
    },
    getDuplicate: function(t) {
        if (this._currentAnimationData &amp;&amp; this._currentAnimationData.name === t) return this._currentAnimationData;
        for (var i = 0; i &lt; this.queue.length; i++) {
            var n = this.queue[i];
            if (n.name === t) return n
        }
        return null
    },
    doEvent: function(t, i) {
        t &amp;&amp; (this.complete ? console.warn("Unable to fire event", t) : (this.fire(t, i), "complete" === t &amp;&amp; (this.completed = !0)))
    },
    getDespawnDelay: function() {
        var t = 0;
        if (!this._currentAnimationData) return t;
        t += this._currentAnimationData.delay;
        for (var i = 0; i &lt; this.queue.length; i++) t += this.queue[i].delay;
        return t
    }
});
var AnimationData = function(t, i, n, a, e) {
    this.name = t, this.delay = i || 0, this.animation = null, this.playing = !1, this.eventStart = n, this.eventEnd = a, this.canOverride = e
};
var ChapterInformationBar = pc.createScript("chapterInformationBar");
ChapterInformationBar.attributes.add("currentStarsTextEntity", {
    type: "entity"
}), ChapterInformationBar.attributes.add("totalStarsTextEntity", {
    type: "entity"
}), ChapterInformationBar.attributes.add("currentPartsTextEntity", {
    type: "entity"
}), ChapterInformationBar.attributes.add("totalPartsTextEntity", {
    type: "entity"
}), ChapterInformationBar.attributes.add("statsGroupEntity", {
    type: "entity"
}), ChapterInformationBar.attributes.add("partImageEntity", {
    type: "entity"
}), pc.extend(ChapterInformationBar.prototype, {
    initialize: function() {
        this.app.on("ChapterInformationBar:updateStats", this._updateStats.bind(this)), this.app.on("BookUI:switchPage", this._onPageSwitch, this)
    },
    _updateStats: function(t, e, a, r, n) {
        this.currentStarsTextEntity.element.text = t, this.totalStarsTextEntity.element.text = e, this.currentPartsTextEntity.element.text = a, this.totalPartsTextEntity.element.text = r;
        var i = WorldManager.instance.getPartAssets(n).partSprite.resource;
        this.partImageEntity.element.sprite = i
    },
    _onPageSwitch: function(t, e, a) {
        this.statsGroupEntity.enabled = !isNaN(a.pageInfo.chapterID)
    }
});
var SkipTutorialButton = pc.createScript("skipTutorialButton");
pc.extend(SkipTutorialButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this)
    },
    _onClick: function() {
        TutorialManager.instance.endTutorial()
    }
});
var ComicButton = pc.createScript("comicButton");
pc.extend(ComicButton.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onClick, this), this.app.on("BookUI:switchPage", this._onPageSwitch, this), this.pageID = 0, this.chapterID = 1
    },
    _onClick: function() {
        this.app.fire("ComicInterface:showComic", this.chapterID, this.pageID)
    },
    _onPageSwitch: function(t, i, e) {
        this.pageID = e.pageInfo.pageID, this.chapterID = e.pageInfo.chapterID
    }
});
var Virus = pc.createScript("virus");
Virus.attributes.add("models", {
    type: "asset",
    assetType: "model",
    array: !0
}), pc.extend(Virus.prototype, {
    initialize: function() {
        this.parent = null, this._explode = !1, this._allDestroyed = !1, this.animationController = this.entity.script.tileAnimationController, this.animationController.on("explode", this._onExplodeAnimation, this), this.animationController.on("complete", this._onCompleteAnimation, this)
    },
    despawnInstant: function() {
        this._explode = !0
    },
    recycle: function() {
        this._explode ? console.warn("already recycled") : (this._explode = !0, this.entity.objectPool.recycle(this.entity))
    },
    init: function(t) {
        this.parent = t, this.parent.typeID = backgroundTileEnum.VIRUS
    },
    awake: function() {
        this.parent.hasExploded = !1, this._explode = !1, this.parent._modelComponent.entity.enabled = !0, this.animationController.setLayer(this.parent.currentLayer - 1), this._allDestroyed = !1
    },
    explode: function(t) {
        return this.parent.hasExploded ? (this.animationController.playExplode(this.parent.currentLayer, t, !0), !0) : (GridManager.instance.onVirusHit(), this._allDestroyed = !GridManager.instance.nViruses, this.parent._onLayerExplode(), this.parent.currentLayer--, this.parent.hasExploded = !0, this.animationController.playExplode(this.parent.currentLayer, t), 0 === this.parent.currentLayer &amp;&amp; (this.parent.isDestroyed = !0, GridManager.instance.onVirusDespawn(this.parent)), !0)
    },
    _onExplodeAnimation: function(t) {
        var e = 0 === this.parent.currentLayer;
        this.parent._onExplode(e, t.delay, !0), GridManager.instance.playSFX("virus_hit.mp3"), this._allDestroyed ? GridManager.instance.playSFX("virus_destroy_all.mp3") : GridManager.instance.playSFX("virus_destroy_voice.mp3")
    },
    _onCompleteAnimation: function() {
        this.recycle()
    },
    getDespawnDelay: function() {
        this.animationController.getDespawnDelay()
    },
    playAnimation: function(t, e, n, i) {
        this.animationController.playAnimation(t, e, n, i)
    }
});
var BackToPage = pc.createScript("backToPage");
BackToPage.attributes.add("pageID", {
    type: "number",
    default: 0
}), BackToPage.attributes.add("worldID", {
    type: "number",
    default: 1
}), BackToPage.attributes.add("isUnlocked", {
    type: "boolean",
    default: !1
}), pc.extend(BackToPage.prototype, {
    initialize: function() {
        this.entity.script.elementInput.on(inputEvents.CLICK, this._onCLick, this), this.app.on("BookUI:switchPage", this._onPageSwitch, this)
    },
    _onCLick: function() {
        this.isUnlocked &amp;&amp; (this.app.fire("BookUI:levelSelect", this.worldID, this.pageID), this.app.fire("UIManager:hideUI", "Comic"), this.app.fire("LevelSelectPage:scrollTo", 0))
    }
});</pre></body></html>