From 06aec0308d0ec55c1797560864507637c5dba480 Mon Sep 17 00:00:00 2001 From: Sebastian Kupke Date: Tue, 30 Apr 2019 12:18:36 +0200 Subject: [PATCH] Adjustments for Pixi.JS 5.0. --- dist/iwmlib.3rdparty.js | 85420 +++++++++++++++++----------------- dist/iwmlib.3rdparty.min.js | 2 +- dist/iwmlib.pixi.js | 34 +- lib/pixi/app.js | 22 +- package-lock.json | 606 +- package.json | 4 +- 6 files changed, 44044 insertions(+), 42044 deletions(-) diff --git a/dist/iwmlib.3rdparty.js b/dist/iwmlib.3rdparty.js index cc5089e..cc5fce2 100644 --- a/dist/iwmlib.3rdparty.js +++ b/dist/iwmlib.3rdparty.js @@ -5245,42029 +5245,43639 @@ https://highlightjs.org/ })); /*! - * pixi.js - v4.8.7 - * Compiled Fri, 22 Mar 2019 16:20:35 UTC + * pixi.js - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license */ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.PIXI = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) - (v < 0); -} - -//Computes absolute value of integer -exports.abs = function(v) { - var mask = v >> (INT_BITS-1); - return (v ^ mask) - mask; -} - -//Computes minimum of integers x and y -exports.min = function(x, y) { - return y ^ ((x ^ y) & -(x < y)); -} - -//Computes maximum of integers x and y -exports.max = function(x, y) { - return x ^ ((x ^ y) & -(x < y)); -} - -//Checks if a number is a power of two -exports.isPow2 = function(v) { - return !(v & (v-1)) && (!!v); -} - -//Computes log base 2 of v -exports.log2 = function(v) { - var r, shift; - r = (v > 0xFFFF) << 4; v >>>= r; - shift = (v > 0xFF ) << 3; v >>>= shift; r |= shift; - shift = (v > 0xF ) << 2; v >>>= shift; r |= shift; - shift = (v > 0x3 ) << 1; v >>>= shift; r |= shift; - return r | (v >> 1); -} - -//Computes log base 10 of v -exports.log10 = function(v) { - return (v >= 1000000000) ? 9 : (v >= 100000000) ? 8 : (v >= 10000000) ? 7 : - (v >= 1000000) ? 6 : (v >= 100000) ? 5 : (v >= 10000) ? 4 : - (v >= 1000) ? 3 : (v >= 100) ? 2 : (v >= 10) ? 1 : 0; -} - -//Counts number of bits -exports.popCount = function(v) { - v = v - ((v >>> 1) & 0x55555555); - v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); - return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; -} - -//Counts number of trailing zeros -function countTrailingZeros(v) { - var c = 32; - v &= -v; - if (v) c--; - if (v & 0x0000FFFF) c -= 16; - if (v & 0x00FF00FF) c -= 8; - if (v & 0x0F0F0F0F) c -= 4; - if (v & 0x33333333) c -= 2; - if (v & 0x55555555) c -= 1; - return c; -} -exports.countTrailingZeros = countTrailingZeros; - -//Rounds to next power of 2 -exports.nextPow2 = function(v) { - v += v === 0; - --v; - v |= v >>> 1; - v |= v >>> 2; - v |= v >>> 4; - v |= v >>> 8; - v |= v >>> 16; - return v + 1; -} - -//Rounds down to previous power of 2 -exports.prevPow2 = function(v) { - v |= v >>> 1; - v |= v >>> 2; - v |= v >>> 4; - v |= v >>> 8; - v |= v >>> 16; - return v - (v>>>1); -} - -//Computes parity of word -exports.parity = function(v) { - v ^= v >>> 16; - v ^= v >>> 8; - v ^= v >>> 4; - v &= 0xf; - return (0x6996 >>> v) & 1; -} - -var REVERSE_TABLE = new Array(256); - -(function(tab) { - for(var i=0; i<256; ++i) { - var v = i, r = i, s = 7; - for (v >>>= 1; v; v >>>= 1) { - r <<= 1; - r |= v & 1; - --s; - } - tab[i] = (r << s) & 0xff; - } -})(REVERSE_TABLE); - -//Reverse bits in a 32 bit word -exports.reverse = function(v) { - return (REVERSE_TABLE[ v & 0xff] << 24) | - (REVERSE_TABLE[(v >>> 8) & 0xff] << 16) | - (REVERSE_TABLE[(v >>> 16) & 0xff] << 8) | - REVERSE_TABLE[(v >>> 24) & 0xff]; -} - -//Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes -exports.interleave2 = function(x, y) { - x &= 0xFFFF; - x = (x | (x << 8)) & 0x00FF00FF; - x = (x | (x << 4)) & 0x0F0F0F0F; - x = (x | (x << 2)) & 0x33333333; - x = (x | (x << 1)) & 0x55555555; - - y &= 0xFFFF; - y = (y | (y << 8)) & 0x00FF00FF; - y = (y | (y << 4)) & 0x0F0F0F0F; - y = (y | (y << 2)) & 0x33333333; - y = (y | (y << 1)) & 0x55555555; - - return x | (y << 1); -} - -//Extracts the nth interleaved component -exports.deinterleave2 = function(v, n) { - v = (v >>> n) & 0x55555555; - v = (v | (v >>> 1)) & 0x33333333; - v = (v | (v >>> 2)) & 0x0F0F0F0F; - v = (v | (v >>> 4)) & 0x00FF00FF; - v = (v | (v >>> 16)) & 0x000FFFF; - return (v << 16) >> 16; -} - - -//Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes -exports.interleave3 = function(x, y, z) { - x &= 0x3FF; - x = (x | (x<<16)) & 4278190335; - x = (x | (x<<8)) & 251719695; - x = (x | (x<<4)) & 3272356035; - x = (x | (x<<2)) & 1227133513; - - y &= 0x3FF; - y = (y | (y<<16)) & 4278190335; - y = (y | (y<<8)) & 251719695; - y = (y | (y<<4)) & 3272356035; - y = (y | (y<<2)) & 1227133513; - x |= (y << 1); - - z &= 0x3FF; - z = (z | (z<<16)) & 4278190335; - z = (z | (z<<8)) & 251719695; - z = (z | (z<<4)) & 3272356035; - z = (z | (z<<2)) & 1227133513; - - return x | (z << 2); -} - -//Extracts nth interleaved component of a 3-tuple -exports.deinterleave3 = function(v, n) { - v = (v >>> n) & 1227133513; - v = (v | (v>>>2)) & 3272356035; - v = (v | (v>>>4)) & 251719695; - v = (v | (v>>>8)) & 4278190335; - v = (v | (v>>>16)) & 0x3FF; - return (v<<22)>>22; -} - -//Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page) -exports.nextCombination = function(v) { - var t = v | (v - 1); - return (t + 1) | (((~t & -~t) - 1) >>> (countTrailingZeros(v) + 1)); -} - - -},{}],2:[function(require,module,exports){ -'use strict'; - -module.exports = earcut; -module.exports.default = earcut; - -function earcut(data, holeIndices, dim) { - - dim = dim || 2; - - var hasHoles = holeIndices && holeIndices.length, - outerLen = hasHoles ? holeIndices[0] * dim : data.length, - outerNode = linkedList(data, 0, outerLen, dim, true), - triangles = []; - - if (!outerNode || outerNode.next === outerNode.prev) return triangles; - - var minX, minY, maxX, maxY, x, y, invSize; - - if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); - - // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox - if (data.length > 80 * dim) { - minX = maxX = data[0]; - minY = maxY = data[1]; - - for (var i = dim; i < outerLen; i += dim) { - x = data[i]; - y = data[i + 1]; - if (x < minX) minX = x; - if (y < minY) minY = y; - if (x > maxX) maxX = x; - if (y > maxY) maxY = y; - } - - // minX, minY and invSize are later used to transform coords into integers for z-order calculation - invSize = Math.max(maxX - minX, maxY - minY); - invSize = invSize !== 0 ? 1 / invSize : 0; - } - - earcutLinked(outerNode, triangles, dim, minX, minY, invSize); - - return triangles; -} - -// create a circular doubly linked list from polygon points in the specified winding order -function linkedList(data, start, end, dim, clockwise) { - var i, last; - - if (clockwise === (signedArea(data, start, end, dim) > 0)) { - for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); - } else { - for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); - } - - if (last && equals(last, last.next)) { - removeNode(last); - last = last.next; - } - - return last; -} - -// eliminate colinear or duplicate points -function filterPoints(start, end) { - if (!start) return start; - if (!end) end = start; - - var p = start, - again; - do { - again = false; - - if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { - removeNode(p); - p = end = p.prev; - if (p === p.next) break; - again = true; - - } else { - p = p.next; - } - } while (again || p !== end); - - return end; -} - -// main ear slicing loop which triangulates a polygon (given as a linked list) -function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) { - if (!ear) return; - - // interlink polygon nodes in z-order - if (!pass && invSize) indexCurve(ear, minX, minY, invSize); - - var stop = ear, - prev, next; - - // iterate through ears, slicing them one by one - while (ear.prev !== ear.next) { - prev = ear.prev; - next = ear.next; - - if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) { - // cut off the triangle - triangles.push(prev.i / dim); - triangles.push(ear.i / dim); - triangles.push(next.i / dim); - - removeNode(ear); - - // skipping the next vertex leads to less sliver triangles - ear = next.next; - stop = next.next; - - continue; - } - - ear = next; - - // if we looped through the whole remaining polygon and can't find any more ears - if (ear === stop) { - // try filtering points and slicing again - if (!pass) { - earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); - - // if this didn't work, try curing all small self-intersections locally - } else if (pass === 1) { - ear = cureLocalIntersections(ear, triangles, dim); - earcutLinked(ear, triangles, dim, minX, minY, invSize, 2); - - // as a last resort, try splitting the remaining polygon into two - } else if (pass === 2) { - splitEarcut(ear, triangles, dim, minX, minY, invSize); - } - - break; - } - } -} - -// check whether a polygon node forms a valid ear with adjacent nodes -function isEar(ear) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // now make sure we don't have other points inside the potential ear - var p = ear.next.next; - - while (p !== ear.prev) { - if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.next; - } - - return true; -} - -function isEarHashed(ear, minX, minY, invSize) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // triangle bbox; min & max are calculated like this for speed - var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), - minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), - maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), - maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); - - // z-order range for the current triangle bbox; - var minZ = zOrder(minTX, minTY, minX, minY, invSize), - maxZ = zOrder(maxTX, maxTY, minX, minY, invSize); - - var p = ear.prevZ, - n = ear.nextZ; - - // look for points inside the triangle in both directions - while (p && p.z >= minZ && n && n.z <= maxZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.prevZ; - - if (n !== ear.prev && n !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && - area(n.prev, n, n.next) >= 0) return false; - n = n.nextZ; - } - - // look for remaining points in decreasing z-order - while (p && p.z >= minZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.prevZ; - } - - // look for remaining points in increasing z-order - while (n && n.z <= maxZ) { - if (n !== ear.prev && n !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && - area(n.prev, n, n.next) >= 0) return false; - n = n.nextZ; - } - - return true; -} - -// go through all polygon nodes and cure small local self-intersections -function cureLocalIntersections(start, triangles, dim) { - var p = start; - do { - var a = p.prev, - b = p.next.next; - - if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { - - triangles.push(a.i / dim); - triangles.push(p.i / dim); - triangles.push(b.i / dim); - - // remove two nodes involved - removeNode(p); - removeNode(p.next); - - p = start = b; - } - p = p.next; - } while (p !== start); - - return p; -} - -// try splitting polygon into two and triangulate them independently -function splitEarcut(start, triangles, dim, minX, minY, invSize) { - // look for a valid diagonal that divides the polygon into two - var a = start; - do { - var b = a.next.next; - while (b !== a.prev) { - if (a.i !== b.i && isValidDiagonal(a, b)) { - // split the polygon in two by the diagonal - var c = splitPolygon(a, b); - - // filter colinear points around the cuts - a = filterPoints(a, a.next); - c = filterPoints(c, c.next); - - // run earcut on each half - earcutLinked(a, triangles, dim, minX, minY, invSize); - earcutLinked(c, triangles, dim, minX, minY, invSize); - return; - } - b = b.next; - } - a = a.next; - } while (a !== start); -} - -// link every hole into the outer loop, producing a single-ring polygon without holes -function eliminateHoles(data, holeIndices, outerNode, dim) { - var queue = [], - i, len, start, end, list; - - for (i = 0, len = holeIndices.length; i < len; i++) { - start = holeIndices[i] * dim; - end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - list = linkedList(data, start, end, dim, false); - if (list === list.next) list.steiner = true; - queue.push(getLeftmost(list)); - } - - queue.sort(compareX); - - // process holes from left to right - for (i = 0; i < queue.length; i++) { - eliminateHole(queue[i], outerNode); - outerNode = filterPoints(outerNode, outerNode.next); - } - - return outerNode; -} - -function compareX(a, b) { - return a.x - b.x; -} - -// find a bridge between vertices that connects hole with an outer ring and and link it -function eliminateHole(hole, outerNode) { - outerNode = findHoleBridge(hole, outerNode); - if (outerNode) { - var b = splitPolygon(outerNode, hole); - filterPoints(b, b.next); - } -} - -// David Eberly's algorithm for finding a bridge between hole and outer polygon -function findHoleBridge(hole, outerNode) { - var p = outerNode, - hx = hole.x, - hy = hole.y, - qx = -Infinity, - m; - - // find a segment intersected by a ray from the hole's leftmost point to the left; - // segment's endpoint with lesser x will be potential connection point - do { - if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { - var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); - if (x <= hx && x > qx) { - qx = x; - if (x === hx) { - if (hy === p.y) return p; - if (hy === p.next.y) return p.next; - } - m = p.x < p.next.x ? p : p.next; - } - } - p = p.next; - } while (p !== outerNode); - - if (!m) return null; - - if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint - - // look for points inside the triangle of hole point, segment intersection and endpoint; - // if there are no points found, we have a valid connection; - // otherwise choose the point of the minimum angle with the ray as connection point - - var stop = m, - mx = m.x, - my = m.y, - tanMin = Infinity, - tan; - - p = m.next; - - while (p !== stop) { - if (hx >= p.x && p.x >= mx && hx !== p.x && - pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { - - tan = Math.abs(hy - p.y) / (hx - p.x); // tangential - - if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { - m = p; - tanMin = tan; - } - } - - p = p.next; - } - - return m; -} - -// interlink polygon nodes in z-order -function indexCurve(start, minX, minY, invSize) { - var p = start; - do { - if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize); - p.prevZ = p.prev; - p.nextZ = p.next; - p = p.next; - } while (p !== start); - - p.prevZ.nextZ = null; - p.prevZ = null; - - sortLinked(p); -} - -// Simon Tatham's linked list merge sort algorithm -// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html -function sortLinked(list) { - var i, p, q, e, tail, numMerges, pSize, qSize, - inSize = 1; - - do { - p = list; - list = null; - tail = null; - numMerges = 0; - - while (p) { - numMerges++; - q = p; - pSize = 0; - for (i = 0; i < inSize; i++) { - pSize++; - q = q.nextZ; - if (!q) break; - } - qSize = inSize; - - while (pSize > 0 || (qSize > 0 && q)) { - - if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { - e = p; - p = p.nextZ; - pSize--; - } else { - e = q; - q = q.nextZ; - qSize--; - } - - if (tail) tail.nextZ = e; - else list = e; - - e.prevZ = tail; - tail = e; - } - - p = q; - } - - tail.nextZ = null; - inSize *= 2; - - } while (numMerges > 1); - - return list; -} - -// z-order of a point given coords and inverse of the longer side of data bbox -function zOrder(x, y, minX, minY, invSize) { - // coords are transformed into non-negative 15-bit integer range - x = 32767 * (x - minX) * invSize; - y = 32767 * (y - minY) * invSize; - - x = (x | (x << 8)) & 0x00FF00FF; - x = (x | (x << 4)) & 0x0F0F0F0F; - x = (x | (x << 2)) & 0x33333333; - x = (x | (x << 1)) & 0x55555555; - - y = (y | (y << 8)) & 0x00FF00FF; - y = (y | (y << 4)) & 0x0F0F0F0F; - y = (y | (y << 2)) & 0x33333333; - y = (y | (y << 1)) & 0x55555555; - - return x | (y << 1); -} - -// find the leftmost node of a polygon ring -function getLeftmost(start) { - var p = start, - leftmost = start; - do { - if (p.x < leftmost.x) leftmost = p; - p = p.next; - } while (p !== start); - - return leftmost; -} - -// check if a point lies within a convex triangle -function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { - return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && - (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && - (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; -} - -// check if a diagonal between two polygon nodes is valid (lies in polygon interior) -function isValidDiagonal(a, b) { - return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && - locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); -} - -// signed area of a triangle -function area(p, q, r) { - return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); -} - -// check if two points are equal -function equals(p1, p2) { - return p1.x === p2.x && p1.y === p2.y; -} - -// check if two segments intersect -function intersects(p1, q1, p2, q2) { - if ((equals(p1, q1) && equals(p2, q2)) || - (equals(p1, q2) && equals(p2, q1))) return true; - return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && - area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; -} - -// check if a polygon diagonal intersects any polygon segments -function intersectsPolygon(a, b) { - var p = a; - do { - if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && - intersects(p, p.next, a, b)) return true; - p = p.next; - } while (p !== a); - - return false; -} - -// check if a polygon diagonal is locally inside the polygon -function locallyInside(a, b) { - return area(a.prev, a, a.next) < 0 ? - area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : - area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; -} - -// check if the middle point of a polygon diagonal is inside the polygon -function middleInside(a, b) { - var p = a, - inside = false, - px = (a.x + b.x) / 2, - py = (a.y + b.y) / 2; - do { - if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && - (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) - inside = !inside; - p = p.next; - } while (p !== a); - - return inside; -} - -// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; -// if one belongs to the outer ring and another to a hole, it merges it into a single ring -function splitPolygon(a, b) { - var a2 = new Node(a.i, a.x, a.y), - b2 = new Node(b.i, b.x, b.y), - an = a.next, - bp = b.prev; - - a.next = b; - b.prev = a; - - a2.next = an; - an.prev = a2; - - b2.next = a2; - a2.prev = b2; - - bp.next = b2; - b2.prev = bp; - - return b2; -} - -// create a node and optionally link it with previous one (in a circular doubly linked list) -function insertNode(i, x, y, last) { - var p = new Node(i, x, y); - - if (!last) { - p.prev = p; - p.next = p; - - } else { - p.next = last.next; - p.prev = last; - last.next.prev = p; - last.next = p; - } - return p; -} - -function removeNode(p) { - p.next.prev = p.prev; - p.prev.next = p.next; - - if (p.prevZ) p.prevZ.nextZ = p.nextZ; - if (p.nextZ) p.nextZ.prevZ = p.prevZ; -} - -function Node(i, x, y) { - // vertex index in coordinates array - this.i = i; - - // vertex coordinates - this.x = x; - this.y = y; - - // previous and next vertex nodes in a polygon ring - this.prev = null; - this.next = null; - - // z-order curve value - this.z = null; - - // previous and next nodes in z-order - this.prevZ = null; - this.nextZ = null; - - // indicates whether this is a steiner point - this.steiner = false; -} - -// return a percentage difference between the polygon area and its triangulation area; -// used to verify correctness of triangulation -earcut.deviation = function (data, holeIndices, dim, triangles) { - var hasHoles = holeIndices && holeIndices.length; - var outerLen = hasHoles ? holeIndices[0] * dim : data.length; - - var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); - if (hasHoles) { - for (var i = 0, len = holeIndices.length; i < len; i++) { - var start = holeIndices[i] * dim; - var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - polygonArea -= Math.abs(signedArea(data, start, end, dim)); - } - } - - var trianglesArea = 0; - for (i = 0; i < triangles.length; i += 3) { - var a = triangles[i] * dim; - var b = triangles[i + 1] * dim; - var c = triangles[i + 2] * dim; - trianglesArea += Math.abs( - (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - - (data[a] - data[b]) * (data[c + 1] - data[a + 1])); - } - - return polygonArea === 0 && trianglesArea === 0 ? 0 : - Math.abs((trianglesArea - polygonArea) / polygonArea); -}; - -function signedArea(data, start, end, dim) { - var sum = 0; - for (var i = start, j = end - dim; i < end; i += dim) { - sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); - j = i; - } - return sum; -} - -// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts -earcut.flatten = function (data) { - var dim = data[0][0].length, - result = {vertices: [], holes: [], dimensions: dim}, - holeIndex = 0; - - for (var i = 0; i < data.length; i++) { - for (var j = 0; j < data[i].length; j++) { - for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); - } - if (i > 0) { - holeIndex += data[i - 1].length; - result.holes.push(holeIndex); - } - } - return result; -}; - -},{}],3:[function(require,module,exports){ -'use strict'; - -var has = Object.prototype.hasOwnProperty - , prefix = '~'; - -/** - * Constructor to create a storage for our `EE` objects. - * An `Events` instance is a plain object whose properties are event names. - * - * @constructor - * @api private - */ -function Events() {} - -// -// We try to not inherit from `Object.prototype`. In some engines creating an -// instance in this way is faster than calling `Object.create(null)` directly. -// If `Object.create(null)` is not supported we prefix the event names with a -// character to make sure that the built-in object properties are not -// overridden or used as an attack vector. -// -if (Object.create) { - Events.prototype = Object.create(null); - - // - // This hack is needed because the `__proto__` property is still inherited in - // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. - // - if (!new Events().__proto__) prefix = false; -} - -/** - * Representation of a single event listener. - * - * @param {Function} fn The listener function. - * @param {Mixed} context The context to invoke the listener with. - * @param {Boolean} [once=false] Specify if the listener is a one-time listener. - * @constructor - * @api private - */ -function EE(fn, context, once) { - this.fn = fn; - this.context = context; - this.once = once || false; -} - -/** - * Minimal `EventEmitter` interface that is molded against the Node.js - * `EventEmitter` interface. - * - * @constructor - * @api public - */ -function EventEmitter() { - this._events = new Events(); - this._eventsCount = 0; -} - -/** - * Return an array listing the events for which the emitter has registered - * listeners. - * - * @returns {Array} - * @api public - */ -EventEmitter.prototype.eventNames = function eventNames() { - var names = [] - , events - , name; - - if (this._eventsCount === 0) return names; - - for (name in (events = this._events)) { - if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); - } - - if (Object.getOwnPropertySymbols) { - return names.concat(Object.getOwnPropertySymbols(events)); - } - - return names; -}; - -/** - * Return the listeners registered for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Boolean} exists Only check if there are listeners. - * @returns {Array|Boolean} - * @api public - */ -EventEmitter.prototype.listeners = function listeners(event, exists) { - var evt = prefix ? prefix + event : event - , available = this._events[evt]; - - if (exists) return !!available; - if (!available) return []; - if (available.fn) return [available.fn]; - - for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) { - ee[i] = available[i].fn; - } - - return ee; -}; - -/** - * Calls each of the listeners registered for a given event. - * - * @param {String|Symbol} event The event name. - * @returns {Boolean} `true` if the event had listeners, else `false`. - * @api public - */ -EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return false; - - var listeners = this._events[evt] - , len = arguments.length - , args - , i; - - if (listeners.fn) { - if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); - - switch (len) { - case 1: return listeners.fn.call(listeners.context), true; - case 2: return listeners.fn.call(listeners.context, a1), true; - case 3: return listeners.fn.call(listeners.context, a1, a2), true; - case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; - case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; - case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; - } - - for (i = 1, args = new Array(len -1); i < len; i++) { - args[i - 1] = arguments[i]; - } - - listeners.fn.apply(listeners.context, args); - } else { - var length = listeners.length - , j; - - for (i = 0; i < length; i++) { - if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); - - switch (len) { - case 1: listeners[i].fn.call(listeners[i].context); break; - case 2: listeners[i].fn.call(listeners[i].context, a1); break; - case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; - case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; - default: - if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { - args[j - 1] = arguments[j]; - } - - listeners[i].fn.apply(listeners[i].context, args); - } - } - } - - return true; -}; - -/** - * Add a listener for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn The listener function. - * @param {Mixed} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @api public - */ -EventEmitter.prototype.on = function on(event, fn, context) { - var listener = new EE(fn, context || this) - , evt = prefix ? prefix + event : event; - - if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; - else if (!this._events[evt].fn) this._events[evt].push(listener); - else this._events[evt] = [this._events[evt], listener]; - - return this; -}; - -/** - * Add a one-time listener for a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn The listener function. - * @param {Mixed} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @api public - */ -EventEmitter.prototype.once = function once(event, fn, context) { - var listener = new EE(fn, context || this, true) - , evt = prefix ? prefix + event : event; - - if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++; - else if (!this._events[evt].fn) this._events[evt].push(listener); - else this._events[evt] = [this._events[evt], listener]; - - return this; -}; - -/** - * Remove the listeners of a given event. - * - * @param {String|Symbol} event The event name. - * @param {Function} fn Only remove the listeners that match this function. - * @param {Mixed} context Only remove the listeners that have this context. - * @param {Boolean} once Only remove one-time listeners. - * @returns {EventEmitter} `this`. - * @api public - */ -EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return this; - if (!fn) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - return this; - } - - var listeners = this._events[evt]; - - if (listeners.fn) { - if ( - listeners.fn === fn - && (!once || listeners.once) - && (!context || listeners.context === context) - ) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - } else { - for (var i = 0, events = [], length = listeners.length; i < length; i++) { - if ( - listeners[i].fn !== fn - || (once && !listeners[i].once) - || (context && listeners[i].context !== context) - ) { - events.push(listeners[i]); - } - } - - // - // Reset the array, or remove it completely if we have no more listeners. - // - if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; - else if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - - return this; -}; - -/** - * Remove all listeners, or those of the specified event. - * - * @param {String|Symbol} [event] The event name. - * @returns {EventEmitter} `this`. - * @api public - */ -EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { - var evt; - - if (event) { - evt = prefix ? prefix + event : event; - if (this._events[evt]) { - if (--this._eventsCount === 0) this._events = new Events(); - else delete this._events[evt]; - } - } else { - this._events = new Events(); - this._eventsCount = 0; - } - - return this; -}; - -// -// Alias methods names because people roll like that. -// -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; -EventEmitter.prototype.addListener = EventEmitter.prototype.on; - -// -// This function doesn't apply anymore. -// -EventEmitter.prototype.setMaxListeners = function setMaxListeners() { - return this; -}; - -// -// Expose the prefix. -// -EventEmitter.prefixed = prefix; - -// -// Allow `EventEmitter` to be imported as module namespace. -// -EventEmitter.EventEmitter = EventEmitter; - -// -// Expose the module. -// -if ('undefined' !== typeof module) { - module.exports = EventEmitter; -} - -},{}],4:[function(require,module,exports){ -!function(e){var n=/iPhone/i,t=/iPod/i,r=/iPad/i,a=/\bAndroid(?:.+)Mobile\b/i,p=/Android/i,l=/\bAndroid(?:.+)SD4930UR\b/i,b=/\bAndroid(?:.+)(?:KF[A-Z]{2,4})\b/i,f=/Windows Phone/i,u=/\bWindows(?:.+)ARM\b/i,c=/BlackBerry/i,s=/BB10/i,v=/Opera Mini/i,h=/\b(CriOS|Chrome)(?:.+)Mobile/i,w=/\Mobile(?:.+)Firefox\b/i;function m(e,i){return e.test(i)}function i(e){var i=e||("undefined"!=typeof navigator?navigator.userAgent:""),o=i.split("[FBAN");void 0!==o[1]&&(i=o[0]),void 0!==(o=i.split("Twitter"))[1]&&(i=o[0]);var d={apple:{phone:m(n,i)&&!m(f,i),ipod:m(t,i),tablet:!m(n,i)&&m(r,i)&&!m(f,i),device:(m(n,i)||m(t,i)||m(r,i))&&!m(f,i)},amazon:{phone:m(l,i),tablet:!m(l,i)&&m(b,i),device:m(l,i)||m(b,i)},android:{phone:!m(f,i)&&m(l,i)||!m(f,i)&&m(a,i),tablet:!m(f,i)&&!m(l,i)&&!m(a,i)&&(m(b,i)||m(p,i)),device:!m(f,i)&&(m(l,i)||m(b,i)||m(a,i)||m(p,i))},windows:{phone:m(f,i),tablet:m(u,i),device:m(f,i)||m(u,i)},other:{blackberry:m(c,i),blackberry10:m(s,i),opera:m(v,i),firefox:m(w,i),chrome:m(h,i),device:m(c,i)||m(s,i)||m(v,i)||m(w,i)||m(h,i)}};return d.any=d.apple.device||d.android.device||d.windows.device||d.other.device,d.phone=d.apple.phone||d.android.phone||d.windows.phone,d.tablet=d.apple.tablet||d.android.tablet||d.windows.tablet,d}"undefined"!=typeof module&&module.exports&&"undefined"==typeof window?module.exports=i:"undefined"!=typeof module&&module.exports&&"undefined"!=typeof window?module.exports=i():"function"==typeof define&&define.amd?define([],e.isMobile=i()):e.isMobile=i()}(this); -},{}],5:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -var MiniSignalBinding = (function () { - function MiniSignalBinding(fn, once, thisArg) { - if (once === undefined) once = false; - - _classCallCheck(this, MiniSignalBinding); - - this._fn = fn; - this._once = once; - this._thisArg = thisArg; - this._next = this._prev = this._owner = null; - } - - _createClass(MiniSignalBinding, [{ - key: 'detach', - value: function detach() { - if (this._owner === null) return false; - this._owner.detach(this); - return true; - } - }]); - - return MiniSignalBinding; -})(); - -function _addMiniSignalBinding(self, node) { - if (!self._head) { - self._head = node; - self._tail = node; - } else { - self._tail._next = node; - node._prev = self._tail; - self._tail = node; - } - - node._owner = self; - - return node; -} - -var MiniSignal = (function () { - function MiniSignal() { - _classCallCheck(this, MiniSignal); - - this._head = this._tail = undefined; - } - - _createClass(MiniSignal, [{ - key: 'handlers', - value: function handlers() { - var exists = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; - - var node = this._head; - - if (exists) return !!node; - - var ee = []; - - while (node) { - ee.push(node); - node = node._next; - } - - return ee; - } - }, { - key: 'has', - value: function has(node) { - if (!(node instanceof MiniSignalBinding)) { - throw new Error('MiniSignal#has(): First arg must be a MiniSignalBinding object.'); - } - - return node._owner === this; - } - }, { - key: 'dispatch', - value: function dispatch() { - var node = this._head; - - if (!node) return false; - - while (node) { - if (node._once) this.detach(node); - node._fn.apply(node._thisArg, arguments); - node = node._next; - } - - return true; - } - }, { - key: 'add', - value: function add(fn) { - var thisArg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - - if (typeof fn !== 'function') { - throw new Error('MiniSignal#add(): First arg must be a Function.'); - } - return _addMiniSignalBinding(this, new MiniSignalBinding(fn, false, thisArg)); - } - }, { - key: 'once', - value: function once(fn) { - var thisArg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - - if (typeof fn !== 'function') { - throw new Error('MiniSignal#once(): First arg must be a Function.'); - } - return _addMiniSignalBinding(this, new MiniSignalBinding(fn, true, thisArg)); - } - }, { - key: 'detach', - value: function detach(node) { - if (!(node instanceof MiniSignalBinding)) { - throw new Error('MiniSignal#detach(): First arg must be a MiniSignalBinding object.'); - } - if (node._owner !== this) return this; - - if (node._prev) node._prev._next = node._next; - if (node._next) node._next._prev = node._prev; - - if (node === this._head) { - this._head = node._next; - if (node._next === null) { - this._tail = null; - } - } else if (node === this._tail) { - this._tail = node._prev; - this._tail._next = null; - } - - node._owner = null; - return this; - } - }, { - key: 'detachAll', - value: function detachAll() { - var node = this._head; - if (!node) return this; - - this._head = this._tail = null; - - while (node) { - node._owner = null; - node = node._next; - } - return this; - } - }]); - - return MiniSignal; -})(); - -MiniSignal.MiniSignalBinding = MiniSignalBinding; - -exports['default'] = MiniSignal; -module.exports = exports['default']; - -},{}],6:[function(require,module,exports){ -/* -object-assign -(c) Sindre Sorhus -@license MIT -*/ - -'use strict'; -/* eslint-disable no-unused-vars */ -var getOwnPropertySymbols = Object.getOwnPropertySymbols; -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); + function commonjsRequire () { + throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs'); } - return Object(val); -} - -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } -} - -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } + function unwrapExports (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } - return to; -}; + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } -},{}],7:[function(require,module,exports){ -'use strict' + function getCjsExportFromNamespace (n) { + return n && n['default'] || n; + } -module.exports = function parseURI (str, opts) { - opts = opts || {} + var promise = createCommonjsModule(function (module, exports) { + (function(global){ - var o = { - key: ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'], - q: { - name: 'queryKey', - parser: /(?:^|&)([^&=]*)=?([^&]*)/g - }, - parser: { - strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, - loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ - } - } + // + // Check for native Promise and it has correct interface + // - var m = o.parser[opts.strictMode ? 'strict' : 'loose'].exec(str) - var uri = {} - var i = 14 - - while (i--) uri[o.key[i]] = m[i] || '' - - uri[o.q.name] = {} - uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { - if ($1) uri[o.q.name][$1] = $2 - }) - - return uri -} - -},{}],8:[function(require,module,exports){ -(function (process){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length - 1; i >= 0; i--) { - var last = parts[i]; - if (last === '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -// Split a filename into [root, dir, basename, ext], unix version -// 'root' is just a slash, or nothing. -var splitPathRe = - /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; -var splitPath = function(filename) { - return splitPathRe.exec(filename).slice(1); -}; - -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { - var resolvedPath = '', - resolvedAbsolute = false; - - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) ? arguments[i] : process.cwd(); - - // Skip empty and invalid entries - if (typeof path !== 'string') { - throw new TypeError('Arguments to path.resolve must be strings'); - } else if (!path) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; - } - - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) - - // Normalize the path - resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); - - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; - -// path.normalize(path) -// posix version -exports.normalize = function(path) { - var isAbsolute = exports.isAbsolute(path), - trailingSlash = substr(path, -1) === '/'; - - // Normalize the path - path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; -}; - -// posix version -exports.isAbsolute = function(path) { - return path.charAt(0) === '/'; -}; - -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - if (typeof p !== 'string') { - throw new TypeError('Arguments to path.join must be strings'); - } - return p; - }).join('/')); -}; + var NativePromise = global['Promise']; + var nativePromiseSupported = + NativePromise && + // Some of these methods are missing from + // Firefox/Chrome experimental implementations + 'resolve' in NativePromise && + 'reject' in NativePromise && + 'all' in NativePromise && + 'race' in NativePromise && + // Older version of the spec had a resolver object + // as the arg rather than a function + (function(){ + var resolve; + new NativePromise(function(r){ resolve = r; }); + return typeof resolve === 'function'; + })(); -// path.relative(from, to) -// posix version -exports.relative = function(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); + // + // export if necessary + // - function trim(arr) { - var start = 0; - for (; start < arr.length; start++) { - if (arr[start] !== '') break; - } - - var end = arr.length - 1; - for (; end >= 0; end--) { - if (arr[end] !== '') break; - } - - if (start > end) return []; - return arr.slice(start, end - start + 1); - } - - var fromParts = trim(from.split('/')); - var toParts = trim(to.split('/')); - - var length = Math.min(fromParts.length, toParts.length); - var samePartsLength = length; - for (var i = 0; i < length; i++) { - if (fromParts[i] !== toParts[i]) { - samePartsLength = i; - break; - } - } - - var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { - outputParts.push('..'); - } - - outputParts = outputParts.concat(toParts.slice(samePartsLength)); - - return outputParts.join('/'); -}; - -exports.sep = '/'; -exports.delimiter = ':'; - -exports.dirname = function(path) { - var result = splitPath(path), - root = result[0], - dir = result[1]; - - if (!root && !dir) { - // No dirname whatsoever - return '.'; - } - - if (dir) { - // It has a dirname, strip trailing slash - dir = dir.substr(0, dir.length - 1); - } - - return root + dir; -}; - - -exports.basename = function(path, ext) { - var f = splitPath(path)[2]; - // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; - - -exports.extname = function(path) { - return splitPath(path)[3]; -}; - -function filter (xs, f) { - if (xs.filter) return xs.filter(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - if (f(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} - -// String.prototype.substr - negative index don't work in IE8 -var substr = 'ab'.substr(-1) === 'b' - ? function (str, start, len) { return str.substr(start, len) } - : function (str, start, len) { - if (start < 0) start = str.length + start; - return str.substr(start, len); - } -; - -}).call(this,require('_process')) - -},{"_process":26}],9:[function(require,module,exports){ -var EMPTY_ARRAY_BUFFER = new ArrayBuffer(0); - -/** - * Helper class to create a webGL buffer - * - * @class - * @memberof PIXI.glCore - * @param gl {WebGLRenderingContext} The current WebGL rendering context - * @param type {gl.ARRAY_BUFFER | gl.ELEMENT_ARRAY_BUFFER} @mat - * @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data - * @param drawType {gl.STATIC_DRAW|gl.DYNAMIC_DRAW|gl.STREAM_DRAW} - */ -var Buffer = function(gl, type, data, drawType) -{ - - /** - * The current WebGL rendering context - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - /** - * The WebGL buffer, created upon instantiation - * - * @member {WebGLBuffer} - */ - this.buffer = gl.createBuffer(); - - /** - * The type of the buffer - * - * @member {gl.ARRAY_BUFFER|gl.ELEMENT_ARRAY_BUFFER} - */ - this.type = type || gl.ARRAY_BUFFER; - - /** - * The draw type of the buffer - * - * @member {gl.STATIC_DRAW|gl.DYNAMIC_DRAW|gl.STREAM_DRAW} - */ - this.drawType = drawType || gl.STATIC_DRAW; - - /** - * The data in the buffer, as a typed array - * - * @member {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} - */ - this.data = EMPTY_ARRAY_BUFFER; - - if(data) + if ('object' !== 'undefined' && exports) { - this.upload(data); - } - - this._updateID = 0; -}; - -/** - * Uploads the buffer to the GPU - * @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data to upload - * @param offset {Number} if only a subset of the data should be uploaded, this is the amount of data to subtract - * @param dontBind {Boolean} whether to bind the buffer before uploading it - */ -Buffer.prototype.upload = function(data, offset, dontBind) -{ - // todo - needed? - if(!dontBind) this.bind(); - - var gl = this.gl; - - data = data || this.data; - offset = offset || 0; - - if(this.data.byteLength >= data.byteLength) - { - gl.bufferSubData(this.type, offset, data); + // node.js + exports.Promise = nativePromiseSupported ? NativePromise : Promise; + exports.Polyfill = Promise; } else { - gl.bufferData(this.type, data, this.drawType); + // AMD + if (typeof undefined == 'function' && undefined.amd) + { + undefined(function(){ + return nativePromiseSupported ? NativePromise : Promise; + }); + } + else + { + // in browser add to global + if (!nativePromiseSupported) + { global['Promise'] = Promise; } + } } - this.data = data; -}; -/** - * Binds the buffer - * - */ -Buffer.prototype.bind = function() -{ - var gl = this.gl; - gl.bindBuffer(this.type, this.buffer); -}; -Buffer.createVertexBuffer = function(gl, data, drawType) -{ - return new Buffer(gl, gl.ARRAY_BUFFER, data, drawType); -}; + // + // Polyfill + // -Buffer.createIndexBuffer = function(gl, data, drawType) -{ - return new Buffer(gl, gl.ELEMENT_ARRAY_BUFFER, data, drawType); -}; + var PENDING = 'pending'; + var SEALED = 'sealed'; + var FULFILLED = 'fulfilled'; + var REJECTED = 'rejected'; + var NOOP = function(){}; -Buffer.create = function(gl, type, data, drawType) -{ - return new Buffer(gl, type, data, drawType); -}; + function isArray(value) { + return Object.prototype.toString.call(value) === '[object Array]'; + } -/** - * Destroys the buffer - * - */ -Buffer.prototype.destroy = function(){ - this.gl.deleteBuffer(this.buffer); -}; + // async calls + var asyncSetTimer = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout; + var asyncQueue = []; + var asyncTimer; -module.exports = Buffer; + function asyncFlush(){ + // run promise callbacks + for (var i = 0; i < asyncQueue.length; i++) + { asyncQueue[i][0](asyncQueue[i][1]); } -},{}],10:[function(require,module,exports){ + // reset async asyncQueue + asyncQueue = []; + asyncTimer = false; + } -var Texture = require('./GLTexture'); + function asyncCall(callback, arg){ + asyncQueue.push([callback, arg]); -/** - * Helper class to create a webGL Framebuffer - * - * @class - * @memberof PIXI.glCore - * @param gl {WebGLRenderingContext} The current WebGL rendering context - * @param width {Number} the width of the drawing area of the frame buffer - * @param height {Number} the height of the drawing area of the frame buffer - */ -var Framebuffer = function(gl, width, height) -{ - /** - * The current WebGL rendering context - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - /** - * The frame buffer - * - * @member {WebGLFramebuffer} - */ - this.framebuffer = gl.createFramebuffer(); - - /** - * The stencil buffer - * - * @member {WebGLRenderbuffer} - */ - this.stencil = null; - - /** - * The stencil buffer - * - * @member {PIXI.glCore.GLTexture} - */ - this.texture = null; - - /** - * The width of the drawing area of the buffer - * - * @member {Number} - */ - this.width = width || 100; - /** - * The height of the drawing area of the buffer - * - * @member {Number} - */ - this.height = height || 100; -}; - -/** - * Adds a texture to the frame buffer - * @param texture {PIXI.glCore.GLTexture} - */ -Framebuffer.prototype.enableTexture = function(texture) -{ - var gl = this.gl; - - this.texture = texture || new Texture(gl); - - this.texture.bind(); - - //gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - - this.bind(); - - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture.texture, 0); -}; - -/** - * Initialises the stencil buffer - */ -Framebuffer.prototype.enableStencil = function() -{ - if(this.stencil)return; - - var gl = this.gl; - - this.stencil = gl.createRenderbuffer(); - - gl.bindRenderbuffer(gl.RENDERBUFFER, this.stencil); - - // TODO.. this is depth AND stencil? - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.stencil); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, this.width , this.height ); + if (!asyncTimer) + { + asyncTimer = true; + asyncSetTimer(asyncFlush, 0); + } + } -}; + function invokeResolver(resolver, promise) { + function resolvePromise(value) { + resolve(promise, value); + } -/** - * Erases the drawing area and fills it with a colour - * @param r {Number} the red value of the clearing colour - * @param g {Number} the green value of the clearing colour - * @param b {Number} the blue value of the clearing colour - * @param a {Number} the alpha value of the clearing colour - */ -Framebuffer.prototype.clear = function( r, g, b, a ) -{ - this.bind(); + function rejectPromise(reason) { + reject(promise, reason); + } - var gl = this.gl; + try { + resolver(resolvePromise, rejectPromise); + } catch(e) { + rejectPromise(e); + } + } - gl.clearColor(r, g, b, a); - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); -}; + function invokeCallback(subscriber){ + var owner = subscriber.owner; + var settled = owner.state_; + var value = owner.data_; + var callback = subscriber[settled]; + var promise = subscriber.then; -/** - * Binds the frame buffer to the WebGL context - */ -Framebuffer.prototype.bind = function() -{ - var gl = this.gl; - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); -}; + if (typeof callback === 'function') + { + settled = FULFILLED; + try { + value = callback(value); + } catch(e) { + reject(promise, e); + } + } -/** - * Unbinds the frame buffer to the WebGL context - */ -Framebuffer.prototype.unbind = function() -{ - var gl = this.gl; - gl.bindFramebuffer(gl.FRAMEBUFFER, null ); -}; -/** - * Resizes the drawing area of the buffer to the given width and height - * @param width {Number} the new width - * @param height {Number} the new height - */ -Framebuffer.prototype.resize = function(width, height) -{ - var gl = this.gl; + if (!handleThenable(promise, value)) + { + if (settled === FULFILLED) + { resolve(promise, value); } - this.width = width; - this.height = height; + if (settled === REJECTED) + { reject(promise, value); } + } + } - if ( this.texture ) - { - this.texture.uploadData(null, width, height); - } + function handleThenable(promise, value) { + var resolved; - if ( this.stencil ) - { - // update the stencil buffer width and height - gl.bindRenderbuffer(gl.RENDERBUFFER, this.stencil); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); - } -}; + try { + if (promise === value) + { throw new TypeError('A promises callback cannot return that same promise.'); } -/** - * Destroys this buffer - */ -Framebuffer.prototype.destroy = function() -{ - var gl = this.gl; + if (value && (typeof value === 'function' || typeof value === 'object')) + { + var then = value.then; // then should be retrived only once - //TODO - if(this.texture) - { - this.texture.destroy(); - } + if (typeof then === 'function') + { + then.call(value, function(val){ + if (!resolved) + { + resolved = true; - gl.deleteFramebuffer(this.framebuffer); + if (value !== val) + { resolve(promise, val); } + else + { fulfill(promise, val); } + } + }, function(reason){ + if (!resolved) + { + resolved = true; - this.gl = null; + reject(promise, reason); + } + }); - this.stencil = null; - this.texture = null; -}; + return true; + } + } + } catch (e) { + if (!resolved) + { reject(promise, e); } -/** - * Creates a frame buffer with a texture containing the given data - * @static - * @param gl {WebGLRenderingContext} The current WebGL rendering context - * @param width {Number} the width of the drawing area of the frame buffer - * @param height {Number} the height of the drawing area of the frame buffer - * @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data - */ -Framebuffer.createRGBA = function(gl, width, height, data) -{ - var texture = Texture.fromData(gl, null, width, height); - texture.enableNearestScaling(); - texture.enableWrapClamp(); + return true; + } - //now create the framebuffer object and attach the texture to it. - var fbo = new Framebuffer(gl, width, height); - fbo.enableTexture(texture); - //fbo.enableStencil(); // get this back on soon! + return false; + } - //fbo.enableStencil(); // get this back on soon! + function resolve(promise, value){ + if (promise === value || !handleThenable(promise, value)) + { fulfill(promise, value); } + } - fbo.unbind(); + function fulfill(promise, value){ + if (promise.state_ === PENDING) + { + promise.state_ = SEALED; + promise.data_ = value; - return fbo; -}; + asyncCall(publishFulfillment, promise); + } + } -/** - * Creates a frame buffer with a texture containing the given data - * @static - * @param gl {WebGLRenderingContext} The current WebGL rendering context - * @param width {Number} the width of the drawing area of the frame buffer - * @param height {Number} the height of the drawing area of the frame buffer - * @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data - */ -Framebuffer.createFloat32 = function(gl, width, height, data) -{ - // create a new texture.. - var texture = new Texture.fromData(gl, data, width, height); - texture.enableNearestScaling(); - texture.enableWrapClamp(); + function reject(promise, reason){ + if (promise.state_ === PENDING) + { + promise.state_ = SEALED; + promise.data_ = reason; - //now create the framebuffer object and attach the texture to it. - var fbo = new Framebuffer(gl, width, height); - fbo.enableTexture(texture); + asyncCall(publishRejection, promise); + } + } - fbo.unbind(); + function publish(promise) { + var callbacks = promise.then_; + promise.then_ = undefined; - return fbo; -}; + for (var i = 0; i < callbacks.length; i++) { + invokeCallback(callbacks[i]); + } + } -module.exports = Framebuffer; + function publishFulfillment(promise){ + promise.state_ = FULFILLED; + publish(promise); + } -},{"./GLTexture":12}],11:[function(require,module,exports){ - -var compileProgram = require('./shader/compileProgram'), - extractAttributes = require('./shader/extractAttributes'), - extractUniforms = require('./shader/extractUniforms'), - setPrecision = require('./shader/setPrecision'), - generateUniformAccessObject = require('./shader/generateUniformAccessObject'); - -/** - * Helper class to create a webGL Shader - * - * @class - * @memberof PIXI.glCore - * @param gl {WebGLRenderingContext} - * @param vertexSrc {string|string[]} The vertex shader source as an array of strings. - * @param fragmentSrc {string|string[]} The fragment shader source as an array of strings. - * @param precision {string} The float precision of the shader. Options are 'lowp', 'mediump' or 'highp'. - * @param attributeLocations {object} A key value pair showing which location eact attribute should sit eg {position:0, uvs:1} - */ -var Shader = function(gl, vertexSrc, fragmentSrc, precision, attributeLocations) -{ - /** - * The current WebGL rendering context - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - if(precision) - { - vertexSrc = setPrecision(vertexSrc, precision); - fragmentSrc = setPrecision(fragmentSrc, precision); + function publishRejection(promise){ + promise.state_ = REJECTED; + publish(promise); } /** - * The shader program - * - * @member {WebGLProgram} - */ - // First compile the program.. - this.program = compileProgram(gl, vertexSrc, fragmentSrc, attributeLocations); + * @class + */ + function Promise(resolver){ + if (typeof resolver !== 'function') + { throw new TypeError('Promise constructor takes a function argument'); } - /** - * The attributes of the shader as an object containing the following properties - * { - * type, - * size, - * location, - * pointer - * } - * @member {Object} - */ - // next extract the attributes - this.attributes = extractAttributes(gl, this.program); + if (this instanceof Promise === false) + { throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.'); } - this.uniformData = extractUniforms(gl, this.program); + this.then_ = []; - /** - * The uniforms of the shader as an object containing the following properties - * { - * gl, - * data - * } - * @member {Object} - */ - this.uniforms = generateUniformAccessObject( gl, this.uniformData ); - -}; -/** - * Uses this shader - * - * @return {PIXI.glCore.GLShader} Returns itself. - */ -Shader.prototype.bind = function() -{ - this.gl.useProgram(this.program); - return this; -}; - -/** - * Destroys this shader - * TODO - */ -Shader.prototype.destroy = function() -{ - this.attributes = null; - this.uniformData = null; - this.uniforms = null; - - var gl = this.gl; - gl.deleteProgram(this.program); -}; - - -module.exports = Shader; - -},{"./shader/compileProgram":17,"./shader/extractAttributes":19,"./shader/extractUniforms":20,"./shader/generateUniformAccessObject":21,"./shader/setPrecision":25}],12:[function(require,module,exports){ - -/** - * Helper class to create a WebGL Texture - * - * @class - * @memberof PIXI.glCore - * @param gl {WebGLRenderingContext} The current WebGL context - * @param width {number} the width of the texture - * @param height {number} the height of the texture - * @param format {number} the pixel format of the texture. defaults to gl.RGBA - * @param type {number} the gl type of the texture. defaults to gl.UNSIGNED_BYTE - */ -var Texture = function(gl, width, height, format, type) -{ - /** - * The current WebGL rendering context - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - - /** - * The WebGL texture - * - * @member {WebGLTexture} - */ - this.texture = gl.createTexture(); - - /** - * If mipmapping was used for this texture, enable and disable with enableMipmap() - * - * @member {Boolean} - */ - // some settings.. - this.mipmap = false; - - - /** - * Set to true to enable pre-multiplied alpha - * - * @member {Boolean} - */ - this.premultiplyAlpha = false; - - /** - * The width of texture - * - * @member {Number} - */ - this.width = width || -1; - /** - * The height of texture - * - * @member {Number} - */ - this.height = height || -1; - - /** - * The pixel format of the texture. defaults to gl.RGBA - * - * @member {Number} - */ - this.format = format || gl.RGBA; - - /** - * The gl type of the texture. defaults to gl.UNSIGNED_BYTE - * - * @member {Number} - */ - this.type = type || gl.UNSIGNED_BYTE; - - -}; - -/** - * Uploads this texture to the GPU - * @param source {HTMLImageElement|ImageData|HTMLVideoElement} the source image of the texture - */ -Texture.prototype.upload = function(source) -{ - this.bind(); - - var gl = this.gl; - - - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha); - - var newWidth = source.videoWidth || source.width; - var newHeight = source.videoHeight || source.height; - - if(newHeight !== this.height || newWidth !== this.width) - { - gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, source); - } - else - { - gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.format, this.type, source); + invokeResolver(resolver, this); } - // if the source is a video, we need to use the videoWidth / videoHeight properties as width / height will be incorrect. - this.width = newWidth; - this.height = newHeight; - -}; - -var FLOATING_POINT_AVAILABLE = false; - -/** - * Use a data source and uploads this texture to the GPU - * @param data {TypedArray} the data to upload to the texture - * @param width {number} the new width of the texture - * @param height {number} the new height of the texture - */ -Texture.prototype.uploadData = function(data, width, height) -{ - this.bind(); - - var gl = this.gl; - - - if(data instanceof Float32Array) - { - if(!FLOATING_POINT_AVAILABLE) - { - var ext = gl.getExtension("OES_texture_float"); - - if(ext) - { - FLOATING_POINT_AVAILABLE = true; - } - else - { - throw new Error('floating point textures not available'); - } - } - - this.type = gl.FLOAT; - } - else - { - // TODO support for other types - this.type = this.type || gl.UNSIGNED_BYTE; - } - - // what type of data? - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha); - - - if(width !== this.width || height !== this.height) - { - gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, this.type, data || null); - } - else - { - gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, width, height, this.format, this.type, data || null); - } - - this.width = width; - this.height = height; - - -// texSubImage2D -}; - -/** - * Binds the texture - * @param location - */ -Texture.prototype.bind = function(location) -{ - var gl = this.gl; - - if(location !== undefined) - { - gl.activeTexture(gl.TEXTURE0 + location); - } - - gl.bindTexture(gl.TEXTURE_2D, this.texture); -}; - -/** - * Unbinds the texture - */ -Texture.prototype.unbind = function() -{ - var gl = this.gl; - gl.bindTexture(gl.TEXTURE_2D, null); -}; - -/** - * @param linear {Boolean} if we want to use linear filtering or nearest neighbour interpolation - */ -Texture.prototype.minFilter = function( linear ) -{ - var gl = this.gl; - - this.bind(); - - if(this.mipmap) - { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, linear ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); - } - else - { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, linear ? gl.LINEAR : gl.NEAREST); - } -}; - -/** - * @param linear {Boolean} if we want to use linear filtering or nearest neighbour interpolation - */ -Texture.prototype.magFilter = function( linear ) -{ - var gl = this.gl; - - this.bind(); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, linear ? gl.LINEAR : gl.NEAREST); -}; - -/** - * Enables mipmapping - */ -Texture.prototype.enableMipmap = function() -{ - var gl = this.gl; - - this.bind(); - - this.mipmap = true; - - gl.generateMipmap(gl.TEXTURE_2D); -}; - -/** - * Enables linear filtering - */ -Texture.prototype.enableLinearScaling = function() -{ - this.minFilter(true); - this.magFilter(true); -}; - -/** - * Enables nearest neighbour interpolation - */ -Texture.prototype.enableNearestScaling = function() -{ - this.minFilter(false); - this.magFilter(false); -}; - -/** - * Enables clamping on the texture so WebGL will not repeat it - */ -Texture.prototype.enableWrapClamp = function() -{ - var gl = this.gl; - - this.bind(); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); -}; - -/** - * Enable tiling on the texture - */ -Texture.prototype.enableWrapRepeat = function() -{ - var gl = this.gl; - - this.bind(); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); -}; - -Texture.prototype.enableWrapMirrorRepeat = function() -{ - var gl = this.gl; - - this.bind(); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.MIRRORED_REPEAT); -}; - - -/** - * Destroys this texture - */ -Texture.prototype.destroy = function() -{ - var gl = this.gl; - //TODO - gl.deleteTexture(this.texture); -}; - -/** - * @static - * @param gl {WebGLRenderingContext} The current WebGL context - * @param source {HTMLImageElement|ImageData} the source image of the texture - * @param premultiplyAlpha {Boolean} If we want to use pre-multiplied alpha - */ -Texture.fromSource = function(gl, source, premultiplyAlpha) -{ - var texture = new Texture(gl); - texture.premultiplyAlpha = premultiplyAlpha || false; - texture.upload(source); - - return texture; -}; - -/** - * @static - * @param gl {WebGLRenderingContext} The current WebGL context - * @param data {TypedArray} the data to upload to the texture - * @param width {number} the new width of the texture - * @param height {number} the new height of the texture - */ -Texture.fromData = function(gl, data, width, height) -{ - //console.log(data, width, height); - var texture = new Texture(gl); - texture.uploadData(data, width, height); - - return texture; -}; - - -module.exports = Texture; - -},{}],13:[function(require,module,exports){ - -// state object// -var setVertexAttribArrays = require( './setVertexAttribArrays' ); - -/** - * Helper class to work with WebGL VertexArrayObjects (vaos) - * Only works if WebGL extensions are enabled (they usually are) - * - * @class - * @memberof PIXI.glCore - * @param gl {WebGLRenderingContext} The current WebGL rendering context - */ -function VertexArrayObject(gl, state) -{ - this.nativeVaoExtension = null; - - if(!VertexArrayObject.FORCE_NATIVE) - { - this.nativeVaoExtension = gl.getExtension('OES_vertex_array_object') || - gl.getExtension('MOZ_OES_vertex_array_object') || - gl.getExtension('WEBKIT_OES_vertex_array_object'); - } - - this.nativeState = state; - - if(this.nativeVaoExtension) - { - this.nativeVao = this.nativeVaoExtension.createVertexArrayOES(); - - var maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); - - // VAO - overwrite the state.. - this.nativeState = { - tempAttribState: new Array(maxAttribs), - attribState: new Array(maxAttribs) - }; - } - - /** - * The current WebGL rendering context - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - /** - * An array of attributes - * - * @member {Array} - */ - this.attributes = []; - - /** - * @member {PIXI.glCore.GLBuffer} - */ - this.indexBuffer = null; - - /** - * A boolean flag - * - * @member {Boolean} - */ - this.dirty = false; -} - -VertexArrayObject.prototype.constructor = VertexArrayObject; -module.exports = VertexArrayObject; - -/** -* Some devices behave a bit funny when using the newer extensions (im looking at you ipad 2!) -* If you find on older devices that things have gone a bit weird then set this to true. -*/ -/** - * Lets the VAO know if you should use the WebGL extension or the native methods. - * Some devices behave a bit funny when using the newer extensions (im looking at you ipad 2!) - * If you find on older devices that things have gone a bit weird then set this to true. - * @static - * @property {Boolean} FORCE_NATIVE - */ -VertexArrayObject.FORCE_NATIVE = false; - -/** - * Binds the buffer - */ -VertexArrayObject.prototype.bind = function() -{ - if(this.nativeVao) - { - this.nativeVaoExtension.bindVertexArrayOES(this.nativeVao); - - if(this.dirty) - { - this.dirty = false; - this.activate(); - return this; - } - if (this.indexBuffer) - { - this.indexBuffer.bind(); - } - } - else - { - this.activate(); - } - - return this; -}; - -/** - * Unbinds the buffer - */ -VertexArrayObject.prototype.unbind = function() -{ - if(this.nativeVao) - { - this.nativeVaoExtension.bindVertexArrayOES(null); - } - - return this; -}; - -/** - * Uses this vao - */ -VertexArrayObject.prototype.activate = function() -{ - - var gl = this.gl; - var lastBuffer = null; - - for (var i = 0; i < this.attributes.length; i++) - { - var attrib = this.attributes[i]; - - if(lastBuffer !== attrib.buffer) - { - attrib.buffer.bind(); - lastBuffer = attrib.buffer; - } - - gl.vertexAttribPointer(attrib.attribute.location, - attrib.attribute.size, - attrib.type || gl.FLOAT, - attrib.normalized || false, - attrib.stride || 0, - attrib.start || 0); - } - - setVertexAttribArrays(gl, this.attributes, this.nativeState); - - if(this.indexBuffer) - { - this.indexBuffer.bind(); - } - - return this; -}; - -/** - * - * @param buffer {PIXI.gl.GLBuffer} - * @param attribute {*} - * @param type {String} - * @param normalized {Boolean} - * @param stride {Number} - * @param start {Number} - */ -VertexArrayObject.prototype.addAttribute = function(buffer, attribute, type, normalized, stride, start) -{ - this.attributes.push({ - buffer: buffer, - attribute: attribute, - - location: attribute.location, - type: type || this.gl.FLOAT, - normalized: normalized || false, - stride: stride || 0, - start: start || 0 - }); - - this.dirty = true; - - return this; -}; - -/** - * - * @param buffer {PIXI.gl.GLBuffer} - */ -VertexArrayObject.prototype.addIndex = function(buffer/*, options*/) -{ - this.indexBuffer = buffer; - - this.dirty = true; - - return this; -}; - -/** - * Unbinds this vao and disables it - */ -VertexArrayObject.prototype.clear = function() -{ - // var gl = this.gl; - - // TODO - should this function unbind after clear? - // for now, no but lets see what happens in the real world! - if(this.nativeVao) - { - this.nativeVaoExtension.bindVertexArrayOES(this.nativeVao); - } - - this.attributes.length = 0; - this.indexBuffer = null; - - return this; -}; - -/** - * @param type {Number} - * @param size {Number} - * @param start {Number} - */ -VertexArrayObject.prototype.draw = function(type, size, start) -{ - var gl = this.gl; - - if(this.indexBuffer) - { - gl.drawElements(type, size || this.indexBuffer.data.length, gl.UNSIGNED_SHORT, (start || 0) * 2 ); - } - else - { - // TODO need a better way to calculate size.. - gl.drawArrays(type, start, size || this.getSize()); - } - - return this; -}; - -/** - * Destroy this vao - */ -VertexArrayObject.prototype.destroy = function() -{ - // lose references - this.gl = null; - this.indexBuffer = null; - this.attributes = null; - this.nativeState = null; - - if(this.nativeVao) - { - this.nativeVaoExtension.deleteVertexArrayOES(this.nativeVao); - } - - this.nativeVaoExtension = null; - this.nativeVao = null; -}; - -VertexArrayObject.prototype.getSize = function() -{ - var attrib = this.attributes[0]; - return attrib.buffer.data.length / (( attrib.stride/4 ) || attrib.attribute.size); -}; - -},{"./setVertexAttribArrays":16}],14:[function(require,module,exports){ - -/** - * Helper class to create a webGL Context - * - * @class - * @memberof PIXI.glCore - * @param canvas {HTMLCanvasElement} the canvas element that we will get the context from - * @param options {Object} An options object that gets passed in to the canvas element containing the context attributes, - * see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext for the options available - * @return {WebGLRenderingContext} the WebGL context - */ -var createContext = function(canvas, options) -{ - var gl = canvas.getContext('webgl', options) || - canvas.getContext('experimental-webgl', options); - - if (!gl) - { - // fail, not able to get a context - throw new Error('This browser does not support webGL. Try using the canvas renderer'); - } - - return gl; -}; - -module.exports = createContext; - -},{}],15:[function(require,module,exports){ -var gl = { - createContext: require('./createContext'), - setVertexAttribArrays: require('./setVertexAttribArrays'), - GLBuffer: require('./GLBuffer'), - GLFramebuffer: require('./GLFramebuffer'), - GLShader: require('./GLShader'), - GLTexture: require('./GLTexture'), - VertexArrayObject: require('./VertexArrayObject'), - shader: require('./shader') -}; - -// Export for Node-compatible environments -if (typeof module !== 'undefined' && module.exports) -{ - // Export the module - module.exports = gl; -} - -// Add to the browser window pixi.gl -if (typeof window !== 'undefined') -{ - // add the window object - window.PIXI = window.PIXI || {}; - window.PIXI.glCore = gl; -} - -},{"./GLBuffer":9,"./GLFramebuffer":10,"./GLShader":11,"./GLTexture":12,"./VertexArrayObject":13,"./createContext":14,"./setVertexAttribArrays":16,"./shader":22}],16:[function(require,module,exports){ -// var GL_MAP = {}; - -/** - * @param gl {WebGLRenderingContext} The current WebGL context - * @param attribs {*} - * @param state {*} - */ -var setVertexAttribArrays = function (gl, attribs, state) -{ - var i; - if(state) - { - var tempAttribState = state.tempAttribState, - attribState = state.attribState; - - for (i = 0; i < tempAttribState.length; i++) - { - tempAttribState[i] = false; - } - - // set the new attribs - for (i = 0; i < attribs.length; i++) - { - tempAttribState[attribs[i].attribute.location] = true; - } - - for (i = 0; i < attribState.length; i++) - { - if (attribState[i] !== tempAttribState[i]) - { - attribState[i] = tempAttribState[i]; - - if (state.attribState[i]) - { - gl.enableVertexAttribArray(i); - } - else - { - gl.disableVertexAttribArray(i); - } - } - } - - } - else - { - for (i = 0; i < attribs.length; i++) - { - var attrib = attribs[i]; - gl.enableVertexAttribArray(attrib.attribute.location); - } - } -}; - -module.exports = setVertexAttribArrays; - -},{}],17:[function(require,module,exports){ - -/** - * @class - * @memberof PIXI.glCore.shader - * @param gl {WebGLRenderingContext} The current WebGL context {WebGLProgram} - * @param vertexSrc {string|string[]} The vertex shader source as an array of strings. - * @param fragmentSrc {string|string[]} The fragment shader source as an array of strings. - * @param attributeLocations {Object} An attribute location map that lets you manually set the attribute locations - * @return {WebGLProgram} the shader program - */ -var compileProgram = function(gl, vertexSrc, fragmentSrc, attributeLocations) -{ - var glVertShader = compileShader(gl, gl.VERTEX_SHADER, vertexSrc); - var glFragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSrc); - - var program = gl.createProgram(); - - gl.attachShader(program, glVertShader); - gl.attachShader(program, glFragShader); - - // optionally, set the attributes manually for the program rather than letting WebGL decide.. - if(attributeLocations) - { - for(var i in attributeLocations) - { - gl.bindAttribLocation(program, attributeLocations[i], i); - } - } - - - gl.linkProgram(program); - - // if linking fails, then log and cleanup - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - { - console.error('Pixi.js Error: Could not initialize shader.'); - console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); - console.error('gl.getError()', gl.getError()); - - // if there is a program info log, log it - if (gl.getProgramInfoLog(program) !== '') - { - console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); - } - - gl.deleteProgram(program); - program = null; - } - - // clean up some shaders - gl.deleteShader(glVertShader); - gl.deleteShader(glFragShader); - - return program; -}; - -/** - * @private - * @param gl {WebGLRenderingContext} The current WebGL context {WebGLProgram} - * @param type {Number} the type, can be either VERTEX_SHADER or FRAGMENT_SHADER - * @param vertexSrc {string|string[]} The vertex shader source as an array of strings. - * @return {WebGLShader} the shader - */ -var compileShader = function (gl, type, src) -{ - var shader = gl.createShader(type); - - gl.shaderSource(shader, src); - gl.compileShader(shader); - - if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) - { - console.log(gl.getShaderInfoLog(shader)); - return null; - } - - return shader; -}; - -module.exports = compileProgram; - -},{}],18:[function(require,module,exports){ -/** - * @class - * @memberof PIXI.glCore.shader - * @param type {String} Type of value - * @param size {Number} - */ -var defaultValue = function(type, size) -{ - switch (type) - { - case 'float': - return 0; - - case 'vec2': - return new Float32Array(2 * size); - - case 'vec3': - return new Float32Array(3 * size); - - case 'vec4': - return new Float32Array(4 * size); - - case 'int': - case 'sampler2D': - return 0; - - case 'ivec2': - return new Int32Array(2 * size); - - case 'ivec3': - return new Int32Array(3 * size); - - case 'ivec4': - return new Int32Array(4 * size); - - case 'bool': - return false; - - case 'bvec2': - - return booleanArray( 2 * size); - - case 'bvec3': - return booleanArray(3 * size); - - case 'bvec4': - return booleanArray(4 * size); - - case 'mat2': - return new Float32Array([1, 0, - 0, 1]); - - case 'mat3': - return new Float32Array([1, 0, 0, - 0, 1, 0, - 0, 0, 1]); - - case 'mat4': - return new Float32Array([1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1]); - } -}; - -var booleanArray = function(size) -{ - var array = new Array(size); - - for (var i = 0; i < array.length; i++) - { - array[i] = false; - } - - return array; -}; - -module.exports = defaultValue; - -},{}],19:[function(require,module,exports){ - -var mapType = require('./mapType'); -var mapSize = require('./mapSize'); - -/** - * Extracts the attributes - * @class - * @memberof PIXI.glCore.shader - * @param gl {WebGLRenderingContext} The current WebGL rendering context - * @param program {WebGLProgram} The shader program to get the attributes from - * @return attributes {Object} - */ -var extractAttributes = function(gl, program) -{ - var attributes = {}; - - var totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); - - for (var i = 0; i < totalAttributes; i++) - { - var attribData = gl.getActiveAttrib(program, i); - var type = mapType(gl, attribData.type); - - attributes[attribData.name] = { - type:type, - size:mapSize(type), - location:gl.getAttribLocation(program, attribData.name), - //TODO - make an attribute object - pointer: pointer - }; - } - - return attributes; -}; - -var pointer = function(type, normalized, stride, start){ - // console.log(this.location) - gl.vertexAttribPointer(this.location,this.size, type || gl.FLOAT, normalized || false, stride || 0, start || 0); -}; - -module.exports = extractAttributes; - -},{"./mapSize":23,"./mapType":24}],20:[function(require,module,exports){ -var mapType = require('./mapType'); -var defaultValue = require('./defaultValue'); - -/** - * Extracts the uniforms - * @class - * @memberof PIXI.glCore.shader - * @param gl {WebGLRenderingContext} The current WebGL rendering context - * @param program {WebGLProgram} The shader program to get the uniforms from - * @return uniforms {Object} - */ -var extractUniforms = function(gl, program) -{ - var uniforms = {}; - - var totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); - - for (var i = 0; i < totalUniforms; i++) - { - var uniformData = gl.getActiveUniform(program, i); - var name = uniformData.name.replace(/\[.*?\]/, ""); - var type = mapType(gl, uniformData.type ); - - uniforms[name] = { - type:type, - size:uniformData.size, - location:gl.getUniformLocation(program, name), - value:defaultValue(type, uniformData.size) - }; - } - - return uniforms; -}; - -module.exports = extractUniforms; - -},{"./defaultValue":18,"./mapType":24}],21:[function(require,module,exports){ -/** - * Extracts the attributes - * @class - * @memberof PIXI.glCore.shader - * @param gl {WebGLRenderingContext} The current WebGL rendering context - * @param uniforms {Array} @mat ? - * @return attributes {Object} - */ -var generateUniformAccessObject = function(gl, uniformData) -{ - // this is the object we will be sending back. - // an object hierachy will be created for structs - var uniforms = {data:{}}; - - uniforms.gl = gl; - - var uniformKeys= Object.keys(uniformData); - - for (var i = 0; i < uniformKeys.length; i++) - { - var fullName = uniformKeys[i]; - - var nameTokens = fullName.split('.'); - var name = nameTokens[nameTokens.length - 1]; - - - var uniformGroup = getUniformGroup(nameTokens, uniforms); - - var uniform = uniformData[fullName]; - uniformGroup.data[name] = uniform; - - uniformGroup.gl = gl; - - Object.defineProperty(uniformGroup, name, { - get: generateGetter(name), - set: generateSetter(name, uniform) - }); - } - - return uniforms; -}; - -var generateGetter = function(name) -{ - return function() { - return this.data[name].value; - }; -}; - -var GLSL_SINGLE_SETTERS = { - float: function setSingleFloat(gl, location, value) { gl.uniform1f(location, value); }, - vec2: function setSingleVec2(gl, location, value) { gl.uniform2f(location, value[0], value[1]); }, - vec3: function setSingleVec3(gl, location, value) { gl.uniform3f(location, value[0], value[1], value[2]); }, - vec4: function setSingleVec4(gl, location, value) { gl.uniform4f(location, value[0], value[1], value[2], value[3]); }, - - int: function setSingleInt(gl, location, value) { gl.uniform1i(location, value); }, - ivec2: function setSingleIvec2(gl, location, value) { gl.uniform2i(location, value[0], value[1]); }, - ivec3: function setSingleIvec3(gl, location, value) { gl.uniform3i(location, value[0], value[1], value[2]); }, - ivec4: function setSingleIvec4(gl, location, value) { gl.uniform4i(location, value[0], value[1], value[2], value[3]); }, - - bool: function setSingleBool(gl, location, value) { gl.uniform1i(location, value); }, - bvec2: function setSingleBvec2(gl, location, value) { gl.uniform2i(location, value[0], value[1]); }, - bvec3: function setSingleBvec3(gl, location, value) { gl.uniform3i(location, value[0], value[1], value[2]); }, - bvec4: function setSingleBvec4(gl, location, value) { gl.uniform4i(location, value[0], value[1], value[2], value[3]); }, - - mat2: function setSingleMat2(gl, location, value) { gl.uniformMatrix2fv(location, false, value); }, - mat3: function setSingleMat3(gl, location, value) { gl.uniformMatrix3fv(location, false, value); }, - mat4: function setSingleMat4(gl, location, value) { gl.uniformMatrix4fv(location, false, value); }, - - sampler2D: function setSingleSampler2D(gl, location, value) { gl.uniform1i(location, value); }, -}; - -var GLSL_ARRAY_SETTERS = { - float: function setFloatArray(gl, location, value) { gl.uniform1fv(location, value); }, - vec2: function setVec2Array(gl, location, value) { gl.uniform2fv(location, value); }, - vec3: function setVec3Array(gl, location, value) { gl.uniform3fv(location, value); }, - vec4: function setVec4Array(gl, location, value) { gl.uniform4fv(location, value); }, - int: function setIntArray(gl, location, value) { gl.uniform1iv(location, value); }, - ivec2: function setIvec2Array(gl, location, value) { gl.uniform2iv(location, value); }, - ivec3: function setIvec3Array(gl, location, value) { gl.uniform3iv(location, value); }, - ivec4: function setIvec4Array(gl, location, value) { gl.uniform4iv(location, value); }, - bool: function setBoolArray(gl, location, value) { gl.uniform1iv(location, value); }, - bvec2: function setBvec2Array(gl, location, value) { gl.uniform2iv(location, value); }, - bvec3: function setBvec3Array(gl, location, value) { gl.uniform3iv(location, value); }, - bvec4: function setBvec4Array(gl, location, value) { gl.uniform4iv(location, value); }, - sampler2D: function setSampler2DArray(gl, location, value) { gl.uniform1iv(location, value); }, -}; - -function generateSetter(name, uniform) -{ - return function(value) { - this.data[name].value = value; - var location = this.data[name].location; - if (uniform.size === 1) - { - GLSL_SINGLE_SETTERS[uniform.type](this.gl, location, value); - } - else - { - // glslSetArray(gl, location, type, value) { - GLSL_ARRAY_SETTERS[uniform.type](this.gl, location, value); - } - }; -} - -function getUniformGroup(nameTokens, uniform) -{ - var cur = uniform; - - for (var i = 0; i < nameTokens.length - 1; i++) - { - var o = cur[nameTokens[i]] || {data:{}}; - cur[nameTokens[i]] = o; - cur = o; - } - - return cur; -} - - -module.exports = generateUniformAccessObject; - -},{}],22:[function(require,module,exports){ -module.exports = { - compileProgram: require('./compileProgram'), - defaultValue: require('./defaultValue'), - extractAttributes: require('./extractAttributes'), - extractUniforms: require('./extractUniforms'), - generateUniformAccessObject: require('./generateUniformAccessObject'), - setPrecision: require('./setPrecision'), - mapSize: require('./mapSize'), - mapType: require('./mapType') -}; -},{"./compileProgram":17,"./defaultValue":18,"./extractAttributes":19,"./extractUniforms":20,"./generateUniformAccessObject":21,"./mapSize":23,"./mapType":24,"./setPrecision":25}],23:[function(require,module,exports){ -/** - * @class - * @memberof PIXI.glCore.shader - * @param type {String} - * @return {Number} - */ -var mapSize = function(type) -{ - return GLSL_TO_SIZE[type]; -}; - - -var GLSL_TO_SIZE = { - 'float': 1, - 'vec2': 2, - 'vec3': 3, - 'vec4': 4, - - 'int': 1, - 'ivec2': 2, - 'ivec3': 3, - 'ivec4': 4, - - 'bool': 1, - 'bvec2': 2, - 'bvec3': 3, - 'bvec4': 4, - - 'mat2': 4, - 'mat3': 9, - 'mat4': 16, - - 'sampler2D': 1 -}; - -module.exports = mapSize; - -},{}],24:[function(require,module,exports){ - - -var mapType = function(gl, type) -{ - if(!GL_TABLE) - { - var typeNames = Object.keys(GL_TO_GLSL_TYPES); - - GL_TABLE = {}; - - for(var i = 0; i < typeNames.length; ++i) - { - var tn = typeNames[i]; - GL_TABLE[ gl[tn] ] = GL_TO_GLSL_TYPES[tn]; - } - } - - return GL_TABLE[type]; -}; - -var GL_TABLE = null; - -var GL_TO_GLSL_TYPES = { - 'FLOAT': 'float', - 'FLOAT_VEC2': 'vec2', - 'FLOAT_VEC3': 'vec3', - 'FLOAT_VEC4': 'vec4', - - 'INT': 'int', - 'INT_VEC2': 'ivec2', - 'INT_VEC3': 'ivec3', - 'INT_VEC4': 'ivec4', - - 'BOOL': 'bool', - 'BOOL_VEC2': 'bvec2', - 'BOOL_VEC3': 'bvec3', - 'BOOL_VEC4': 'bvec4', - - 'FLOAT_MAT2': 'mat2', - 'FLOAT_MAT3': 'mat3', - 'FLOAT_MAT4': 'mat4', - - 'SAMPLER_2D': 'sampler2D' -}; - -module.exports = mapType; - -},{}],25:[function(require,module,exports){ -/** - * Sets the float precision on the shader. If the precision is already present this function will do nothing - * @param {string} src the shader source - * @param {string} precision The float precision of the shader. Options are 'lowp', 'mediump' or 'highp'. - * - * @return {string} modified shader source - */ -var setPrecision = function(src, precision) -{ - if(src.substring(0, 9) !== 'precision') - { - return 'precision ' + precision + ' float;\n' + src; - } - - return src; -}; - -module.exports = setPrecision; - -},{}],26:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],27:[function(require,module,exports){ -(function (global){ -/*! https://mths.be/punycode v1.4.1 by @mathias */ -;(function(root) { - - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && - !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } - - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, - - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' - - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators - - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, - - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, - - /** Temporary variable */ - key; - - /*--------------------------------------------------------------------------*/ - - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } - - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } - - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } - - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } - - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } - - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } - - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } - - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. - - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } - - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } - - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. - - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { - - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { - - if (index >= inputLength) { - error('invalid-input'); - } - - digit = basicToDigit(input.charCodeAt(index++)); - - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } - - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - - if (digit < t) { - break; - } - - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } - - w *= baseMinusT; - - } - - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); - - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } - - n += floor(i / out); - i %= out; - - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); - - } - - return ucs2encode(output); - } - - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); - - // Cache the length - inputLength = input.length; - - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; - - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } - - handledCPCount = basicLength = output.length; - - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. - - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } - - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - - ++delta; - ++n; - - } - return output.join(''); - } - - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } - - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } - - /*--------------------------------------------------------------------------*/ - - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.4.1', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode + Promise.prototype = { + constructor: Promise, + + state_: PENDING, + then_: null, + data_: undefined, + + then: function(onFulfillment, onRejection){ + var subscriber = { + owner: this, + then: new this.constructor(NOOP), + fulfilled: onFulfillment, + rejected: onRejection + }; + + if (this.state_ === FULFILLED || this.state_ === REJECTED) + { + // already resolved, call callback async + asyncCall(invokeCallback, subscriber); + } + else + { + // subscribe + this.then_.push(subscriber); + } + + return subscriber.then; + }, + + 'catch': function(onRejection) { + return this.then(null, onRejection); + } }; - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define('punycode', function() { - return punycode; - }); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { - // in Node.js, io.js, or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { - // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } + Promise.all = function(promises){ + var Class = this; + + if (!isArray(promises)) + { throw new TypeError('You must pass an array to Promise.all().'); } + + return new Class(function(resolve, reject){ + var results = []; + var remaining = 0; + + function resolver(index){ + remaining++; + return function(value){ + results[index] = value; + if (!--remaining) + { resolve(results); } + }; + } + + for (var i = 0, promise; i < promises.length; i++) + { + promise = promises[i]; + + if (promise && typeof promise.then === 'function') + { promise.then(resolver(i), reject); } + else + { results[i] = promise; } + } + + if (!remaining) + { resolve(results); } + }); + }; + + Promise.race = function(promises){ + var Class = this; + + if (!isArray(promises)) + { throw new TypeError('You must pass an array to Promise.race().'); } + + return new Class(function(resolve, reject) { + for (var i = 0, promise; i < promises.length; i++) + { + promise = promises[i]; + + if (promise && typeof promise.then === 'function') + { promise.then(resolve, reject); } + else + { resolve(promise); } + } + }); + }; + + Promise.resolve = function(value){ + var Class = this; + + if (value && typeof value === 'object' && value.constructor === Class) + { return value; } + + return new Class(function(resolve){ + resolve(value); + }); + }; + + Promise.reject = function(reason){ + var Class = this; + + return new Class(function(resolve, reject){ + reject(reason); + }); + }; + + })(typeof window != 'undefined' ? window : typeof commonjsGlobal != 'undefined' ? commonjsGlobal : typeof self != 'undefined' ? self : commonjsGlobal); + }); + var promise_1 = promise.Promise; + var promise_2 = promise.Polyfill; + + /* + object-assign + (c) Sindre Sorhus + @license MIT + */ + + 'use strict'; + /* eslint-disable no-unused-vars */ + var getOwnPropertySymbols = Object.getOwnPropertySymbols; + var hasOwnProperty = Object.prototype.hasOwnProperty; + var propIsEnumerable = Object.prototype.propertyIsEnumerable; + + function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); } - } else { - // in Rhino or a web browser - root.punycode = punycode; + + return Object(val); } -}(this)); - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - -},{}],28:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -// If obj.hasOwnProperty has been overridden, then calling -// obj.hasOwnProperty(prop) will break. -// See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -module.exports = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; - var obj = {}; - - if (typeof qs !== 'string' || qs.length === 0) { - return obj; - } - - var regexp = /\+/g; - qs = qs.split(sep); - - var maxKeys = 1000; - if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; - } - - var len = qs.length; - // maxKeys <= 0 means that we should not limit keys count - if (maxKeys > 0 && len > maxKeys) { - len = maxKeys; - } - - for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - kstr, vstr, k, v; - - if (idx >= 0) { - kstr = x.substr(0, idx); - vstr = x.substr(idx + 1); - } else { - kstr = x; - vstr = ''; - } - - k = decodeURIComponent(kstr); - v = decodeURIComponent(vstr); - - if (!hasOwnProperty(obj, k)) { - obj[k] = v; - } else if (isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } - - return obj; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -},{}],29:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var stringifyPrimitive = function(v) { - switch (typeof v) { - case 'string': - return v; - - case 'boolean': - return v ? 'true' : 'false'; - - case 'number': - return isFinite(v) ? v : ''; - - default: - return ''; - } -}; - -module.exports = function(obj, sep, eq, name) { - sep = sep || '&'; - eq = eq || '='; - if (obj === null) { - obj = undefined; - } - - if (typeof obj === 'object') { - return map(objectKeys(obj), function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (isArray(obj[k])) { - return map(obj[k], function(v) { - return ks + encodeURIComponent(stringifyPrimitive(v)); - }).join(sep); - } else { - return ks + encodeURIComponent(stringifyPrimitive(obj[k])); - } - }).join(sep); - - } - - if (!name) return ''; - return encodeURIComponent(stringifyPrimitive(name)) + eq + - encodeURIComponent(stringifyPrimitive(obj)); -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -function map (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f(xs[i], i)); - } - return res; -} - -var objectKeys = Object.keys || function (obj) { - var res = []; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); - } - return res; -}; - -},{}],30:[function(require,module,exports){ -'use strict'; - -exports.decode = exports.parse = require('./decode'); -exports.encode = exports.stringify = require('./encode'); - -},{"./decode":28,"./encode":29}],31:[function(require,module,exports){ -'use strict' - -/** - * Remove a range of items from an array - * - * @function removeItems - * @param {Array<*>} arr The target array - * @param {number} startIdx The index to begin removing from (inclusive) - * @param {number} removeCount How many items to remove - */ -module.exports = function removeItems(arr, startIdx, removeCount) -{ - var i, length = arr.length - - if (startIdx >= length || removeCount === 0) { - return - } - - removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount) - - var len = length - removeCount - - for (i = startIdx; i < len; ++i) { - arr[i] = arr[i + removeCount] - } - - arr.length = len -} - -},{}],32:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.Loader = undefined; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _miniSignals = require('mini-signals'); - -var _miniSignals2 = _interopRequireDefault(_miniSignals); - -var _parseUri = require('parse-uri'); - -var _parseUri2 = _interopRequireDefault(_parseUri); - -var _async = require('./async'); - -var async = _interopRequireWildcard(_async); - -var _Resource = require('./Resource'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// some constants -var MAX_PROGRESS = 100; -var rgxExtractUrlHash = /(#[\w-]+)?$/; - -/** - * Manages the state and loading of multiple resources to load. - * - * @class - */ - -var Loader = exports.Loader = function () { - /** - * @param {string} [baseUrl=''] - The base url for all resources loaded by this loader. - * @param {number} [concurrency=10] - The number of resources to load concurrently. - */ - function Loader() { - var _this = this; - - var baseUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var concurrency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; - - _classCallCheck(this, Loader); - - /** - * The base url for all resources loaded by this loader. - * - * @member {string} - */ - this.baseUrl = baseUrl; - - /** - * The progress percent of the loader going through the queue. - * - * @member {number} - */ - this.progress = 0; - - /** - * Loading state of the loader, true if it is currently loading resources. - * - * @member {boolean} - */ - this.loading = false; - - /** - * A querystring to append to every URL added to the loader. - * - * This should be a valid query string *without* the question-mark (`?`). The loader will - * also *not* escape values for you. Make sure to escape your parameters with - * [`encodeURIComponent`](https://mdn.io/encodeURIComponent) before assigning this property. - * - * @example - * const loader = new Loader(); - * - * loader.defaultQueryString = 'user=me&password=secret'; - * - * // This will request 'image.png?user=me&password=secret' - * loader.add('image.png').load(); - * - * loader.reset(); - * - * // This will request 'image.png?v=1&user=me&password=secret' - * loader.add('iamge.png?v=1').load(); - * - * @member {string} - */ - this.defaultQueryString = ''; - - /** - * The middleware to run before loading each resource. - * - * @private - * @member {function[]} - */ - this._beforeMiddleware = []; - - /** - * The middleware to run after loading each resource. - * - * @private - * @member {function[]} - */ - this._afterMiddleware = []; - - /** - * The tracks the resources we are currently completing parsing for. - * - * @private - * @member {Resource[]} - */ - this._resourcesParsing = []; - - /** - * The `_loadResource` function bound with this object context. - * - * @private - * @member {function} - * @param {Resource} r - The resource to load - * @param {Function} d - The dequeue function - * @return {undefined} - */ - this._boundLoadResource = function (r, d) { - return _this._loadResource(r, d); - }; - - /** - * The resources waiting to be loaded. - * - * @private - * @member {Resource[]} - */ - this._queue = async.queue(this._boundLoadResource, concurrency); - - this._queue.pause(); - - /** - * All the resources for this loader keyed by name. - * - * @member {object} - */ - this.resources = {}; - - /** - * Dispatched once per loaded or errored resource. - * - * The callback looks like {@link Loader.OnProgressSignal}. - * - * @member {Signal} - */ - this.onProgress = new _miniSignals2.default(); - - /** - * Dispatched once per errored resource. - * - * The callback looks like {@link Loader.OnErrorSignal}. - * - * @member {Signal} - */ - this.onError = new _miniSignals2.default(); - - /** - * Dispatched once per loaded resource. - * - * The callback looks like {@link Loader.OnLoadSignal}. - * - * @member {Signal} - */ - this.onLoad = new _miniSignals2.default(); - - /** - * Dispatched when the loader begins to process the queue. - * - * The callback looks like {@link Loader.OnStartSignal}. - * - * @member {Signal} - */ - this.onStart = new _miniSignals2.default(); - - /** - * Dispatched when the queued resources all load. - * - * The callback looks like {@link Loader.OnCompleteSignal}. - * - * @member {Signal} - */ - this.onComplete = new _miniSignals2.default(); - - // Add default before middleware - for (var i = 0; i < Loader._defaultBeforeMiddleware.length; ++i) { - this.pre(Loader._defaultBeforeMiddleware[i]); - } - - // Add default after middleware - for (var _i = 0; _i < Loader._defaultAfterMiddleware.length; ++_i) { - this.use(Loader._defaultAfterMiddleware[_i]); - } - } - - /** - * When the progress changes the loader and resource are disaptched. - * - * @memberof Loader - * @callback OnProgressSignal - * @param {Loader} loader - The loader the progress is advancing on. - * @param {Resource} resource - The resource that has completed or failed to cause the progress to advance. - */ - - /** - * When an error occurrs the loader and resource are disaptched. - * - * @memberof Loader - * @callback OnErrorSignal - * @param {Loader} loader - The loader the error happened in. - * @param {Resource} resource - The resource that caused the error. - */ - - /** - * When a load completes the loader and resource are disaptched. - * - * @memberof Loader - * @callback OnLoadSignal - * @param {Loader} loader - The loader that laoded the resource. - * @param {Resource} resource - The resource that has completed loading. - */ - - /** - * When the loader starts loading resources it dispatches this callback. - * - * @memberof Loader - * @callback OnStartSignal - * @param {Loader} loader - The loader that has started loading resources. - */ - - /** - * When the loader completes loading resources it dispatches this callback. - * - * @memberof Loader - * @callback OnCompleteSignal - * @param {Loader} loader - The loader that has finished loading resources. - */ - - /** - * Options for a call to `.add()`. - * - * @see Loader#add - * - * @typedef {object} IAddOptions - * @property {string} [name] - The name of the resource to load, if not passed the url is used. - * @property {string} [key] - Alias for `name`. - * @property {string} [url] - The url for this resource, relative to the baseUrl of this loader. - * @property {string|boolean} [crossOrigin] - Is this request cross-origin? Default is to - * determine automatically. - * @property {number} [timeout=0] - A timeout in milliseconds for the load. If the load takes - * longer than this time it is cancelled and the load is considered a failure. If this value is - * set to `0` then there is no explicit timeout. - * @property {Resource.LOAD_TYPE} [loadType=Resource.LOAD_TYPE.XHR] - How should this resource - * be loaded? - * @property {Resource.XHR_RESPONSE_TYPE} [xhrType=Resource.XHR_RESPONSE_TYPE.DEFAULT] - How - * should the data being loaded be interpreted when using XHR? - * @property {Loader.OnCompleteSignal} [onComplete] - Callback to add an an onComplete signal istener. - * @property {Loader.OnCompleteSignal} [callback] - Alias for `onComplete`. - * @property {Resource.IMetadata} [metadata] - Extra configuration for middleware and the Resource object. - */ - - /** - * Adds a resource (or multiple resources) to the loader queue. - * - * This function can take a wide variety of different parameters. The only thing that is always - * required the url to load. All the following will work: - * - * ```js - * loader - * // normal param syntax - * .add('key', 'http://...', function () {}) - * .add('http://...', function () {}) - * .add('http://...') - * - * // object syntax - * .add({ - * name: 'key2', - * url: 'http://...' - * }, function () {}) - * .add({ - * url: 'http://...' - * }, function () {}) - * .add({ - * name: 'key3', - * url: 'http://...' - * onComplete: function () {} - * }) - * .add({ - * url: 'https://...', - * onComplete: function () {}, - * crossOrigin: true - * }) - * - * // you can also pass an array of objects or urls or both - * .add([ - * { name: 'key4', url: 'http://...', onComplete: function () {} }, - * { url: 'http://...', onComplete: function () {} }, - * 'http://...' - * ]) - * - * // and you can use both params and options - * .add('key', 'http://...', { crossOrigin: true }, function () {}) - * .add('http://...', { crossOrigin: true }, function () {}); - * ``` - * - * @param {string|IAddOptions} [name] - The name of the resource to load, if not passed the url is used. - * @param {string} [url] - The url for this resource, relative to the baseUrl of this loader. - * @param {IAddOptions} [options] - The options for the load. - * @param {Loader.OnCompleteSignal} [cb] - Function to call when this specific resource completes loading. - * @return {this} Returns itself. - */ - - - Loader.prototype.add = function add(name, url, options, cb) { - // special case of an array of objects or urls - if (Array.isArray(name)) { - for (var i = 0; i < name.length; ++i) { - this.add(name[i]); - } - - return this; - } - - // if an object is passed instead of params - if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { - cb = url || name.callback || name.onComplete; - options = name; - url = name.url; - name = name.name || name.key || name.url; - } - - // case where no name is passed shift all args over by one. - if (typeof url !== 'string') { - cb = options; - options = url; - url = name; - } - - // now that we shifted make sure we have a proper url. - if (typeof url !== 'string') { - throw new Error('No url passed to add resource to loader.'); - } - - // options are optional so people might pass a function and no options - if (typeof options === 'function') { - cb = options; - options = null; - } - - // if loading already you can only add resources that have a parent. - if (this.loading && (!options || !options.parentResource)) { - throw new Error('Cannot add resources while the loader is running.'); - } - - // check if resource already exists. - if (this.resources[name]) { - throw new Error('Resource named "' + name + '" already exists.'); - } - - // add base url if this isn't an absolute url - url = this._prepareUrl(url); - - // create the store the resource - this.resources[name] = new _Resource.Resource(name, url, options); - - if (typeof cb === 'function') { - this.resources[name].onAfterMiddleware.once(cb); - } - - // if actively loading, make sure to adjust progress chunks for that parent and its children - if (this.loading) { - var parent = options.parentResource; - var incompleteChildren = []; - - for (var _i2 = 0; _i2 < parent.children.length; ++_i2) { - if (!parent.children[_i2].isComplete) { - incompleteChildren.push(parent.children[_i2]); - } - } - - var fullChunk = parent.progressChunk * (incompleteChildren.length + 1); // +1 for parent - var eachChunk = fullChunk / (incompleteChildren.length + 2); // +2 for parent & new child - - parent.children.push(this.resources[name]); - parent.progressChunk = eachChunk; - - for (var _i3 = 0; _i3 < incompleteChildren.length; ++_i3) { - incompleteChildren[_i3].progressChunk = eachChunk; - } - - this.resources[name].progressChunk = eachChunk; - } - - // add the resource to the queue - this._queue.push(this.resources[name]); - - return this; - }; - - /** - * Sets up a middleware function that will run *before* the - * resource is loaded. - * - * @param {function} fn - The middleware function to register. - * @return {this} Returns itself. - */ - - - Loader.prototype.pre = function pre(fn) { - this._beforeMiddleware.push(fn); - - return this; - }; - - /** - * Sets up a middleware function that will run *after* the - * resource is loaded. - * - * @param {function} fn - The middleware function to register. - * @return {this} Returns itself. - */ - - - Loader.prototype.use = function use(fn) { - this._afterMiddleware.push(fn); - - return this; - }; - - /** - * Resets the queue of the loader to prepare for a new load. - * - * @return {this} Returns itself. - */ - - - Loader.prototype.reset = function reset() { - this.progress = 0; - this.loading = false; - - this._queue.kill(); - this._queue.pause(); - - // abort all resource loads - for (var k in this.resources) { - var res = this.resources[k]; - - if (res._onLoadBinding) { - res._onLoadBinding.detach(); - } - - if (res.isLoading) { - res.abort(); - } - } - - this.resources = {}; - - return this; - }; - - /** - * Starts loading the queued resources. - * - * @param {function} [cb] - Optional callback that will be bound to the `complete` event. - * @return {this} Returns itself. - */ - - - Loader.prototype.load = function load(cb) { - // register complete callback if they pass one - if (typeof cb === 'function') { - this.onComplete.once(cb); - } - - // if the queue has already started we are done here - if (this.loading) { - return this; - } - - if (this._queue.idle()) { - this._onStart(); - this._onComplete(); - } else { - // distribute progress chunks - var numTasks = this._queue._tasks.length; - var chunk = MAX_PROGRESS / numTasks; - - for (var i = 0; i < this._queue._tasks.length; ++i) { - this._queue._tasks[i].data.progressChunk = chunk; - } - - // notify we are starting - this._onStart(); - - // start loading - this._queue.resume(); - } - - return this; - }; - - /** - * The number of resources to load concurrently. - * - * @member {number} - * @default 10 - */ - - - /** - * Prepares a url for usage based on the configuration of this object - * - * @private - * @param {string} url - The url to prepare. - * @return {string} The prepared url. - */ - Loader.prototype._prepareUrl = function _prepareUrl(url) { - var parsedUrl = (0, _parseUri2.default)(url, { strictMode: true }); - var result = void 0; - - // absolute url, just use it as is. - if (parsedUrl.protocol || !parsedUrl.path || url.indexOf('//') === 0) { - result = url; - } - // if baseUrl doesn't end in slash and url doesn't start with slash, then add a slash inbetween - else if (this.baseUrl.length && this.baseUrl.lastIndexOf('/') !== this.baseUrl.length - 1 && url.charAt(0) !== '/') { - result = this.baseUrl + '/' + url; - } else { - result = this.baseUrl + url; - } - - // if we need to add a default querystring, there is a bit more work - if (this.defaultQueryString) { - var hash = rgxExtractUrlHash.exec(result)[0]; - - result = result.substr(0, result.length - hash.length); - - if (result.indexOf('?') !== -1) { - result += '&' + this.defaultQueryString; - } else { - result += '?' + this.defaultQueryString; - } - - result += hash; - } - - return result; - }; - - /** - * Loads a single resource. - * - * @private - * @param {Resource} resource - The resource to load. - * @param {function} dequeue - The function to call when we need to dequeue this item. - */ - - - Loader.prototype._loadResource = function _loadResource(resource, dequeue) { - var _this2 = this; - - resource._dequeue = dequeue; - - // run before middleware - async.eachSeries(this._beforeMiddleware, function (fn, next) { - fn.call(_this2, resource, function () { - // if the before middleware marks the resource as complete, - // break and don't process any more before middleware - next(resource.isComplete ? {} : null); - }); - }, function () { - if (resource.isComplete) { - _this2._onLoad(resource); - } else { - resource._onLoadBinding = resource.onComplete.once(_this2._onLoad, _this2); - resource.load(); - } - }, true); - }; - - /** - * Called once loading has started. - * - * @private - */ - - - Loader.prototype._onStart = function _onStart() { - this.progress = 0; - this.loading = true; - this.onStart.dispatch(this); - }; - - /** - * Called once each resource has loaded. - * - * @private - */ - - - Loader.prototype._onComplete = function _onComplete() { - this.progress = MAX_PROGRESS; - this.loading = false; - this.onComplete.dispatch(this, this.resources); - }; - - /** - * Called each time a resources is loaded. - * - * @private - * @param {Resource} resource - The resource that was loaded - */ - - - Loader.prototype._onLoad = function _onLoad(resource) { - var _this3 = this; - - resource._onLoadBinding = null; - - // remove this resource from the async queue, and add it to our list of resources that are being parsed - this._resourcesParsing.push(resource); - resource._dequeue(); - - // run all the after middleware for this resource - async.eachSeries(this._afterMiddleware, function (fn, next) { - fn.call(_this3, resource, next); - }, function () { - resource.onAfterMiddleware.dispatch(resource); - - _this3.progress = Math.min(MAX_PROGRESS, _this3.progress + resource.progressChunk); - _this3.onProgress.dispatch(_this3, resource); - - if (resource.error) { - _this3.onError.dispatch(resource.error, _this3, resource); - } else { - _this3.onLoad.dispatch(_this3, resource); - } - - _this3._resourcesParsing.splice(_this3._resourcesParsing.indexOf(resource), 1); - - // do completion check - if (_this3._queue.idle() && _this3._resourcesParsing.length === 0) { - _this3._onComplete(); - } - }, true); - }; - - _createClass(Loader, [{ - key: 'concurrency', - get: function get() { - return this._queue.concurrency; - } - // eslint-disable-next-line require-jsdoc - , - set: function set(concurrency) { - this._queue.concurrency = concurrency; - } - }]); - - return Loader; -}(); - -/** - * A default array of middleware to run before loading each resource. - * Each of these middlewares are added to any new Loader instances when they are created. - * - * @private - * @member {function[]} - */ - - -Loader._defaultBeforeMiddleware = []; - -/** - * A default array of middleware to run after loading each resource. - * Each of these middlewares are added to any new Loader instances when they are created. - * - * @private - * @member {function[]} - */ -Loader._defaultAfterMiddleware = []; - -/** - * Sets up a middleware function that will run *before* the - * resource is loaded. - * - * @static - * @param {function} fn - The middleware function to register. - * @return {Loader} Returns itself. - */ -Loader.pre = function LoaderPreStatic(fn) { - Loader._defaultBeforeMiddleware.push(fn); - - return Loader; -}; - -/** - * Sets up a middleware function that will run *after* the - * resource is loaded. - * - * @static - * @param {function} fn - The middleware function to register. - * @return {Loader} Returns itself. - */ -Loader.use = function LoaderUseStatic(fn) { - Loader._defaultAfterMiddleware.push(fn); - - return Loader; -}; - -},{"./Resource":33,"./async":34,"mini-signals":5,"parse-uri":7}],33:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.Resource = undefined; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _parseUri = require('parse-uri'); - -var _parseUri2 = _interopRequireDefault(_parseUri); - -var _miniSignals = require('mini-signals'); - -var _miniSignals2 = _interopRequireDefault(_miniSignals); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// tests if CORS is supported in XHR, if not we need to use XDR -var useXdr = !!(window.XDomainRequest && !('withCredentials' in new XMLHttpRequest())); -var tempAnchor = null; - -// some status constants -var STATUS_NONE = 0; -var STATUS_OK = 200; -var STATUS_EMPTY = 204; -var STATUS_IE_BUG_EMPTY = 1223; -var STATUS_TYPE_OK = 2; - -// noop -function _noop() {} /* empty */ - -/** - * Manages the state and loading of a resource and all child resources. - * - * @class - */ - -var Resource = exports.Resource = function () { - /** - * Sets the load type to be used for a specific extension. - * - * @static - * @param {string} extname - The extension to set the type for, e.g. "png" or "fnt" - * @param {Resource.LOAD_TYPE} loadType - The load type to set it to. - */ - Resource.setExtensionLoadType = function setExtensionLoadType(extname, loadType) { - setExtMap(Resource._loadTypeMap, extname, loadType); - }; - - /** - * Sets the load type to be used for a specific extension. - * - * @static - * @param {string} extname - The extension to set the type for, e.g. "png" or "fnt" - * @param {Resource.XHR_RESPONSE_TYPE} xhrType - The xhr type to set it to. - */ - - - Resource.setExtensionXhrType = function setExtensionXhrType(extname, xhrType) { - setExtMap(Resource._xhrTypeMap, extname, xhrType); - }; - - /** - * @param {string} name - The name of the resource to load. - * @param {string|string[]} url - The url for this resource, for audio/video loads you can pass - * an array of sources. - * @param {object} [options] - The options for the load. - * @param {string|boolean} [options.crossOrigin] - Is this request cross-origin? Default is to - * determine automatically. - * @param {number} [options.timeout=0] - A timeout in milliseconds for the load. If the load takes - * longer than this time it is cancelled and the load is considered a failure. If this value is - * set to `0` then there is no explicit timeout. - * @param {Resource.LOAD_TYPE} [options.loadType=Resource.LOAD_TYPE.XHR] - How should this resource - * be loaded? - * @param {Resource.XHR_RESPONSE_TYPE} [options.xhrType=Resource.XHR_RESPONSE_TYPE.DEFAULT] - How - * should the data being loaded be interpreted when using XHR? - * @param {Resource.IMetadata} [options.metadata] - Extra configuration for middleware and the Resource object. - */ - - - function Resource(name, url, options) { - _classCallCheck(this, Resource); - - if (typeof name !== 'string' || typeof url !== 'string') { - throw new Error('Both name and url are required for constructing a resource.'); - } - - options = options || {}; - - /** - * The state flags of this resource. - * - * @private - * @member {number} - */ - this._flags = 0; - - // set data url flag, needs to be set early for some _determineX checks to work. - this._setFlag(Resource.STATUS_FLAGS.DATA_URL, url.indexOf('data:') === 0); - - /** - * The name of this resource. - * - * @readonly - * @member {string} - */ - this.name = name; - - /** - * The url used to load this resource. - * - * @readonly - * @member {string} - */ - this.url = url; - - /** - * The extension used to load this resource. - * - * @readonly - * @member {string} - */ - this.extension = this._getExtension(); - - /** - * The data that was loaded by the resource. - * - * @member {any} - */ - this.data = null; - - /** - * Is this request cross-origin? If unset, determined automatically. - * - * @member {string} - */ - this.crossOrigin = options.crossOrigin === true ? 'anonymous' : options.crossOrigin; - - /** - * A timeout in milliseconds for the load. If the load takes longer than this time - * it is cancelled and the load is considered a failure. If this value is set to `0` - * then there is no explicit timeout. - * - * @member {number} - */ - this.timeout = options.timeout || 0; - - /** - * The method of loading to use for this resource. - * - * @member {Resource.LOAD_TYPE} - */ - this.loadType = options.loadType || this._determineLoadType(); - - /** - * The type used to load the resource via XHR. If unset, determined automatically. - * - * @member {string} - */ - this.xhrType = options.xhrType; - - /** - * Extra info for middleware, and controlling specifics about how the resource loads. - * - * Note that if you pass in a `loadElement`, the Resource class takes ownership of it. - * Meaning it will modify it as it sees fit. - * - * @member {Resource.IMetadata} - */ - this.metadata = options.metadata || {}; - - /** - * The error that occurred while loading (if any). - * - * @readonly - * @member {Error} - */ - this.error = null; - - /** - * The XHR object that was used to load this resource. This is only set - * when `loadType` is `Resource.LOAD_TYPE.XHR`. - * - * @readonly - * @member {XMLHttpRequest} - */ - this.xhr = null; - - /** - * The child resources this resource owns. - * - * @readonly - * @member {Resource[]} - */ - this.children = []; - - /** - * The resource type. - * - * @readonly - * @member {Resource.TYPE} - */ - this.type = Resource.TYPE.UNKNOWN; - - /** - * The progress chunk owned by this resource. - * - * @readonly - * @member {number} - */ - this.progressChunk = 0; - - /** - * The `dequeue` method that will be used a storage place for the async queue dequeue method - * used privately by the loader. - * - * @private - * @member {function} - */ - this._dequeue = _noop; - - /** - * Used a storage place for the on load binding used privately by the loader. - * - * @private - * @member {function} - */ - this._onLoadBinding = null; - - /** - * The timer for element loads to check if they timeout. - * - * @private - * @member {number} - */ - this._elementTimer = 0; - - /** - * The `complete` function bound to this resource's context. - * - * @private - * @member {function} - */ - this._boundComplete = this.complete.bind(this); - - /** - * The `_onError` function bound to this resource's context. - * - * @private - * @member {function} - */ - this._boundOnError = this._onError.bind(this); - - /** - * The `_onProgress` function bound to this resource's context. - * - * @private - * @member {function} - */ - this._boundOnProgress = this._onProgress.bind(this); - - /** - * The `_onTimeout` function bound to this resource's context. - * - * @private - * @member {function} - */ - this._boundOnTimeout = this._onTimeout.bind(this); - - // xhr callbacks - this._boundXhrOnError = this._xhrOnError.bind(this); - this._boundXhrOnTimeout = this._xhrOnTimeout.bind(this); - this._boundXhrOnAbort = this._xhrOnAbort.bind(this); - this._boundXhrOnLoad = this._xhrOnLoad.bind(this); - - /** - * Dispatched when the resource beings to load. - * - * The callback looks like {@link Resource.OnStartSignal}. - * - * @member {Signal} - */ - this.onStart = new _miniSignals2.default(); - - /** - * Dispatched each time progress of this resource load updates. - * Not all resources types and loader systems can support this event - * so sometimes it may not be available. If the resource - * is being loaded on a modern browser, using XHR, and the remote server - * properly sets Content-Length headers, then this will be available. - * - * The callback looks like {@link Resource.OnProgressSignal}. - * - * @member {Signal} - */ - this.onProgress = new _miniSignals2.default(); - - /** - * Dispatched once this resource has loaded, if there was an error it will - * be in the `error` property. - * - * The callback looks like {@link Resource.OnCompleteSignal}. - * - * @member {Signal} - */ - this.onComplete = new _miniSignals2.default(); - - /** - * Dispatched after this resource has had all the *after* middleware run on it. - * - * The callback looks like {@link Resource.OnCompleteSignal}. - * - * @member {Signal} - */ - this.onAfterMiddleware = new _miniSignals2.default(); - } - - /** - * When the resource starts to load. - * - * @memberof Resource - * @callback OnStartSignal - * @param {Resource} resource - The resource that the event happened on. - */ - - /** - * When the resource reports loading progress. - * - * @memberof Resource - * @callback OnProgressSignal - * @param {Resource} resource - The resource that the event happened on. - * @param {number} percentage - The progress of the load in the range [0, 1]. - */ - - /** - * When the resource finishes loading. - * - * @memberof Resource - * @callback OnCompleteSignal - * @param {Resource} resource - The resource that the event happened on. - */ - - /** - * @memberof Resource - * @typedef {object} IMetadata - * @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The - * element to use for loading, instead of creating one. - * @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This - * is useful if you want to pass in a `loadElement` that you already added load sources to. - * @property {string|string[]} [mimeType] - The mime type to use for the source element - * of a video/audio elment. If the urls are an array, you can pass this as an array as well - * where each index is the mime type to use for the corresponding url index. - */ - - /** - * Stores whether or not this url is a data url. - * - * @readonly - * @member {boolean} - */ - - - /** - * Marks the resource as complete. - * - */ - Resource.prototype.complete = function complete() { - this._clearEvents(); - this._finish(); - }; - - /** - * Aborts the loading of this resource, with an optional message. - * - * @param {string} message - The message to use for the error - */ - - - Resource.prototype.abort = function abort(message) { - // abort can be called multiple times, ignore subsequent calls. - if (this.error) { - return; - } - - // store error - this.error = new Error(message); - - // clear events before calling aborts - this._clearEvents(); - - // abort the actual loading - if (this.xhr) { - this.xhr.abort(); - } else if (this.xdr) { - this.xdr.abort(); - } else if (this.data) { - // single source - if (this.data.src) { - this.data.src = Resource.EMPTY_GIF; - } - // multi-source - else { - while (this.data.firstChild) { - this.data.removeChild(this.data.firstChild); - } - } - } - - // done now. - this._finish(); - }; - - /** - * Kicks off loading of this resource. This method is asynchronous. - * - * @param {Resource.OnCompleteSignal} [cb] - Optional callback to call once the resource is loaded. - */ - - - Resource.prototype.load = function load(cb) { - var _this = this; - - if (this.isLoading) { - return; - } - - if (this.isComplete) { - if (cb) { - setTimeout(function () { - return cb(_this); - }, 1); - } - - return; - } else if (cb) { - this.onComplete.once(cb); - } - - this._setFlag(Resource.STATUS_FLAGS.LOADING, true); - - this.onStart.dispatch(this); - - // if unset, determine the value - if (this.crossOrigin === false || typeof this.crossOrigin !== 'string') { - this.crossOrigin = this._determineCrossOrigin(this.url); - } - - switch (this.loadType) { - case Resource.LOAD_TYPE.IMAGE: - this.type = Resource.TYPE.IMAGE; - this._loadElement('image'); - break; - - case Resource.LOAD_TYPE.AUDIO: - this.type = Resource.TYPE.AUDIO; - this._loadSourceElement('audio'); - break; - - case Resource.LOAD_TYPE.VIDEO: - this.type = Resource.TYPE.VIDEO; - this._loadSourceElement('video'); - break; - - case Resource.LOAD_TYPE.XHR: - /* falls through */ - default: - if (useXdr && this.crossOrigin) { - this._loadXdr(); - } else { - this._loadXhr(); - } - break; - } - }; - - /** - * Checks if the flag is set. - * - * @private - * @param {number} flag - The flag to check. - * @return {boolean} True if the flag is set. - */ - - - Resource.prototype._hasFlag = function _hasFlag(flag) { - return (this._flags & flag) !== 0; - }; - - /** - * (Un)Sets the flag. - * - * @private - * @param {number} flag - The flag to (un)set. - * @param {boolean} value - Whether to set or (un)set the flag. - */ - - - Resource.prototype._setFlag = function _setFlag(flag, value) { - this._flags = value ? this._flags | flag : this._flags & ~flag; - }; - - /** - * Clears all the events from the underlying loading source. - * - * @private - */ - - - Resource.prototype._clearEvents = function _clearEvents() { - clearTimeout(this._elementTimer); - - if (this.data && this.data.removeEventListener) { - this.data.removeEventListener('error', this._boundOnError, false); - this.data.removeEventListener('load', this._boundComplete, false); - this.data.removeEventListener('progress', this._boundOnProgress, false); - this.data.removeEventListener('canplaythrough', this._boundComplete, false); - } - - if (this.xhr) { - if (this.xhr.removeEventListener) { - this.xhr.removeEventListener('error', this._boundXhrOnError, false); - this.xhr.removeEventListener('timeout', this._boundXhrOnTimeout, false); - this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false); - this.xhr.removeEventListener('progress', this._boundOnProgress, false); - this.xhr.removeEventListener('load', this._boundXhrOnLoad, false); - } else { - this.xhr.onerror = null; - this.xhr.ontimeout = null; - this.xhr.onprogress = null; - this.xhr.onload = null; - } - } - }; - - /** - * Finalizes the load. - * - * @private - */ - - - Resource.prototype._finish = function _finish() { - if (this.isComplete) { - throw new Error('Complete called again for an already completed resource.'); - } - - this._setFlag(Resource.STATUS_FLAGS.COMPLETE, true); - this._setFlag(Resource.STATUS_FLAGS.LOADING, false); - - this.onComplete.dispatch(this); - }; - - /** - * Loads this resources using an element that has a single source, - * like an HTMLImageElement. - * - * @private - * @param {string} type - The type of element to use. - */ - - - Resource.prototype._loadElement = function _loadElement(type) { - if (this.metadata.loadElement) { - this.data = this.metadata.loadElement; - } else if (type === 'image' && typeof window.Image !== 'undefined') { - this.data = new Image(); - } else { - this.data = document.createElement(type); - } - - if (this.crossOrigin) { - this.data.crossOrigin = this.crossOrigin; - } - - if (!this.metadata.skipSource) { - this.data.src = this.url; - } - - this.data.addEventListener('error', this._boundOnError, false); - this.data.addEventListener('load', this._boundComplete, false); - this.data.addEventListener('progress', this._boundOnProgress, false); - - if (this.timeout) { - this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout); - } - }; - - /** - * Loads this resources using an element that has multiple sources, - * like an HTMLAudioElement or HTMLVideoElement. - * - * @private - * @param {string} type - The type of element to use. - */ - - - Resource.prototype._loadSourceElement = function _loadSourceElement(type) { - if (this.metadata.loadElement) { - this.data = this.metadata.loadElement; - } else if (type === 'audio' && typeof window.Audio !== 'undefined') { - this.data = new Audio(); - } else { - this.data = document.createElement(type); - } - - if (this.data === null) { - this.abort('Unsupported element: ' + type); - - return; - } - - if (this.crossOrigin) { - this.data.crossOrigin = this.crossOrigin; - } - - if (!this.metadata.skipSource) { - // support for CocoonJS Canvas+ runtime, lacks document.createElement('source') - if (navigator.isCocoonJS) { - this.data.src = Array.isArray(this.url) ? this.url[0] : this.url; - } else if (Array.isArray(this.url)) { - var mimeTypes = this.metadata.mimeType; - - for (var i = 0; i < this.url.length; ++i) { - this.data.appendChild(this._createSource(type, this.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes)); - } - } else { - var _mimeTypes = this.metadata.mimeType; - - this.data.appendChild(this._createSource(type, this.url, Array.isArray(_mimeTypes) ? _mimeTypes[0] : _mimeTypes)); - } - } - - this.data.addEventListener('error', this._boundOnError, false); - this.data.addEventListener('load', this._boundComplete, false); - this.data.addEventListener('progress', this._boundOnProgress, false); - this.data.addEventListener('canplaythrough', this._boundComplete, false); - - this.data.load(); - - if (this.timeout) { - this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout); - } - }; - - /** - * Loads this resources using an XMLHttpRequest. - * - * @private - */ - - - Resource.prototype._loadXhr = function _loadXhr() { - // if unset, determine the value - if (typeof this.xhrType !== 'string') { - this.xhrType = this._determineXhrType(); - } - - var xhr = this.xhr = new XMLHttpRequest(); - - // set the request type and url - xhr.open('GET', this.url, true); - - xhr.timeout = this.timeout; - - // load json as text and parse it ourselves. We do this because some browsers - // *cough* safari *cough* can't deal with it. - if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON || this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) { - xhr.responseType = Resource.XHR_RESPONSE_TYPE.TEXT; - } else { - xhr.responseType = this.xhrType; - } - - xhr.addEventListener('error', this._boundXhrOnError, false); - xhr.addEventListener('timeout', this._boundXhrOnTimeout, false); - xhr.addEventListener('abort', this._boundXhrOnAbort, false); - xhr.addEventListener('progress', this._boundOnProgress, false); - xhr.addEventListener('load', this._boundXhrOnLoad, false); - - xhr.send(); - }; - - /** - * Loads this resources using an XDomainRequest. This is here because we need to support IE9 (gross). - * - * @private - */ - - - Resource.prototype._loadXdr = function _loadXdr() { - // if unset, determine the value - if (typeof this.xhrType !== 'string') { - this.xhrType = this._determineXhrType(); - } - - var xdr = this.xhr = new XDomainRequest(); // eslint-disable-line no-undef - - // XDomainRequest has a few quirks. Occasionally it will abort requests - // A way to avoid this is to make sure ALL callbacks are set even if not used - // More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9 - xdr.timeout = this.timeout || 5000; // XDR needs a timeout value or it breaks in IE9 - - xdr.onerror = this._boundXhrOnError; - xdr.ontimeout = this._boundXhrOnTimeout; - xdr.onprogress = this._boundOnProgress; - xdr.onload = this._boundXhrOnLoad; - - xdr.open('GET', this.url, true); - - // Note: The xdr.send() call is wrapped in a timeout to prevent an - // issue with the interface where some requests are lost if multiple - // XDomainRequests are being sent at the same time. - // Some info here: https://github.com/photonstorm/phaser/issues/1248 - setTimeout(function () { - return xdr.send(); - }, 1); - }; + function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } + } + + var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { + var arguments$1 = arguments; + + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments$1[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; + }; + + /*! + * @pixi/polyfill - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/polyfill is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + // Support for IE 9 - 11 which does not include Promises + if (!window.Promise) + { + window.Promise = promise_2; + } + + // References: + + if (!Object.assign) + { + Object.assign = objectAssign; + } + + var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + // References: + // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + // https://gist.github.com/1579671 + // http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision + // https://gist.github.com/timhall/4078614 + // https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame + + // Expected to be used with Browserfiy + // Browserify automatically detects the use of `global` and passes the + // correct reference of `global`, `self`, and finally `window` + + var ONE_FRAME_TIME = 16; + + // Date.now + if (!(Date.now && Date.prototype.getTime)) + { + Date.now = function now() + { + return new Date().getTime(); + }; + } + + // performance.now + if (!(commonjsGlobal$1.performance && commonjsGlobal$1.performance.now)) + { + var startTime = Date.now(); + + if (!commonjsGlobal$1.performance) + { + commonjsGlobal$1.performance = {}; + } + + commonjsGlobal$1.performance.now = function () { return Date.now() - startTime; }; + } + + // requestAnimationFrame + var lastTime = Date.now(); + var vendors = ['ms', 'moz', 'webkit', 'o']; + + for (var x = 0; x < vendors.length && !commonjsGlobal$1.requestAnimationFrame; ++x) + { + var p = vendors[x]; + + commonjsGlobal$1.requestAnimationFrame = commonjsGlobal$1[(p + "RequestAnimationFrame")]; + commonjsGlobal$1.cancelAnimationFrame = commonjsGlobal$1[(p + "CancelAnimationFrame")] || commonjsGlobal$1[(p + "CancelRequestAnimationFrame")]; + } + + if (!commonjsGlobal$1.requestAnimationFrame) + { + commonjsGlobal$1.requestAnimationFrame = function (callback) { + if (typeof callback !== 'function') + { + throw new TypeError((callback + "is not a function")); + } + + var currentTime = Date.now(); + var delay = ONE_FRAME_TIME + lastTime - currentTime; + + if (delay < 0) + { + delay = 0; + } + + lastTime = currentTime; + + return setTimeout(function () { + lastTime = Date.now(); + callback(performance.now()); + }, delay); + }; + } + + if (!commonjsGlobal$1.cancelAnimationFrame) + { + commonjsGlobal$1.cancelAnimationFrame = function (id) { return clearTimeout(id); }; + } + + // References: + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign + + if (!Math.sign) + { + Math.sign = function mathSign(x) + { + x = Number(x); + + if (x === 0 || isNaN(x)) + { + return x; + } + + return x > 0 ? 1 : -1; + }; + } + + // References: + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger + + if (!Number.isInteger) + { + Number.isInteger = function numberIsInteger(value) + { + return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; + }; + } + + if (!window.ArrayBuffer) + { + window.ArrayBuffer = Array; + } + + if (!window.Float32Array) + { + window.Float32Array = Array; + } + + if (!window.Uint32Array) + { + window.Uint32Array = Array; + } + + if (!window.Uint16Array) + { + window.Uint16Array = Array; + } + + if (!window.Uint8Array) + { + window.Uint8Array = Array; + } + + if (!window.Int32Array) + { + window.Int32Array = Array; + } + + var isMobile_min = createCommonjsModule(function (module) { + !function(e){var n=/iPhone/i,t=/iPod/i,r=/iPad/i,a=/\bAndroid(?:.+)Mobile\b/i,p=/Android/i,l=/\bAndroid(?:.+)SD4930UR\b/i,b=/\bAndroid(?:.+)(?:KF[A-Z]{2,4})\b/i,f=/Windows Phone/i,u=/\bWindows(?:.+)ARM\b/i,c=/BlackBerry/i,s=/BB10/i,v=/Opera Mini/i,h=/\b(CriOS|Chrome)(?:.+)Mobile/i,w=/\Mobile(?:.+)Firefox\b/i;function m(e,i){return e.test(i)}function i(e){var i=e||("undefined"!=typeof navigator?navigator.userAgent:""),o=i.split("[FBAN");void 0!==o[1]&&(i=o[0]),void 0!==(o=i.split("Twitter"))[1]&&(i=o[0]);var d={apple:{phone:m(n,i)&&!m(f,i),ipod:m(t,i),tablet:!m(n,i)&&m(r,i)&&!m(f,i),device:(m(n,i)||m(t,i)||m(r,i))&&!m(f,i)},amazon:{phone:m(l,i),tablet:!m(l,i)&&m(b,i),device:m(l,i)||m(b,i)},android:{phone:!m(f,i)&&m(l,i)||!m(f,i)&&m(a,i),tablet:!m(f,i)&&!m(l,i)&&!m(a,i)&&(m(b,i)||m(p,i)),device:!m(f,i)&&(m(l,i)||m(b,i)||m(a,i)||m(p,i))},windows:{phone:m(f,i),tablet:m(u,i),device:m(f,i)||m(u,i)},other:{blackberry:m(c,i),blackberry10:m(s,i),opera:m(v,i),firefox:m(w,i),chrome:m(h,i),device:m(c,i)||m(s,i)||m(v,i)||m(w,i)||m(h,i)}};return d.any=d.apple.device||d.android.device||d.windows.device||d.other.device,d.phone=d.apple.phone||d.android.phone||d.windows.phone,d.tablet=d.apple.tablet||d.android.tablet||d.windows.tablet,d}"undefined"!='object'&&module.exports&&"undefined"==typeof window?module.exports=i:"undefined"!='object'&&module.exports&&"undefined"!=typeof window?module.exports=i():"function"==typeof undefined&&undefined.amd?undefined([],e.isMobile=i()):e.isMobile=i();}(commonjsGlobal); + }); + + /*! + * @pixi/settings - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/settings is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * The maximum recommended texture units to use. + * In theory the bigger the better, and for desktop we'll use as many as we can. + * But some mobile devices slow down if there is to many branches in the shader. + * So in practice there seems to be a sweet spot size that varies depending on the device. + * + * In v4, all mobile devices were limited to 4 texture units because for this. + * In v5, we allow all texture units to be used on modern Apple or Android devices. + * + * @private + * @param {number} max + * @returns {number} + */ + function maxRecommendedTextures(max) + { + var allowMax = true; + + if (isMobile_min.tablet || isMobile_min.phone) + { + allowMax = false; + + if (isMobile_min.apple.device) + { + var match = (navigator.userAgent).match(/OS (\d+)_(\d+)?/); + + if (match) + { + var majorVersion = parseInt(match[1], 10); + + // All texture units can be used on devices that support ios 11 or above + if (majorVersion >= 11) + { + allowMax = true; + } + } + } + if (isMobile_min.android.device) + { + var match$1 = (navigator.userAgent).match(/Android\s([0-9.]*)/); + + if (match$1) + { + var majorVersion$1 = parseInt(match$1[1], 10); + + // All texture units can be used on devices that support Android 7 (Nougat) or above + if (majorVersion$1 >= 7) + { + allowMax = true; + } + } + } + } + + return allowMax ? max : 4; + } + + /** + * Uploading the same buffer multiple times in a single frame can cause performance issues. + * Apparent on iOS so only check for that at the moment + * This check may become more complex if this issue pops up elsewhere. + * + * @private + * @returns {boolean} + */ + function canUploadSameBuffer() + { + return !isMobile_min.apple.device; + } + + /** + * User's customizable globals for overriding the default PIXI settings, such + * as a renderer's default resolution, framerate, float precision, etc. + * @example + * // Use the native window resolution as the default resolution + * // will support high-density displays when rendering + * PIXI.settings.RESOLUTION = window.devicePixelRatio. + * + * // Disable interpolation when scaling, will make texture be pixelated + * PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST; + * @namespace PIXI.settings + */ + var settings = { + + /** + * If set to true WebGL will attempt make textures mimpaped by default. + * Mipmapping will only succeed if the base texture uploaded has power of two dimensions. + * + * @static + * @name MIPMAP_TEXTURES + * @memberof PIXI.settings + * @type {PIXI.MIPMAP_MODES} + * @default PIXI.MIPMAP_MODES.POW2 + */ + MIPMAP_TEXTURES: 1, + + /** + * Default resolution / device pixel ratio of the renderer. + * + * @static + * @name RESOLUTION + * @memberof PIXI.settings + * @type {number} + * @default 1 + */ + RESOLUTION: 1, + + /** + * Default filter resolution. + * + * @static + * @name FILTER_RESOLUTION + * @memberof PIXI.settings + * @type {number} + * @default 1 + */ + FILTER_RESOLUTION: 1, + + /** + * The maximum textures that this device supports. + * + * @static + * @name SPRITE_MAX_TEXTURES + * @memberof PIXI.settings + * @type {number} + * @default 32 + */ + SPRITE_MAX_TEXTURES: maxRecommendedTextures(32), + + // TODO: maybe change to SPRITE.BATCH_SIZE: 2000 + // TODO: maybe add PARTICLE.BATCH_SIZE: 15000 + + /** + * The default sprite batch size. + * + * The default aims to balance desktop and mobile devices. + * + * @static + * @name SPRITE_BATCH_SIZE + * @memberof PIXI.settings + * @type {number} + * @default 4096 + */ + SPRITE_BATCH_SIZE: 4096, + + /** + * The default render options if none are supplied to {@link PIXI.Renderer} + * or {@link PIXI.CanvasRenderer}. + * + * @static + * @name RENDER_OPTIONS + * @memberof PIXI.settings + * @type {object} + * @property {HTMLCanvasElement} view=null + * @property {number} resolution=1 + * @property {boolean} antialias=false + * @property {boolean} forceFXAA=false + * @property {boolean} autoDensity=false + * @property {boolean} transparent=false + * @property {number} backgroundColor=0x000000 + * @property {boolean} clearBeforeRender=true + * @property {boolean} preserveDrawingBuffer=false + * @property {number} width=800 + * @property {number} height=600 + * @property {boolean} legacy=false + */ + RENDER_OPTIONS: { + view: null, + antialias: false, + forceFXAA: false, + autoDensity: false, + transparent: false, + backgroundColor: 0x000000, + clearBeforeRender: true, + preserveDrawingBuffer: false, + width: 800, + height: 600, + legacy: false, + }, + + /** + * Default Garbage Collection mode. + * + * @static + * @name GC_MODE + * @memberof PIXI.settings + * @type {PIXI.GC_MODES} + * @default PIXI.GC_MODES.AUTO + */ + GC_MODE: 0, + + /** + * Default Garbage Collection max idle. + * + * @static + * @name GC_MAX_IDLE + * @memberof PIXI.settings + * @type {number} + * @default 3600 + */ + GC_MAX_IDLE: 60 * 60, + + /** + * Default Garbage Collection maximum check count. + * + * @static + * @name GC_MAX_CHECK_COUNT + * @memberof PIXI.settings + * @type {number} + * @default 600 + */ + GC_MAX_CHECK_COUNT: 60 * 10, + + /** + * Default wrap modes that are supported by pixi. + * + * @static + * @name WRAP_MODE + * @memberof PIXI.settings + * @type {PIXI.WRAP_MODES} + * @default PIXI.WRAP_MODES.CLAMP + */ + WRAP_MODE: 33071, + + /** + * Default scale mode for textures. + * + * @static + * @name SCALE_MODE + * @memberof PIXI.settings + * @type {PIXI.SCALE_MODES} + * @default PIXI.SCALE_MODES.LINEAR + */ + SCALE_MODE: 1, + + /** + * Default specify float precision in vertex shader. + * + * @static + * @name PRECISION_VERTEX + * @memberof PIXI.settings + * @type {PIXI.PRECISION} + * @default PIXI.PRECISION.HIGH + */ + PRECISION_VERTEX: 'highp', + + /** + * Default specify float precision in fragment shader. + * iOS is best set at highp due to https://github.com/pixijs/pixi.js/issues/3742 + * + * @static + * @name PRECISION_FRAGMENT + * @memberof PIXI.settings + * @type {PIXI.PRECISION} + * @default PIXI.PRECISION.MEDIUM + */ + PRECISION_FRAGMENT: isMobile_min.apple.device ? 'highp' : 'mediump', + + /** + * Can we upload the same buffer in a single frame? + * + * @static + * @name CAN_UPLOAD_SAME_BUFFER + * @memberof PIXI.settings + * @type {boolean} + */ + CAN_UPLOAD_SAME_BUFFER: canUploadSameBuffer(), + + /** + * Enables bitmap creation before image load + * + * @static + * @name CREATE_IMAGE_BITMAP + * @memberof PIXI.settings + * @type {boolean} + * @default true + */ + CREATE_IMAGE_BITMAP: true, + + /** + * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. + * Advantages can include sharper image quality (like text) and faster rendering on canvas. + * The main disadvantage is movement of objects may appear less smooth. + * + * @static + * @constant + * @memberof PIXI.settings + * @type {boolean} + * @default false + */ + ROUND_PIXELS: false, + }; + + var eventemitter3 = createCommonjsModule(function (module) { + 'use strict'; + + var has = Object.prototype.hasOwnProperty + , prefix = '~'; + + /** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @private + */ + function Events() {} + + // + // We try to not inherit from `Object.prototype`. In some engines creating an + // instance in this way is faster than calling `Object.create(null)` directly. + // If `Object.create(null)` is not supported we prefix the event names with a + // character to make sure that the built-in object properties are not + // overridden or used as an attack vector. + // + if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) { prefix = false; } + } + + /** + * Representation of a single event listener. + * + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @private + */ + function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; + } + + /** + * Add a listener for a given event. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} once Specify if the listener is a one-time listener. + * @returns {EventEmitter} + * @private + */ + function addListener(emitter, event, fn, context, once) { + if (typeof fn !== 'function') { + throw new TypeError('The listener must be a function'); + } + + var listener = new EE(fn, context || emitter, once) + , evt = prefix ? prefix + event : event; + + if (!emitter._events[evt]) { emitter._events[evt] = listener, emitter._eventsCount++; } + else if (!emitter._events[evt].fn) { emitter._events[evt].push(listener); } + else { emitter._events[evt] = [emitter._events[evt], listener]; } + + return emitter; + } + + /** + * Clear event by name. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} evt The Event name. + * @private + */ + function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) { emitter._events = new Events(); } + else { delete emitter._events[evt]; } + } + + /** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @public + */ + function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; + } + + /** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @public + */ + EventEmitter.prototype.eventNames = function eventNames() { + var names = [] + , events + , name; + + if (this._eventsCount === 0) { return names; } + + for (name in (events = this._events)) { + if (has.call(events, name)) { names.push(prefix ? name.slice(1) : name); } + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; + }; + + /** + * Return the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Array} The registered listeners. + * @public + */ + EventEmitter.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event + , handlers = this._events[evt]; + + if (!handlers) { return []; } + if (handlers.fn) { return [handlers.fn]; } + + for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { + ee[i] = handlers[i].fn; + } + + return ee; + }; + + /** + * Return the number of listeners listening to a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Number} The number of listeners. + * @public + */ + EventEmitter.prototype.listenerCount = function listenerCount(event) { + var evt = prefix ? prefix + event : event + , listeners = this._events[evt]; + + if (!listeners) { return 0; } + if (listeners.fn) { return 1; } + return listeners.length; + }; + + /** + * Calls each of the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. + * @public + */ + EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var arguments$1 = arguments; + + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) { return false; } + + var listeners = this._events[evt] + , len = arguments.length + , args + , i; + + if (listeners.fn) { + if (listeners.once) { this.removeListener(event, listeners.fn, undefined, true); } + + switch (len) { + case 1: return listeners.fn.call(listeners.context), true; + case 2: return listeners.fn.call(listeners.context, a1), true; + case 3: return listeners.fn.call(listeners.context, a1, a2), true; + case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + + for (i = 1, args = new Array(len -1); i < len; i++) { + args[i - 1] = arguments$1[i]; + } + + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length + , j; + + for (i = 0; i < length; i++) { + if (listeners[i].once) { this.removeListener(event, listeners[i].fn, undefined, true); } + + switch (len) { + case 1: listeners[i].fn.call(listeners[i].context); break; + case 2: listeners[i].fn.call(listeners[i].context, a1); break; + case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; + case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; + default: + if (!args) { for (j = 1, args = new Array(len -1); j < len; j++) { + args[j - 1] = arguments$1[j]; + } } + + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + + return true; + }; + + /** + * Add a listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ + EventEmitter.prototype.on = function on(event, fn, context) { + return addListener(this, event, fn, context, false); + }; + + /** + * Add a one-time listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ + EventEmitter.prototype.once = function once(event, fn, context) { + return addListener(this, event, fn, context, true); + }; + + /** + * Remove the listeners of a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {*} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @public + */ + EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) { return this; } + if (!fn) { + clearEvent(this, evt); + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn && + (!once || listeners.once) && + (!context || listeners.context === context) + ) { + clearEvent(this, evt); + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if ( + listeners[i].fn !== fn || + (once && !listeners[i].once) || + (context && listeners[i].context !== context) + ) { + events.push(listeners[i]); + } + } + + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) { this._events[evt] = events.length === 1 ? events[0] : events; } + else { clearEvent(this, evt); } + } + + return this; + }; + + /** + * Remove all listeners, or those of the specified event. + * + * @param {(String|Symbol)} [event] The event name. + * @returns {EventEmitter} `this`. + * @public + */ + EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) { clearEvent(this, evt); } + } else { + this._events = new Events(); + this._eventsCount = 0; + } + + return this; + }; + + // + // Alias methods names because people roll like that. + // + EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + EventEmitter.prototype.addListener = EventEmitter.prototype.on; + + // + // Expose the prefix. + // + EventEmitter.prefixed = prefix; + + // + // Allow `EventEmitter` to be imported as module namespace. + // + EventEmitter.EventEmitter = EventEmitter; + + // + // Expose the module. + // + if ('undefined' !== 'object') { + module.exports = EventEmitter; + } + }); + + 'use strict'; + + var earcut_1 = earcut; + var default_1 = earcut; + + function earcut(data, holeIndices, dim) { + + dim = dim || 2; + + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = linkedList(data, 0, outerLen, dim, true), + triangles = []; + + if (!outerNode || outerNode.next === outerNode.prev) { return triangles; } + + var minX, minY, maxX, maxY, x, y, invSize; + + if (hasHoles) { outerNode = eliminateHoles(data, holeIndices, outerNode, dim); } + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) { minX = x; } + if (y < minY) { minY = y; } + if (x > maxX) { maxX = x; } + if (y > maxY) { maxY = y; } + } + + // minX, minY and invSize are later used to transform coords into integers for z-order calculation + invSize = Math.max(maxX - minX, maxY - minY); + invSize = invSize !== 0 ? 1 / invSize : 0; + } + + earcutLinked(outerNode, triangles, dim, minX, minY, invSize); + + return triangles; + } + + // create a circular doubly linked list from polygon points in the specified winding order + function linkedList(data, start, end, dim, clockwise) { + var i, last; + + if (clockwise === (signedArea(data, start, end, dim) > 0)) { + for (i = start; i < end; i += dim) { last = insertNode(i, data[i], data[i + 1], last); } + } else { + for (i = end - dim; i >= start; i -= dim) { last = insertNode(i, data[i], data[i + 1], last); } + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; + } + + // eliminate colinear or duplicate points + function filterPoints(start, end) { + if (!start) { return start; } + if (!end) { end = start; } + + var p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) { break; } + again = true; + + } else { + p = p.next; + } + } while (again || p !== end); + + return end; + } + + // main ear slicing loop which triangulates a polygon (given as a linked list) + function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) { + if (!ear) { return; } + + // interlink polygon nodes in z-order + if (!pass && invSize) { indexCurve(ear, minX, minY, invSize); } + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + + removeNode(ear); + + // skipping the next vertex leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(ear, triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, invSize, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, invSize); + } + + break; + } + } + } + + // check whether a polygon node forms a valid ear with adjacent nodes + function isEar(ear) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) { return false; } // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + var p = ear.next.next; + + while (p !== ear.prev) { + if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) { return false; } + p = p.next; + } + + return true; + } + + function isEarHashed(ear, minX, minY, invSize) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) { return false; } // reflex, can't be an ear + + // triangle bbox; min & max are calculated like this for speed + var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), + minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), + maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), + maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); + + // z-order range for the current triangle bbox; + var minZ = zOrder(minTX, minTY, minX, minY, invSize), + maxZ = zOrder(maxTX, maxTY, minX, minY, invSize); + + var p = ear.prevZ, + n = ear.nextZ; + + // look for points inside the triangle in both directions + while (p && p.z >= minZ && n && n.z <= maxZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) { return false; } + p = p.prevZ; + + if (n !== ear.prev && n !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && + area(n.prev, n, n.next) >= 0) { return false; } + n = n.nextZ; + } + + // look for remaining points in decreasing z-order + while (p && p.z >= minZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) { return false; } + p = p.prevZ; + } + + // look for remaining points in increasing z-order + while (n && n.z <= maxZ) { + if (n !== ear.prev && n !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && + area(n.prev, n, n.next) >= 0) { return false; } + n = n.nextZ; + } + + return true; + } + + // go through all polygon nodes and cure small local self-intersections + function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + + triangles.push(a.i / dim); + triangles.push(p.i / dim); + triangles.push(b.i / dim); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + p = p.next; + } while (p !== start); + + return p; + } + + // try splitting polygon into two and triangulate them independently + function splitEarcut(start, triangles, dim, minX, minY, invSize) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, invSize); + earcutLinked(c, triangles, dim, minX, minY, invSize); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); + } + + // link every hole into the outer loop, producing a single-ring polygon without holes + function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) { list.steiner = true; } + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + eliminateHole(queue[i], outerNode); + outerNode = filterPoints(outerNode, outerNode.next); + } + + return outerNode; + } + + function compareX(a, b) { + return a.x - b.x; + } + + // find a bridge between vertices that connects hole with an outer ring and and link it + function eliminateHole(hole, outerNode) { + outerNode = findHoleBridge(hole, outerNode); + if (outerNode) { + var b = splitPolygon(outerNode, hole); + filterPoints(b, b.next); + } + } + + // David Eberly's algorithm for finding a bridge between hole and outer polygon + function findHoleBridge(hole, outerNode) { + var p = outerNode, + hx = hole.x, + hy = hole.y, + qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + if (x === hx) { + if (hy === p.y) { return p; } + if (hy === p.next.y) { return p.next; } + } + m = p.x < p.next.x ? p : p.next; + } + } + p = p.next; + } while (p !== outerNode); + + if (!m) { return null; } + + if (hx === qx) { return m.prev; } // hole touches outer segment; pick lower endpoint + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var stop = m, + mx = m.x, + my = m.y, + tanMin = Infinity, + tan; + + p = m.next; + + while (p !== stop) { + if (hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } + + return m; + } + + // interlink polygon nodes in z-order + function indexCurve(start, minX, minY, invSize) { + var p = start; + do { + if (p.z === null) { p.z = zOrder(p.x, p.y, minX, minY, invSize); } + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); + } + + // Simon Tatham's linked list merge sort algorithm + // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html + function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) { break; } + } + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) { tail.nextZ = e; } + else { list = e; } + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; + } + + // z-order of a point given coords and inverse of the longer side of data bbox + function zOrder(x, y, minX, minY, invSize) { + // coords are transformed into non-negative 15-bit integer range + x = 32767 * (x - minX) * invSize; + y = 32767 * (y - minY) * invSize; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); + } + + // find the leftmost node of a polygon ring + function getLeftmost(start) { + var p = start, + leftmost = start; + do { + if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) { leftmost = p; } + p = p.next; + } while (p !== start); + + return leftmost; + } + + // check if a point lies within a convex triangle + function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && + (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && + (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; + } + + // check if a diagonal between two polygon nodes is valid (lies in polygon interior) + function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && + locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); + } + + // signed area of a triangle + function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); + } + + // check if two points are equal + function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; + } + + // check if two segments intersect + function intersects(p1, q1, p2, q2) { + if ((equals(p1, q1) && equals(p2, q2)) || + (equals(p1, q2) && equals(p2, q1))) { return true; } + return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && + area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; + } + + // check if a polygon diagonal intersects any polygon segments + function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects(p, p.next, a, b)) { return true; } + p = p.next; + } while (p !== a); + + return false; + } + + // check if a polygon diagonal is locally inside the polygon + function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? + area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : + area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; + } + + // check if the middle point of a polygon diagonal is inside the polygon + function middleInside(a, b) { + var p = a, + inside = false, + px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && + (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) + { inside = !inside; } + p = p.next; + } while (p !== a); + + return inside; + } + + // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; + // if one belongs to the outer ring and another to a hole, it merges it into a single ring + function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; + } + + // create a node and optionally link it with previous one (in a circular doubly linked list) + function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + return p; + } + + function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) { p.prevZ.nextZ = p.nextZ; } + if (p.nextZ) { p.nextZ.prevZ = p.prevZ; } + } + + function Node(i, x, y) { + // vertex index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertex nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; + } + + // return a percentage difference between the polygon area and its triangulation area; + // used to verify correctness of triangulation + earcut.deviation = function (data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + + var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); + if (hasHoles) { + for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea(data, start, end, dim)); + } + } + + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs( + (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - + (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + + return polygonArea === 0 && trianglesArea === 0 ? 0 : + Math.abs((trianglesArea - polygonArea) / polygonArea); + }; + + function signedArea(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; + } + + // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts + earcut.flatten = function (data) { + var dim = data[0][0].length, + result = {vertices: [], holes: [], dimensions: dim}, + holeIndex = 0; + + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) { + for (var d = 0; d < dim; d++) { result.vertices.push(data[i][j][d]); } + } + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; + }; + earcut_1.default = default_1; + + var punycode = createCommonjsModule(function (module, exports) { + /*! https://mths.be/punycode v1.3.2 by @mathias */ + ;(function(root) { + + /** Detect free variables */ + var freeExports = 'object' == 'object' && exports && + !exports.nodeType && exports; + var freeModule = 'object' == 'object' && module && + !module.nodeType && module; + var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal; + if ( + freeGlobal.global === freeGlobal || + freeGlobal.window === freeGlobal || + freeGlobal.self === freeGlobal + ) { + root = freeGlobal; + } + + /** + * The `punycode` object. + * @name punycode + * @type Object + */ + var punycode, + + /** Highest positive signed 32-bit float value */ + maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 + + /** Bootstring parameters */ + base = 36, + tMin = 1, + tMax = 26, + skew = 38, + damp = 700, + initialBias = 72, + initialN = 128, // 0x80 + delimiter = '-', // '\x2D' + + /** Regular expressions */ + regexPunycode = /^xn--/, + regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars + regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators + + /** Error messages */ + errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }, + + /** Convenience shortcuts */ + baseMinusTMin = base - tMin, + floor = Math.floor, + stringFromCharCode = String.fromCharCode, + + /** Temporary variable */ + key; + + /*--------------------------------------------------------------------------*/ + + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw RangeError(errors[type]); + } + + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } + + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } + + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } + + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + function ucs2encode(array) { + return map(array, function(value) { + var output = ''; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + return output; + }).join(''); + } + + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + function basicToDigit(codePoint) { + if (codePoint - 48 < 10) { + return codePoint - 22; + } + if (codePoint - 65 < 26) { + return codePoint - 65; + } + if (codePoint - 97 < 26) { + return codePoint - 97; + } + return base; + } + + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } + + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * http://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } + + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + function decode(input) { + // Don't use UCS-2 + var output = [], + inputLength = input.length, + out, + i = 0, + n = initialN, + bias = initialBias, + basic, + j, + index, + oldi, + w, + k, + digit, + t, + /** Cached calculation results */ + baseMinusT; + + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. + + basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } + + for (j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error('not-basic'); + } + output.push(input.charCodeAt(j)); + } + + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. + + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { + + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + for (oldi = i, w = 1, k = base; /* no condition */; k += base) { + + if (index >= inputLength) { + error('invalid-input'); + } + + digit = basicToDigit(input.charCodeAt(index++)); + + if (digit >= base || digit > floor((maxInt - i) / w)) { + error('overflow'); + } + + i += digit * w; + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + + if (digit < t) { + break; + } + + baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error('overflow'); + } + + w *= baseMinusT; + + } + + out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); + + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error('overflow'); + } + + n += floor(i / out); + i %= out; + + // Insert `n` at position `i` of the output + output.splice(i++, 0, n); + + } + + return ucs2encode(output); + } + + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; + + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); + + // Cache the length + inputLength = input.length; + + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; + + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } + + handledCPCount = basicLength = output.length; + + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. + + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } + + // Main encoding loop: + while (handledCPCount < inputLength) { + + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } + + delta += (m - n) * handledCPCountPlusOne; + n = m; + + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } + + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } + + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } + + ++delta; + ++n; + + } + return output.join(''); + } + + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + function toUnicode(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) + ? decode(string.slice(4).toLowerCase()) + : string; + }); + } + + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) + ? 'xn--' + encode(string) + : string; + }); + } + + /*--------------------------------------------------------------------------*/ + + /** Define the public API */ + punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '1.3.2', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; + + /** Expose `punycode` */ + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof undefined == 'function' && + typeof undefined.amd == 'object' && + undefined.amd + ) { + undefined('punycode', function() { + return punycode; + }); + } else if (freeExports && freeModule) { + if (module.exports == freeExports) { // in Node.js or RingoJS v0.8.0+ + freeModule.exports = punycode; + } else { // in Narwhal or RingoJS v0.7.0- + for (key in punycode) { + punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); + } + } + } else { // in Rhino or a web browser + root.punycode = punycode; + } + + }(commonjsGlobal)); + }); + + 'use strict'; + + var util = { + isString: function(arg) { + return typeof(arg) === 'string'; + }, + isObject: function(arg) { + return typeof(arg) === 'object' && arg !== null; + }, + isNull: function(arg) { + return arg === null; + }, + isNullOrUndefined: function(arg) { + return arg == null; + } + }; + var util_1 = util.isString; + var util_2 = util.isObject; + var util_3 = util.isNull; + var util_4 = util.isNullOrUndefined; + + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + 'use strict'; + + // If obj.hasOwnProperty has been overridden, then calling + // obj.hasOwnProperty(prop) will break. + // See: https://github.com/joyent/node/issues/1707 + function hasOwnProperty$1(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); + } + + var decode = function(qs, sep, eq, options) { + sep = sep || '&'; + eq = eq || '='; + var obj = {}; + + if (typeof qs !== 'string' || qs.length === 0) { + return obj; + } + + var regexp = /\+/g; + qs = qs.split(sep); + + var maxKeys = 1000; + if (options && typeof options.maxKeys === 'number') { + maxKeys = options.maxKeys; + } + + var len = qs.length; + // maxKeys <= 0 means that we should not limit keys count + if (maxKeys > 0 && len > maxKeys) { + len = maxKeys; + } + + for (var i = 0; i < len; ++i) { + var x = qs[i].replace(regexp, '%20'), + idx = x.indexOf(eq), + kstr, vstr, k, v; + + if (idx >= 0) { + kstr = x.substr(0, idx); + vstr = x.substr(idx + 1); + } else { + kstr = x; + vstr = ''; + } + + k = decodeURIComponent(kstr); + v = decodeURIComponent(vstr); + + if (!hasOwnProperty$1(obj, k)) { + obj[k] = v; + } else if (Array.isArray(obj[k])) { + obj[k].push(v); + } else { + obj[k] = [obj[k], v]; + } + } + + return obj; + }; + + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + 'use strict'; + + var stringifyPrimitive = function(v) { + switch (typeof v) { + case 'string': + return v; + + case 'boolean': + return v ? 'true' : 'false'; + + case 'number': + return isFinite(v) ? v : ''; + + default: + return ''; + } + }; + + var encode = function(obj, sep, eq, name) { + sep = sep || '&'; + eq = eq || '='; + if (obj === null) { + obj = undefined; + } + + if (typeof obj === 'object') { + return Object.keys(obj).map(function(k) { + var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; + if (Array.isArray(obj[k])) { + return obj[k].map(function(v) { + return ks + encodeURIComponent(stringifyPrimitive(v)); + }).join(sep); + } else { + return ks + encodeURIComponent(stringifyPrimitive(obj[k])); + } + }).join(sep); + + } + + if (!name) { return ''; } + return encodeURIComponent(stringifyPrimitive(name)) + eq + + encodeURIComponent(stringifyPrimitive(obj)); + }; + + var querystring = createCommonjsModule(function (module, exports) { + 'use strict'; + + exports.decode = exports.parse = decode; + exports.encode = exports.stringify = encode; + }); + var querystring_1 = querystring.decode; + var querystring_2 = querystring.parse; + var querystring_3 = querystring.encode; + var querystring_4 = querystring.stringify; + + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + 'use strict'; + + + + + var parse = urlParse; + var resolve = urlResolve; + var resolveObject = urlResolveObject; + var format = urlFormat; + + var Url_1 = Url; + + function Url() { + this.protocol = null; + this.slashes = null; + this.auth = null; + this.host = null; + this.port = null; + this.hostname = null; + this.hash = null; + this.search = null; + this.query = null; + this.pathname = null; + this.path = null; + this.href = null; + } + + // Reference: RFC 3986, RFC 1808, RFC 2396 + + // define these here so at least they only have to be + // compiled once on the first module load. + var protocolPattern = /^([a-z0-9.+-]+:)/i, + portPattern = /:[0-9]*$/, + + // Special case for a simple path URL + simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, + + // RFC 2396: characters reserved for delimiting URLs. + // We actually just auto-escape these. + delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], + + // RFC 2396: characters not allowed for various reasons. + unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), + + // Allowed by RFCs, but cause of XSS attacks. Always escape these. + autoEscape = ['\''].concat(unwise), + // Characters that are never ever allowed in a hostname. + // Note that any invalid chars are also handled, but these + // are the ones that are *expected* to be seen, so we fast-path + // them. + nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), + hostEndingChars = ['/', '?', '#'], + hostnameMaxLen = 255, + hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, + hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, + // protocols that can allow "unsafe" and "unwise" chars. + unsafeProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that never have a hostname. + hostlessProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that always contain a // bit. + slashedProtocol = { + 'http': true, + 'https': true, + 'ftp': true, + 'gopher': true, + 'file': true, + 'http:': true, + 'https:': true, + 'ftp:': true, + 'gopher:': true, + 'file:': true + }; + + function urlParse(url, parseQueryString, slashesDenoteHost) { + if (url && util.isObject(url) && url instanceof Url) { return url; } + + var u = new Url; + u.parse(url, parseQueryString, slashesDenoteHost); + return u; + } + + Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { + if (!util.isString(url)) { + throw new TypeError("Parameter 'url' must be a string, not " + typeof url); + } + + // Copy chrome, IE, opera backslash-handling behavior. + // Back slashes before the query string get converted to forward slashes + // See: https://code.google.com/p/chromium/issues/detail?id=25916 + var queryIndex = url.indexOf('?'), + splitter = + (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', + uSplit = url.split(splitter), + slashRegex = /\\/g; + uSplit[0] = uSplit[0].replace(slashRegex, '/'); + url = uSplit.join(splitter); + + var rest = url; + + // trim before proceeding. + // This is to support parse stuff like " http://foo.com \n" + rest = rest.trim(); + + if (!slashesDenoteHost && url.split('#').length === 1) { + // Try fast path regexp + var simplePath = simplePathPattern.exec(rest); + if (simplePath) { + this.path = rest; + this.href = rest; + this.pathname = simplePath[1]; + if (simplePath[2]) { + this.search = simplePath[2]; + if (parseQueryString) { + this.query = querystring.parse(this.search.substr(1)); + } else { + this.query = this.search.substr(1); + } + } else if (parseQueryString) { + this.search = ''; + this.query = {}; + } + return this; + } + } + + var proto = protocolPattern.exec(rest); + if (proto) { + proto = proto[0]; + var lowerProto = proto.toLowerCase(); + this.protocol = lowerProto; + rest = rest.substr(proto.length); + } + + // figure out if it's got a host + // user@server is *always* interpreted as a hostname, and url + // resolution will treat //foo/bar as host=foo,path=bar because that's + // how the browser resolves relative URLs. + if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { + var slashes = rest.substr(0, 2) === '//'; + if (slashes && !(proto && hostlessProtocol[proto])) { + rest = rest.substr(2); + this.slashes = true; + } + } + + if (!hostlessProtocol[proto] && + (slashes || (proto && !slashedProtocol[proto]))) { + + // there's a hostname. + // the first instance of /, ?, ;, or # ends the host. + // + // If there is an @ in the hostname, then non-host chars *are* allowed + // to the left of the last @ sign, unless some host-ending character + // comes *before* the @-sign. + // URLs are obnoxious. + // + // ex: + // http://a@b@c/ => user:a@b host:c + // http://a@b?@c => user:a host:c path:/?@c + + // v0.12 TODO(isaacs): This is not quite how Chrome does things. + // Review our test case against browsers more comprehensively. + + // find the first instance of any hostEndingChars + var hostEnd = -1; + for (var i = 0; i < hostEndingChars.length; i++) { + var hec = rest.indexOf(hostEndingChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + { hostEnd = hec; } + } + + // at this point, either we have an explicit point where the + // auth portion cannot go past, or the last @ char is the decider. + var auth, atSign; + if (hostEnd === -1) { + // atSign can be anywhere. + atSign = rest.lastIndexOf('@'); + } else { + // atSign must be in auth portion. + // http://a@b/c@d => host:b auth:a path:/c@d + atSign = rest.lastIndexOf('@', hostEnd); + } + + // Now we have a portion which is definitely the auth. + // Pull that off. + if (atSign !== -1) { + auth = rest.slice(0, atSign); + rest = rest.slice(atSign + 1); + this.auth = decodeURIComponent(auth); + } + + // the host is the remaining to the left of the first non-host char + hostEnd = -1; + for (var i = 0; i < nonHostChars.length; i++) { + var hec = rest.indexOf(nonHostChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + { hostEnd = hec; } + } + // if we still have not hit it, then the entire thing is a host. + if (hostEnd === -1) + { hostEnd = rest.length; } + + this.host = rest.slice(0, hostEnd); + rest = rest.slice(hostEnd); + + // pull out port. + this.parseHost(); + + // we've indicated that there is a hostname, + // so even if it's empty, it has to be present. + this.hostname = this.hostname || ''; + + // if hostname begins with [ and ends with ] + // assume that it's an IPv6 address. + var ipv6Hostname = this.hostname[0] === '[' && + this.hostname[this.hostname.length - 1] === ']'; + + // validate a little. + if (!ipv6Hostname) { + var hostparts = this.hostname.split(/\./); + for (var i = 0, l = hostparts.length; i < l; i++) { + var part = hostparts[i]; + if (!part) { continue; } + if (!part.match(hostnamePartPattern)) { + var newpart = ''; + for (var j = 0, k = part.length; j < k; j++) { + if (part.charCodeAt(j) > 127) { + // we replace non-ASCII char with a temporary placeholder + // we need this to make sure size of hostname is not + // broken by replacing non-ASCII by nothing + newpart += 'x'; + } else { + newpart += part[j]; + } + } + // we test again with ASCII char only + if (!newpart.match(hostnamePartPattern)) { + var validParts = hostparts.slice(0, i); + var notHost = hostparts.slice(i + 1); + var bit = part.match(hostnamePartStart); + if (bit) { + validParts.push(bit[1]); + notHost.unshift(bit[2]); + } + if (notHost.length) { + rest = '/' + notHost.join('.') + rest; + } + this.hostname = validParts.join('.'); + break; + } + } + } + } + + if (this.hostname.length > hostnameMaxLen) { + this.hostname = ''; + } else { + // hostnames are always lower case. + this.hostname = this.hostname.toLowerCase(); + } + + if (!ipv6Hostname) { + // IDNA Support: Returns a punycoded representation of "domain". + // It only converts parts of the domain name that + // have non-ASCII characters, i.e. it doesn't matter if + // you call it with a domain that already is ASCII-only. + this.hostname = punycode.toASCII(this.hostname); + } + + var p = this.port ? ':' + this.port : ''; + var h = this.hostname || ''; + this.host = h + p; + this.href += this.host; + + // strip [ and ] from the hostname + // the host field still retains them, though + if (ipv6Hostname) { + this.hostname = this.hostname.substr(1, this.hostname.length - 2); + if (rest[0] !== '/') { + rest = '/' + rest; + } + } + } + + // now rest is set to the post-host stuff. + // chop off any delim chars. + if (!unsafeProtocol[lowerProto]) { + + // First, make 100% sure that any "autoEscape" chars get + // escaped, even if encodeURIComponent doesn't think they + // need to be. + for (var i = 0, l = autoEscape.length; i < l; i++) { + var ae = autoEscape[i]; + if (rest.indexOf(ae) === -1) + { continue; } + var esc = encodeURIComponent(ae); + if (esc === ae) { + esc = escape(ae); + } + rest = rest.split(ae).join(esc); + } + } + + + // chop off from the tail first. + var hash = rest.indexOf('#'); + if (hash !== -1) { + // got a fragment string. + this.hash = rest.substr(hash); + rest = rest.slice(0, hash); + } + var qm = rest.indexOf('?'); + if (qm !== -1) { + this.search = rest.substr(qm); + this.query = rest.substr(qm + 1); + if (parseQueryString) { + this.query = querystring.parse(this.query); + } + rest = rest.slice(0, qm); + } else if (parseQueryString) { + // no query string, but parseQueryString still requested + this.search = ''; + this.query = {}; + } + if (rest) { this.pathname = rest; } + if (slashedProtocol[lowerProto] && + this.hostname && !this.pathname) { + this.pathname = '/'; + } + + //to support http.request + if (this.pathname || this.search) { + var p = this.pathname || ''; + var s = this.search || ''; + this.path = p + s; + } + + // finally, reconstruct the href based on what has been validated. + this.href = this.format(); + return this; + }; + + // format a parsed object into a url string + function urlFormat(obj) { + // ensure it's an object, and not a string url. + // If it's an obj, this is a no-op. + // this way, you can call url_format() on strings + // to clean up potentially wonky urls. + if (util.isString(obj)) { obj = urlParse(obj); } + if (!(obj instanceof Url)) { return Url.prototype.format.call(obj); } + return obj.format(); + } + + Url.prototype.format = function() { + var auth = this.auth || ''; + if (auth) { + auth = encodeURIComponent(auth); + auth = auth.replace(/%3A/i, ':'); + auth += '@'; + } + + var protocol = this.protocol || '', + pathname = this.pathname || '', + hash = this.hash || '', + host = false, + query = ''; + + if (this.host) { + host = auth + this.host; + } else if (this.hostname) { + host = auth + (this.hostname.indexOf(':') === -1 ? + this.hostname : + '[' + this.hostname + ']'); + if (this.port) { + host += ':' + this.port; + } + } + + if (this.query && + util.isObject(this.query) && + Object.keys(this.query).length) { + query = querystring.stringify(this.query); + } + + var search = this.search || (query && ('?' + query)) || ''; + + if (protocol && protocol.substr(-1) !== ':') { protocol += ':'; } + + // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. + // unless they had them to begin with. + if (this.slashes || + (!protocol || slashedProtocol[protocol]) && host !== false) { + host = '//' + (host || ''); + if (pathname && pathname.charAt(0) !== '/') { pathname = '/' + pathname; } + } else if (!host) { + host = ''; + } + + if (hash && hash.charAt(0) !== '#') { hash = '#' + hash; } + if (search && search.charAt(0) !== '?') { search = '?' + search; } + + pathname = pathname.replace(/[?#]/g, function(match) { + return encodeURIComponent(match); + }); + search = search.replace('#', '%23'); + + return protocol + host + pathname + search + hash; + }; + + function urlResolve(source, relative) { + return urlParse(source, false, true).resolve(relative); + } + + Url.prototype.resolve = function(relative) { + return this.resolveObject(urlParse(relative, false, true)).format(); + }; + + function urlResolveObject(source, relative) { + if (!source) { return relative; } + return urlParse(source, false, true).resolveObject(relative); + } + + Url.prototype.resolveObject = function(relative) { + if (util.isString(relative)) { + var rel = new Url(); + rel.parse(relative, false, true); + relative = rel; + } + + var result = new Url(); + var tkeys = Object.keys(this); + for (var tk = 0; tk < tkeys.length; tk++) { + var tkey = tkeys[tk]; + result[tkey] = this[tkey]; + } + + // hash is always overridden, no matter what. + // even href="" will remove it. + result.hash = relative.hash; + + // if the relative url is empty, then there's nothing left to do here. + if (relative.href === '') { + result.href = result.format(); + return result; + } + + // hrefs like //foo/bar always cut to the protocol. + if (relative.slashes && !relative.protocol) { + // take everything except the protocol from relative + var rkeys = Object.keys(relative); + for (var rk = 0; rk < rkeys.length; rk++) { + var rkey = rkeys[rk]; + if (rkey !== 'protocol') + { result[rkey] = relative[rkey]; } + } + + //urlParse appends trailing / to urls like http://www.example.com + if (slashedProtocol[result.protocol] && + result.hostname && !result.pathname) { + result.path = result.pathname = '/'; + } + + result.href = result.format(); + return result; + } + + if (relative.protocol && relative.protocol !== result.protocol) { + // if it's a known url protocol, then changing + // the protocol does weird things + // first, if it's not file:, then we MUST have a host, + // and if there was a path + // to begin with, then we MUST have a path. + // if it is file:, then the host is dropped, + // because that's known to be hostless. + // anything else is assumed to be absolute. + if (!slashedProtocol[relative.protocol]) { + var keys = Object.keys(relative); + for (var v = 0; v < keys.length; v++) { + var k = keys[v]; + result[k] = relative[k]; + } + result.href = result.format(); + return result; + } + + result.protocol = relative.protocol; + if (!relative.host && !hostlessProtocol[relative.protocol]) { + var relPath = (relative.pathname || '').split('/'); + while (relPath.length && !(relative.host = relPath.shift())){ ; } + if (!relative.host) { relative.host = ''; } + if (!relative.hostname) { relative.hostname = ''; } + if (relPath[0] !== '') { relPath.unshift(''); } + if (relPath.length < 2) { relPath.unshift(''); } + result.pathname = relPath.join('/'); + } else { + result.pathname = relative.pathname; + } + result.search = relative.search; + result.query = relative.query; + result.host = relative.host || ''; + result.auth = relative.auth; + result.hostname = relative.hostname || relative.host; + result.port = relative.port; + // to support http.request + if (result.pathname || result.search) { + var p = result.pathname || ''; + var s = result.search || ''; + result.path = p + s; + } + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; + } + + var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), + isRelAbs = ( + relative.host || + relative.pathname && relative.pathname.charAt(0) === '/' + ), + mustEndAbs = (isRelAbs || isSourceAbs || + (result.host && relative.pathname)), + removeAllDots = mustEndAbs, + srcPath = result.pathname && result.pathname.split('/') || [], + relPath = relative.pathname && relative.pathname.split('/') || [], + psychotic = result.protocol && !slashedProtocol[result.protocol]; + + // if the url is a non-slashed url, then relative + // links like ../.. should be able + // to crawl up to the hostname, as well. This is strange. + // result.protocol has already been set by now. + // Later on, put the first path part into the host field. + if (psychotic) { + result.hostname = ''; + result.port = null; + if (result.host) { + if (srcPath[0] === '') { srcPath[0] = result.host; } + else { srcPath.unshift(result.host); } + } + result.host = ''; + if (relative.protocol) { + relative.hostname = null; + relative.port = null; + if (relative.host) { + if (relPath[0] === '') { relPath[0] = relative.host; } + else { relPath.unshift(relative.host); } + } + relative.host = null; + } + mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); + } + + if (isRelAbs) { + // it's absolute. + result.host = (relative.host || relative.host === '') ? + relative.host : result.host; + result.hostname = (relative.hostname || relative.hostname === '') ? + relative.hostname : result.hostname; + result.search = relative.search; + result.query = relative.query; + srcPath = relPath; + // fall through to the dot-handling below. + } else if (relPath.length) { + // it's relative + // throw away the existing file, and take the new path instead. + if (!srcPath) { srcPath = []; } + srcPath.pop(); + srcPath = srcPath.concat(relPath); + result.search = relative.search; + result.query = relative.query; + } else if (!util.isNullOrUndefined(relative.search)) { + // just pull out the search. + // like href='?foo'. + // Put this after the other two cases because it simplifies the booleans + if (psychotic) { + result.hostname = result.host = srcPath.shift(); + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + var authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + result.search = relative.search; + result.query = relative.query; + //to support http.request + if (!util.isNull(result.pathname) || !util.isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.href = result.format(); + return result; + } + + if (!srcPath.length) { + // no path at all. easy. + // we've already handled the other stuff above. + result.pathname = null; + //to support http.request + if (result.search) { + result.path = '/' + result.search; + } else { + result.path = null; + } + result.href = result.format(); + return result; + } + + // if a url ENDs in . or .., then it must get a trailing slash. + // however, if it ends in anything else non-slashy, + // then it must NOT get a trailing slash. + var last = srcPath.slice(-1)[0]; + var hasTrailingSlash = ( + (result.host || relative.host || srcPath.length > 1) && + (last === '.' || last === '..') || last === ''); + + // strip single dots, resolve double dots to parent dir + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = srcPath.length; i >= 0; i--) { + last = srcPath[i]; + if (last === '.') { + srcPath.splice(i, 1); + } else if (last === '..') { + srcPath.splice(i, 1); + up++; + } else if (up) { + srcPath.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (!mustEndAbs && !removeAllDots) { + for (; up--; up) { + srcPath.unshift('..'); + } + } + + if (mustEndAbs && srcPath[0] !== '' && + (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { + srcPath.unshift(''); + } + + if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { + srcPath.push(''); + } + + var isAbsolute = srcPath[0] === '' || + (srcPath[0] && srcPath[0].charAt(0) === '/'); + + // put the host back + if (psychotic) { + result.hostname = result.host = isAbsolute ? '' : + srcPath.length ? srcPath.shift() : ''; + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + var authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + + mustEndAbs = mustEndAbs || (result.host && srcPath.length); + + if (mustEndAbs && !isAbsolute) { + srcPath.unshift(''); + } + + if (!srcPath.length) { + result.pathname = null; + result.path = null; + } else { + result.pathname = srcPath.join('/'); + } + + //to support request.http + if (!util.isNull(result.pathname) || !util.isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.auth = relative.auth || result.auth; + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; + }; + + Url.prototype.parseHost = function() { + var host = this.host; + var port = portPattern.exec(host); + if (port) { + port = port[0]; + if (port !== ':') { + this.port = port.substr(1); + } + host = host.substr(0, host.length - port.length); + } + if (host) { this.hostname = host; } + }; + + var url = { + parse: parse, + resolve: resolve, + resolveObject: resolveObject, + format: format, + Url: Url_1 + }; + + /*! + * @pixi/constants - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/constants is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + /** + * Different types of environments for WebGL. + * + * @static + * @memberof PIXI + * @name ENV + * @enum {number} + * @property {number} WEBGL_LEGACY - Used for older v1 WebGL devices. PixiJS will aim to ensure compatibility + * with older / less advanced devices. If you experience unexplained flickering prefer this environment. + * @property {number} WEBGL - Version 1 of WebGL + * @property {number} WEBGL2 - Version 2 of WebGL + */ + var ENV = { + WEBGL_LEGACY: 0, + WEBGL: 1, + WEBGL2: 2, + }; + + /** + * Constant to identify the Renderer Type. + * + * @static + * @memberof PIXI + * @name RENDERER_TYPE + * @enum {number} + * @property {number} UNKNOWN - Unknown render type. + * @property {number} WEBGL - WebGL render type. + * @property {number} CANVAS - Canvas render type. + */ + var RENDERER_TYPE = { + UNKNOWN: 0, + WEBGL: 1, + CANVAS: 2, + }; + + /** + * Various blend modes supported by PIXI. + * + * IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes. + * Anything else will silently act like NORMAL. + * + * @memberof PIXI + * @name BLEND_MODES + * @enum {number} + * @property {number} NORMAL + * @property {number} ADD + * @property {number} MULTIPLY + * @property {number} SCREEN + * @property {number} OVERLAY + * @property {number} DARKEN + * @property {number} LIGHTEN + * @property {number} COLOR_DODGE + * @property {number} COLOR_BURN + * @property {number} HARD_LIGHT + * @property {number} SOFT_LIGHT + * @property {number} DIFFERENCE + * @property {number} EXCLUSION + * @property {number} HUE + * @property {number} SATURATION + * @property {number} COLOR + * @property {number} LUMINOSITY + * @property {number} NORMAL_NPM + * @property {number} ADD_NPM + * @property {number} SCREEN_NPM + * @property {number} NONE + * @property {number} SRC_IN + * @property {number} SRC_OUT + * @property {number} SRC_ATOP + * @property {number} DST_OVER + * @property {number} DST_IN + * @property {number} DST_OUT + * @property {number} DST_ATOP + * @property {number} SUBTRACT + * @property {number} SRC_OVER + * @property {number} ERASE + */ + var BLEND_MODES = { + NORMAL: 0, + ADD: 1, + MULTIPLY: 2, + SCREEN: 3, + OVERLAY: 4, + DARKEN: 5, + LIGHTEN: 6, + COLOR_DODGE: 7, + COLOR_BURN: 8, + HARD_LIGHT: 9, + SOFT_LIGHT: 10, + DIFFERENCE: 11, + EXCLUSION: 12, + HUE: 13, + SATURATION: 14, + COLOR: 15, + LUMINOSITY: 16, + NORMAL_NPM: 17, + ADD_NPM: 18, + SCREEN_NPM: 19, + NONE: 20, + + SRC_OVER: 0, + SRC_IN: 21, + SRC_OUT: 22, + SRC_ATOP: 23, + DST_OVER: 24, + DST_IN: 25, + DST_OUT: 26, + DST_ATOP: 27, + ERASE: 26, + SUBTRACT: 28, + }; + + /** + * Various webgl draw modes. These can be used to specify which GL drawMode to use + * under certain situations and renderers. + * + * @memberof PIXI + * @static + * @name DRAW_MODES + * @enum {number} + * @property {number} POINTS + * @property {number} LINES + * @property {number} LINE_LOOP + * @property {number} LINE_STRIP + * @property {number} TRIANGLES + * @property {number} TRIANGLE_STRIP + * @property {number} TRIANGLE_FAN + */ + var DRAW_MODES = { + POINTS: 0, + LINES: 1, + LINE_LOOP: 2, + LINE_STRIP: 3, + TRIANGLES: 4, + TRIANGLE_STRIP: 5, + TRIANGLE_FAN: 6, + }; + + /** + * Various GL texture/resources formats. + * + * @memberof PIXI + * @static + * @name FORMATS + * @enum {number} + * @property {number} RGBA=6408 + * @property {number} RGB=6407 + * @property {number} ALPHA=6406 + * @property {number} LUMINANCE=6409 + * @property {number} LUMINANCE_ALPHA=6410 + * @property {number} DEPTH_COMPONENT=6402 + * @property {number} DEPTH_STENCIL=34041 + */ + var FORMATS = { + RGBA: 6408, + RGB: 6407, + ALPHA: 6406, + LUMINANCE: 6409, + LUMINANCE_ALPHA: 6410, + DEPTH_COMPONENT: 6402, + DEPTH_STENCIL: 34041, + }; + + /** + * Various GL target types. + * + * @memberof PIXI + * @static + * @name TARGETS + * @enum {number} + * @property {number} TEXTURE_2D=3553 + * @property {number} TEXTURE_CUBE_MAP=34067 + * @property {number} TEXTURE_2D_ARRAY=35866 + * @property {number} TEXTURE_CUBE_MAP_POSITIVE_X=34069 + * @property {number} TEXTURE_CUBE_MAP_NEGATIVE_X=34070 + * @property {number} TEXTURE_CUBE_MAP_POSITIVE_Y=34071 + * @property {number} TEXTURE_CUBE_MAP_NEGATIVE_Y=34072 + * @property {number} TEXTURE_CUBE_MAP_POSITIVE_Z=34073 + * @property {number} TEXTURE_CUBE_MAP_NEGATIVE_Z=34074 + */ + var TARGETS = { + TEXTURE_2D: 3553, + TEXTURE_CUBE_MAP: 34067, + TEXTURE_2D_ARRAY: 35866, + TEXTURE_CUBE_MAP_POSITIVE_X: 34069, + TEXTURE_CUBE_MAP_NEGATIVE_X: 34070, + TEXTURE_CUBE_MAP_POSITIVE_Y: 34071, + TEXTURE_CUBE_MAP_NEGATIVE_Y: 34072, + TEXTURE_CUBE_MAP_POSITIVE_Z: 34073, + TEXTURE_CUBE_MAP_NEGATIVE_Z: 34074, + }; + + /** + * Various GL data format types. + * + * @memberof PIXI + * @static + * @name TYPES + * @enum {number} + * @property {number} UNSIGNED_BYTE=5121 + * @property {number} UNSIGNED_SHORT=5123 + * @property {number} UNSIGNED_SHORT_5_6_5=33635 + * @property {number} UNSIGNED_SHORT_4_4_4_4=32819 + * @property {number} UNSIGNED_SHORT_5_5_5_1=32820 + * @property {number} FLOAT=5126 + * @property {number} HALF_FLOAT=36193 + */ + var TYPES = { + UNSIGNED_BYTE: 5121, + UNSIGNED_SHORT: 5123, + UNSIGNED_SHORT_5_6_5: 33635, + UNSIGNED_SHORT_4_4_4_4: 32819, + UNSIGNED_SHORT_5_5_5_1: 32820, + FLOAT: 5126, + HALF_FLOAT: 36193, + }; + + /** + * The scale modes that are supported by pixi. + * + * The {@link PIXI.settings.SCALE_MODE} scale mode affects the default scaling mode of future operations. + * It can be re-assigned to either LINEAR or NEAREST, depending upon suitability. + * + * @memberof PIXI + * @static + * @name SCALE_MODES + * @enum {number} + * @property {number} LINEAR Smooth scaling + * @property {number} NEAREST Pixelating scaling + */ + var SCALE_MODES = { + LINEAR: 1, + NEAREST: 0, + }; + + /** + * The wrap modes that are supported by pixi. + * + * The {@link PIXI.settings.WRAP_MODE} wrap mode affects the default wrapping mode of future operations. + * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability. + * If the texture is non power of two then clamp will be used regardless as WebGL can + * only use REPEAT if the texture is po2. + * + * This property only affects WebGL. + * + * @name WRAP_MODES + * @memberof PIXI + * @static + * @enum {number} + * @property {number} CLAMP - The textures uvs are clamped + * @property {number} REPEAT - The texture uvs tile and repeat + * @property {number} MIRRORED_REPEAT - The texture uvs tile and repeat with mirroring + */ + var WRAP_MODES = { + CLAMP: 33071, + REPEAT: 10497, + MIRRORED_REPEAT: 33648, + }; + + /** + * Mipmap filtering modes that are supported by pixi. + * + * The {@link PIXI.settings.MIPMAP_TEXTURES} affects default texture filtering. + * Mipmaps are generated for a baseTexture if its `mipmap` field is `ON`, + * or its `POW2` and texture dimensions are powers of 2. + * Due to platform restriction, `ON` option will work like `POW2` for webgl-1. + * + * This property only affects WebGL. + * + * @name MIPMAP_MODES + * @memberof PIXI + * @static + * @enum {number} + * @property {number} OFF - No mipmaps + * @property {number} POW2 - Generate mipmaps if texture dimensions are pow2 + * @property {number} ON - Always generate mipmaps + */ + var MIPMAP_MODES = { + OFF: 0, + POW2: 1, + ON: 2, + }; + + /** + * The gc modes that are supported by pixi. + * + * The {@link PIXI.settings.GC_MODE} Garbage Collection mode for PixiJS textures is AUTO + * If set to GC_MODE, the renderer will occasionally check textures usage. If they are not + * used for a specified period of time they will be removed from the GPU. They will of course + * be uploaded again when they are required. This is a silent behind the scenes process that + * should ensure that the GPU does not get filled up. + * + * Handy for mobile devices! + * This property only affects WebGL. + * + * @name GC_MODES + * @enum {number} + * @static + * @memberof PIXI + * @property {number} AUTO - Garbage collection will happen periodically automatically + * @property {number} MANUAL - Garbage collection will need to be called manually + */ + var GC_MODES = { + AUTO: 0, + MANUAL: 1, + }; + + /** + * Constants that specify float precision in shaders. + * + * @name PRECISION + * @memberof PIXI + * @static + * @enum {string} + * @constant + * @property {string} LOW='lowp' + * @property {string} MEDIUM='mediump' + * @property {string} HIGH='highp' + */ + var PRECISION = { + LOW: 'lowp', + MEDIUM: 'mediump', + HIGH: 'highp', + }; + + /*! + * @pixi/utils - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/utils is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * The prefix that denotes a URL is for a retina asset. + * + * @static + * @name RETINA_PREFIX + * @memberof PIXI.settings + * @type {RegExp} + * @default /@([0-9\.]+)x/ + * @example `@2x` + */ + settings.RETINA_PREFIX = /@([0-9\.]+)x/; + + var saidHello = false; + var VERSION = '5.0.0-rc.3'; + + /** + * Skips the hello message of renderers that are created after this is run. + * + * @function skipHello + * @memberof PIXI.utils + */ + function skipHello() + { + saidHello = true; + } + + /** + * Logs out the version and renderer information for this running instance of PIXI. + * If you don't want to see this message you can run `PIXI.utils.skipHello()` before + * creating your renderer. Keep in mind that doing that will forever makes you a jerk face. + * + * @static + * @function sayHello + * @memberof PIXI.utils + * @param {string} type - The string renderer type to log. + */ + function sayHello(type) + { + if (saidHello) + { + return; + } + + if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) + { + var args = [ + ("\n %c %c %c PixiJS " + VERSION + " - ✰ " + type + " ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ \n\n"), + 'background: #ff66a5; padding:5px 0;', + 'background: #ff66a5; padding:5px 0;', + 'color: #ff66a5; background: #030307; padding:5px 0;', + 'background: #ff66a5; padding:5px 0;', + 'background: #ffc3dc; padding:5px 0;', + 'background: #ff66a5; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;', + 'color: #ff2424; background: #fff; padding:5px 0;' ]; + + window.console.log.apply(console, args); + } + else if (window.console) + { + window.console.log(("PixiJS " + VERSION + " - " + type + " - http://www.pixijs.com/")); + } + + saidHello = true; + } + + var supported; + + /** + * Helper for checking for WebGL support. + * + * @memberof PIXI.utils + * @function isWebGLSupported + * @return {boolean} Is WebGL supported. + */ + function isWebGLSupported() + { + if (typeof supported === 'undefined') + { + supported = (function supported() + { + var contextOptions = { stencil: true, failIfMajorPerformanceCaveat: true }; + + try + { + if (!window.WebGLRenderingContext) + { + return false; + } + + var canvas = document.createElement('canvas'); + var gl = canvas.getContext('webgl', contextOptions) + || canvas.getContext('experimental-webgl', contextOptions); + + var success = !!(gl && gl.getContextAttributes().stencil); + + if (gl) + { + var loseContext = gl.getExtension('WEBGL_lose_context'); + + if (loseContext) + { + loseContext.loseContext(); + } + } + + gl = null; + + return success; + } + catch (e) + { + return false; + } + })(); + } + + return supported; + } + + /** + * Converts a hexadecimal color number to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0). + * + * @example + * PIXI.utils.hex2rgb(0xffffff); // returns [1, 1, 1] + * @memberof PIXI.utils + * @function hex2rgb + * @param {number} hex - The hexadecimal number to convert + * @param {number[]} [out=[]] If supplied, this array will be used rather than returning a new one + * @return {number[]} An array representing the [R, G, B] of the color where all values are floats. + */ + function hex2rgb(hex, out) + { + out = out || []; + + out[0] = ((hex >> 16) & 0xFF) / 255; + out[1] = ((hex >> 8) & 0xFF) / 255; + out[2] = (hex & 0xFF) / 255; + + return out; + } + + /** + * Converts a hexadecimal color number to a string. + * + * @example + * PIXI.utils.hex2string(0xffffff); // returns "#ffffff" + * @memberof PIXI.utils + * @function hex2string + * @param {number} hex - Number in hex (e.g., `0xffffff`) + * @return {string} The string color (e.g., `"#ffffff"`). + */ + function hex2string(hex) + { + hex = hex.toString(16); + hex = '000000'.substr(0, 6 - hex.length) + hex; + + return ("#" + hex); + } + + /** + * Converts a hexadecimal string to a hexadecimal color number. + * + * @example + * PIXI.utils.string2hex("#ffffff"); // returns 0xffffff + * @memberof PIXI.utils + * @function string2hex + * @param {string} The string color (e.g., `"#ffffff"`) + * @return {number} Number in hexadecimal. + */ + function string2hex(string) + { + if (typeof string === 'string' && string[0] === '#') + { + string = string.substr(1); + } + + return parseInt(string, 16); + } + + /** + * Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number. + * + * @example + * PIXI.utils.rgb2hex([1, 1, 1]); // returns 0xffffff + * @memberof PIXI.utils + * @function rgb2hex + * @param {number[]} rgb - Array of numbers where all values are normalized floats from 0.0 to 1.0. + * @return {number} Number in hexadecimal. + */ + function rgb2hex(rgb) + { + return (((rgb[0] * 255) << 16) + ((rgb[1] * 255) << 8) + (rgb[2] * 255 | 0)); + } + + /** + * Corrects PixiJS blend, takes premultiplied alpha into account + * + * @memberof PIXI.utils + * @function mapPremultipliedBlendModes + * @private + * @param {Array} [array] - The array to output into. + * @return {Array} Mapped modes. + */ + function mapPremultipliedBlendModes() + { + var pm = []; + var npm = []; + + for (var i = 0; i < 32; i++) + { + pm[i] = i; + npm[i] = i; + } + + pm[BLEND_MODES.NORMAL_NPM] = BLEND_MODES.NORMAL; + pm[BLEND_MODES.ADD_NPM] = BLEND_MODES.ADD; + pm[BLEND_MODES.SCREEN_NPM] = BLEND_MODES.SCREEN; + + npm[BLEND_MODES.NORMAL] = BLEND_MODES.NORMAL_NPM; + npm[BLEND_MODES.ADD] = BLEND_MODES.ADD_NPM; + npm[BLEND_MODES.SCREEN] = BLEND_MODES.SCREEN_NPM; + + var array = []; + + array.push(npm); + array.push(pm); + + return array; + } + + /** + * maps premultiply flag and blendMode to adjusted blendMode + * @memberof PIXI.utils + * @const premultiplyBlendMode + * @type {Array} + */ + var premultiplyBlendMode = mapPremultipliedBlendModes(); + + /** + * changes blendMode according to texture format + * + * @memberof PIXI.utils + * @function correctBlendMode + * @param {number} blendMode supposed blend mode + * @param {boolean} premultiplied whether source is premultiplied + * @returns {number} true blend mode for this texture + */ + function correctBlendMode(blendMode, premultiplied) + { + return premultiplyBlendMode[premultiplied ? 1 : 0][blendMode]; + } + + /** + * combines rgb and alpha to out array + * + * @memberof PIXI.utils + * @function premultiplyRgba + * @param {Float32Array|number[]} rgb input rgb + * @param {number} alpha alpha param + * @param {Float32Array} [out] output + * @param {boolean} [premultiply=true] do premultiply it + * @returns {Float32Array} vec4 rgba + */ + function premultiplyRgba(rgb, alpha, out, premultiply) + { + out = out || new Float32Array(4); + if (premultiply || premultiply === undefined) + { + out[0] = rgb[0] * alpha; + out[1] = rgb[1] * alpha; + out[2] = rgb[2] * alpha; + } + else + { + out[0] = rgb[0]; + out[1] = rgb[1]; + out[2] = rgb[2]; + } + out[3] = alpha; + + return out; + } + + /** + * premultiplies tint + * + * @memberof PIXI.utils + * @function premultiplyTint + * @param {number} tint integer RGB + * @param {number} alpha floating point alpha (0.0-1.0) + * @returns {number} tint multiplied by alpha + */ + function premultiplyTint(tint, alpha) + { + if (alpha === 1.0) + { + return (alpha * 255 << 24) + tint; + } + if (alpha === 0.0) + { + return 0; + } + var R = ((tint >> 16) & 0xFF); + var G = ((tint >> 8) & 0xFF); + var B = (tint & 0xFF); + + R = ((R * alpha) + 0.5) | 0; + G = ((G * alpha) + 0.5) | 0; + B = ((B * alpha) + 0.5) | 0; + + return (alpha * 255 << 24) + (R << 16) + (G << 8) + B; + } + + /** + * converts integer tint and float alpha to vec4 form, premultiplies by default + * + * @memberof PIXI.utils + * @function premultiplyTintToRgba + * @param {number} tint input tint + * @param {number} alpha alpha param + * @param {Float32Array} [out] output + * @param {boolean} [premultiply=true] do premultiply it + * @returns {Float32Array} vec4 rgba + */ + function premultiplyTintToRgba(tint, alpha, out, premultiply) + { + out = out || new Float32Array(4); + out[0] = ((tint >> 16) & 0xFF) / 255.0; + out[1] = ((tint >> 8) & 0xFF) / 255.0; + out[2] = (tint & 0xFF) / 255.0; + if (premultiply || premultiply === undefined) + { + out[0] *= alpha; + out[1] *= alpha; + out[2] *= alpha; + } + out[3] = alpha; + + return out; + } + + /** + * Generic Mask Stack data structure + * + * @memberof PIXI + * @function createIndicesForQuads + * @private + * @param {number} size - Number of quads + * @return {Uint16Array} indices + */ + function createIndicesForQuads(size) + { + // the total number of indices in our array, there are 6 points per quad. + + var totalIndices = size * 6; + + var indices = new Uint16Array(totalIndices); + + // fill the indices with the quads to draw + for (var i = 0, j = 0; i < totalIndices; i += 6, j += 4) + { + indices[i + 0] = j + 0; + indices[i + 1] = j + 1; + indices[i + 2] = j + 2; + indices[i + 3] = j + 0; + indices[i + 4] = j + 2; + indices[i + 5] = j + 3; + } + + return indices; + } + + /** + * Remove items from a javascript array without generating garbage + * + * @function removeItems + * @memberof PIXI.utils + * @param {Array} arr Array to remove elements from + * @param {number} startIdx starting index + * @param {number} removeCount how many to remove + */ + function removeItems(arr, startIdx, removeCount) + { + var length = arr.length; + var i; + + if (startIdx >= length || removeCount === 0) + { + return; + } + + removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount); + + var len = length - removeCount; + + for (i = startIdx; i < len; ++i) + { + arr[i] = arr[i + removeCount]; + } + + arr.length = len; + } + + var nextUid = 0; + + /** + * Gets the next unique identifier + * + * @memberof PIXI.utils + * @function uid + * @return {number} The next unique identifier to use. + */ + function uid() + { + return ++nextUid; + } + + /** + * Returns sign of number + * + * @memberof PIXI.utils + * @function sign + * @param {number} n - the number to check the sign of + * @returns {number} 0 if `n` is 0, -1 if `n` is negative, 1 if `n` is positive + */ + function sign(n) + { + if (n === 0) { return 0; } + + return n < 0 ? -1 : 1; + } + + // Taken from the bit-twiddle package + + /** + * Rounds to next power of two. + * + * @function isPow2 + * @memberof PIXI.utils + * @param {number} v input value + * @return {number} + */ + function nextPow2(v) + { + v += v === 0; + --v; + v |= v >>> 1; + v |= v >>> 2; + v |= v >>> 4; + v |= v >>> 8; + v |= v >>> 16; + + return v + 1; + } + + /** + * Checks if a number is a power of two. + * + * @function isPow2 + * @memberof PIXI.utils + * @param {number} v input value + * @return {boolean} `true` if value is power of two + */ + function isPow2(v) + { + return !(v & (v - 1)) && (!!v); + } + + /** + * Computes ceil of log base 2 + * + * @function log2 + * @memberof PIXI.utils + * @param {number} v input value + * @return {number} logarithm base 2 + */ + function log2(v) + { + var r = (v > 0xFFFF) << 4; + + v >>>= r; + + var shift = (v > 0xFF) << 3; + + v >>>= shift; r |= shift; + shift = (v > 0xF) << 2; + v >>>= shift; r |= shift; + shift = (v > 0x3) << 1; + v >>>= shift; r |= shift; + + return r | (v >> 1); + } + + /** + * @todo Describe property usage + * + * @static + * @name ProgramCache + * @memberof PIXI.utils + * @type {Object} + */ + var ProgramCache = {}; + + /** + * @todo Describe property usage + * + * @static + * @name TextureCache + * @memberof PIXI.utils + * @type {Object} + */ + var TextureCache = Object.create(null); + + /** + * @todo Describe property usage + * + * @static + * @name BaseTextureCache + * @memberof PIXI.utils + * @type {Object} + */ + + var BaseTextureCache = Object.create(null); + /** + * Destroys all texture in the cache + * + * @memberof PIXI.utils + * @function destroyTextureCache + */ + function destroyTextureCache() + { + var key; + + for (key in TextureCache) + { + TextureCache[key].destroy(); + } + for (key in BaseTextureCache) + { + BaseTextureCache[key].destroy(); + } + } + + /** + * Removes all textures from cache, but does not destroy them + * + * @memberof PIXI.utils + * @function clearTextureCache + */ + function clearTextureCache() + { + var key; + + for (key in TextureCache) + { + delete TextureCache[key]; + } + for (key in BaseTextureCache) + { + delete BaseTextureCache[key]; + } + } + + /** + * Trim transparent borders from a canvas + * + * @memberof PIXI.utils + * @function trimCanvas + * @param {HTMLCanvasElement} canvas - the canvas to trim + * @returns {object} Trim data + */ + function trimCanvas(canvas) + { + // https://gist.github.com/remy/784508 + + var width = canvas.width; + var height = canvas.height; + + var context = canvas.getContext('2d'); + var imageData = context.getImageData(0, 0, width, height); + var pixels = imageData.data; + var len = pixels.length; + + var bound = { + top: null, + left: null, + right: null, + bottom: null, + }; + var data = null; + var i; + var x; + var y; + + for (i = 0; i < len; i += 4) + { + if (pixels[i + 3] !== 0) + { + x = (i / 4) % width; + y = ~~((i / 4) / width); + + if (bound.top === null) + { + bound.top = y; + } + + if (bound.left === null) + { + bound.left = x; + } + else if (x < bound.left) + { + bound.left = x; + } + + if (bound.right === null) + { + bound.right = x + 1; + } + else if (bound.right < x) + { + bound.right = x + 1; + } + + if (bound.bottom === null) + { + bound.bottom = y; + } + else if (bound.bottom < y) + { + bound.bottom = y; + } + } + } + + if (bound.top !== null) + { + width = bound.right - bound.left; + height = bound.bottom - bound.top + 1; + data = context.getImageData(bound.left, bound.top, width, height); + } + + return { + height: height, + width: width, + data: data, + }; + } + + /** + * Creates a Canvas element of the given size to be used as a target for rendering to. + * + * @class + * @memberof PIXI.utils + */ + var CanvasRenderTarget = function CanvasRenderTarget(width, height, resolution) + { + /** + * The Canvas object that belongs to this CanvasRenderTarget. + * + * @member {HTMLCanvasElement} + */ + this.canvas = document.createElement('canvas'); + + /** + * A CanvasRenderingContext2D object representing a two-dimensional rendering context. + * + * @member {CanvasRenderingContext2D} + */ + this.context = this.canvas.getContext('2d'); + + this.resolution = resolution || settings.RESOLUTION; + + this.resize(width, height); + }; + + var prototypeAccessors = { width: { configurable: true },height: { configurable: true } }; + + /** + * Clears the canvas that was created by the CanvasRenderTarget class. + * + * @private + */ + CanvasRenderTarget.prototype.clear = function clear () + { + this.context.setTransform(1, 0, 0, 1, 0, 0); + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + }; + + /** + * Resizes the canvas to the specified width and height. + * + * @param {number} width - the new width of the canvas + * @param {number} height - the new height of the canvas + */ + CanvasRenderTarget.prototype.resize = function resize (width, height) + { + this.canvas.width = width * this.resolution; + this.canvas.height = height * this.resolution; + }; + + /** + * Destroys this canvas. + * + */ + CanvasRenderTarget.prototype.destroy = function destroy () + { + this.context = null; + this.canvas = null; + }; + + /** + * The width of the canvas buffer in pixels. + * + * @member {number} + */ + prototypeAccessors.width.get = function () + { + return this.canvas.width; + }; + + prototypeAccessors.width.set = function (val) // eslint-disable-line require-jsdoc + { + this.canvas.width = val; + }; + + /** + * The height of the canvas buffer in pixels. + * + * @member {number} + */ + prototypeAccessors.height.get = function () + { + return this.canvas.height; + }; + + prototypeAccessors.height.set = function (val) // eslint-disable-line require-jsdoc + { + this.canvas.height = val; + }; + + Object.defineProperties( CanvasRenderTarget.prototype, prototypeAccessors ); + + /** + * Regexp for data URI. + * Based on: {@link https://github.com/ragingwind/data-uri-regex} + * + * @static + * @constant {RegExp|string} DATA_URI + * @memberof PIXI + * @example data:image/png;base64 + */ + var DATA_URI = /^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i; + + /** + * Typedef for decomposeDataUri return object. + * + * @memberof PIXI.utils + * @typedef {object} DecomposedDataUri + * @property {string} mediaType Media type, eg. `image` + * @property {string} subType Sub type, eg. `png` + * @property {string} encoding Data encoding, eg. `base64` + * @property {string} data The actual data + */ + + /** + * Split a data URI into components. Returns undefined if + * parameter `dataUri` is not a valid data URI. + * + * @memberof PIXI.utils + * @function decomposeDataUri + * @param {string} dataUri - the data URI to check + * @return {PIXI.utils.DecomposedDataUri|undefined} The decomposed data uri or undefined + */ + function decomposeDataUri(dataUri) + { + var dataUriMatch = DATA_URI.exec(dataUri); + + if (dataUriMatch) + { + return { + mediaType: dataUriMatch[1] ? dataUriMatch[1].toLowerCase() : undefined, + subType: dataUriMatch[2] ? dataUriMatch[2].toLowerCase() : undefined, + charset: dataUriMatch[3] ? dataUriMatch[3].toLowerCase() : undefined, + encoding: dataUriMatch[4] ? dataUriMatch[4].toLowerCase() : undefined, + data: dataUriMatch[5], + }; + } + + return undefined; + } + + var tempAnchor; + + /** + * Sets the `crossOrigin` property for this resource based on if the url + * for this resource is cross-origin. If crossOrigin was manually set, this + * function does nothing. + * Nipped from the resource loader! + * + * @ignore + * @param {string} url - The url to test. + * @param {object} [loc=window.location] - The location object to test against. + * @return {string} The crossOrigin value to use (or empty string for none). + */ + function determineCrossOrigin(url$1, loc) + { + if ( loc === void 0 ) { loc = window.location; } + + // data: and javascript: urls are considered same-origin + if (url$1.indexOf('data:') === 0) + { + return ''; + } + + // default is window.location + loc = loc || window.location; + + if (!tempAnchor) + { + tempAnchor = document.createElement('a'); + } + + // let the browser determine the full href for the url of this resource and then + // parse with the node url lib, we can't use the properties of the anchor element + // because they don't work in IE9 :( + tempAnchor.href = url$1; + url$1 = url.parse(tempAnchor.href); + + var samePort = (!url$1.port && loc.port === '') || (url$1.port === loc.port); + + // if cross origin + if (url$1.hostname !== loc.hostname || !samePort || url$1.protocol !== loc.protocol) + { + return 'anonymous'; + } + + return ''; + } + + /** + * get the resolution / device pixel ratio of an asset by looking for the prefix + * used by spritesheets and image urls + * + * @memberof PIXI.utils + * @function getResolutionOfUrl + * @param {string} url - the image path + * @param {number} [defaultValue=1] - the defaultValue if no filename prefix is set. + * @return {number} resolution / device pixel ratio of an asset + */ + function getResolutionOfUrl(url, defaultValue) + { + var resolution = settings.RETINA_PREFIX.exec(url); + + if (resolution) + { + return parseFloat(resolution[1]); + } + + return defaultValue !== undefined ? defaultValue : 1; + } + + // A map of warning messages already fired + var warnings = {}; + + /** + * Helper for warning developers about deprecated features & settings. + * A stack track for warnings is given; useful for tracking-down where + * deprecated methods/properties/classes are being used within the code. + * + * @memberof PIXI.utils + * @function deprecation + * @param {string} version - The version where the feature became deprecated + * @param {string} message - Message should include what is deprecated, where, and the new solution + * @param {number} [ignoreDepth=3] - The number of steps to ignore at the top of the error stack + * this is mostly to ignore internal deprecation calls. + */ + function deprecation(version, message, ignoreDepth) + { + if ( ignoreDepth === void 0 ) { ignoreDepth = 3; } + + // Ignore duplicat + if (warnings[message]) + { + return; + } + + /* eslint-disable no-console */ + var stack = new Error().stack; + + // Handle IE < 10 and Safari < 6 + if (typeof stack === 'undefined') + { + console.warn('PixiJS Deprecation Warning: ', (message + "\nDeprecated since v" + version)); + } + else + { + // chop off the stack trace which includes PixiJS internal calls + stack = stack.split('\n').splice(ignoreDepth).join('\n'); + + if (console.groupCollapsed) + { + console.groupCollapsed( + '%cPixiJS Deprecation Warning: %c%s', + 'color:#614108;background:#fffbe6', + 'font-weight:normal;color:#614108;background:#fffbe6', + (message + "\nDeprecated since v" + version) + ); + console.warn(stack); + console.groupEnd(); + } + else + { + console.warn('PixiJS Deprecation Warning: ', (message + "\nDeprecated since v" + version)); + console.warn(stack); + } + } + /* eslint-enable no-console */ + + warnings[message] = true; + } + + var utils_es = ({ + BaseTextureCache: BaseTextureCache, + CanvasRenderTarget: CanvasRenderTarget, + DATA_URI: DATA_URI, + ProgramCache: ProgramCache, + TextureCache: TextureCache, + clearTextureCache: clearTextureCache, + correctBlendMode: correctBlendMode, + createIndicesForQuads: createIndicesForQuads, + decomposeDataUri: decomposeDataUri, + deprecation: deprecation, + destroyTextureCache: destroyTextureCache, + determineCrossOrigin: determineCrossOrigin, + getResolutionOfUrl: getResolutionOfUrl, + hex2rgb: hex2rgb, + hex2string: hex2string, + isPow2: isPow2, + isWebGLSupported: isWebGLSupported, + log2: log2, + nextPow2: nextPow2, + premultiplyBlendMode: premultiplyBlendMode, + premultiplyRgba: premultiplyRgba, + premultiplyTint: premultiplyTint, + premultiplyTintToRgba: premultiplyTintToRgba, + removeItems: removeItems, + rgb2hex: rgb2hex, + sayHello: sayHello, + sign: sign, + skipHello: skipHello, + string2hex: string2hex, + trimCanvas: trimCanvas, + uid: uid, + isMobile: isMobile_min, + EventEmitter: eventemitter3, + earcut: earcut_1, + url: url + }); + + /*! + * @pixi/math - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/math is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + /** + * The Point object represents a location in a two-dimensional coordinate system, where x represents + * the horizontal axis and y represents the vertical axis. + * + * @class + * @memberof PIXI + */ + var Point = function Point(x, y) + { + if ( x === void 0 ) { x = 0; } + if ( y === void 0 ) { y = 0; } + + /** + * @member {number} + * @default 0 + */ + this.x = x; + + /** + * @member {number} + * @default 0 + */ + this.y = y; + }; + + /** + * Creates a clone of this point + * + * @return {PIXI.Point} a copy of the point + */ + Point.prototype.clone = function clone () + { + return new Point(this.x, this.y); + }; + + /** + * Copies x and y from the given point + * + * @param {PIXI.IPoint} p - The point to copy from + * @returns {PIXI.IPoint} Returns itself. + */ + Point.prototype.copyFrom = function copyFrom (p) + { + this.set(p.x, p.y); + + return this; + }; + + /** + * Copies x and y into the given point + * + * @param {PIXI.IPoint} p - The point to copy. + * @returns {PIXI.IPoint} Given point with values updated + */ + Point.prototype.copyTo = function copyTo (p) + { + p.set(this.x, this.y); + + return p; + }; + + /** + * Returns true if the given point is equal to this point + * + * @param {PIXI.IPoint} p - The point to check + * @returns {boolean} Whether the given point equal to this point + */ + Point.prototype.equals = function equals (p) + { + return (p.x === this.x) && (p.y === this.y); + }; + + /** + * Sets the point to a new x and y position. + * If y is omitted, both x and y will be set to x. + * + * @param {number} [x=0] - position of the point on the x axis + * @param {number} [y=0] - position of the point on the y axis + */ + Point.prototype.set = function set (x, y) + { + this.x = x || 0; + this.y = y || ((y !== 0) ? this.x : 0); + }; + + /** + * The Point object represents a location in a two-dimensional coordinate system, where x represents + * the horizontal axis and y represents the vertical axis. + * + * An ObservablePoint is a point that triggers a callback when the point's position is changed. + * + * @class + * @memberof PIXI + */ + var ObservablePoint = function ObservablePoint(cb, scope, x, y) + { + if ( x === void 0 ) { x = 0; } + if ( y === void 0 ) { y = 0; } + + this._x = x; + this._y = y; + + this.cb = cb; + this.scope = scope; + }; + + var prototypeAccessors$1 = { x: { configurable: true },y: { configurable: true } }; + + /** + * Creates a clone of this point. + * The callback and scope params can be overidden otherwise they will default + * to the clone object's values. + * + * @override + * @param {Function} [cb=null] - callback when changed + * @param {object} [scope=null] - owner of callback + * @return {PIXI.ObservablePoint} a copy of the point + */ + ObservablePoint.prototype.clone = function clone (cb, scope) + { + if ( cb === void 0 ) { cb = null; } + if ( scope === void 0 ) { scope = null; } + + var _cb = cb || this.cb; + var _scope = scope || this.scope; + + return new ObservablePoint(_cb, _scope, this._x, this._y); + }; + + /** + * Sets the point to a new x and y position. + * If y is omitted, both x and y will be set to x. + * + * @param {number} [x=0] - position of the point on the x axis + * @param {number} [y=0] - position of the point on the y axis + */ + ObservablePoint.prototype.set = function set (x, y) + { + var _x = x || 0; + var _y = y || ((y !== 0) ? _x : 0); + + if (this._x !== _x || this._y !== _y) + { + this._x = _x; + this._y = _y; + this.cb.call(this.scope); + } + }; + + /** + * Copies x and y from the given point + * + * @param {PIXI.IPoint} p - The point to copy from. + * @returns {PIXI.IPoint} Returns itself. + */ + ObservablePoint.prototype.copyFrom = function copyFrom (p) + { + if (this._x !== p.x || this._y !== p.y) + { + this._x = p.x; + this._y = p.y; + this.cb.call(this.scope); + } + + return this; + }; + + /** + * Copies x and y into the given point + * + * @param {PIXI.IPoint} p - The point to copy. + * @returns {PIXI.IPoint} Given point with values updated + */ + ObservablePoint.prototype.copyTo = function copyTo (p) + { + p.set(this._x, this._y); + + return p; + }; + + /** + * Returns true if the given point is equal to this point + * + * @param {PIXI.IPoint} p - The point to check + * @returns {boolean} Whether the given point equal to this point + */ + ObservablePoint.prototype.equals = function equals (p) + { + return (p.x === this._x) && (p.y === this._y); + }; + + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + */ + prototypeAccessors$1.x.get = function () + { + return this._x; + }; + + prototypeAccessors$1.x.set = function (value) // eslint-disable-line require-jsdoc + { + if (this._x !== value) + { + this._x = value; + this.cb.call(this.scope); + } + }; + + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + */ + prototypeAccessors$1.y.get = function () + { + return this._y; + }; + + prototypeAccessors$1.y.set = function (value) // eslint-disable-line require-jsdoc + { + if (this._y !== value) + { + this._y = value; + this.cb.call(this.scope); + } + }; + + Object.defineProperties( ObservablePoint.prototype, prototypeAccessors$1 ); + + /** + * A number, or a string containing a number. + * @memberof PIXI + * @typedef {(PIXI.Point|PIXI.ObservablePoint)} IPoint + */ + + /** + * Two Pi. + * + * @static + * @constant {number} PI_2 + * @memberof PIXI + */ + var PI_2 = Math.PI * 2; + + /** + * Conversion factor for converting radians to degrees. + * + * @static + * @constant {number} RAD_TO_DEG + * @memberof PIXI + */ + var RAD_TO_DEG = 180 / Math.PI; + + /** + * Conversion factor for converting degrees to radians. + * + * @static + * @constant {number} DEG_TO_RAD + * @memberof PIXI + */ + var DEG_TO_RAD = Math.PI / 180; + + /** + * Constants that identify shapes, mainly to prevent `instanceof` calls. + * + * @static + * @constant + * @name SHAPES + * @memberof PIXI + * @type {object} + * @property {number} POLY Polygon + * @property {number} RECT Rectangle + * @property {number} CIRC Circle + * @property {number} ELIP Ellipse + * @property {number} RREC Rounded Rectangle + */ + var SHAPES = { + POLY: 0, + RECT: 1, + CIRC: 2, + ELIP: 3, + RREC: 4, + }; + + /** + * The PixiJS Matrix as a class makes it a lot faster. + * + * Here is a representation of it: + * ```js + * | a | c | tx| + * | b | d | ty| + * | 0 | 0 | 1 | + * ``` + * @class + * @memberof PIXI + */ + var Matrix = function Matrix(a, b, c, d, tx, ty) + { + if ( a === void 0 ) { a = 1; } + if ( b === void 0 ) { b = 0; } + if ( c === void 0 ) { c = 0; } + if ( d === void 0 ) { d = 1; } + if ( tx === void 0 ) { tx = 0; } + if ( ty === void 0 ) { ty = 0; } + + /** + * @member {number} + * @default 1 + */ + this.a = a; + + /** + * @member {number} + * @default 0 + */ + this.b = b; + + /** + * @member {number} + * @default 0 + */ + this.c = c; + + /** + * @member {number} + * @default 1 + */ + this.d = d; + + /** + * @member {number} + * @default 0 + */ + this.tx = tx; + + /** + * @member {number} + * @default 0 + */ + this.ty = ty; + + this.array = null; + }; + + var staticAccessors = { IDENTITY: { configurable: true },TEMP_MATRIX: { configurable: true } }; + + /** + * Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows: + * + * a = array[0] + * b = array[1] + * c = array[3] + * d = array[4] + * tx = array[2] + * ty = array[5] + * + * @param {number[]} array - The array that the matrix will be populated from. + */ + Matrix.prototype.fromArray = function fromArray (array) + { + this.a = array[0]; + this.b = array[1]; + this.c = array[3]; + this.d = array[4]; + this.tx = array[2]; + this.ty = array[5]; + }; + + /** + * sets the matrix properties + * + * @param {number} a - Matrix component + * @param {number} b - Matrix component + * @param {number} c - Matrix component + * @param {number} d - Matrix component + * @param {number} tx - Matrix component + * @param {number} ty - Matrix component + * + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.set = function set (a, b, c, d, tx, ty) + { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.tx = tx; + this.ty = ty; + + return this; + }; + + /** + * Creates an array from the current Matrix object. + * + * @param {boolean} transpose - Whether we need to transpose the matrix or not + * @param {Float32Array} [out=new Float32Array(9)] - If provided the array will be assigned to out + * @return {number[]} the newly created array which contains the matrix + */ + Matrix.prototype.toArray = function toArray (transpose, out) + { + if (!this.array) + { + this.array = new Float32Array(9); + } + + var array = out || this.array; + + if (transpose) + { + array[0] = this.a; + array[1] = this.b; + array[2] = 0; + array[3] = this.c; + array[4] = this.d; + array[5] = 0; + array[6] = this.tx; + array[7] = this.ty; + array[8] = 1; + } + else + { + array[0] = this.a; + array[1] = this.c; + array[2] = this.tx; + array[3] = this.b; + array[4] = this.d; + array[5] = this.ty; + array[6] = 0; + array[7] = 0; + array[8] = 1; + } + + return array; + }; + + /** + * Get a new position with the current transformation applied. + * Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering) + * + * @param {PIXI.Point} pos - The origin + * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input) + * @return {PIXI.Point} The new point, transformed through this matrix + */ + Matrix.prototype.apply = function apply (pos, newPos) + { + newPos = newPos || new Point(); + + var x = pos.x; + var y = pos.y; + + newPos.x = (this.a * x) + (this.c * y) + this.tx; + newPos.y = (this.b * x) + (this.d * y) + this.ty; + + return newPos; + }; + + /** + * Get a new position with the inverse of the current transformation applied. + * Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input) + * + * @param {PIXI.Point} pos - The origin + * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input) + * @return {PIXI.Point} The new point, inverse-transformed through this matrix + */ + Matrix.prototype.applyInverse = function applyInverse (pos, newPos) + { + newPos = newPos || new Point(); + + var id = 1 / ((this.a * this.d) + (this.c * -this.b)); + + var x = pos.x; + var y = pos.y; + + newPos.x = (this.d * id * x) + (-this.c * id * y) + (((this.ty * this.c) - (this.tx * this.d)) * id); + newPos.y = (this.a * id * y) + (-this.b * id * x) + (((-this.ty * this.a) + (this.tx * this.b)) * id); + + return newPos; + }; + + /** + * Translates the matrix on the x and y. + * + * @param {number} x How much to translate x by + * @param {number} y How much to translate y by + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.translate = function translate (x, y) + { + this.tx += x; + this.ty += y; + + return this; + }; + + /** + * Applies a scale transformation to the matrix. + * + * @param {number} x The amount to scale horizontally + * @param {number} y The amount to scale vertically + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.scale = function scale (x, y) + { + this.a *= x; + this.d *= y; + this.c *= x; + this.b *= y; + this.tx *= x; + this.ty *= y; + + return this; + }; + + /** + * Applies a rotation transformation to the matrix. + * + * @param {number} angle - The angle in radians. + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.rotate = function rotate (angle) + { + var cos = Math.cos(angle); + var sin = Math.sin(angle); + + var a1 = this.a; + var c1 = this.c; + var tx1 = this.tx; + + this.a = (a1 * cos) - (this.b * sin); + this.b = (a1 * sin) + (this.b * cos); + this.c = (c1 * cos) - (this.d * sin); + this.d = (c1 * sin) + (this.d * cos); + this.tx = (tx1 * cos) - (this.ty * sin); + this.ty = (tx1 * sin) + (this.ty * cos); + + return this; + }; + + /** + * Appends the given Matrix to this Matrix. + * + * @param {PIXI.Matrix} matrix - The matrix to append. + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.append = function append (matrix) + { + var a1 = this.a; + var b1 = this.b; + var c1 = this.c; + var d1 = this.d; + + this.a = (matrix.a * a1) + (matrix.b * c1); + this.b = (matrix.a * b1) + (matrix.b * d1); + this.c = (matrix.c * a1) + (matrix.d * c1); + this.d = (matrix.c * b1) + (matrix.d * d1); + + this.tx = (matrix.tx * a1) + (matrix.ty * c1) + this.tx; + this.ty = (matrix.tx * b1) + (matrix.ty * d1) + this.ty; + + return this; + }; + + /** + * Sets the matrix based on all the available properties + * + * @param {number} x - Position on the x axis + * @param {number} y - Position on the y axis + * @param {number} pivotX - Pivot on the x axis + * @param {number} pivotY - Pivot on the y axis + * @param {number} scaleX - Scale on the x axis + * @param {number} scaleY - Scale on the y axis + * @param {number} rotation - Rotation in radians + * @param {number} skewX - Skew on the x axis + * @param {number} skewY - Skew on the y axis + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.setTransform = function setTransform (x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) + { + this.a = Math.cos(rotation + skewY) * scaleX; + this.b = Math.sin(rotation + skewY) * scaleX; + this.c = -Math.sin(rotation - skewX) * scaleY; + this.d = Math.cos(rotation - skewX) * scaleY; + + this.tx = x - ((pivotX * this.a) + (pivotY * this.c)); + this.ty = y - ((pivotX * this.b) + (pivotY * this.d)); + + return this; + }; + + /** + * Prepends the given Matrix to this Matrix. + * + * @param {PIXI.Matrix} matrix - The matrix to prepend + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.prepend = function prepend (matrix) + { + var tx1 = this.tx; + + if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) + { + var a1 = this.a; + var c1 = this.c; + + this.a = (a1 * matrix.a) + (this.b * matrix.c); + this.b = (a1 * matrix.b) + (this.b * matrix.d); + this.c = (c1 * matrix.a) + (this.d * matrix.c); + this.d = (c1 * matrix.b) + (this.d * matrix.d); + } + + this.tx = (tx1 * matrix.a) + (this.ty * matrix.c) + matrix.tx; + this.ty = (tx1 * matrix.b) + (this.ty * matrix.d) + matrix.ty; + + return this; + }; + + /** + * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform. + * + * @param {PIXI.Transform} transform - The transform to apply the properties to. + * @return {PIXI.Transform} The transform with the newly applied properties + */ + Matrix.prototype.decompose = function decompose (transform) + { + // sort out rotation / skew.. + var a = this.a; + var b = this.b; + var c = this.c; + var d = this.d; + + var skewX = -Math.atan2(-c, d); + var skewY = Math.atan2(b, a); + + var delta = Math.abs(skewX + skewY); + + if (delta < 0.00001 || Math.abs(PI_2 - delta) < 0.00001) + { + transform.rotation = skewY; + transform.skew.x = transform.skew.y = 0; + } + else + { + transform.rotation = 0; + transform.skew.x = skewX; + transform.skew.y = skewY; + } + + // next set scale + transform.scale.x = Math.sqrt((a * a) + (b * b)); + transform.scale.y = Math.sqrt((c * c) + (d * d)); + + // next set position + transform.position.x = this.tx; + transform.position.y = this.ty; + + return transform; + }; + + /** + * Inverts this matrix + * + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.invert = function invert () + { + var a1 = this.a; + var b1 = this.b; + var c1 = this.c; + var d1 = this.d; + var tx1 = this.tx; + var n = (a1 * d1) - (b1 * c1); + + this.a = d1 / n; + this.b = -b1 / n; + this.c = -c1 / n; + this.d = a1 / n; + this.tx = ((c1 * this.ty) - (d1 * tx1)) / n; + this.ty = -((a1 * this.ty) - (b1 * tx1)) / n; + + return this; + }; + + /** + * Resets this Matrix to an identity (default) matrix. + * + * @return {PIXI.Matrix} This matrix. Good for chaining method calls. + */ + Matrix.prototype.identity = function identity () + { + this.a = 1; + this.b = 0; + this.c = 0; + this.d = 1; + this.tx = 0; + this.ty = 0; + + return this; + }; + + /** + * Creates a new Matrix object with the same values as this one. + * + * @return {PIXI.Matrix} A copy of this matrix. Good for chaining method calls. + */ + Matrix.prototype.clone = function clone () + { + var matrix = new Matrix(); + + matrix.a = this.a; + matrix.b = this.b; + matrix.c = this.c; + matrix.d = this.d; + matrix.tx = this.tx; + matrix.ty = this.ty; + + return matrix; + }; + + /** + * Changes the values of the given matrix to be the same as the ones in this matrix + * + * @param {PIXI.Matrix} matrix - The matrix to copy to. + * @return {PIXI.Matrix} The matrix given in parameter with its values updated. + */ + Matrix.prototype.copyTo = function copyTo (matrix) + { + matrix.a = this.a; + matrix.b = this.b; + matrix.c = this.c; + matrix.d = this.d; + matrix.tx = this.tx; + matrix.ty = this.ty; + + return matrix; + }; + + /** + * Changes the values of the matrix to be the same as the ones in given matrix + * + * @param {PIXI.Matrix} matrix - The matrix to copy from. + * @return {PIXI.Matrix} this + */ + Matrix.prototype.copyFrom = function copyFrom (matrix) + { + this.a = matrix.a; + this.b = matrix.b; + this.c = matrix.c; + this.d = matrix.d; + this.tx = matrix.tx; + this.ty = matrix.ty; + + return this; + }; + + /** + * A default (identity) matrix + * + * @static + * @const + * @member {PIXI.Matrix} + */ + staticAccessors.IDENTITY.get = function () + { + return new Matrix(); + }; + + /** + * A temp matrix + * + * @static + * @const + * @member {PIXI.Matrix} + */ + staticAccessors.TEMP_MATRIX.get = function () + { + return new Matrix(); + }; + + Object.defineProperties( Matrix, staticAccessors ); + + // Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16 + + var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; + var uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1]; + var vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1]; + var vy = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1]; + var tempMatrices = []; + + var mul = []; + + function signum(x) + { + if (x < 0) + { + return -1; + } + if (x > 0) + { + return 1; + } + + return 0; + } + + function init() + { + for (var i = 0; i < 16; i++) + { + var row = []; + + mul.push(row); + + for (var j = 0; j < 16; j++) + { + var _ux = signum((ux[i] * ux[j]) + (vx[i] * uy[j])); + var _uy = signum((uy[i] * ux[j]) + (vy[i] * uy[j])); + var _vx = signum((ux[i] * vx[j]) + (vx[i] * vy[j])); + var _vy = signum((uy[i] * vx[j]) + (vy[i] * vy[j])); + + for (var k = 0; k < 16; k++) + { + if (ux[k] === _ux && uy[k] === _uy && vx[k] === _vx && vy[k] === _vy) + { + row.push(k); + break; + } + } + } + } + + for (var i$1 = 0; i$1 < 16; i$1++) + { + var mat = new Matrix(); + + mat.set(ux[i$1], uy[i$1], vx[i$1], vy[i$1], 0, 0); + tempMatrices.push(mat); + } + } + + init(); + + /** + * Implements Dihedral Group D_8, see [group D4]{@link http://mathworld.wolfram.com/DihedralGroupD4.html}, + * D8 is the same but with diagonals. Used for texture rotations. + * + * Vector xX(i), xY(i) is U-axis of sprite with rotation i + * Vector yY(i), yY(i) is V-axis of sprite with rotation i + * Rotations: 0 grad (0), 90 grad (2), 180 grad (4), 270 grad (6) + * Mirrors: vertical (8), main diagonal (10), horizontal (12), reverse diagonal (14) + * This is the small part of gameofbombs.com portal system. It works. + * + * @author Ivan @ivanpopelyshev + * @class + * @memberof PIXI + */ + var GroupD8 = { + E: 0, + SE: 1, + S: 2, + SW: 3, + W: 4, + NW: 5, + N: 6, + NE: 7, + MIRROR_VERTICAL: 8, + MIRROR_HORIZONTAL: 12, + uX: function (ind) { return ux[ind]; }, + uY: function (ind) { return uy[ind]; }, + vX: function (ind) { return vx[ind]; }, + vY: function (ind) { return vy[ind]; }, + inv: function (rotation) { + if (rotation & 8) + { + return rotation & 15; + } + + return (-rotation) & 7; + }, + add: function (rotationSecond, rotationFirst) { return mul[rotationSecond][rotationFirst]; }, + sub: function (rotationSecond, rotationFirst) { return mul[rotationSecond][GroupD8.inv(rotationFirst)]; }, + + /** + * Adds 180 degrees to rotation. Commutative operation. + * + * @memberof PIXI.GroupD8 + * @param {number} rotation - The number to rotate. + * @returns {number} rotated number + */ + rotate180: function (rotation) { return rotation ^ 4; }, + + /** + * Direction of main vector can be horizontal, vertical or diagonal. + * Some objects work with vertical directions different. + * + * @memberof PIXI.GroupD8 + * @param {number} rotation - The number to check. + * @returns {boolean} Whether or not the direction is vertical + */ + isVertical: function (rotation) { return (rotation & 3) === 2; }, + + /** + * @memberof PIXI.GroupD8 + * @param {number} dx - TODO + * @param {number} dy - TODO + * + * @return {number} TODO + */ + byDirection: function (dx, dy) { + if (Math.abs(dx) * 2 <= Math.abs(dy)) + { + if (dy >= 0) + { + return GroupD8.S; + } + + return GroupD8.N; + } + else if (Math.abs(dy) * 2 <= Math.abs(dx)) + { + if (dx > 0) + { + return GroupD8.E; + } + + return GroupD8.W; + } + else if (dy > 0) + { + if (dx > 0) + { + return GroupD8.SE; + } + + return GroupD8.SW; + } + else if (dx > 0) + { + return GroupD8.NE; + } + + return GroupD8.NW; + }, + + /** + * Helps sprite to compensate texture packer rotation. + * + * @memberof PIXI.GroupD8 + * @param {PIXI.Matrix} matrix - sprite world matrix + * @param {number} rotation - The rotation factor to use. + * @param {number} tx - sprite anchoring + * @param {number} ty - sprite anchoring + */ + matrixAppendRotationInv: function (matrix, rotation, tx, ty) { + if ( tx === void 0 ) { tx = 0; } + if ( ty === void 0 ) { ty = 0; } + + // Packer used "rotation", we use "inv(rotation)" + var mat = tempMatrices[GroupD8.inv(rotation)]; + + mat.tx = tx; + mat.ty = ty; + matrix.append(mat); + }, + }; + + /** + * Transform that takes care about its versions + * + * @class + * @memberof PIXI + */ + var Transform = function Transform() + { + /** + * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds() + * + * @member {PIXI.Matrix} + */ + this.worldTransform = new Matrix(); + + /** + * The local matrix transform + * + * @member {PIXI.Matrix} + */ + this.localTransform = new Matrix(); + + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this.onChange, this, 0, 0); + + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this.onChange, this, 1, 1); + + /** + * The pivot point of the displayObject that it rotates around. + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this.onChange, this, 0, 0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this.updateSkew, this, 0, 0); + + this._rotation = 0; + + this._cx = 1; // cos rotation + skewY; + this._sx = 0; // sin rotation + skewY; + this._cy = 0; // cos rotation + Math.PI/2 - skewX; + this._sy = 1; // sin rotation + Math.PI/2 - skewX; + + this._localID = 0; + this._currentLocalID = 0; + + this._worldID = 0; + this._parentID = 0; + }; + + var prototypeAccessors$1$1 = { rotation: { configurable: true } }; + + /** + * Called when a value changes. + * + * @private + */ + Transform.prototype.onChange = function onChange () + { + this._localID++; + }; + + /** + * Called when skew or rotation changes + * + * @private + */ + Transform.prototype.updateSkew = function updateSkew () + { + this._cx = Math.cos(this._rotation + this.skew._y); + this._sx = Math.sin(this._rotation + this.skew._y); + this._cy = -Math.sin(this._rotation - this.skew._x); // cos, added PI/2 + this._sy = Math.cos(this._rotation - this.skew._x); // sin, added PI/2 + + this._localID++; + }; + + /** + * Updates only local matrix + */ + Transform.prototype.updateLocalTransform = function updateLocalTransform () + { + var lt = this.localTransform; + + if (this._localID !== this._currentLocalID) + { + // get the matrix values of the displayobject based on its transform properties.. + lt.a = this._cx * this.scale._x; + lt.b = this._sx * this.scale._x; + lt.c = this._cy * this.scale._y; + lt.d = this._sy * this.scale._y; + + lt.tx = this.position._x - ((this.pivot._x * lt.a) + (this.pivot._y * lt.c)); + lt.ty = this.position._y - ((this.pivot._x * lt.b) + (this.pivot._y * lt.d)); + this._currentLocalID = this._localID; + + // force an update.. + this._parentID = -1; + } + }; + + /** + * Updates the values of the object and applies the parent's transform. + * + * @param {PIXI.Transform} parentTransform - The transform of the parent of this object + */ + Transform.prototype.updateTransform = function updateTransform (parentTransform) + { + var lt = this.localTransform; + + if (this._localID !== this._currentLocalID) + { + // get the matrix values of the displayobject based on its transform properties.. + lt.a = this._cx * this.scale._x; + lt.b = this._sx * this.scale._x; + lt.c = this._cy * this.scale._y; + lt.d = this._sy * this.scale._y; + + lt.tx = this.position._x - ((this.pivot._x * lt.a) + (this.pivot._y * lt.c)); + lt.ty = this.position._y - ((this.pivot._x * lt.b) + (this.pivot._y * lt.d)); + this._currentLocalID = this._localID; + + // force an update.. + this._parentID = -1; + } + + if (this._parentID !== parentTransform._worldID) + { + // concat the parent matrix with the objects transform. + var pt = parentTransform.worldTransform; + var wt = this.worldTransform; + + wt.a = (lt.a * pt.a) + (lt.b * pt.c); + wt.b = (lt.a * pt.b) + (lt.b * pt.d); + wt.c = (lt.c * pt.a) + (lt.d * pt.c); + wt.d = (lt.c * pt.b) + (lt.d * pt.d); + wt.tx = (lt.tx * pt.a) + (lt.ty * pt.c) + pt.tx; + wt.ty = (lt.tx * pt.b) + (lt.ty * pt.d) + pt.ty; + + this._parentID = parentTransform._worldID; + + // update the id of the transform.. + this._worldID++; + } + }; + + /** + * Decomposes a matrix and sets the transforms properties based on it. + * + * @param {PIXI.Matrix} matrix - The matrix to decompose + */ + Transform.prototype.setFromMatrix = function setFromMatrix (matrix) + { + matrix.decompose(this); + this._localID++; + }; + + /** + * The rotation of the object in radians. + * + * @member {number} + */ + prototypeAccessors$1$1.rotation.get = function () + { + return this._rotation; + }; + + prototypeAccessors$1$1.rotation.set = function (value) // eslint-disable-line require-jsdoc + { + if (this._rotation !== value) + { + this._rotation = value; + this.updateSkew(); + } + }; + + Object.defineProperties( Transform.prototype, prototypeAccessors$1$1 ); + + Transform.IDENTITY = new Transform(); + + /** + * Rectangle object is an area defined by its position, as indicated by its top-left corner + * point (x, y) and by its width and its height. + * + * @class + * @memberof PIXI + */ + var Rectangle = function Rectangle(x, y, width, height) + { + if ( x === void 0 ) { x = 0; } + if ( y === void 0 ) { y = 0; } + if ( width === void 0 ) { width = 0; } + if ( height === void 0 ) { height = 0; } + + /** + * @member {number} + * @default 0 + */ + this.x = Number(x); + + /** + * @member {number} + * @default 0 + */ + this.y = Number(y); + + /** + * @member {number} + * @default 0 + */ + this.width = Number(width); + + /** + * @member {number} + * @default 0 + */ + this.height = Number(height); + + /** + * The type of the object, mainly used to avoid `instanceof` checks + * + * @member {number} + * @readOnly + * @default PIXI.SHAPES.RECT + * @see PIXI.SHAPES + */ + this.type = SHAPES.RECT; + }; + + var prototypeAccessors$2 = { left: { configurable: true },right: { configurable: true },top: { configurable: true },bottom: { configurable: true } }; + var staticAccessors$1 = { EMPTY: { configurable: true } }; + + /** + * returns the left edge of the rectangle + * + * @member {number} + */ + prototypeAccessors$2.left.get = function () + { + return this.x; + }; + + /** + * returns the right edge of the rectangle + * + * @member {number} + */ + prototypeAccessors$2.right.get = function () + { + return this.x + this.width; + }; + + /** + * returns the top edge of the rectangle + * + * @member {number} + */ + prototypeAccessors$2.top.get = function () + { + return this.y; + }; + + /** + * returns the bottom edge of the rectangle + * + * @member {number} + */ + prototypeAccessors$2.bottom.get = function () + { + return this.y + this.height; + }; + + /** + * A constant empty rectangle. + * + * @static + * @constant + * @member {PIXI.Rectangle} + */ + staticAccessors$1.EMPTY.get = function () + { + return new Rectangle(0, 0, 0, 0); + }; + + /** + * Creates a clone of this Rectangle + * + * @return {PIXI.Rectangle} a copy of the rectangle + */ + Rectangle.prototype.clone = function clone () + { + return new Rectangle(this.x, this.y, this.width, this.height); + }; + + /** + * Copies another rectangle to this one. + * + * @param {PIXI.Rectangle} rectangle - The rectangle to copy from. + * @return {PIXI.Rectangle} Returns itself. + */ + Rectangle.prototype.copyFrom = function copyFrom (rectangle) + { + this.x = rectangle.x; + this.y = rectangle.y; + this.width = rectangle.width; + this.height = rectangle.height; + + return this; + }; + + /** + * Copies this rectangle to another one. + * + * @param {PIXI.Rectangle} rectangle - The rectangle to copy to. + * @return {PIXI.Rectangle} Returns given parameter. + */ + Rectangle.prototype.copyTo = function copyTo (rectangle) + { + rectangle.x = this.x; + rectangle.y = this.y; + rectangle.width = this.width; + rectangle.height = this.height; + + return rectangle; + }; + + /** + * Checks whether the x and y coordinates given are contained within this Rectangle + * + * @param {number} x - The X coordinate of the point to test + * @param {number} y - The Y coordinate of the point to test + * @return {boolean} Whether the x/y coordinates are within this Rectangle + */ + Rectangle.prototype.contains = function contains (x, y) + { + if (this.width <= 0 || this.height <= 0) + { + return false; + } + + if (x >= this.x && x < this.x + this.width) + { + if (y >= this.y && y < this.y + this.height) + { + return true; + } + } + + return false; + }; + + /** + * Pads the rectangle making it grow in all directions. + * + * @param {number} paddingX - The horizontal padding amount. + * @param {number} paddingY - The vertical padding amount. + */ + Rectangle.prototype.pad = function pad (paddingX, paddingY) + { + paddingX = paddingX || 0; + paddingY = paddingY || ((paddingY !== 0) ? paddingX : 0); + + this.x -= paddingX; + this.y -= paddingY; + + this.width += paddingX * 2; + this.height += paddingY * 2; + }; + + /** + * Fits this rectangle around the passed one. + * + * @param {PIXI.Rectangle} rectangle - The rectangle to fit. + */ + Rectangle.prototype.fit = function fit (rectangle) + { + var x1 = Math.max(this.x, rectangle.x); + var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width); + var y1 = Math.max(this.y, rectangle.y); + var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height); + + this.x = x1; + this.width = Math.max(x2 - x1, 0); + this.y = y1; + this.height = Math.max(y2 - y1, 0); + }; + + /** + * Enlarges rectangle that way its corners lie on grid + * + * @param {number} [resolution=1] resolution + * @param {number} [eps=0.001] precision + */ + Rectangle.prototype.ceil = function ceil (resolution, eps) + { + if ( resolution === void 0 ) { resolution = 1; } + if ( eps === void 0 ) { eps = 0.001; } + + var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution; + var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution; + + this.x = Math.floor((this.x + eps) * resolution) / resolution; + this.y = Math.floor((this.y + eps) * resolution) / resolution; + + this.width = x2 - this.x; + this.height = y2 - this.y; + }; + + /** + * Enlarges this rectangle to include the passed rectangle. + * + * @param {PIXI.Rectangle} rectangle - The rectangle to include. + */ + Rectangle.prototype.enlarge = function enlarge (rectangle) + { + var x1 = Math.min(this.x, rectangle.x); + var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width); + var y1 = Math.min(this.y, rectangle.y); + var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height); + + this.x = x1; + this.width = x2 - x1; + this.y = y1; + this.height = y2 - y1; + }; + + Object.defineProperties( Rectangle.prototype, prototypeAccessors$2 ); + Object.defineProperties( Rectangle, staticAccessors$1 ); + + /** + * The Circle object is used to help draw graphics and can also be used to specify a hit area for displayObjects. + * + * @class + * @memberof PIXI + */ + var Circle = function Circle(x, y, radius) + { + if ( x === void 0 ) { x = 0; } + if ( y === void 0 ) { y = 0; } + if ( radius === void 0 ) { radius = 0; } + + /** + * @member {number} + * @default 0 + */ + this.x = x; + + /** + * @member {number} + * @default 0 + */ + this.y = y; + + /** + * @member {number} + * @default 0 + */ + this.radius = radius; + + /** + * The type of the object, mainly used to avoid `instanceof` checks + * + * @member {number} + * @readOnly + * @default PIXI.SHAPES.CIRC + * @see PIXI.SHAPES + */ + this.type = SHAPES.CIRC; + }; + + /** + * Creates a clone of this Circle instance + * + * @return {PIXI.Circle} a copy of the Circle + */ + Circle.prototype.clone = function clone () + { + return new Circle(this.x, this.y, this.radius); + }; + + /** + * Checks whether the x and y coordinates given are contained within this circle + * + * @param {number} x - The X coordinate of the point to test + * @param {number} y - The Y coordinate of the point to test + * @return {boolean} Whether the x/y coordinates are within this Circle + */ + Circle.prototype.contains = function contains (x, y) + { + if (this.radius <= 0) + { + return false; + } + + var r2 = this.radius * this.radius; + var dx = (this.x - x); + var dy = (this.y - y); + + dx *= dx; + dy *= dy; + + return (dx + dy <= r2); + }; + + /** + * Returns the framing rectangle of the circle as a Rectangle object + * + * @return {PIXI.Rectangle} the framing rectangle + */ + Circle.prototype.getBounds = function getBounds () + { + return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); + }; + + /** + * The Ellipse object is used to help draw graphics and can also be used to specify a hit area for displayObjects. + * + * @class + * @memberof PIXI + */ + var Ellipse = function Ellipse(x, y, halfWidth, halfHeight) + { + if ( x === void 0 ) { x = 0; } + if ( y === void 0 ) { y = 0; } + if ( halfWidth === void 0 ) { halfWidth = 0; } + if ( halfHeight === void 0 ) { halfHeight = 0; } + + /** + * @member {number} + * @default 0 + */ + this.x = x; + + /** + * @member {number} + * @default 0 + */ + this.y = y; + + /** + * @member {number} + * @default 0 + */ + this.width = halfWidth; + + /** + * @member {number} + * @default 0 + */ + this.height = halfHeight; + + /** + * The type of the object, mainly used to avoid `instanceof` checks + * + * @member {number} + * @readOnly + * @default PIXI.SHAPES.ELIP + * @see PIXI.SHAPES + */ + this.type = SHAPES.ELIP; + }; + + /** + * Creates a clone of this Ellipse instance + * + * @return {PIXI.Ellipse} a copy of the ellipse + */ + Ellipse.prototype.clone = function clone () + { + return new Ellipse(this.x, this.y, this.width, this.height); + }; + + /** + * Checks whether the x and y coordinates given are contained within this ellipse + * + * @param {number} x - The X coordinate of the point to test + * @param {number} y - The Y coordinate of the point to test + * @return {boolean} Whether the x/y coords are within this ellipse + */ + Ellipse.prototype.contains = function contains (x, y) + { + if (this.width <= 0 || this.height <= 0) + { + return false; + } + + // normalize the coords to an ellipse with center 0,0 + var normx = ((x - this.x) / this.width); + var normy = ((y - this.y) / this.height); + + normx *= normx; + normy *= normy; + + return (normx + normy <= 1); + }; + + /** + * Returns the framing rectangle of the ellipse as a Rectangle object + * + * @return {PIXI.Rectangle} the framing rectangle + */ + Ellipse.prototype.getBounds = function getBounds () + { + return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height); + }; + + /** + * A class to define a shape via user defined co-orinates. + * + * @class + * @memberof PIXI + */ + var Polygon = function Polygon() + { + var arguments$1 = arguments; + + var points = [], len = arguments.length; + while ( len-- ) { points[ len ] = arguments$1[ len ]; } + + if (Array.isArray(points[0])) + { + points = points[0]; + } + + // if this is an array of points, convert it to a flat array of numbers + if (points[0] instanceof Point) + { + var p = []; + + for (var i = 0, il = points.length; i < il; i++) + { + p.push(points[i].x, points[i].y); + } + + points = p; + } + + /** + * An array of the points of this polygon + * + * @member {number[]} + */ + this.points = points; + + /** + * The type of the object, mainly used to avoid `instanceof` checks + * + * @member {number} + * @readOnly + * @default PIXI.SHAPES.POLY + * @see PIXI.SHAPES + */ + this.type = SHAPES.POLY; + + /** + * `false` after moveTo, `true` after `closePath`. In all other cases it is `true`. + * @member {boolean} + * @default true + */ + this.closeStroke = true; + }; + + /** + * Creates a clone of this polygon + * + * @return {PIXI.Polygon} a copy of the polygon + */ + Polygon.prototype.clone = function clone () + { + var polygon = new Polygon(this.points.slice()); + + polygon.closeStroke = this.closeStroke; + + return polygon; + }; + + /** + * Checks whether the x and y coordinates passed to this function are contained within this polygon + * + * @param {number} x - The X coordinate of the point to test + * @param {number} y - The Y coordinate of the point to test + * @return {boolean} Whether the x/y coordinates are within this polygon + */ + Polygon.prototype.contains = function contains (x, y) + { + var inside = false; + + // use some raycasting to test hits + // https://github.com/substack/point-in-polygon/blob/master/index.js + var length = this.points.length / 2; + + for (var i = 0, j = length - 1; i < length; j = i++) + { + var xi = this.points[i * 2]; + var yi = this.points[(i * 2) + 1]; + var xj = this.points[j * 2]; + var yj = this.points[(j * 2) + 1]; + var intersect = ((yi > y) !== (yj > y)) && (x < ((xj - xi) * ((y - yi) / (yj - yi))) + xi); + + if (intersect) + { + inside = !inside; + } + } + + return inside; + }; + + /** + * The Rounded Rectangle object is an area that has nice rounded corners, as indicated by its + * top-left corner point (x, y) and by its width and its height and its radius. + * + * @class + * @memberof PIXI + */ + var RoundedRectangle = function RoundedRectangle(x, y, width, height, radius) + { + if ( x === void 0 ) { x = 0; } + if ( y === void 0 ) { y = 0; } + if ( width === void 0 ) { width = 0; } + if ( height === void 0 ) { height = 0; } + if ( radius === void 0 ) { radius = 20; } + + /** + * @member {number} + * @default 0 + */ + this.x = x; + + /** + * @member {number} + * @default 0 + */ + this.y = y; + + /** + * @member {number} + * @default 0 + */ + this.width = width; + + /** + * @member {number} + * @default 0 + */ + this.height = height; + + /** + * @member {number} + * @default 20 + */ + this.radius = radius; + + /** + * The type of the object, mainly used to avoid `instanceof` checks + * + * @member {number} + * @readonly + * @default PIXI.SHAPES.RREC + * @see PIXI.SHAPES + */ + this.type = SHAPES.RREC; + }; + + /** + * Creates a clone of this Rounded Rectangle + * + * @return {PIXI.RoundedRectangle} a copy of the rounded rectangle + */ + RoundedRectangle.prototype.clone = function clone () + { + return new RoundedRectangle(this.x, this.y, this.width, this.height, this.radius); + }; + + /** + * Checks whether the x and y coordinates given are contained within this Rounded Rectangle + * + * @param {number} x - The X coordinate of the point to test + * @param {number} y - The Y coordinate of the point to test + * @return {boolean} Whether the x/y coordinates are within this Rounded Rectangle + */ + RoundedRectangle.prototype.contains = function contains (x, y) + { + if (this.width <= 0 || this.height <= 0) + { + return false; + } + if (x >= this.x && x <= this.x + this.width) + { + if (y >= this.y && y <= this.y + this.height) + { + if ((y >= this.y + this.radius && y <= this.y + this.height - this.radius) + || (x >= this.x + this.radius && x <= this.x + this.width - this.radius)) + { + return true; + } + var dx = x - (this.x + this.radius); + var dy = y - (this.y + this.radius); + var radius2 = this.radius * this.radius; + + if ((dx * dx) + (dy * dy) <= radius2) + { + return true; + } + dx = x - (this.x + this.width - this.radius); + if ((dx * dx) + (dy * dy) <= radius2) + { + return true; + } + dy = y - (this.y + this.height - this.radius); + if ((dx * dx) + (dy * dy) <= radius2) + { + return true; + } + dx = x - (this.x + this.radius); + if ((dx * dx) + (dy * dy) <= radius2) + { + return true; + } + } + } + + return false; + }; + + /*! + * @pixi/display - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/display is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Sets the default value for the container property 'sortableChildren'. + * If set to true, the container will sort its children by zIndex value + * when updateTransform() is called, or manually if sortChildren() is called. + * + * This actually changes the order of elements in the array, so should be treated + * as a basic solution that is not performant compared to other solutions, + * such as @link https://github.com/pixijs/pixi-display + * + * Also be aware of that this may not work nicely with the addChildAt() function, + * as the zIndex sorting may cause the child to automatically sorted to another position. + * + * @static + * @constant + * @name SORTABLE_CHILDREN + * @memberof PIXI.settings + * @type {boolean} + * @default false + */ + settings.SORTABLE_CHILDREN = false; + + /** + * 'Builder' pattern for bounds rectangles. + * + * This could be called an Axis-Aligned Bounding Box. + * It is not an actual shape. It is a mutable thing; no 'EMPTY' or those kind of problems. + * + * @class + * @memberof PIXI + */ + var Bounds = function Bounds() + { + /** + * @member {number} + * @default 0 + */ + this.minX = Infinity; + + /** + * @member {number} + * @default 0 + */ + this.minY = Infinity; + + /** + * @member {number} + * @default 0 + */ + this.maxX = -Infinity; + + /** + * @member {number} + * @default 0 + */ + this.maxY = -Infinity; + + this.rect = null; + }; + + /** + * Checks if bounds are empty. + * + * @return {boolean} True if empty. + */ + Bounds.prototype.isEmpty = function isEmpty () + { + return this.minX > this.maxX || this.minY > this.maxY; + }; + + /** + * Clears the bounds and resets. + * + */ + Bounds.prototype.clear = function clear () + { + this.updateID++; + + this.minX = Infinity; + this.minY = Infinity; + this.maxX = -Infinity; + this.maxY = -Infinity; + }; + + /** + * Can return Rectangle.EMPTY constant, either construct new rectangle, either use your rectangle + * It is not guaranteed that it will return tempRect + * + * @param {PIXI.Rectangle} rect - temporary object will be used if AABB is not empty + * @returns {PIXI.Rectangle} A rectangle of the bounds + */ + Bounds.prototype.getRectangle = function getRectangle (rect) + { + if (this.minX > this.maxX || this.minY > this.maxY) + { + return Rectangle.EMPTY; + } + + rect = rect || new Rectangle(0, 0, 1, 1); + + rect.x = this.minX; + rect.y = this.minY; + rect.width = this.maxX - this.minX; + rect.height = this.maxY - this.minY; + + return rect; + }; + + /** + * This function should be inlined when its possible. + * + * @param {PIXI.Point} point - The point to add. + */ + Bounds.prototype.addPoint = function addPoint (point) + { + this.minX = Math.min(this.minX, point.x); + this.maxX = Math.max(this.maxX, point.x); + this.minY = Math.min(this.minY, point.y); + this.maxY = Math.max(this.maxY, point.y); + }; + + /** + * Adds a quad, not transformed + * + * @param {Float32Array} vertices - The verts to add. + */ + Bounds.prototype.addQuad = function addQuad (vertices) + { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + + var x = vertices[0]; + var y = vertices[1]; + + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + + x = vertices[2]; + y = vertices[3]; + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + + x = vertices[4]; + y = vertices[5]; + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + + x = vertices[6]; + y = vertices[7]; + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + + /** + * Adds sprite frame, transformed. + * + * @param {PIXI.Transform} transform - TODO + * @param {number} x0 - TODO + * @param {number} y0 - TODO + * @param {number} x1 - TODO + * @param {number} y1 - TODO + */ + Bounds.prototype.addFrame = function addFrame (transform, x0, y0, x1, y1) + { + var matrix = transform.worldTransform; + var a = matrix.a; + var b = matrix.b; + var c = matrix.c; + var d = matrix.d; + var tx = matrix.tx; + var ty = matrix.ty; + + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + + var x = (a * x0) + (c * y0) + tx; + var y = (b * x0) + (d * y0) + ty; + + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + + x = (a * x1) + (c * y0) + tx; + y = (b * x1) + (d * y0) + ty; + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + + x = (a * x0) + (c * y1) + tx; + y = (b * x0) + (d * y1) + ty; + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + + x = (a * x1) + (c * y1) + tx; + y = (b * x1) + (d * y1) + ty; + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + + /** + * Adds screen vertices from array + * + * @param {Float32Array} vertexData - calculated vertices + * @param {number} beginOffset - begin offset + * @param {number} endOffset - end offset, excluded + */ + Bounds.prototype.addVertexData = function addVertexData (vertexData, beginOffset, endOffset) + { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + + for (var i = beginOffset; i < endOffset; i += 2) + { + var x = vertexData[i]; + var y = vertexData[i + 1]; + + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + } + + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + + /** + * Add an array of mesh vertices + * + * @param {PIXI.Transform} transform - mesh transform + * @param {Float32Array} vertices - mesh coordinates in array + * @param {number} beginOffset - begin offset + * @param {number} endOffset - end offset, excluded + */ + Bounds.prototype.addVertices = function addVertices (transform, vertices, beginOffset, endOffset) + { + var matrix = transform.worldTransform; + var a = matrix.a; + var b = matrix.b; + var c = matrix.c; + var d = matrix.d; + var tx = matrix.tx; + var ty = matrix.ty; + + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + + for (var i = beginOffset; i < endOffset; i += 2) + { + var rawX = vertices[i]; + var rawY = vertices[i + 1]; + var x = (a * rawX) + (c * rawY) + tx; + var y = (d * rawY) + (b * rawX) + ty; + + minX = x < minX ? x : minX; + minY = y < minY ? y : minY; + maxX = x > maxX ? x : maxX; + maxY = y > maxY ? y : maxY; + } + + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + + /** + * Adds other Bounds + * + * @param {PIXI.Bounds} bounds - TODO + */ + Bounds.prototype.addBounds = function addBounds (bounds) + { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + + this.minX = bounds.minX < minX ? bounds.minX : minX; + this.minY = bounds.minY < minY ? bounds.minY : minY; + this.maxX = bounds.maxX > maxX ? bounds.maxX : maxX; + this.maxY = bounds.maxY > maxY ? bounds.maxY : maxY; + }; + + /** + * Adds other Bounds, masked with Bounds + * + * @param {PIXI.Bounds} bounds - TODO + * @param {PIXI.Bounds} mask - TODO + */ + Bounds.prototype.addBoundsMask = function addBoundsMask (bounds, mask) + { + var _minX = bounds.minX > mask.minX ? bounds.minX : mask.minX; + var _minY = bounds.minY > mask.minY ? bounds.minY : mask.minY; + var _maxX = bounds.maxX < mask.maxX ? bounds.maxX : mask.maxX; + var _maxY = bounds.maxY < mask.maxY ? bounds.maxY : mask.maxY; + + if (_minX <= _maxX && _minY <= _maxY) + { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + + this.minX = _minX < minX ? _minX : minX; + this.minY = _minY < minY ? _minY : minY; + this.maxX = _maxX > maxX ? _maxX : maxX; + this.maxY = _maxY > maxY ? _maxY : maxY; + } + }; + + /** + * Adds other Bounds, masked with Rectangle + * + * @param {PIXI.Bounds} bounds - TODO + * @param {PIXI.Rectangle} area - TODO + */ + Bounds.prototype.addBoundsArea = function addBoundsArea (bounds, area) + { + var _minX = bounds.minX > area.x ? bounds.minX : area.x; + var _minY = bounds.minY > area.y ? bounds.minY : area.y; + var _maxX = bounds.maxX < area.x + area.width ? bounds.maxX : (area.x + area.width); + var _maxY = bounds.maxY < area.y + area.height ? bounds.maxY : (area.y + area.height); + + if (_minX <= _maxX && _minY <= _maxY) + { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + + this.minX = _minX < minX ? _minX : minX; + this.minY = _minY < minY ? _minY : minY; + this.maxX = _maxX > maxX ? _maxX : maxX; + this.maxY = _maxY > maxY ? _maxY : maxY; + } + }; + + // _tempDisplayObjectParent = new DisplayObject(); + + /** + * The base class for all objects that are rendered on the screen. + * + * This is an abstract class and should not be used on its own; rather it should be extended. + * + * @class + * @extends PIXI.utils.EventEmitter + * @memberof PIXI + */ + var DisplayObject = /*@__PURE__*/(function (EventEmitter) { + function DisplayObject() + { + EventEmitter.call(this); + + this.tempDisplayObjectParent = null; + + // TODO: need to create Transform from factory + /** + * World transform and local transform of this object. + * This will become read-only later, please do not assign anything there unless you know what are you doing. + * + * @member {PIXI.Transform} + */ + this.transform = new Transform(); + + /** + * The opacity of the object. + * + * @member {number} + */ + this.alpha = 1; + + /** + * The visibility of the object. If false the object will not be drawn, and + * the updateTransform function will not be called. + * + * Only affects recursive calls from parent. You can ask for bounds or call updateTransform manually. + * + * @member {boolean} + */ + this.visible = true; + + /** + * Can this object be rendered, if false the object will not be drawn but the updateTransform + * methods will still be called. + * + * Only affects recursive calls from parent. You can ask for bounds manually. + * + * @member {boolean} + */ + this.renderable = true; + + /** + * The display object container that contains this display object. + * + * @member {PIXI.Container} + * @readonly + */ + this.parent = null; + + /** + * The multiplied alpha of the displayObject. + * + * @member {number} + * @readonly + */ + this.worldAlpha = 1; + + /** + * Which index in the children array the display component was before the previous zIndex sort. + * Used by containers to help sort objects with the same zIndex, by using previous array index as the decider. + * + * @member {number} + * @protected + */ + this._lastSortedIndex = 0; + + /** + * The zIndex of the displayObject. + * A higher value will mean it will be rendered on top of other displayObjects within the same container. + * + * @member {number} + * @protected + */ + this._zIndex = 0; + + /** + * The area the filter is applied to. This is used as more of an optimization + * rather than figuring out the dimensions of the displayObject each frame you can set this rectangle. + * + * Also works as an interaction mask. + * + * @member {?PIXI.Rectangle} + */ + this.filterArea = null; + + /** + * Sets the filters for the displayObject. + * * IMPORTANT: This is a WebGL only feature and will be ignored by the canvas renderer. + * To remove filters simply set this property to `'null'`. + * + * @member {?PIXI.Filter[]} + */ + this.filters = null; + this._enabledFilters = null; + + /** + * The bounds object, this is used to calculate and store the bounds of the displayObject. + * + * @member {PIXI.Bounds} + * @protected + */ + this._bounds = new Bounds(); + this._boundsID = 0; + this._lastBoundsID = -1; + this._boundsRect = null; + this._localBoundsRect = null; + + /** + * The original, cached mask of the object. + * + * @member {PIXI.Graphics|PIXI.Sprite} + * @protected + */ + this._mask = null; + + /** + * Fired when this DisplayObject is added to a Container. + * + * @event PIXI.DisplayObject#added + * @param {PIXI.Container} container - The container added to. + */ + + /** + * Fired when this DisplayObject is removed from a Container. + * + * @event PIXI.DisplayObject#removed + * @param {PIXI.Container} container - The container removed from. + */ + + /** + * If the object has been destroyed via destroy(). If true, it should not be used. + * + * @member {boolean} + * @protected + */ + this._destroyed = false; + + /** + * used to fast check if a sprite is.. a sprite! + * @member {boolean} + */ + this.isSprite = false; + } + + if ( EventEmitter ) { DisplayObject.__proto__ = EventEmitter; } + DisplayObject.prototype = Object.create( EventEmitter && EventEmitter.prototype ); + DisplayObject.prototype.constructor = DisplayObject; + + var prototypeAccessors = { _tempDisplayObjectParent: { configurable: true },x: { configurable: true },y: { configurable: true },worldTransform: { configurable: true },localTransform: { configurable: true },position: { configurable: true },scale: { configurable: true },pivot: { configurable: true },skew: { configurable: true },rotation: { configurable: true },angle: { configurable: true },zIndex: { configurable: true },worldVisible: { configurable: true },mask: { configurable: true } }; + + /** + * @protected + * @member {PIXI.DisplayObject} + */ + DisplayObject.mixin = function mixin (source) + { + // in ES8/ES2017, this would be really easy: + // Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + + // get all the enumerable property keys + var keys = Object.keys(source); + + // loop through properties + for (var i = 0; i < keys.length; ++i) + { + var propertyName = keys[i]; + + // Set the property using the property descriptor - this works for accessors and normal value properties + Object.defineProperty( + DisplayObject.prototype, + propertyName, + Object.getOwnPropertyDescriptor(source, propertyName) + ); + } + }; + + prototypeAccessors._tempDisplayObjectParent.get = function () + { + if (this.tempDisplayObjectParent === null) + { + this.tempDisplayObjectParent = new DisplayObject(); + } + + return this.tempDisplayObjectParent; + }; + + /** + * Updates the object transform for rendering. + * + * TODO - Optimization pass! + */ + DisplayObject.prototype.updateTransform = function updateTransform () + { + this.transform.updateTransform(this.parent.transform); + // multiply the alphas.. + this.worldAlpha = this.alpha * this.parent.worldAlpha; + + this._bounds.updateID++; + }; + + /** + * Recursively updates transform of all objects from the root to this one + * internal function for toLocal() + */ + DisplayObject.prototype._recursivePostUpdateTransform = function _recursivePostUpdateTransform () + { + if (this.parent) + { + this.parent._recursivePostUpdateTransform(); + this.transform.updateTransform(this.parent.transform); + } + else + { + this.transform.updateTransform(this._tempDisplayObjectParent.transform); + } + }; + + /** + * Retrieves the bounds of the displayObject as a rectangle object. + * + * @param {boolean} [skipUpdate] - Setting to `true` will stop the transforms of the scene graph from + * being updated. This means the calculation returned MAY be out of date BUT will give you a + * nice performance boost. + * @param {PIXI.Rectangle} [rect] - Optional rectangle to store the result of the bounds calculation. + * @return {PIXI.Rectangle} The rectangular bounding area. + */ + DisplayObject.prototype.getBounds = function getBounds (skipUpdate, rect) + { + if (!skipUpdate) + { + if (!this.parent) + { + this.parent = this._tempDisplayObjectParent; + this.updateTransform(); + this.parent = null; + } + else + { + this._recursivePostUpdateTransform(); + this.updateTransform(); + } + } + + if (this._boundsID !== this._lastBoundsID) + { + this.calculateBounds(); + } + + if (!rect) + { + if (!this._boundsRect) + { + this._boundsRect = new Rectangle(); + } + + rect = this._boundsRect; + } + + return this._bounds.getRectangle(rect); + }; + + /** + * Retrieves the local bounds of the displayObject as a rectangle object. + * + * @param {PIXI.Rectangle} [rect] - Optional rectangle to store the result of the bounds calculation. + * @return {PIXI.Rectangle} The rectangular bounding area. + */ + DisplayObject.prototype.getLocalBounds = function getLocalBounds (rect) + { + var transformRef = this.transform; + var parentRef = this.parent; + + this.parent = null; + this.transform = this._tempDisplayObjectParent.transform; + + if (!rect) + { + if (!this._localBoundsRect) + { + this._localBoundsRect = new Rectangle(); + } + + rect = this._localBoundsRect; + } + + var bounds = this.getBounds(false, rect); + + this.parent = parentRef; + this.transform = transformRef; + + return bounds; + }; + + /** + * Calculates the global position of the display object. + * + * @param {PIXI.IPoint} position - The world origin to calculate from. + * @param {PIXI.IPoint} [point] - A Point object in which to store the value, optional + * (otherwise will create a new Point). + * @param {boolean} [skipUpdate=false] - Should we skip the update transform. + * @return {PIXI.IPoint} A point object representing the position of this object. + */ + DisplayObject.prototype.toGlobal = function toGlobal (position, point, skipUpdate) + { + if ( skipUpdate === void 0 ) { skipUpdate = false; } + + if (!skipUpdate) + { + this._recursivePostUpdateTransform(); + + // this parent check is for just in case the item is a root object. + // If it is we need to give it a temporary parent so that displayObjectUpdateTransform works correctly + // this is mainly to avoid a parent check in the main loop. Every little helps for performance :) + if (!this.parent) + { + this.parent = this._tempDisplayObjectParent; + this.displayObjectUpdateTransform(); + this.parent = null; + } + else + { + this.displayObjectUpdateTransform(); + } + } + + // don't need to update the lot + return this.worldTransform.apply(position, point); + }; + + /** + * Calculates the local position of the display object relative to another point. + * + * @param {PIXI.IPoint} position - The world origin to calculate from. + * @param {PIXI.DisplayObject} [from] - The DisplayObject to calculate the global position from. + * @param {PIXI.IPoint} [point] - A Point object in which to store the value, optional + * (otherwise will create a new Point). + * @param {boolean} [skipUpdate=false] - Should we skip the update transform + * @return {PIXI.IPoint} A point object representing the position of this object + */ + DisplayObject.prototype.toLocal = function toLocal (position, from, point, skipUpdate) + { + if (from) + { + position = from.toGlobal(position, point, skipUpdate); + } + + if (!skipUpdate) + { + this._recursivePostUpdateTransform(); + + // this parent check is for just in case the item is a root object. + // If it is we need to give it a temporary parent so that displayObjectUpdateTransform works correctly + // this is mainly to avoid a parent check in the main loop. Every little helps for performance :) + if (!this.parent) + { + this.parent = this._tempDisplayObjectParent; + this.displayObjectUpdateTransform(); + this.parent = null; + } + else + { + this.displayObjectUpdateTransform(); + } + } + + // simply apply the matrix.. + return this.worldTransform.applyInverse(position, point); + }; + + /** + * Renders the object using the WebGL renderer. + * + * @param {PIXI.Renderer} renderer - The renderer. + */ + DisplayObject.prototype.render = function render (renderer) // eslint-disable-line no-unused-vars + { + // OVERWRITE; + }; + + /** + * Set the parent Container of this DisplayObject. + * + * @param {PIXI.Container} container - The Container to add this DisplayObject to. + * @return {PIXI.Container} The Container that this DisplayObject was added to. + */ + DisplayObject.prototype.setParent = function setParent (container) + { + if (!container || !container.addChild) + { + throw new Error('setParent: Argument must be a Container'); + } + + container.addChild(this); + + return container; + }; + + /** + * Convenience function to set the position, scale, skew and pivot at once. + * + * @param {number} [x=0] - The X position + * @param {number} [y=0] - The Y position + * @param {number} [scaleX=1] - The X scale value + * @param {number} [scaleY=1] - The Y scale value + * @param {number} [rotation=0] - The rotation + * @param {number} [skewX=0] - The X skew value + * @param {number} [skewY=0] - The Y skew value + * @param {number} [pivotX=0] - The X pivot value + * @param {number} [pivotY=0] - The Y pivot value + * @return {PIXI.DisplayObject} The DisplayObject instance + */ + DisplayObject.prototype.setTransform = function setTransform (x, y, scaleX, scaleY, rotation, skewX, skewY, pivotX, pivotY) + { + if ( x === void 0 ) { x = 0; } + if ( y === void 0 ) { y = 0; } + if ( scaleX === void 0 ) { scaleX = 1; } + if ( scaleY === void 0 ) { scaleY = 1; } + if ( rotation === void 0 ) { rotation = 0; } + if ( skewX === void 0 ) { skewX = 0; } + if ( skewY === void 0 ) { skewY = 0; } + if ( pivotX === void 0 ) { pivotX = 0; } + if ( pivotY === void 0 ) { pivotY = 0; } + + this.position.x = x; + this.position.y = y; + this.scale.x = !scaleX ? 1 : scaleX; + this.scale.y = !scaleY ? 1 : scaleY; + this.rotation = rotation; + this.skew.x = skewX; + this.skew.y = skewY; + this.pivot.x = pivotX; + this.pivot.y = pivotY; + + return this; + }; + + /** + * Base destroy method for generic display objects. This will automatically + * remove the display object from its parent Container as well as remove + * all current event listeners and internal references. Do not use a DisplayObject + * after calling `destroy()`. + * + */ + DisplayObject.prototype.destroy = function destroy () + { + this.removeAllListeners(); + if (this.parent) + { + this.parent.removeChild(this); + } + this.transform = null; + + this.parent = null; + + this._bounds = null; + this._currentBounds = null; + this._mask = null; + + this.filterArea = null; + + this.interactive = false; + this.interactiveChildren = false; + + this._destroyed = true; + }; + + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * An alias to position.x + * + * @member {number} + */ + prototypeAccessors.x.get = function () + { + return this.position.x; + }; + + prototypeAccessors.x.set = function (value) // eslint-disable-line require-jsdoc + { + this.transform.position.x = value; + }; + + /** + * The position of the displayObject on the y axis relative to the local coordinates of the parent. + * An alias to position.y + * + * @member {number} + */ + prototypeAccessors.y.get = function () + { + return this.position.y; + }; + + prototypeAccessors.y.set = function (value) // eslint-disable-line require-jsdoc + { + this.transform.position.y = value; + }; + + /** + * Current transform of the object based on world (parent) factors. + * + * @member {PIXI.Matrix} + * @readonly + */ + prototypeAccessors.worldTransform.get = function () + { + return this.transform.worldTransform; + }; + + /** + * Current transform of the object based on local factors: position, scale, other stuff. + * + * @member {PIXI.Matrix} + * @readonly + */ + prototypeAccessors.localTransform.get = function () + { + return this.transform.localTransform; + }; + + /** + * The coordinate of the object relative to the local coordinates of the parent. + * Assignment by value since pixi-v4. + * + * @member {PIXI.IPoint} + */ + prototypeAccessors.position.get = function () + { + return this.transform.position; + }; + + prototypeAccessors.position.set = function (value) // eslint-disable-line require-jsdoc + { + this.transform.position.copyFrom(value); + }; + + /** + * The scale factor of the object. + * Assignment by value since pixi-v4. + * + * @member {PIXI.IPoint} + */ + prototypeAccessors.scale.get = function () + { + return this.transform.scale; + }; + + prototypeAccessors.scale.set = function (value) // eslint-disable-line require-jsdoc + { + this.transform.scale.copyFrom(value); + }; + + /** + * The pivot point of the displayObject that it rotates around. + * Assignment by value since pixi-v4. + * + * @member {PIXI.IPoint} + */ + prototypeAccessors.pivot.get = function () + { + return this.transform.pivot; + }; + + prototypeAccessors.pivot.set = function (value) // eslint-disable-line require-jsdoc + { + this.transform.pivot.copyFrom(value); + }; + + /** + * The skew factor for the object in radians. + * Assignment by value since pixi-v4. + * + * @member {PIXI.ObservablePoint} + */ + prototypeAccessors.skew.get = function () + { + return this.transform.skew; + }; + + prototypeAccessors.skew.set = function (value) // eslint-disable-line require-jsdoc + { + this.transform.skew.copyFrom(value); + }; + + /** + * The rotation of the object in radians. + * 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees. + * + * @member {number} + */ + prototypeAccessors.rotation.get = function () + { + return this.transform.rotation; + }; + + prototypeAccessors.rotation.set = function (value) // eslint-disable-line require-jsdoc + { + this.transform.rotation = value; + }; + + /** + * The angle of the object in degrees. + * 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees. + * + * @member {number} + */ + prototypeAccessors.angle.get = function () + { + return this.transform.rotation * RAD_TO_DEG; + }; + + prototypeAccessors.angle.set = function (value) // eslint-disable-line require-jsdoc + { + this.transform.rotation = value * DEG_TO_RAD; + }; + + /** + * The zIndex of the displayObject. + * If a container has the sortableChildren property set to true, children will be automatically + * sorted by zIndex value; a higher value will mean it will be moved towards the end of the array, + * and thus rendered on top of other displayObjects within the same container. + * + * @member {number} + */ + prototypeAccessors.zIndex.get = function () + { + return this._zIndex; + }; + + prototypeAccessors.zIndex.set = function (value) // eslint-disable-line require-jsdoc + { + this._zIndex = value; + if (this.parent) + { + this.parent.sortDirty = true; + } + }; + + /** + * Indicates if the object is globally visible. + * + * @member {boolean} + * @readonly + */ + prototypeAccessors.worldVisible.get = function () + { + var item = this; + + do + { + if (!item.visible) + { + return false; + } + + item = item.parent; + } while (item); + + return true; + }; + + /** + * Sets a mask for the displayObject. A mask is an object that limits the visibility of an + * object to the shape of the mask applied to it. In PixiJS a regular mask must be a + * {@link PIXI.Graphics} or a {@link PIXI.Sprite} object. This allows for much faster masking in canvas as it + * utilities shape clipping. To remove a mask, set this property to `null`. + * + * For sprite mask both alpha and red channel are used. Black mask is the same as transparent mask. + * @example + * const graphics = new PIXI.Graphics(); + * graphics.beginFill(0xFF3300); + * graphics.drawRect(50, 250, 100, 100); + * graphics.endFill(); + * + * const sprite = new PIXI.Sprite(texture); + * sprite.mask = graphics; + * @todo At the moment, PIXI.CanvasRenderer doesn't support PIXI.Sprite as mask. + * + * @member {PIXI.Graphics|PIXI.Sprite} + */ + prototypeAccessors.mask.get = function () + { + return this._mask; + }; + + prototypeAccessors.mask.set = function (value) // eslint-disable-line require-jsdoc + { + if (this._mask) + { + this._mask.renderable = true; + this._mask.isMask = false; + } + + this._mask = value; + + if (this._mask) + { + this._mask.renderable = false; + this._mask.isMask = true; + } + }; + + Object.defineProperties( DisplayObject.prototype, prototypeAccessors ); + + return DisplayObject; + }(eventemitter3)); + + // performance increase to avoid using call.. (10x faster) + DisplayObject.prototype.displayObjectUpdateTransform = DisplayObject.prototype.updateTransform; + + function sortChildren(a, b) + { + if (a.zIndex === b.zIndex) + { + return a._lastSortedIndex - b._lastSortedIndex; + } + + return a.zIndex - b.zIndex; + } + + /** + * A Container represents a collection of display objects. + * + * It is the base class of all display objects that act as a container for other objects (like Sprites). + * + *```js + * let container = new PIXI.Container(); + * container.addChild(sprite); + * ``` + * + * @class + * @extends PIXI.DisplayObject + * @memberof PIXI + */ + var Container = /*@__PURE__*/(function (DisplayObject) { + function Container() + { + DisplayObject.call(this); + + /** + * The array of children of this container. + * + * @member {PIXI.DisplayObject[]} + * @readonly + */ + this.children = []; + + /** + * If set to true, the container will sort its children by zIndex value + * when updateTransform() is called, or manually if sortChildren() is called. + * + * This actually changes the order of elements in the array, so should be treated + * as a basic solution that is not performant compared to other solutions, + * such as @link https://github.com/pixijs/pixi-display + * + * Also be aware of that this may not work nicely with the addChildAt() function, + * as the zIndex sorting may cause the child to automatically sorted to another position. + * + * @see PIXI.settings.SORTABLE_CHILDREN + * + * @member {boolean} + */ + this.sortableChildren = settings.SORTABLE_CHILDREN; + + /** + * Should children be sorted by zIndex at the next updateTransform call. + * Will get automatically set to true if a new child is added, or if a child's zIndex changes. + * + * @member {boolean} + */ + this.sortDirty = false; + + /** + * Fired when a DisplayObject is added to this Container. + * + * @event PIXI.Container#childAdded + * @param {PIXI.DisplayObject} child - The child added to the Container. + * @param {PIXI.Container} container - The container that added the child. + * @param {number} index - The children's index of the added child. + */ + + /** + * Fired when a DisplayObject is removed from this Container. + * + * @event PIXI.DisplayObject#removedFrom + * @param {PIXI.DisplayObject} child - The child removed from the Container. + * @param {PIXI.Container} container - The container that removed removed the child. + * @param {number} index - The former children's index of the removed child + */ + } + + if ( DisplayObject ) { Container.__proto__ = DisplayObject; } + Container.prototype = Object.create( DisplayObject && DisplayObject.prototype ); + Container.prototype.constructor = Container; + + var prototypeAccessors = { width: { configurable: true },height: { configurable: true } }; + + /** + * Overridable method that can be used by Container subclasses whenever the children array is modified + * + * @protected + */ + Container.prototype.onChildrenChange = function onChildrenChange () + { + /* empty */ + }; + + /** + * Adds one or more children to the container. + * + * Multiple items can be added like so: `myContainer.addChild(thingOne, thingTwo, thingThree)` + * + * @param {...PIXI.DisplayObject} child - The DisplayObject(s) to add to the container + * @return {PIXI.DisplayObject} The first child that was added. + */ + Container.prototype.addChild = function addChild (child) + { + var arguments$1 = arguments; + + var argumentsLength = arguments.length; + + // if there is only one argument we can bypass looping through the them + if (argumentsLength > 1) + { + // loop through the arguments property and add all children + // use it the right way (.length and [i]) so that this function can still be optimized by JS runtimes + for (var i = 0; i < argumentsLength; i++) + { + this.addChild(arguments$1[i]); + } + } + else + { + // if the child has a parent then lets remove it as PixiJS objects can only exist in one place + if (child.parent) + { + child.parent.removeChild(child); + } + + child.parent = this; + this.sortDirty = true; + + // ensure child transform will be recalculated + child.transform._parentID = -1; + + this.children.push(child); + + // ensure bounds will be recalculated + this._boundsID++; + + // TODO - lets either do all callbacks or all events.. not both! + this.onChildrenChange(this.children.length - 1); + this.emit('childAdded', child, this, this.children.length - 1); + child.emit('added', this); + } + + return child; + }; + + /** + * Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown + * + * @param {PIXI.DisplayObject} child - The child to add + * @param {number} index - The index to place the child in + * @return {PIXI.DisplayObject} The child that was added. + */ + Container.prototype.addChildAt = function addChildAt (child, index) + { + if (index < 0 || index > this.children.length) + { + throw new Error((child + "addChildAt: The index " + index + " supplied is out of bounds " + (this.children.length))); + } + + if (child.parent) + { + child.parent.removeChild(child); + } + + child.parent = this; + this.sortDirty = true; + + // ensure child transform will be recalculated + child.transform._parentID = -1; + + this.children.splice(index, 0, child); + + // ensure bounds will be recalculated + this._boundsID++; + + // TODO - lets either do all callbacks or all events.. not both! + this.onChildrenChange(index); + child.emit('added', this); + this.emit('childAdded', child, this, index); + + return child; + }; + + /** + * Swaps the position of 2 Display Objects within this container. + * + * @param {PIXI.DisplayObject} child - First display object to swap + * @param {PIXI.DisplayObject} child2 - Second display object to swap + */ + Container.prototype.swapChildren = function swapChildren (child, child2) + { + if (child === child2) + { + return; + } + + var index1 = this.getChildIndex(child); + var index2 = this.getChildIndex(child2); + + this.children[index1] = child2; + this.children[index2] = child; + this.onChildrenChange(index1 < index2 ? index1 : index2); + }; + + /** + * Returns the index position of a child DisplayObject instance + * + * @param {PIXI.DisplayObject} child - The DisplayObject instance to identify + * @return {number} The index position of the child display object to identify + */ + Container.prototype.getChildIndex = function getChildIndex (child) + { + var index = this.children.indexOf(child); + + if (index === -1) + { + throw new Error('The supplied DisplayObject must be a child of the caller'); + } + + return index; + }; + + /** + * Changes the position of an existing child in the display object container + * + * @param {PIXI.DisplayObject} child - The child DisplayObject instance for which you want to change the index number + * @param {number} index - The resulting index number for the child display object + */ + Container.prototype.setChildIndex = function setChildIndex (child, index) + { + if (index < 0 || index >= this.children.length) + { + throw new Error(("The index " + index + " supplied is out of bounds " + (this.children.length))); + } + + var currentIndex = this.getChildIndex(child); + + removeItems(this.children, currentIndex, 1); // remove from old position + this.children.splice(index, 0, child); // add at new position + + this.onChildrenChange(index); + }; + + /** + * Returns the child at the specified index + * + * @param {number} index - The index to get the child at + * @return {PIXI.DisplayObject} The child at the given index, if any. + */ + Container.prototype.getChildAt = function getChildAt (index) + { + if (index < 0 || index >= this.children.length) + { + throw new Error(("getChildAt: Index (" + index + ") does not exist.")); + } + + return this.children[index]; + }; + + /** + * Removes one or more children from the container. + * + * @param {...PIXI.DisplayObject} child - The DisplayObject(s) to remove + * @return {PIXI.DisplayObject} The first child that was removed. + */ + Container.prototype.removeChild = function removeChild (child) + { + var arguments$1 = arguments; + + var argumentsLength = arguments.length; + + // if there is only one argument we can bypass looping through the them + if (argumentsLength > 1) + { + // loop through the arguments property and add all children + // use it the right way (.length and [i]) so that this function can still be optimized by JS runtimes + for (var i = 0; i < argumentsLength; i++) + { + this.removeChild(arguments$1[i]); + } + } + else + { + var index = this.children.indexOf(child); + + if (index === -1) { return null; } + + child.parent = null; + // ensure child transform will be recalculated + child.transform._parentID = -1; + removeItems(this.children, index, 1); + + // ensure bounds will be recalculated + this._boundsID++; + + // TODO - lets either do all callbacks or all events.. not both! + this.onChildrenChange(index); + child.emit('removed', this); + this.emit('childRemoved', child, this, index); + } + + return child; + }; + + /** + * Removes a child from the specified index position. + * + * @param {number} index - The index to get the child from + * @return {PIXI.DisplayObject} The child that was removed. + */ + Container.prototype.removeChildAt = function removeChildAt (index) + { + var child = this.getChildAt(index); + + // ensure child transform will be recalculated.. + child.parent = null; + child.transform._parentID = -1; + removeItems(this.children, index, 1); + + // ensure bounds will be recalculated + this._boundsID++; + + // TODO - lets either do all callbacks or all events.. not both! + this.onChildrenChange(index); + child.emit('removed', this); + this.emit('childRemoved', child, this, index); + + return child; + }; + + /** + * Removes all children from this container that are within the begin and end indexes. + * + * @param {number} [beginIndex=0] - The beginning position. + * @param {number} [endIndex=this.children.length] - The ending position. Default value is size of the container. + * @returns {DisplayObject[]} List of removed children + */ + Container.prototype.removeChildren = function removeChildren (beginIndex, endIndex) + { + if ( beginIndex === void 0 ) { beginIndex = 0; } + + var begin = beginIndex; + var end = typeof endIndex === 'number' ? endIndex : this.children.length; + var range = end - begin; + var removed; + + if (range > 0 && range <= end) + { + removed = this.children.splice(begin, range); + + for (var i = 0; i < removed.length; ++i) + { + removed[i].parent = null; + if (removed[i].transform) + { + removed[i].transform._parentID = -1; + } + } + + this._boundsID++; + + this.onChildrenChange(beginIndex); + + for (var i$1 = 0; i$1 < removed.length; ++i$1) + { + removed[i$1].emit('removed', this); + this.emit('childRemoved', removed[i$1], this, i$1); + } + + return removed; + } + else if (range === 0 && this.children.length === 0) + { + return []; + } + + throw new RangeError('removeChildren: numeric values are outside the acceptable range.'); + }; + + /** + * Sorts children by zIndex. Previous order is mantained for 2 children with the same zIndex. + */ + Container.prototype.sortChildren = function sortChildren$1 () + { + var sortRequired = false; + + for (var i = 0, j = this.children.length; i < j; ++i) + { + var child = this.children[i]; + + child._lastSortedIndex = i; + + if (!sortRequired && child.zIndex !== 0) + { + sortRequired = true; + } + } + + if (sortRequired && this.children.length > 1) + { + this.children.sort(sortChildren); + } + + this.sortDirty = false; + }; + + /** + * Updates the transform on all children of this container for rendering + */ + Container.prototype.updateTransform = function updateTransform () + { + if (this.sortableChildren && this.sortDirty) + { + this.sortChildren(); + } + + this._boundsID++; + + this.transform.updateTransform(this.parent.transform); + + // TODO: check render flags, how to process stuff here + this.worldAlpha = this.alpha * this.parent.worldAlpha; + + for (var i = 0, j = this.children.length; i < j; ++i) + { + var child = this.children[i]; + + if (child.visible) + { + child.updateTransform(); + } + } + }; + + /** + * Recalculates the bounds of the container. + * + */ + Container.prototype.calculateBounds = function calculateBounds () + { + this._bounds.clear(); + + this._calculateBounds(); + + for (var i = 0; i < this.children.length; i++) + { + var child = this.children[i]; + + if (!child.visible || !child.renderable) + { + continue; + } + + child.calculateBounds(); + + // TODO: filter+mask, need to mask both somehow + if (child._mask) + { + child._mask.calculateBounds(); + this._bounds.addBoundsMask(child._bounds, child._mask._bounds); + } + else if (child.filterArea) + { + this._bounds.addBoundsArea(child._bounds, child.filterArea); + } + else + { + this._bounds.addBounds(child._bounds); + } + } + + this._lastBoundsID = this._boundsID; + }; + + /** + * Recalculates the bounds of the object. Override this to + * calculate the bounds of the specific object (not including children). + * + * @protected + */ + Container.prototype._calculateBounds = function _calculateBounds () + { + // FILL IN// + }; + + /** + * Renders the object using the WebGL renderer + * + * @param {PIXI.Renderer} renderer - The renderer + */ + Container.prototype.render = function render (renderer) + { + // if the object is not visible or the alpha is 0 then no need to render this element + if (!this.visible || this.worldAlpha <= 0 || !this.renderable) + { + return; + } + + // do a quick check to see if this element has a mask or a filter. + if (this._mask || this.filters) + { + this.renderAdvanced(renderer); + } + else + { + this._render(renderer); + + // simple render children! + for (var i = 0, j = this.children.length; i < j; ++i) + { + this.children[i].render(renderer); + } + } + }; + + /** + * Render the object using the WebGL renderer and advanced features. + * + * @protected + * @param {PIXI.Renderer} renderer - The renderer + */ + Container.prototype.renderAdvanced = function renderAdvanced (renderer) + { + renderer.batch.flush(); + + var filters = this.filters; + var mask = this._mask; + + // push filter first as we need to ensure the stencil buffer is correct for any masking + if (filters) + { + if (!this._enabledFilters) + { + this._enabledFilters = []; + } + + this._enabledFilters.length = 0; + + for (var i = 0; i < filters.length; i++) + { + if (filters[i].enabled) + { + this._enabledFilters.push(filters[i]); + } + } + + if (this._enabledFilters.length) + { + renderer.filter.push(this, this._enabledFilters); + } + } + + if (mask) + { + renderer.mask.push(this, this._mask); + } + + // add this object to the batch, only rendered if it has a texture. + this._render(renderer); + + // now loop through the children and make sure they get rendered + for (var i$1 = 0, j = this.children.length; i$1 < j; i$1++) + { + this.children[i$1].render(renderer); + } + + renderer.batch.flush(); + + if (mask) + { + renderer.mask.pop(this, this._mask); + } + + if (filters && this._enabledFilters && this._enabledFilters.length) + { + renderer.filter.pop(); + } + }; + + /** + * To be overridden by the subclasses. + * + * @protected + * @param {PIXI.Renderer} renderer - The renderer + */ + Container.prototype._render = function _render (renderer) // eslint-disable-line no-unused-vars + { + // this is where content itself gets rendered... + }; + + /** + * Removes all internal references and listeners as well as removes children from the display list. + * Do not use a Container after calling `destroy`. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options + * have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy + * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + Container.prototype.destroy = function destroy (options) + { + DisplayObject.prototype.destroy.call(this); + + this.sortDirty = false; + + var destroyChildren = typeof options === 'boolean' ? options : options && options.children; + + var oldChildren = this.removeChildren(0, this.children.length); + + if (destroyChildren) + { + for (var i = 0; i < oldChildren.length; ++i) + { + oldChildren[i].destroy(options); + } + } + }; + + /** + * The width of the Container, setting this will actually modify the scale to achieve the value set + * + * @member {number} + */ + prototypeAccessors.width.get = function () + { + return this.scale.x * this.getLocalBounds().width; + }; + + prototypeAccessors.width.set = function (value) // eslint-disable-line require-jsdoc + { + var width = this.getLocalBounds().width; + + if (width !== 0) + { + this.scale.x = value / width; + } + else + { + this.scale.x = 1; + } + + this._width = value; + }; + + /** + * The height of the Container, setting this will actually modify the scale to achieve the value set + * + * @member {number} + */ + prototypeAccessors.height.get = function () + { + return this.scale.y * this.getLocalBounds().height; + }; + + prototypeAccessors.height.set = function (value) // eslint-disable-line require-jsdoc + { + var height = this.getLocalBounds().height; + + if (height !== 0) + { + this.scale.y = value / height; + } + else + { + this.scale.y = 1; + } + + this._height = value; + }; + + Object.defineProperties( Container.prototype, prototypeAccessors ); + + return Container; + }(DisplayObject)); + + // performance increase to avoid using call.. (10x faster) + Container.prototype.containerUpdateTransform = Container.prototype.updateTransform; + + /*! + * @pixi/accessibility - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/accessibility is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Default property values of accessible objects + * used by {@link PIXI.accessibility.AccessibilityManager}. + * + * @private + * @function accessibleTarget + * @memberof PIXI.accessibility + * @type {Object} + * @example + * function MyObject() {} + * + * Object.assign( + * MyObject.prototype, + * PIXI.accessibility.accessibleTarget + * ); + */ + var accessibleTarget = { + /** + * Flag for if the object is accessible. If true AccessibilityManager will overlay a + * shadow div with attributes set + * + * @member {boolean} + * @memberof PIXI.DisplayObject# + */ + accessible: false, + + /** + * Sets the title attribute of the shadow div + * If accessibleTitle AND accessibleHint has not been this will default to 'displayObject [tabIndex]' + * + * @member {?string} + * @memberof PIXI.DisplayObject# + */ + accessibleTitle: null, + + /** + * Sets the aria-label attribute of the shadow div + * + * @member {string} + * @memberof PIXI.DisplayObject# + */ + accessibleHint: null, + + /** + * @member {number} + * @memberof PIXI.DisplayObject# + * @private + * @todo Needs docs. + */ + tabIndex: 0, + + /** + * @member {boolean} + * @memberof PIXI.DisplayObject# + * @todo Needs docs. + */ + _accessibleActive: false, + + /** + * @member {boolean} + * @memberof PIXI.DisplayObject# + * @todo Needs docs. + */ + _accessibleDiv: false, + }; + + // add some extra variables to the container.. + DisplayObject.mixin(accessibleTarget); + + var KEY_CODE_TAB = 9; + + var DIV_TOUCH_SIZE = 100; + var DIV_TOUCH_POS_X = 0; + var DIV_TOUCH_POS_Y = 0; + var DIV_TOUCH_ZINDEX = 2; + + var DIV_HOOK_SIZE = 1; + var DIV_HOOK_POS_X = -1000; + var DIV_HOOK_POS_Y = -1000; + var DIV_HOOK_ZINDEX = 2; + + /** + * The Accessibility manager recreates the ability to tab and have content read by screen readers. + * This is very important as it can possibly help people with disabilities access PixiJS content. + * + * A DisplayObject can be made accessible just like it can be made interactive. This manager will map the + * events as if the mouse was being used, minimizing the effort required to implement. + * + * An instance of this class is automatically created by default, and can be found at `renderer.plugins.accessibility` + * + * @class + * @memberof PIXI.accessibility + */ + var AccessibilityManager = function AccessibilityManager(renderer) + { + /** + * @type {?HTMLElement} + * @private + */ + this._hookDiv = null; + if (isMobile_min.tablet || isMobile_min.phone) + { + this.createTouchHook(); + } + + // first we create a div that will sit over the PixiJS element. This is where the div overlays will go. + var div = document.createElement('div'); + + div.style.width = DIV_TOUCH_SIZE + "px"; + div.style.height = DIV_TOUCH_SIZE + "px"; + div.style.position = 'absolute'; + div.style.top = DIV_TOUCH_POS_X + "px"; + div.style.left = DIV_TOUCH_POS_Y + "px"; + div.style.zIndex = DIV_TOUCH_ZINDEX; + + /** + * This is the dom element that will sit over the PixiJS element. This is where the div overlays will go. + * + * @type {HTMLElement} + * @private + */ + this.div = div; + + /** + * A simple pool for storing divs. + * + * @type {*} + * @private + */ + this.pool = []; + + /** + * This is a tick used to check if an object is no longer being rendered. + * + * @type {Number} + * @private + */ + this.renderId = 0; + + /** + * Setting this to true will visually show the divs. + * + * @type {boolean} + */ + this.debug = false; + + /** + * The renderer this accessibility manager works for. + * + * @member {PIXI.AbstractRenderer} + */ + this.renderer = renderer; + + /** + * The array of currently active accessible items. + * + * @member {Array<*>} + * @private + */ + this.children = []; + + /** + * pre-bind the functions + * + * @type {Function} + * @private + */ + this._onKeyDown = this._onKeyDown.bind(this); + + /** + * pre-bind the functions + * + * @type {Function} + * @private + */ + this._onMouseMove = this._onMouseMove.bind(this); + + /** + * A flag + * @type {boolean} + * @readonly + */ + this.isActive = false; + + /** + * A flag + * @type {boolean} + * @readonly + */ + this.isMobileAccessibility = false; + + // let listen for tab.. once pressed we can fire up and show the accessibility layer + window.addEventListener('keydown', this._onKeyDown, false); + }; + + /** + * Creates the touch hooks. + * + * @private + */ + AccessibilityManager.prototype.createTouchHook = function createTouchHook () + { + var this$1 = this; + + var hookDiv = document.createElement('button'); + + hookDiv.style.width = DIV_HOOK_SIZE + "px"; + hookDiv.style.height = DIV_HOOK_SIZE + "px"; + hookDiv.style.position = 'absolute'; + hookDiv.style.top = DIV_HOOK_POS_X + "px"; + hookDiv.style.left = DIV_HOOK_POS_Y + "px"; + hookDiv.style.zIndex = DIV_HOOK_ZINDEX; + hookDiv.style.backgroundColor = '#FF0000'; + hookDiv.title = 'HOOK DIV'; + + hookDiv.addEventListener('focus', function () { + this$1.isMobileAccessibility = true; + this$1.activate(); + this$1.destroyTouchHook(); + }); + + document.body.appendChild(hookDiv); + this._hookDiv = hookDiv; + }; + + /** + * Destroys the touch hooks. + * + * @private + */ + AccessibilityManager.prototype.destroyTouchHook = function destroyTouchHook () + { + if (!this._hookDiv) + { + return; + } + document.body.removeChild(this._hookDiv); + this._hookDiv = null; + }; + + /** + * Activating will cause the Accessibility layer to be shown. + * This is called when a user presses the tab key. + * + * @private + */ + AccessibilityManager.prototype.activate = function activate () + { + if (this.isActive) + { + return; + } + + this.isActive = true; + + window.document.addEventListener('mousemove', this._onMouseMove, true); + window.removeEventListener('keydown', this._onKeyDown, false); + + this.renderer.on('postrender', this.update, this); + + if (this.renderer.view.parentNode) + { + this.renderer.view.parentNode.appendChild(this.div); + } + }; + + /** + * Deactivating will cause the Accessibility layer to be hidden. + * This is called when a user moves the mouse. + * + * @private + */ + AccessibilityManager.prototype.deactivate = function deactivate () + { + if (!this.isActive || this.isMobileAccessibility) + { + return; + } + + this.isActive = false; + + window.document.removeEventListener('mousemove', this._onMouseMove, true); + window.addEventListener('keydown', this._onKeyDown, false); + + this.renderer.off('postrender', this.update); + + if (this.div.parentNode) + { + this.div.parentNode.removeChild(this.div); + } + }; + + /** + * This recursive function will run through the scene graph and add any new accessible objects to the DOM layer. + * + * @private + * @param {PIXI.Container} displayObject - The DisplayObject to check. + */ + AccessibilityManager.prototype.updateAccessibleObjects = function updateAccessibleObjects (displayObject) + { + if (!displayObject.visible) + { + return; + } + + if (displayObject.accessible && displayObject.interactive) + { + if (!displayObject._accessibleActive) + { + this.addChild(displayObject); + } + + displayObject.renderId = this.renderId; + } + + var children = displayObject.children; + + for (var i = 0; i < children.length; i++) + { + this.updateAccessibleObjects(children[i]); + } + }; + + /** + * Before each render this function will ensure that all divs are mapped correctly to their DisplayObjects. + * + * @private + */ + AccessibilityManager.prototype.update = function update () + { + if (!this.renderer.renderingToScreen) + { + return; + } + + // update children... + this.updateAccessibleObjects(this.renderer._lastObjectRendered); + + var rect = this.renderer.view.getBoundingClientRect(); + var sx = rect.width / this.renderer.width; + var sy = rect.height / this.renderer.height; + + var div = this.div; + + div.style.left = (rect.left) + "px"; + div.style.top = (rect.top) + "px"; + div.style.width = (this.renderer.width) + "px"; + div.style.height = (this.renderer.height) + "px"; + + for (var i = 0; i < this.children.length; i++) + { + var child = this.children[i]; + + if (child.renderId !== this.renderId) + { + child._accessibleActive = false; + + removeItems(this.children, i, 1); + this.div.removeChild(child._accessibleDiv); + this.pool.push(child._accessibleDiv); + child._accessibleDiv = null; + + i--; + + if (this.children.length === 0) + { + this.deactivate(); + } + } + else + { + // map div to display.. + div = child._accessibleDiv; + var hitArea = child.hitArea; + var wt = child.worldTransform; + + if (child.hitArea) + { + div.style.left = ((wt.tx + (hitArea.x * wt.a)) * sx) + "px"; + div.style.top = ((wt.ty + (hitArea.y * wt.d)) * sy) + "px"; + + div.style.width = (hitArea.width * wt.a * sx) + "px"; + div.style.height = (hitArea.height * wt.d * sy) + "px"; + } + else + { + hitArea = child.getBounds(); + + this.capHitArea(hitArea); + + div.style.left = (hitArea.x * sx) + "px"; + div.style.top = (hitArea.y * sy) + "px"; + + div.style.width = (hitArea.width * sx) + "px"; + div.style.height = (hitArea.height * sy) + "px"; + + // update button titles and hints if they exist and they've changed + if (div.title !== child.accessibleTitle && child.accessibleTitle !== null) + { + div.title = child.accessibleTitle; + } + if (div.getAttribute('aria-label') !== child.accessibleHint + && child.accessibleHint !== null) + { + div.setAttribute('aria-label', child.accessibleHint); + } + } + } + } + + // increment the render id.. + this.renderId++; + }; + + /** + * Adjust the hit area based on the bounds of a display object + * + * @param {Rectangle} hitArea - Bounds of the child + */ + AccessibilityManager.prototype.capHitArea = function capHitArea (hitArea) + { + if (hitArea.x < 0) + { + hitArea.width += hitArea.x; + hitArea.x = 0; + } + + if (hitArea.y < 0) + { + hitArea.height += hitArea.y; + hitArea.y = 0; + } + + if (hitArea.x + hitArea.width > this.renderer.width) + { + hitArea.width = this.renderer.width - hitArea.x; + } + + if (hitArea.y + hitArea.height > this.renderer.height) + { + hitArea.height = this.renderer.height - hitArea.y; + } + }; + + /** + * Adds a DisplayObject to the accessibility manager + * + * @private + * @param {DisplayObject} displayObject - The child to make accessible. + */ + AccessibilityManager.prototype.addChild = function addChild (displayObject) + { + //this.activate(); + + var div = this.pool.pop(); + + if (!div) + { + div = document.createElement('button'); + + div.style.width = DIV_TOUCH_SIZE + "px"; + div.style.height = DIV_TOUCH_SIZE + "px"; + div.style.backgroundColor = this.debug ? 'rgba(255,0,0,0.5)' : 'transparent'; + div.style.position = 'absolute'; + div.style.zIndex = DIV_TOUCH_ZINDEX; + div.style.borderStyle = 'none'; + + // ARIA attributes ensure that button title and hint updates are announced properly + if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) + { + // Chrome doesn't need aria-live to work as intended; in fact it just gets more confused. + div.setAttribute('aria-live', 'off'); + } + else + { + div.setAttribute('aria-live', 'polite'); + } + + if (navigator.userAgent.match(/rv:.*Gecko\//)) + { + // FireFox needs this to announce only the new button name + div.setAttribute('aria-relevant', 'additions'); + } + else + { + // required by IE, other browsers don't much care + div.setAttribute('aria-relevant', 'text'); + } + + div.addEventListener('click', this._onClick.bind(this)); + div.addEventListener('focus', this._onFocus.bind(this)); + div.addEventListener('focusout', this._onFocusOut.bind(this)); + } + + if (displayObject.accessibleTitle && displayObject.accessibleTitle !== null) + { + div.title = displayObject.accessibleTitle; + } + else if (!displayObject.accessibleHint + || displayObject.accessibleHint === null) + { + div.title = "displayObject " + (displayObject.tabIndex); + } + + if (displayObject.accessibleHint + && displayObject.accessibleHint !== null) + { + div.setAttribute('aria-label', displayObject.accessibleHint); + } + + // + + displayObject._accessibleActive = true; + displayObject._accessibleDiv = div; + div.displayObject = displayObject; + + this.children.push(displayObject); + this.div.appendChild(displayObject._accessibleDiv); + displayObject._accessibleDiv.tabIndex = displayObject.tabIndex; + }; + + /** + * Maps the div button press to pixi's InteractionManager (click) + * + * @private + * @param {MouseEvent} e - The click event. + */ + AccessibilityManager.prototype._onClick = function _onClick (e) + { + var interactionManager = this.renderer.plugins.interaction; + + interactionManager.dispatchEvent(e.target.displayObject, 'click', interactionManager.eventData); + }; + + /** + * Maps the div focus events to pixi's InteractionManager (mouseover) + * + * @private + * @param {FocusEvent} e - The focus event. + */ + AccessibilityManager.prototype._onFocus = function _onFocus (e) + { + if (!e.target.getAttribute('aria-live', 'off')) + { + e.target.setAttribute('aria-live', 'assertive'); + } + var interactionManager = this.renderer.plugins.interaction; + + interactionManager.dispatchEvent(e.target.displayObject, 'mouseover', interactionManager.eventData); + }; + + /** + * Maps the div focus events to pixi's InteractionManager (mouseout) + * + * @private + * @param {FocusEvent} e - The focusout event. + */ + AccessibilityManager.prototype._onFocusOut = function _onFocusOut (e) + { + if (!e.target.getAttribute('aria-live', 'off')) + { + e.target.setAttribute('aria-live', 'polite'); + } + var interactionManager = this.renderer.plugins.interaction; + + interactionManager.dispatchEvent(e.target.displayObject, 'mouseout', interactionManager.eventData); + }; + + /** + * Is called when a key is pressed + * + * @private + * @param {KeyboardEvent} e - The keydown event. + */ + AccessibilityManager.prototype._onKeyDown = function _onKeyDown (e) + { + if (e.keyCode !== KEY_CODE_TAB) + { + return; + } + + this.activate(); + }; + + /** + * Is called when the mouse moves across the renderer element + * + * @private + * @param {MouseEvent} e - The mouse event. + */ + AccessibilityManager.prototype._onMouseMove = function _onMouseMove (e) + { + if (e.movementX === 0 && e.movementY === 0) + { + return; + } + + this.deactivate(); + }; + + /** + * Destroys the accessibility manager + * + */ + AccessibilityManager.prototype.destroy = function destroy () + { + this.destroyTouchHook(); + this.div = null; + + for (var i = 0; i < this.children.length; i++) + { + this.children[i].div = null; + } + + window.document.removeEventListener('mousemove', this._onMouseMove, true); + window.removeEventListener('keydown', this._onKeyDown); + + this.pool = null; + this.children = null; + this.renderer = null; + }; + + var accessibility_es = ({ + AccessibilityManager: AccessibilityManager, + accessibleTarget: accessibleTarget + }); + + /*! + * @pixi/runner - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/runner is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + /** + * A Runner is a highly performant and simple alternative to signals. Best used in situations + * where events are dispatched to many objects at high frequency (say every frame!) + * + * + * like a signal.. + * ``` + * const myObject = { + * loaded: new PIXI.Runner('loaded') + * } + * + * const listener = { + * loaded: function(){ + * // thin + * } + * } + * + * myObject.update.add(listener); + * + * myObject.loaded.emit(); + * ``` + * + * Or for handling calling the same function on many items + * ``` + * const myGame = { + * update: new PIXI.Runner('update') + * } + * + * const gameObject = { + * update: function(time){ + * // update my gamey state + * } + * } + * + * myGame.update.add(gameObject1); + * + * myGame.update.emit(time); + * ``` + * @class + * @memberof PIXI + */ + var Runner = function Runner(name) + { + this.items = []; + this._name = name; + }; + + var prototypeAccessors$3 = { empty: { configurable: true },name: { configurable: true } }; + + /** + * Dispatch/Broadcast Runner to all listeners added to the queue. + * @param {...any} params - optional parameters to pass to each listener + */ + Runner.prototype.emit = function emit (a0, a1, a2, a3, a4, a5, a6, a7) + { + if (arguments.length > 8) + { + throw new Error('max arguments reached'); + } + + var ref = this; + var name = ref.name; + var items = ref.items; + + for (var i = 0, len = items.length; i < len; i++) + { + items[i][name](a0, a1, a2, a3, a4, a5, a6, a7); + } + + return this; + }; + + /** + * Add a listener to the Runner + * + * Runners do not need to have scope or functions passed to them. + * All that is required is to pass the listening object and ensure that it has contains a function that has the same name + * as the name provided to the Runner when it was created. + * + * Eg A listener passed to this Runner will require a 'complete' function. + * + * ``` + * const complete = new PIXI.Runner('complete'); + * ``` + * + * The scope used will be the object itself. + * + * @param {any} item - The object that will be listening. + */ + Runner.prototype.add = function add (item) + { + if (item[this._name]) + { + this.remove(item); + this.items.push(item); + } + + return this; + }; + + /** + * Remove a single listener from the dispatch queue. + * @param {any} item - The listenr that you would like to remove. + */ + Runner.prototype.remove = function remove (item) + { + var index = this.items.indexOf(item); + + if (index !== -1) + { + this.items.splice(index, 1); + } + + return this; + }; + + /** + * Check to see if the listener is already in the Runner + * @param {any} item - The listener that you would like to check. + */ + Runner.prototype.contains = function contains (item) + { + return this.items.indexOf(item) !== -1; + }; + + /** + * Remove all listeners from the Runner + */ + Runner.prototype.removeAll = function removeAll () + { + this.items.length = 0; + + return this; + }; + + /** + * Remove all references, don't use after this. + */ + Runner.prototype.destroy = function destroy () + { + this.removeAll(); + this.items = null; + this._name = null; + }; + + /** + * `true` if there are no this Runner contains no listeners + * + * @member {boolean} + * @readonly + */ + prototypeAccessors$3.empty.get = function () + { + return this.items.length === 0; + }; + + /** + * The name of the runner. + * + * @member {string} + * @readonly + */ + prototypeAccessors$3.name.get = function () + { + return this._name; + }; + + Object.defineProperties( Runner.prototype, prototypeAccessors$3 ); + + /** + * Alias for `emit` + * @memberof PIXI.Runner# + * @method dispatch + * @see PIXI.Runner#emit + */ + Runner.prototype.dispatch = Runner.prototype.emit; + + /** + * Alias for `emit` + * @memberof PIXI.Runner# + * @method run + * @see PIXI.Runner#emit + */ + Runner.prototype.run = Runner.prototype.emit; + + /*! + * @pixi/ticker - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/ticker is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Target frames per millisecond. + * + * @static + * @name TARGET_FPMS + * @memberof PIXI.settings + * @type {number} + * @default 0.06 + */ + settings.TARGET_FPMS = 0.06; + + /** + * Represents the update priorities used by internal PIXI classes when registered with + * the {@link PIXI.Ticker} object. Higher priority items are updated first and lower + * priority items, such as render, should go later. + * + * @static + * @constant + * @name UPDATE_PRIORITY + * @memberof PIXI + * @type {object} + * @property {number} INTERACTION=50 Highest priority, used for {@link PIXI.interaction.InteractionManager} + * @property {number} HIGH=25 High priority updating, {@link PIXI.VideoBaseTexture} and {@link PIXI.AnimatedSprite} + * @property {number} NORMAL=0 Default priority for ticker events, see {@link PIXI.Ticker#add}. + * @property {number} LOW=-25 Low priority used for {@link PIXI.Application} rendering. + * @property {number} UTILITY=-50 Lowest priority used for {@link PIXI.prepare.BasePrepare} utility. + */ + var UPDATE_PRIORITY = { + INTERACTION: 50, + HIGH: 25, + NORMAL: 0, + LOW: -25, + UTILITY: -50, + }; + + /** + * Internal class for handling the priority sorting of ticker handlers. + * + * @private + * @class + * @memberof PIXI + */ + var TickerListener = function TickerListener(fn, context, priority, once) + { + if ( context === void 0 ) { context = null; } + if ( priority === void 0 ) { priority = 0; } + if ( once === void 0 ) { once = false; } + + /** + * The handler function to execute. + * @private + * @member {Function} + */ + this.fn = fn; + + /** + * The calling to execute. + * @private + * @member {*} + */ + this.context = context; + + /** + * The current priority. + * @private + * @member {number} + */ + this.priority = priority; + + /** + * If this should only execute once. + * @private + * @member {boolean} + */ + this.once = once; + + /** + * The next item in chain. + * @private + * @member {TickerListener} + */ + this.next = null; + + /** + * The previous item in chain. + * @private + * @member {TickerListener} + */ + this.previous = null; + + /** + * `true` if this listener has been destroyed already. + * @member {boolean} + * @private + */ + this._destroyed = false; + }; + + /** + * Simple compare function to figure out if a function and context match. + * @private + * @param {Function} fn - The listener function to be added for one update + * @param {Function} context - The listener context + * @return {boolean} `true` if the listener match the arguments + */ + TickerListener.prototype.match = function match (fn, context) + { + context = context || null; + + return this.fn === fn && this.context === context; + }; + + /** + * Emit by calling the current function. + * @private + * @param {number} deltaTime - time since the last emit. + * @return {TickerListener} Next ticker + */ + TickerListener.prototype.emit = function emit (deltaTime) + { + if (this.fn) + { + if (this.context) + { + this.fn.call(this.context, deltaTime); + } + else + { + this.fn(deltaTime); + } + } + + var redirect = this.next; + + if (this.once) + { + this.destroy(true); + } + + // Soft-destroying should remove + // the next reference + if (this._destroyed) + { + this.next = null; + } + + return redirect; + }; + + /** + * Connect to the list. + * @private + * @param {TickerListener} previous - Input node, previous listener + */ + TickerListener.prototype.connect = function connect (previous) + { + this.previous = previous; + if (previous.next) + { + previous.next.previous = this; + } + this.next = previous.next; + previous.next = this; + }; + + /** + * Destroy and don't use after this. + * @private + * @param {boolean} [hard = false] `true` to remove the `next` reference, this + * is considered a hard destroy. Soft destroy maintains the next reference. + * @return {TickerListener} The listener to redirect while emitting or removing. + */ + TickerListener.prototype.destroy = function destroy (hard) + { + if ( hard === void 0 ) { hard = false; } + + this._destroyed = true; + this.fn = null; + this.context = null; + + // Disconnect, hook up next and previous + if (this.previous) + { + this.previous.next = this.next; + } + + if (this.next) + { + this.next.previous = this.previous; + } + + // Redirect to the next item + var redirect = this.next; + + // Remove references + this.next = hard ? null : redirect; + this.previous = null; + + return redirect; + }; + + /** + * A Ticker class that runs an update loop that other objects listen to. + * + * This class is composed around listeners meant for execution on the next requested animation frame. + * Animation frames are requested only when necessary, e.g. When the ticker is started and the emitter has listeners. + * + * @class + * @memberof PIXI + */ + var Ticker = function Ticker() + { + var this$1 = this; + + /** + * The first listener. All new listeners added are chained on this. + * @private + * @type {TickerListener} + */ + this._head = new TickerListener(null, null, Infinity); + + /** + * Internal current frame request ID + * @type {?number} + * @private + */ + this._requestId = null; + + /** + * Internal value managed by minFPS property setter and getter. + * This is the maximum allowed milliseconds between updates. + * @type {number} + * @private + */ + this._maxElapsedMS = 100; + + /** + * Internal value managed by maxFPS property setter and getter. + * This is the minimum allowed milliseconds between updates. + * @private + */ + this._minElapsedMS = 0; + + /** + * Whether or not this ticker should invoke the method + * {@link PIXI.Ticker#start} automatically + * when a listener is added. + * + * @member {boolean} + * @default false + */ + this.autoStart = false; + + /** + * Scalar time value from last frame to this frame. + * This value is capped by setting {@link PIXI.Ticker#minFPS} + * and is scaled with {@link PIXI.Ticker#speed}. + * **Note:** The cap may be exceeded by scaling. + * + * @member {number} + * @default 1 + */ + this.deltaTime = 1; + + /** + * Scaler time elapsed in milliseconds from last frame to this frame. + * This value is capped by setting {@link PIXI.Ticker#minFPS} + * and is scaled with {@link PIXI.Ticker#speed}. + * **Note:** The cap may be exceeded by scaling. + * If the platform supports DOMHighResTimeStamp, + * this value will have a precision of 1 µs. + * Defaults to target frame time + * + * @member {number} + * @default 16.66 + */ + this.deltaMS = 1 / settings.TARGET_FPMS; + + /** + * Time elapsed in milliseconds from last frame to this frame. + * Opposed to what the scalar {@link PIXI.Ticker#deltaTime} + * is based, this value is neither capped nor scaled. + * If the platform supports DOMHighResTimeStamp, + * this value will have a precision of 1 µs. + * Defaults to target frame time + * + * @member {number} + * @default 16.66 + */ + this.elapsedMS = 1 / settings.TARGET_FPMS; + + /** + * The last time {@link PIXI.Ticker#update} was invoked. + * This value is also reset internally outside of invoking + * update, but only when a new animation frame is requested. + * If the platform supports DOMHighResTimeStamp, + * this value will have a precision of 1 µs. + * + * @member {number} + * @default -1 + */ + this.lastTime = -1; + + /** + * Factor of current {@link PIXI.Ticker#deltaTime}. + * @example + * // Scales ticker.deltaTime to what would be + * // the equivalent of approximately 120 FPS + * ticker.speed = 2; + * + * @member {number} + * @default 1 + */ + this.speed = 1; + + /** + * Whether or not this ticker has been started. + * `true` if {@link PIXI.Ticker#start} has been called. + * `false` if {@link PIXI.Ticker#stop} has been called. + * While `false`, this value may change to `true` in the + * event of {@link PIXI.Ticker#autoStart} being `true` + * and a listener is added. + * + * @member {boolean} + * @default false + */ + this.started = false; + + /** + * If enabled, deleting is disabled. + * @member {boolean} + * @default false + * @private + */ + this._protected = false; + + /** + * Internal tick method bound to ticker instance. + * This is because in early 2015, Function.bind + * is still 60% slower in high performance scenarios. + * Also separating frame requests from update method + * so listeners may be called at any time and with + * any animation API, just invoke ticker.update(time). + * + * @private + * @param {number} time - Time since last tick. + */ + this._tick = function (time) { + this$1._requestId = null; + + if (this$1.started) + { + // Invoke listeners now + this$1.update(time); + // Listener side effects may have modified ticker state. + if (this$1.started && this$1._requestId === null && this$1._head.next) + { + this$1._requestId = requestAnimationFrame(this$1._tick); + } + } + }; + }; + + var prototypeAccessors$4 = { FPS: { configurable: true },minFPS: { configurable: true },maxFPS: { configurable: true } }; + var staticAccessors$2 = { shared: { configurable: true },system: { configurable: true } }; + + /** + * Conditionally requests a new animation frame. + * If a frame has not already been requested, and if the internal + * emitter has listeners, a new frame is requested. + * + * @private + */ + Ticker.prototype._requestIfNeeded = function _requestIfNeeded () + { + if (this._requestId === null && this._head.next) + { + // ensure callbacks get correct delta + this.lastTime = performance.now(); + this._requestId = requestAnimationFrame(this._tick); + } + }; + + /** + * Conditionally cancels a pending animation frame. + * + * @private + */ + Ticker.prototype._cancelIfNeeded = function _cancelIfNeeded () + { + if (this._requestId !== null) + { + cancelAnimationFrame(this._requestId); + this._requestId = null; + } + }; + + /** + * Conditionally requests a new animation frame. + * If the ticker has been started it checks if a frame has not already + * been requested, and if the internal emitter has listeners. If these + * conditions are met, a new frame is requested. If the ticker has not + * been started, but autoStart is `true`, then the ticker starts now, + * and continues with the previous conditions to request a new frame. + * + * @private + */ + Ticker.prototype._startIfPossible = function _startIfPossible () + { + if (this.started) + { + this._requestIfNeeded(); + } + else if (this.autoStart) + { + this.start(); + } + }; + + /** + * Register a handler for tick events. Calls continuously unless + * it is removed or the ticker is stopped. + * + * @param {Function} fn - The listener function to be added for updates + * @param {*} [context] - The listener context + * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting + * @returns {PIXI.Ticker} This instance of a ticker + */ + Ticker.prototype.add = function add (fn, context, priority) + { + if ( priority === void 0 ) { priority = UPDATE_PRIORITY.NORMAL; } + + return this._addListener(new TickerListener(fn, context, priority)); + }; + + /** + * Add a handler for the tick event which is only execute once. + * + * @param {Function} fn - The listener function to be added for one update + * @param {*} [context] - The listener context + * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting + * @returns {PIXI.Ticker} This instance of a ticker + */ + Ticker.prototype.addOnce = function addOnce (fn, context, priority) + { + if ( priority === void 0 ) { priority = UPDATE_PRIORITY.NORMAL; } + + return this._addListener(new TickerListener(fn, context, priority, true)); + }; + + /** + * Internally adds the event handler so that it can be sorted by priority. + * Priority allows certain handler (user, AnimatedSprite, Interaction) to be run + * before the rendering. + * + * @private + * @param {TickerListener} listener - Current listener being added. + * @returns {PIXI.Ticker} This instance of a ticker + */ + Ticker.prototype._addListener = function _addListener (listener) + { + // For attaching to head + var current = this._head.next; + var previous = this._head; + + // Add the first item + if (!current) + { + listener.connect(previous); + } + else + { + // Go from highest to lowest priority + while (current) + { + if (listener.priority > current.priority) + { + listener.connect(previous); + break; + } + previous = current; + current = current.next; + } + + // Not yet connected + if (!listener.previous) + { + listener.connect(previous); + } + } + + this._startIfPossible(); + + return this; + }; + + /** + * Removes any handlers matching the function and context parameters. + * If no handlers are left after removing, then it cancels the animation frame. + * + * @param {Function} fn - The listener function to be removed + * @param {*} [context] - The listener context to be removed + * @returns {PIXI.Ticker} This instance of a ticker + */ + Ticker.prototype.remove = function remove (fn, context) + { + var listener = this._head.next; + + while (listener) + { + // We found a match, lets remove it + // no break to delete all possible matches + // incase a listener was added 2+ times + if (listener.match(fn, context)) + { + listener = listener.destroy(); + } + else + { + listener = listener.next; + } + } + + if (!this._head.next) + { + this._cancelIfNeeded(); + } + + return this; + }; + + /** + * Starts the ticker. If the ticker has listeners + * a new animation frame is requested at this point. + */ + Ticker.prototype.start = function start () + { + if (!this.started) + { + this.started = true; + this._requestIfNeeded(); + } + }; + + /** + * Stops the ticker. If the ticker has requested + * an animation frame it is canceled at this point. + */ + Ticker.prototype.stop = function stop () + { + if (this.started) + { + this.started = false; + this._cancelIfNeeded(); + } + }; + + /** + * Destroy the ticker and don't use after this. Calling + * this method removes all references to internal events. + */ + Ticker.prototype.destroy = function destroy () + { + if (!this._protected) + { + this.stop(); + + var listener = this._head.next; + + while (listener) + { + listener = listener.destroy(true); + } + + this._head.destroy(); + this._head = null; + } + }; + + /** + * Triggers an update. An update entails setting the + * current {@link PIXI.Ticker#elapsedMS}, + * the current {@link PIXI.Ticker#deltaTime}, + * invoking all listeners with current deltaTime, + * and then finally setting {@link PIXI.Ticker#lastTime} + * with the value of currentTime that was provided. + * This method will be called automatically by animation + * frame callbacks if the ticker instance has been started + * and listeners are added. + * + * @param {number} [currentTime=performance.now()] - the current time of execution + */ + Ticker.prototype.update = function update (currentTime) + { + if ( currentTime === void 0 ) { currentTime = performance.now(); } + + var elapsedMS; + + // If the difference in time is zero or negative, we ignore most of the work done here. + // If there is no valid difference, then should be no reason to let anyone know about it. + // A zero delta, is exactly that, nothing should update. + // + // The difference in time can be negative, and no this does not mean time traveling. + // This can be the result of a race condition between when an animation frame is requested + // on the current JavaScript engine event loop, and when the ticker's start method is invoked + // (which invokes the internal _requestIfNeeded method). If a frame is requested before + // _requestIfNeeded is invoked, then the callback for the animation frame the ticker requests, + // can receive a time argument that can be less than the lastTime value that was set within + // _requestIfNeeded. This difference is in microseconds, but this is enough to cause problems. + // + // This check covers this browser engine timing issue, as well as if consumers pass an invalid + // currentTime value. This may happen if consumers opt-out of the autoStart, and update themselves. + + if (currentTime > this.lastTime) + { + // Save uncapped elapsedMS for measurement + elapsedMS = this.elapsedMS = currentTime - this.lastTime; + + // cap the milliseconds elapsed used for deltaTime + if (elapsedMS > this._maxElapsedMS) + { + elapsedMS = this._maxElapsedMS; + } + + elapsedMS *= this.speed; + + // if not enough time has passed, exit the function. + // We give an extra ms to elapsedMS for this check, because the nature of + // request animation frame means that not all browsers will return precise values. + // However, because rAF works based on v-sync, it's won't change the effective FPS. + if (this._minElapsedMS && elapsedMS + 1 < this._minElapsedMS) + { + return; + } + + this.deltaMS = elapsedMS; + this.deltaTime = this.deltaMS * settings.TARGET_FPMS; + + // Cache a local reference, in-case ticker is destroyed + // during the emit, we can still check for head.next + var head = this._head; + + // Invoke listeners added to internal emitter + var listener = head.next; + + while (listener) + { + listener = listener.emit(this.deltaTime); + } + + if (!head.next) + { + this._cancelIfNeeded(); + } + } + else + { + this.deltaTime = this.deltaMS = this.elapsedMS = 0; + } + + this.lastTime = currentTime; + }; + + /** + * The frames per second at which this ticker is running. + * The default is approximately 60 in most modern browsers. + * **Note:** This does not factor in the value of + * {@link PIXI.Ticker#speed}, which is specific + * to scaling {@link PIXI.Ticker#deltaTime}. + * + * @member {number} + * @readonly + */ + prototypeAccessors$4.FPS.get = function () + { + return 1000 / this.elapsedMS; + }; + + /** + * Manages the maximum amount of milliseconds allowed to + * elapse between invoking {@link PIXI.Ticker#update}. + * This value is used to cap {@link PIXI.Ticker#deltaTime}, + * but does not effect the measured value of {@link PIXI.Ticker#FPS}. + * When setting this property it is clamped to a value between + * `0` and `PIXI.settings.TARGET_FPMS * 1000`. + * + * @member {number} + * @default 10 + */ + prototypeAccessors$4.minFPS.get = function () + { + return 1000 / this._maxElapsedMS; + }; + + prototypeAccessors$4.minFPS.set = function (fps) // eslint-disable-line require-jsdoc + { + // Minimum must be below the maxFPS + var minFPS = Math.min(this.maxFPS, fps); + + // Must be at least 0, but below 1 / settings.TARGET_FPMS + var minFPMS = Math.min(Math.max(0, minFPS) / 1000, settings.TARGET_FPMS); + + this._maxElapsedMS = 1 / minFPMS; + }; + + /** + * Manages the minimum amount of milliseconds allowed to + * elapse between invoking {@link PIXI.Ticker#update}. + * This will effect the measured value of {@link PIXI.Ticker#FPS}. + * When setting this property it is clamped to a value between + * `1` and `TARGET_FPMS * 1000`. + * + * @member {number} + * @default 60 + */ + prototypeAccessors$4.maxFPS.get = function () + { + if (this._minElapsedMS) + { + return 1000 / this._minElapsedMS; + } + + return settings.TARGET_FPMS * 1000; + }; + + prototypeAccessors$4.maxFPS.set = function (fps) + { + if (fps / 1000 >= settings.TARGET_FPMS) + { + this._minElapsedMS = 0; + } + else + { + // Max must be at least the minFPS + var maxFPS = Math.max(this.minFPS, fps); + + // Must be at least 1, but below 1 / settings.TARGET_FPMS + var maxFPMS = Math.min(Math.max(1, maxFPS) / 1000, settings.TARGET_FPMS); + + this._minElapsedMS = 1 / maxFPMS; + } + }; + + /** + * The shared ticker instance used by {@link PIXI.AnimatedSprite} and by + * {@link PIXI.VideoResource} to update animation frames / video textures. + * + * It may also be used by {@link PIXI.Application} if created with the `sharedTicker` option property set to true. + * + * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance. + * Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker. + * + * @example + * let ticker = PIXI.Ticker.shared; + * // Set this to prevent starting this ticker when listeners are added. + * // By default this is true only for the PIXI.Ticker.shared instance. + * ticker.autoStart = false; + * // FYI, call this to ensure the ticker is stopped. It should be stopped + * // if you have not attempted to render anything yet. + * ticker.stop(); + * // Call this when you are ready for a running shared ticker. + * ticker.start(); + * + * @example + * // You may use the shared ticker to render... + * let renderer = PIXI.autoDetectRenderer(); + * let stage = new PIXI.Container(); + * document.body.appendChild(renderer.view); + * ticker.add(function (time) { + * renderer.render(stage); + * }); + * + * @example + * // Or you can just update it manually. + * ticker.autoStart = false; + * ticker.stop(); + * function animate(time) { + * ticker.update(time); + * renderer.render(stage); + * requestAnimationFrame(animate); + * } + * animate(performance.now()); + * + * @member {PIXI.Ticker} + * @static + */ + staticAccessors$2.shared.get = function () + { + if (!Ticker._shared) + { + var shared = Ticker._shared = new Ticker(); + + shared.autoStart = true; + shared._protected = true; + } + + return Ticker._shared; + }; + + /** + * The system ticker instance used by {@link PIXI.interaction.InteractionManager} and by + * {@link PIXI.BasePrepare} for core timing functionality that shouldn't usually need to be paused, + * unlike the `shared` ticker which drives visual animations and rendering which may want to be paused. + * + * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance. + * + * @member {PIXI.Ticker} + * @static + */ + staticAccessors$2.system.get = function () + { + if (!Ticker._system) + { + var system = Ticker._system = new Ticker(); + + system.autoStart = true; + system._protected = true; + } + + return Ticker._system; + }; + + Object.defineProperties( Ticker.prototype, prototypeAccessors$4 ); + Object.defineProperties( Ticker, staticAccessors$2 ); + + /** + * Middleware for for Application Ticker. + * + * @example + * import {TickerPlugin} from '@pixi/ticker'; + * import {Application} from '@pixi/app'; + * Application.registerPlugin(TickerPlugin); + * + * @class + * @memberof PIXI + */ + var TickerPlugin = function TickerPlugin () {}; + + TickerPlugin.init = function init (options) + { + var this$1 = this; + + // Set default + options = Object.assign({ + autoStart: true, + sharedTicker: false, + }, options); + + // Create ticker setter + Object.defineProperty(this, 'ticker', + { + set: function set(ticker) + { + if (this._ticker) + { + this._ticker.remove(this.render, this); + } + this._ticker = ticker; + if (ticker) + { + ticker.add(this.render, this, UPDATE_PRIORITY.LOW); + } + }, + get: function get() + { + return this._ticker; + }, + }); + + /** + * Convenience method for stopping the render. + * + * @method PIXI.Application#stop + */ + this.stop = function () { + this$1._ticker.stop(); + }; + + /** + * Convenience method for starting the render. + * + * @method PIXI.Application#start + */ + this.start = function () { + this$1._ticker.start(); + }; + + /** + * Internal reference to the ticker. + * + * @type {PIXI.Ticker} + * @name _ticker + * @memberof PIXI.Application# + * @private + */ + this._ticker = null; + + /** + * Ticker for doing render updates. + * + * @type {PIXI.Ticker} + * @name ticker + * @memberof PIXI.Application# + * @default PIXI.Ticker.shared + */ + this.ticker = options.sharedTicker ? Ticker.shared : new Ticker(); + + // Start the rendering + if (options.autoStart) + { + this.start(); + } + }; + + /** + * Clean up the ticker, scoped to application. + * + * @static + * @private + */ + TickerPlugin.destroy = function destroy () + { + if (this._ticker) + { + var oldTicker = this._ticker; + + this.ticker = null; + oldTicker.destroy(); + } + }; + + /*! + * @pixi/core - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/core is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Base resource class for textures that manages validation and uploading, depending on its type. + * + * Uploading of a base texture to the GPU is required. + * + * @class + * @memberof PIXI.resources + */ + var Resource = function Resource(width, height) + { + if ( width === void 0 ) { width = 0; } + if ( height === void 0 ) { height = 0; } + + /** + * Internal width of the resource + * @member {number} + * @protected + */ + this._width = width; + + /** + * Internal height of the resource + * @member {number} + * @protected + */ + this._height = height; + + /** + * If resource has been destroyed + * @member {boolean} + * @readonly + * @default false + */ + this.destroyed = false; + + /** + * `true` if resource is created by BaseTexture + * useful for doing cleanup with BaseTexture destroy + * and not cleaning up resources that were created + * externally. + * @member {boolean} + * @protected + */ + this.internal = false; + + /** + * Mini-runner for handling resize events + * + * @member {Runner} + * @private + */ + this.onResize = new Runner('setRealSize', 2); + + /** + * Mini-runner for handling update events + * + * @member {Runner} + * @private + */ + this.onUpdate = new Runner('update'); + }; + + var prototypeAccessors$5 = { valid: { configurable: true },width: { configurable: true },height: { configurable: true } }; + + /** + * Bind to a parent BaseTexture + * + * @param {PIXI.BaseTexture} baseTexture - Parent texture + */ + Resource.prototype.bind = function bind (baseTexture) + { + this.onResize.add(baseTexture); + this.onUpdate.add(baseTexture); + + // Call a resize immediate if we already + // have the width and height of the resource + if (this._width || this._height) + { + this.onResize.run(this._width, this._height); + } + }; + + /** + * Unbind to a parent BaseTexture + * + * @param {PIXI.BaseTexture} baseTexture - Parent texture + */ + Resource.prototype.unbind = function unbind (baseTexture) + { + this.onResize.remove(baseTexture); + this.onUpdate.remove(baseTexture); + }; + + /** + * Trigger a resize event + */ + Resource.prototype.resize = function resize (width, height) + { + if (width !== this._width || height !== this._height) + { + this._width = width; + this._height = height; + this.onResize.run(width, height); + } + }; + + /** + * Has been validated + * @readonly + * @member {boolean} + */ + prototypeAccessors$5.valid.get = function () + { + return !!this._width && !!this._height; + }; + + /** + * Has been updated trigger event + */ + Resource.prototype.update = function update () + { + if (!this.destroyed) + { + this.onUpdate.run(); + } + }; + + /** + * This can be overridden to start preloading a resource + * or do any other prepare step. + * @protected + * @return {Promise} Handle the validate event + */ + Resource.prototype.load = function load () + { + return Promise.resolve(); + }; + + /** + * The width of the resource. + * + * @member {number} + * @readonly + */ + prototypeAccessors$5.width.get = function () + { + return this._width; + }; + + /** + * The height of the resource. + * + * @member {number} + * @readonly + */ + prototypeAccessors$5.height.get = function () + { + return this._height; + }; + + /** + * Uploads the texture or returns false if it cant for some reason. Override this. + * + * @param {PIXI.Renderer} renderer - yeah, renderer! + * @param {PIXI.BaseTexture} baseTexture - the texture + * @param {PIXI.GLTexture} glTexture - texture instance for this webgl context + * @returns {boolean} true is success + */ + Resource.prototype.upload = function upload (renderer, baseTexture, glTexture) // eslint-disable-line no-unused-vars + { + return false; + }; + + /** + * Set the style, optional to override + * + * @param {PIXI.Renderer} renderer - yeah, renderer! + * @param {PIXI.BaseTexture} baseTexture - the texture + * @param {PIXI.GLTexture} glTexture - texture instance for this webgl context + * @returns {boolean} `true` is success + */ + Resource.prototype.style = function style (renderer, baseTexture, glTexture) // eslint-disable-line no-unused-vars + { + return false; + }; + + /** + * Clean up anything, this happens when destroying is ready. + * + * @protected + */ + Resource.prototype.dispose = function dispose () + { + // override + }; + + /** + * Call when destroying resource, unbind any BaseTexture object + * before calling this method, as reference counts are maintained + * internally. + */ + Resource.prototype.destroy = function destroy () + { + if (!this.destroyed) + { + this.onResize.removeAll(); + this.onResize = null; + this.onUpdate.removeAll(); + this.onUpdate = null; + this.destroyed = true; + this.dispose(); + } + }; + + Object.defineProperties( Resource.prototype, prototypeAccessors$5 ); + + /** + * Base for all the image/canvas resources + * @class + * @extends PIXI.resources.Resource + * @memberof PIXI.resources + */ + var BaseImageResource = /*@__PURE__*/(function (Resource) { + function BaseImageResource(source) + { + Resource.call(this, source.width, source.height); + + /** + * The source element + * @member {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|SVGElement} + * @readonly + */ + this.source = source; + } + + if ( Resource ) { BaseImageResource.__proto__ = Resource; } + BaseImageResource.prototype = Object.create( Resource && Resource.prototype ); + BaseImageResource.prototype.constructor = BaseImageResource; + + /** + * Set cross origin based detecting the url and the crossorigin + * @protected + * @param {HTMLElement} element - Element to apply crossOrigin + * @param {string} url - URL to check + * @param {boolean|string} [crossorigin=true] - Cross origin value to use + */ + BaseImageResource.crossOrigin = function crossOrigin (element, url, crossorigin) + { + if (crossorigin === undefined && url.indexOf('data:') !== 0) + { + element.crossOrigin = determineCrossOrigin(url); + } + else if (crossorigin !== false) + { + element.crossOrigin = typeof crossorigin === 'string' ? crossorigin : 'anonymous'; + } + }; + + /** + * Upload the texture to the GPU. + * @param {PIXI.Renderer} renderer Upload to the renderer + * @param {PIXI.BaseTexture} baseTexture Reference to parent texture + * @param {PIXI.GLTexture} glTexture + * @param {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|SVGElement} [source] (optional) + * @returns {boolean} true is success + */ + BaseImageResource.prototype.upload = function upload (renderer, baseTexture, glTexture, source) + { + var gl = renderer.gl; + var width = baseTexture.realWidth; + var height = baseTexture.realHeight; + + source = source || this.source; + + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.premultiplyAlpha); + + if (baseTexture.target === gl.TEXTURE_2D && glTexture.width === width && glTexture.height === height) + { + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, baseTexture.format, baseTexture.type, source); + } + else + { + glTexture.width = width; + glTexture.height = height; + + gl.texImage2D(baseTexture.target, 0, baseTexture.format, baseTexture.format, baseTexture.type, source); + } + + return true; + }; + + /** + * Destroy this BaseImageResource + * @override + * @param {PIXI.BaseTexture} [fromTexture] Optional base texture + * @return {boolean} Destroy was successful + */ + BaseImageResource.prototype.dispose = function dispose () + { + this.source = null; + }; + + return BaseImageResource; + }(Resource)); + + /** + * Resource type for HTMLImageElement. + * @class + * @extends PIXI.resources.BaseImageResource + * @memberof PIXI.resources + */ + var ImageResource = /*@__PURE__*/(function (BaseImageResource) { + function ImageResource(source, options) + { + options = options || {}; + + if (!(source instanceof HTMLImageElement)) + { + var imageElement = new Image(); + + BaseImageResource.crossOrigin(imageElement, source, options.crossorigin); + + imageElement.src = source; + source = imageElement; + } + + BaseImageResource.call(this, source); + + /** + * URL of the image source + * @member {string} + */ + this.url = source.src; + + /** + * When process is completed + * @member {Promise} + * @private + */ + this._process = null; + + /** + * If the image should be disposed after upload + * @member {boolean} + * @default false + */ + this.preserveBitmap = false; + + /** + * If capable, convert the image using createImageBitmap API + * @member {boolean} + * @default PIXI.settings.CREATE_IMAGE_BITMAP + */ + this.createBitmap = options.createBitmap !== false && settings.CREATE_IMAGE_BITMAP && !!window.createImageBitmap; + + /** + * Controls texture premultiplyAlpha field + * Copies from options + * @member {boolean|null} + * @readonly + */ + this.premultiplyAlpha = options.premultiplyAlpha !== false; + + /** + * The ImageBitmap element created for HTMLImageElement + * @member {ImageBitmap} + * @default null + */ + this.bitmap = null; + + /** + * Promise when loading + * @member {Promise} + * @private + * @default null + */ + this._load = null; + + if (options.autoLoad !== false) + { + this.load(); + } + } + + if ( BaseImageResource ) { ImageResource.__proto__ = BaseImageResource; } + ImageResource.prototype = Object.create( BaseImageResource && BaseImageResource.prototype ); + ImageResource.prototype.constructor = ImageResource; + + /** + * returns a promise when image will be loaded and processed + * + * @param {boolean} [createBitmap=true] whether process image into bitmap + * @returns {Promise} + */ + ImageResource.prototype.load = function load (createBitmap) + { + var this$1 = this; + + if (createBitmap !== undefined) + { + this.createBitmap = createBitmap; + } + + if (this._load) + { + return this._load; + } + + this._load = new Promise(function (resolve) { + this$1.url = this$1.source.src; + var ref = this$1; + var source = ref.source; + + var completed = function () { + if (this$1.destroyed) + { + return; + } + source.onload = null; + source.onerror = null; + + this$1.resize(source.width, source.height); + this$1._load = null; + + if (this$1.createBitmap) + { + resolve(this$1.process()); + } + else + { + resolve(this$1); + } + }; + + if (source.complete && source.src) + { + completed(); + } + else + { + source.onload = completed; + } + }); + + return this._load; + }; + + /** + * Called when we need to convert image into BitmapImage. + * Can be called multiple times, real promise is cached inside. + * + * @returns {Promise} cached promise to fill that bitmap + */ + ImageResource.prototype.process = function process () + { + var this$1 = this; + + if (this._process !== null) + { + return this._process; + } + if (this.bitmap !== null || !window.createImageBitmap) + { + return Promise.resolve(this); + } + + this._process = window.createImageBitmap(this.source, + 0, 0, this.source.width, this.source.height, + { + premultiplyAlpha: this.premultiplyAlpha ? 'premultiply' : 'none', + }) + .then(function (bitmap) { + if (this$1.destroyed) + { + return Promise.reject(); + } + this$1.bitmap = bitmap; + this$1.update(); + this$1._process = null; + + return Promise.resolve(this$1); + }); + + return this._process; + }; + + /** + * Upload the image resource to GPU. + * + * @param {PIXI.Renderer} renderer - Renderer to upload to + * @param {PIXI.BaseTexture} baseTexture - BaseTexture for this resource + * @param {PIXI.GLTexture} glTexture - GLTexture to use + * @returns {boolean} true is success + */ + ImageResource.prototype.upload = function upload (renderer, baseTexture, glTexture) + { + baseTexture.premultiplyAlpha = this.premultiplyAlpha; + + if (!this.createBitmap) + { + return BaseImageResource.prototype.upload.call(this, renderer, baseTexture, glTexture); + } + if (!this.bitmap) + { + // yeah, ignore the output + this.process(); + if (!this.bitmap) + { + return false; + } + } + + BaseImageResource.prototype.upload.call(this, renderer, baseTexture, glTexture, this.bitmap); + + if (!this.preserveBitmap) + { + // checks if there are other renderers that possibly need this bitmap + + var flag = true; + + for (var key in baseTexture._glTextures) + { + var otherTex = baseTexture._glTextures[key]; + + if (otherTex !== glTexture && otherTex.dirtyId !== baseTexture.dirtyId) + { + flag = false; + break; + } + } + + if (flag) + { + if (this.bitmap.close) + { + this.bitmap.close(); + } + + this.bitmap = null; + } + } + + return true; + }; + + /** + * Destroys this texture + * @override + */ + ImageResource.prototype.dispose = function dispose () + { + BaseImageResource.prototype.dispose.call(this); + + if (this.bitmap) + { + this.bitmap.close(); + this.bitmap = null; + } + this._process = null; + this._load = null; + }; + + return ImageResource; + }(BaseImageResource)); + + /** + * Collection of installed resource types, class must extend {@link PIXI.resources.Resource}. + * @example + * class CustomResource extends PIXI.resources.Resource { + * // MUST have source, options constructor signature + * // for auto-detected resources to be created. + * constructor(source, options) { + * super(); + * } + * upload(renderer, baseTexture, glTexture) { + * // upload with GL + * return true; + * } + * // used to auto-detect resource + * static test(source, extension) { + * return extension === 'xyz'|| source instanceof SomeClass; + * } + * } + * // Install the new resource type + * PIXI.resources.INSTALLED.push(CustomResource); + * + * @name PIXI.resources.INSTALLED + * @type {Array<*>} + * @static + * @readonly + */ + var INSTALLED = []; + + /** + * Create a resource element from a single source element. This + * auto-detects which type of resource to create. All resources that + * are auto-detectable must have a static `test` method and a constructor + * with the arguments `(source, options?)`. Currently, the supported + * resources for auto-detection include: + * - {@link PIXI.resources.ImageResource} + * - {@link PIXI.resources.CanvasResource} + * - {@link PIXI.resources.VideoResource} + * - {@link PIXI.resources.SVGResource} + * - {@link PIXI.resources.BufferResource} + * @static + * @function PIXI.resources.autoDetectResource + * @param {string|*} source - Resource source, this can be the URL to the resource, + * a typed-array (for BufferResource), HTMLVideoElement, SVG data-uri + * or any other resource that can be auto-detected. If not resource is + * detected, it's assumed to be an ImageResource. + * @param {object} [options] - Pass-through options to use for Resource + * @param {number} [options.width] - BufferResource's width + * @param {number} [options.height] - BufferResource's height + * @param {boolean} [options.autoLoad=true] - Image, SVG and Video flag to start loading + * @param {number} [options.scale=1] - SVG source scale + * @param {boolean} [options.createBitmap=true] - Image option to create Bitmap object + * @param {boolean} [options.crossorigin=true] - Image and Video option to set crossOrigin + * @param {boolean} [options.autoPlay=true] - Video option to start playing video immediately + * @param {number} [options.updateFPS=0] - Video option to update how many times a second the + * texture should be updated from the video. Leave at 0 to update at every render + * @return {PIXI.resources.Resource} The created resource. + */ + function autoDetectResource(source, options) + { + if (!source) + { + return null; + } + + var extension = ''; + + if (typeof source === 'string') + { + // search for file extension: period, 3-4 chars, then ?, # or EOL + var result = (/\.(\w{3,4})(?:$|\?|#)/i).exec(source); + + if (result) + { + extension = result[1].toLowerCase(); + } + } + + for (var i = INSTALLED.length - 1; i >= 0; --i) + { + var ResourcePlugin = INSTALLED[i]; + + if (ResourcePlugin.test && ResourcePlugin.test(source, extension)) + { + return new ResourcePlugin(source, options); + } + } + + // When in doubt: probably an image + // might be appropriate to throw an error or return null + return new ImageResource(source, options); + } + + /** + * @interface SharedArrayBuffer + */ + + /** + * Buffer resource with data of typed array. + * @class + * @extends PIXI.resources.Resource + * @memberof PIXI.resources + */ + var BufferResource = /*@__PURE__*/(function (Resource) { + function BufferResource(source, options) + { + var ref = options || {}; + var width = ref.width; + var height = ref.height; + + if (!width || !height) + { + throw new Error('BufferResource width or height invalid'); + } + + Resource.call(this, width, height); + + /** + * Source array + * Cannot be ClampedUint8Array because it cant be uploaded to WebGL + * + * @member {Float32Array|Uint8Array|Uint32Array} + */ + this.data = source; + } + + if ( Resource ) { BufferResource.__proto__ = Resource; } + BufferResource.prototype = Object.create( Resource && Resource.prototype ); + BufferResource.prototype.constructor = BufferResource; + + /** + * Upload the texture to the GPU. + * @param {PIXI.Renderer} renderer Upload to the renderer + * @param {PIXI.BaseTexture} baseTexture Reference to parent texture + * @param {PIXI.GLTexture} glTexture glTexture + * @returns {boolean} true is success + */ + BufferResource.prototype.upload = function upload (renderer, baseTexture, glTexture) + { + var gl = renderer.gl; + + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.premultiplyAlpha); + + if (glTexture.width === baseTexture.width && glTexture.height === baseTexture.height) + { + gl.texSubImage2D( + baseTexture.target, + 0, + 0, + 0, + baseTexture.width, + baseTexture.height, + baseTexture.format, + baseTexture.type, + this.data + ); + } + else + { + glTexture.width = baseTexture.width; + glTexture.height = baseTexture.height; + + var internalFormat = baseTexture.format; + + // guess sized format by type and format + // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D + if (renderer.context.webGLVersion === 2 + && baseTexture.type === renderer.gl.FLOAT + && baseTexture.format === renderer.gl.RGBA) + { + internalFormat = renderer.gl.RGBA32F; + } + + gl.texImage2D( + baseTexture.target, + 0, + internalFormat, + baseTexture.width, + baseTexture.height, + 0, + baseTexture.format, + baseTexture.type, + this.data + ); + } + + return true; + }; + + /** + * Destroy and don't use after this + * @override + */ + BufferResource.prototype.dispose = function dispose () + { + this.data = null; + }; + + /** + * Used to auto-detect the type of resource. + * + * @static + * @param {*} source - The source object + * @return {boolean} `true` if + */ + BufferResource.test = function test (source) + { + return source instanceof Float32Array + || source instanceof Uint8Array + || source instanceof Uint32Array; + }; + + return BufferResource; + }(Resource)); + + var defaultBufferOptions = { + scaleMode: SCALE_MODES.NEAREST, + format: FORMATS.RGBA, + premultiplyAlpha: false, + }; + + /** + * A Texture stores the information that represents an image. + * All textures have a base texture, which contains information about the source. + * Therefore you can have many textures all using a single BaseTexture + * + * @class + * @extends PIXI.utils.EventEmitter + * @memberof PIXI + * @param {PIXI.resources.Resource|string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} [resource=null] + * The current resource to use, for things that aren't Resource objects, will be converted + * into a Resource. + * @param {Object} [options] - Collection of options + * @param {PIXI.MIPMAP_MODES} [options.mipmap=PIXI.settings.MIPMAP_TEXTURES] - If mipmapping is enabled for texture + * @param {PIXI.WRAP_MODES} [options.wrapMode=PIXI.settings.WRAP_MODE] - Wrap mode for textures + * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.settings.SCALE_MODE] - Default scale mode, linear, nearest + * @param {PIXI.FORMATS} [options.format=PIXI.FORMATS.RGBA] - GL format type + * @param {PIXI.TYPES} [options.type=PIXI.TYPES.UNSIGNED_BYTE] - GL data type + * @param {PIXI.TARGETS} [options.target=PIXI.TARGETS.TEXTURE_2D] - GL texture target + * @param {boolean} [options.premultiplyAlpha=true] - Pre multiply the image alpha + * @param {number} [options.width=0] - Width of the texture + * @param {number} [options.height=0] - Height of the texture + * @param {object} [options.resourceOptions] - Optional resource options, + * see {@link PIXI.resources.autoDetectResource autoDetectResource} + */ + var BaseTexture = /*@__PURE__*/(function (EventEmitter) { + function BaseTexture(resource, options) + { + if ( resource === void 0 ) { resource = null; } + if ( options === void 0 ) { options = null; } + + EventEmitter.call(this); + + options = options || {}; + + var premultiplyAlpha = options.premultiplyAlpha; + var mipmap = options.mipmap; + var scaleMode = options.scaleMode; + var width = options.width; + var height = options.height; + var wrapMode = options.wrapMode; + var format = options.format; + var type = options.type; + var target = options.target; + var resolution = options.resolution; + var resourceOptions = options.resourceOptions; + + // Convert the resource to a Resource object + if (resource && !(resource instanceof Resource)) + { + resource = autoDetectResource(resource, resourceOptions); + resource.internal = true; + } + + /** + * The width of the base texture set when the image has loaded + * + * @readonly + * @member {number} + */ + this.width = width || 0; + + /** + * The height of the base texture set when the image has loaded + * + * @readonly + * @member {number} + */ + this.height = height || 0; + + /** + * The resolution / device pixel ratio of the texture + * + * @member {number} + * @default PIXI.settings.RESOLUTION + */ + this.resolution = resolution || settings.RESOLUTION; + + /** + * Mipmap mode of the texture, affects downscaled images + * + * @member {PIXI.MIPMAP_MODES} + * @default PIXI.settings.MIPMAP_TEXTURES + */ + this.mipmap = mipmap !== undefined ? mipmap : settings.MIPMAP_TEXTURES; + + /** + * How the texture wraps + * @member {number} + */ + this.wrapMode = wrapMode || settings.WRAP_MODE; + + /** + * The scale mode to apply when scaling this texture + * + * @member {PIXI.SCALE_MODES} + * @default PIXI.settings.SCALE_MODE + */ + this.scaleMode = scaleMode !== undefined ? scaleMode : settings.SCALE_MODE; + + /** + * The pixel format of the texture + * + * @member {PIXI.FORMATS} + * @default PIXI.FORMATS.RGBA + */ + this.format = format || FORMATS.RGBA; + + /** + * The type of resource data + * + * @member {PIXI.TYPES} + * @default PIXI.TYPES.UNSIGNED_BYTE + */ + this.type = type || TYPES.UNSIGNED_BYTE; + + /** + * The target type + * + * @member {PIXI.TARGETS} + * @default PIXI.TARGETS.TEXTURE_2D + */ + this.target = target || TARGETS.TEXTURE_2D; + + /** + * Set to true to enable pre-multiplied alpha + * + * @member {boolean} + * @default true + */ + this.premultiplyAlpha = premultiplyAlpha !== false; + + /** + * Global unique identifier for this BaseTexture + * + * @member {string} + * @protected + */ + this.uid = uid(); + + /** + * Used by automatic texture Garbage Collection, stores last GC tick when it was bound + * + * @member {number} + * @protected + */ + this.touched = 0; + + /** + * Whether or not the texture is a power of two, try to use power of two textures as much + * as you can + * + * @readonly + * @member {boolean} + * @default false + */ + this.isPowerOfTwo = false; + this._refreshPOT(); + + /** + * The map of render context textures where this is bound + * + * @member {Object} + * @private + */ + this._glTextures = {}; + + /** + * Used by TextureSystem to only update texture to the GPU when needed. + * + * @protected + * @member {number} + */ + this.dirtyId = 0; + + /** + * Used by TextureSystem to only update texture style when needed. + * + * @protected + * @member {number} + */ + this.dirtyStyleId = 0; + + /** + * Currently default cache ID. + * + * @member {string} + */ + this.cacheId = null; + + /** + * Generally speaking means when resource is loaded. + * @readonly + * @member {boolean} + */ + this.valid = width > 0 && height > 0; + + /** + * The collection of alternative cache ids, since some BaseTextures + * can have more than one ID, short name and longer full URL + * + * @member {Array} + * @readonly + */ + this.textureCacheIds = []; + + /** + * Flag if BaseTexture has been destroyed. + * + * @member {boolean} + * @readonly + */ + this.destroyed = false; + + /** + * The resource used by this BaseTexture, there can only + * be one resource per BaseTexture, but textures can share + * resources. + * + * @member {PIXI.resources.Resource} + * @readonly + */ + this.resource = null; + + /** + * Number of the texture batch, used by multi-texture renderers + * + * @member {number} + */ + this._batchEnabled = 0; + + /** + * Fired when a not-immediately-available source finishes loading. + * + * @protected + * @event PIXI.BaseTexture#loaded + * @param {PIXI.BaseTexture} baseTexture - Resource loaded. + */ + + /** + * Fired when a not-immediately-available source fails to load. + * + * @protected + * @event PIXI.BaseTexture#error + * @param {PIXI.BaseTexture} baseTexture - Resource errored. + */ + + /** + * Fired when BaseTexture is updated. + * + * @protected + * @event PIXI.BaseTexture#loaded + * @param {PIXI.BaseTexture} baseTexture - Resource loaded. + */ + + /** + * Fired when BaseTexture is destroyed. + * + * @protected + * @event PIXI.BaseTexture#error + * @param {PIXI.BaseTexture} baseTexture - Resource errored. + */ + + /** + * Fired when BaseTexture is updated. + * + * @protected + * @event PIXI.BaseTexture#update + * @param {PIXI.BaseTexture} baseTexture - Instance of texture being updated. + */ + + /** + * Fired when BaseTexture is destroyed. + * + * @protected + * @event PIXI.BaseTexture#dispose + * @param {PIXI.BaseTexture} baseTexture - Instance of texture being destroyed. + */ + + // Set the resource + this.setResource(resource); + } + + if ( EventEmitter ) { BaseTexture.__proto__ = EventEmitter; } + BaseTexture.prototype = Object.create( EventEmitter && EventEmitter.prototype ); + BaseTexture.prototype.constructor = BaseTexture; + + var prototypeAccessors = { realWidth: { configurable: true },realHeight: { configurable: true } }; + + /** + * Pixel width of the source of this texture + * + * @readonly + * @member {number} + */ + prototypeAccessors.realWidth.get = function () + { + return this.width * this.resolution; + }; + + /** + * Pixel height of the source of this texture + * + * @readonly + * @member {number} + */ + prototypeAccessors.realHeight.get = function () + { + return this.height * this.resolution; + }; + + /** + * Changes style options of BaseTexture + * + * @param {PIXI.SCALE_MODES} [scaleMode] - Pixi scalemode + * @param {PIXI.MIPMAP_MODES} [mipmap] - enable mipmaps + * @returns {BaseTexture} this + */ + BaseTexture.prototype.setStyle = function setStyle (scaleMode, mipmap) + { + var dirty; + + if (scaleMode !== undefined && scaleMode !== this.scaleMode) + { + this.scaleMode = scaleMode; + dirty = true; + } + + if (mipmap !== undefined && mipmap !== this.mipmap) + { + this.mipmap = mipmap; + dirty = true; + } + + if (dirty) + { + this.dirtyStyleId++; + } + + return this; + }; + + /** + * Changes w/h/resolution. Texture becomes valid if width and height are greater than zero. + * + * @param {number} width Visual width + * @param {number} height Visual height + * @param {number} [resolution] Optionally set resolution + * @returns {BaseTexture} this + */ + BaseTexture.prototype.setSize = function setSize (width, height, resolution) + { + this.resolution = resolution || this.resolution; + this.width = width; + this.height = height; + this._refreshPOT(); + this.update(); + + return this; + }; + + /** + * Sets real size of baseTexture, preserves current resolution. + * + * @param {number} realWidth Full rendered width + * @param {number} realHeight Full rendered height + * @param {number} [resolution] Optionally set resolution + * @returns {BaseTexture} this + */ + BaseTexture.prototype.setRealSize = function setRealSize (realWidth, realHeight, resolution) + { + this.resolution = resolution || this.resolution; + this.width = realWidth / this.resolution; + this.height = realHeight / this.resolution; + this._refreshPOT(); + this.update(); + + return this; + }; + + /** + * Refresh check for isPowerOfTwo texture based on size + * + * @private + */ + BaseTexture.prototype._refreshPOT = function _refreshPOT () + { + this.isPowerOfTwo = isPow2(this.realWidth) && isPow2(this.realHeight); + }; + + /** + * Changes resolution + * + * @param {number} [resolution] res + * @returns {BaseTexture} this + */ + BaseTexture.prototype.setResolution = function setResolution (resolution) + { + var oldResolution = this.resolution; + + if (oldResolution === resolution) + { + return this; + } + + this.resolution = resolution; + + if (this.valid) + { + this.width = this.width * oldResolution / resolution; + this.height = this.height * oldResolution / resolution; + this.emit('update'); + } + + this._refreshPOT(); + + return this; + }; + + /** + * Sets the resource if it wasn't set. Throws error if resource already present + * + * @param {PIXI.resources.Resource} resource - that is managing this BaseTexture + * @returns {BaseTexture} this + */ + BaseTexture.prototype.setResource = function setResource (resource) + { + if (this.resource === resource) + { + return this; + } + + if (this.resource) + { + throw new Error('Resource can be set only once'); + } + + resource.bind(this); + + this.resource = resource; + + return this; + }; + + /** + * Invalidates the object. Texture becomes valid if width and height are greater than zero. + */ + BaseTexture.prototype.update = function update () + { + if (!this.valid) + { + if (this.width > 0 && this.height > 0) + { + this.valid = true; + this.emit('loaded', this); + this.emit('update', this); + } + } + else + { + this.dirtyId++; + this.dirtyStyleId++; + this.emit('update', this); + } + }; + + /** + * Destroys this base texture. + * The method stops if resource doesn't want this texture to be destroyed. + * Removes texture from all caches. + */ + BaseTexture.prototype.destroy = function destroy () + { + // remove and destroy the resource + if (this.resource) + { + this.resource.unbind(this); + // only destroy resourced created internally + if (this.resource.internal) + { + this.resource.destroy(); + } + this.resource = null; + } + + if (this.cacheId) + { + delete BaseTextureCache[this.cacheId]; + delete TextureCache[this.cacheId]; + + this.cacheId = null; + } + + // finally let the WebGL renderer know.. + this.dispose(); + + BaseTexture.removeFromCache(this); + this.textureCacheIds = null; + + this.destroyed = true; + }; + + /** + * Frees the texture from WebGL memory without destroying this texture object. + * This means you can still use the texture later which will upload it to GPU + * memory again. + * + * @fires PIXI.BaseTexture#dispose + */ + BaseTexture.prototype.dispose = function dispose () + { + this.emit('dispose', this); + }; + + /** + * Helper function that creates a base texture based on the source you provide. + * The source can be - image url, image element, canvas element. If the + * source is an image url or an image element and not in the base texture + * cache, it will be created and loaded. + * + * @static + * @param {string|HTMLImageElement|HTMLCanvasElement|SVGElement|HTMLVideoElement} source - The + * source to create base texture from. + * @param {object} [options] See {@link PIXI.BaseTexture}'s constructor for options. + * @returns {PIXI.BaseTexture} The new base texture. + */ + BaseTexture.from = function from (source, options) + { + var cacheId = null; + + if (typeof source === 'string') + { + cacheId = source; + } + else + { + if (!source._pixiId) + { + source._pixiId = "pixiid_" + (uid()); + } + + cacheId = source._pixiId; + } + + var baseTexture = BaseTextureCache[cacheId]; + + if (!baseTexture) + { + baseTexture = new BaseTexture(source, options); + baseTexture.cacheId = cacheId; + BaseTexture.addToCache(baseTexture, cacheId); + } + + return baseTexture; + }; + + /** + * Create a new BaseTexture with a BufferResource from a Float32Array. + * RGBA values are floats from 0 to 1. + * @static + * @param {Float32Array|Uint8Array} buffer The optional array to use, if no data + * is provided, a new Float32Array is created. + * @param {number} width - Width of the resource + * @param {number} height - Height of the resource + * @param {object} [options] See {@link PIXI.BaseTexture}'s constructor for options. + * @return {PIXI.BaseTexture} The resulting new BaseTexture + */ + BaseTexture.fromBuffer = function fromBuffer (buffer, width, height, options) + { + buffer = buffer || new Float32Array(width * height * 4); + + var resource = new BufferResource(buffer, { width: width, height: height }); + var type = buffer instanceof Float32Array ? TYPES.FLOAT : TYPES.UNSIGNED_BYTE; + + return new BaseTexture(resource, Object.assign(defaultBufferOptions, options || { width: width, height: height, type: type })); + }; + + /** + * Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object. + * + * @static + * @param {PIXI.BaseTexture} baseTexture - The BaseTexture to add to the cache. + * @param {string} id - The id that the BaseTexture will be stored against. + */ + BaseTexture.addToCache = function addToCache (baseTexture, id) + { + if (id) + { + if (baseTexture.textureCacheIds.indexOf(id) === -1) + { + baseTexture.textureCacheIds.push(id); + } + + if (BaseTextureCache[id]) + { + // eslint-disable-next-line no-console + console.warn(("BaseTexture added to the cache with an id [" + id + "] that already had an entry")); + } + + BaseTextureCache[id] = baseTexture; + } + }; + + /** + * Remove a BaseTexture from the global BaseTextureCache. + * + * @static + * @param {string|PIXI.BaseTexture} baseTexture - id of a BaseTexture to be removed, or a BaseTexture instance itself. + * @return {PIXI.BaseTexture|null} The BaseTexture that was removed. + */ + BaseTexture.removeFromCache = function removeFromCache (baseTexture) + { + if (typeof baseTexture === 'string') + { + var baseTextureFromCache = BaseTextureCache[baseTexture]; + + if (baseTextureFromCache) + { + var index = baseTextureFromCache.textureCacheIds.indexOf(baseTexture); + + if (index > -1) + { + baseTextureFromCache.textureCacheIds.splice(index, 1); + } + + delete BaseTextureCache[baseTexture]; + + return baseTextureFromCache; + } + } + else if (baseTexture && baseTexture.textureCacheIds) + { + for (var i = 0; i < baseTexture.textureCacheIds.length; ++i) + { + delete BaseTextureCache[baseTexture.textureCacheIds[i]]; + } + + baseTexture.textureCacheIds.length = 0; + + return baseTexture; + } + + return null; + }; + + Object.defineProperties( BaseTexture.prototype, prototypeAccessors ); + + return BaseTexture; + }(eventemitter3)); + + /** + * Global number of the texture batch, used by multi-texture renderers + * + * @static + * @member {number} + */ + BaseTexture._globalBatch = 0; + + /** + * A resource that contains a number of sources. + * + * @class + * @extends PIXI.resources.Resource + * @memberof PIXI.resources + * @param {number|Array<*>} source - Number of items in array or the collection + * of image URLs to use. Can also be resources, image elements, canvas, etc. + * @param {object} [options] Options to apply to {@link PIXI.resources.autoDetectResource} + * @param {number} [options.width] - Width of the resource + * @param {number} [options.height] - Height of the resource + */ + var ArrayResource = /*@__PURE__*/(function (Resource) { + function ArrayResource(source, options) + { + options = options || {}; + + var urls; + var length = source; + + if (Array.isArray(source)) + { + urls = source; + length = source.length; + } + + Resource.call(this, options.width, options.height); + + /** + * Collection of resources. + * @member {Array} + * @readonly + */ + this.items = []; + + /** + * Dirty IDs for each part + * @member {Array} + * @readonly + */ + this.itemDirtyIds = []; + + for (var i = 0; i < length; i++) + { + var partTexture = new BaseTexture(); + + this.items.push(partTexture); + this.itemDirtyIds.push(-1); + } + + /** + * Number of elements in array + * + * @member {number} + * @readonly + */ + this.length = length; + + /** + * Promise when loading + * @member {Promise} + * @private + * @default null + */ + this._load = null; + + if (urls) + { + for (var i$1 = 0; i$1 < length; i$1++) + { + this.addResourceAt(autoDetectResource(urls[i$1], options), i$1); + } + } + } + + if ( Resource ) { ArrayResource.__proto__ = Resource; } + ArrayResource.prototype = Object.create( Resource && Resource.prototype ); + ArrayResource.prototype.constructor = ArrayResource; + + /** + * Destroy this BaseImageResource + * @override + */ + ArrayResource.prototype.dispose = function dispose () + { + for (var i = 0, len = this.length; i < len; i++) + { + this.items[i].destroy(); + } + this.items = null; + this.itemDirtyIds = null; + this._load = null; + }; + + /** + * Set a resource by ID + * + * @param {PIXI.resources.Resource} resource + * @param {number} index - Zero-based index of resource to set + * @return {PIXI.resources.ArrayResource} Instance for chaining + */ + ArrayResource.prototype.addResourceAt = function addResourceAt (resource, index) + { + var baseTexture = this.items[index]; + + if (!baseTexture) + { + throw new Error(("Index " + index + " is out of bounds")); + } + + // Inherit the first resource dimensions + if (resource.valid && !this.valid) + { + this.resize(resource.width, resource.height); + } + + this.items[index].setResource(resource); + + return this; + }; + + /** + * Set the parent base texture + * @member {PIXI.BaseTexture} + * @override + */ + ArrayResource.prototype.bind = function bind (baseTexture) + { + Resource.prototype.bind.call(this, baseTexture); + + baseTexture.target = TARGETS.TEXTURE_2D_ARRAY; + + for (var i = 0; i < this.length; i++) + { + this.items[i].on('update', baseTexture.update, baseTexture); + } + }; + + /** + * Unset the parent base texture + * @member {PIXI.BaseTexture} + * @override + */ + ArrayResource.prototype.unbind = function unbind (baseTexture) + { + Resource.prototype.unbind.call(this, baseTexture); + + for (var i = 0; i < this.length; i++) + { + this.items[i].off('update', baseTexture.update, baseTexture); + } + }; + + /** + * Load all the resources simultaneously + * @override + * @return {Promise} When load is resolved + */ + ArrayResource.prototype.load = function load () + { + var this$1 = this; + + if (this._load) + { + return this._load; + } + + var resources = this.items.map(function (item) { return item.resource; }); + + // TODO: also implement load part-by-part strategy + var promises = resources.map(function (item) { return item.load(); }); + + this._load = Promise.all(promises) + .then(function () { + var ref = resources[0]; + var width = ref.width; + var height = ref.height; + + this$1.resize(width, height); + + return Promise.resolve(this$1); + } + ); + + return this._load; + }; + + /** + * Upload the resources to the GPU. + * @param {PIXI.Renderer} renderer + * @param {PIXI.BaseTexture} texture + * @param {PIXI.GLTexture} glTexture + * @returns {boolean} whether texture was uploaded + */ + ArrayResource.prototype.upload = function upload (renderer, texture, glTexture) + { + var ref = this; + var length = ref.length; + var itemDirtyIds = ref.itemDirtyIds; + var items = ref.items; + var gl = renderer.gl; + + if (glTexture.dirtyId < 0) + { + gl.texImage3D( + gl.TEXTURE_2D_ARRAY, + 0, + texture.format, + this._width, + this._height, + length, + 0, + texture.format, + texture.type, + null + ); + } + + for (var i = 0; i < length; i++) + { + var item = items[i]; + + if (itemDirtyIds[i] < item.dirtyId) + { + itemDirtyIds[i] = item.dirtyId; + if (item.valid) + { + gl.texSubImage3D( + gl.TEXTURE_2D_ARRAY, + 0, + 0, // xoffset + 0, // yoffset + i, // zoffset + item.resource.width, + item.resource.height, + 1, + texture.format, + texture.type, + item.resource.source + ); + } + } + } + + return true; + }; + + return ArrayResource; + }(Resource)); + + /** + * Resource type for HTMLCanvasElement. + * @class + * @extends PIXI.resources.BaseImageResource + * @memberof PIXI.resources + * @param {HTMLCanvasElement} source - Canvas element to use + */ + var CanvasResource = /*@__PURE__*/(function (BaseImageResource) { + function CanvasResource () { + BaseImageResource.apply(this, arguments); + } + + if ( BaseImageResource ) { CanvasResource.__proto__ = BaseImageResource; } + CanvasResource.prototype = Object.create( BaseImageResource && BaseImageResource.prototype ); + CanvasResource.prototype.constructor = CanvasResource; + + CanvasResource.test = function test (source) + { + return (source instanceof HTMLCanvasElement); + }; + + return CanvasResource; + }(BaseImageResource)); + + /** + * Resource for a CubeTexture which contains six resources. + * + * @class + * @extends PIXI.resources.ArrayResource + * @memberof PIXI.resources + * @param {Array} [source] Collection of URLs or resources + * to use as the sides of the cube. + * @param {object} [options] - ImageResource options + * @param {number} [options.width] - Width of resource + * @param {number} [options.height] - Height of resource + */ + var CubeResource = /*@__PURE__*/(function (ArrayResource) { + function CubeResource(source, options) + { + options = options || {}; + + ArrayResource.call(this, source, options); + + if (this.length !== CubeResource.SIDES) + { + throw new Error(("Invalid length. Got " + (this.length) + ", expected 6")); + } + + for (var i = 0; i < CubeResource.SIDES; i++) + { + this.items[i].target = TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X + i; + } + + if (options.autoLoad !== false) + { + this.load(); + } + } + + if ( ArrayResource ) { CubeResource.__proto__ = ArrayResource; } + CubeResource.prototype = Object.create( ArrayResource && ArrayResource.prototype ); + CubeResource.prototype.constructor = CubeResource; + + /** + * Add binding + * + * @override + * @param {PIXI.BaseTexture} baseTexture - parent base texture + */ + CubeResource.prototype.bind = function bind (baseTexture) + { + ArrayResource.prototype.bind.call(this, baseTexture); + + baseTexture.target = TARGETS.TEXTURE_CUBE_MAP; + }; + + /** + * Upload the resource + * + * @returns {boolean} true is success + */ + CubeResource.prototype.upload = function upload (renderer, baseTexture, glTexture) + { + var dirty = this.itemDirtyIds; + + for (var i = 0; i < CubeResource.SIDES; i++) + { + var side = this.items[i]; + + if (dirty[i] < side.dirtyId) + { + dirty[i] = side.dirtyId; + if (side.valid) + { + side.resource.upload(renderer, side, glTexture); + } + } + } + + return true; + }; + + return CubeResource; + }(ArrayResource)); + + /** + * Number of texture sides to store for CubeResources + * + * @name PIXI.resources.CubeResource.SIDES + * @static + * @member {number} + * @default 6 + */ + CubeResource.SIDES = 6; + + /** + * Resource type for SVG elements and graphics. + * @class + * @extends PIXI.resources.BaseImageResource + * @memberof PIXI.resources + * @param {string} source - Base64 encoded SVG element or URL for SVG file. + * @param {object} [options] - Options to use + * @param {number} [options.scale=1] Scale to apply to SVG. + * @param {boolean} [options.autoLoad=true] Start loading right away. + */ + var SVGResource = /*@__PURE__*/(function (BaseImageResource) { + function SVGResource(source, options) + { + options = options || {}; + + BaseImageResource.call(this, document.createElement('canvas')); + + /** + * Base64 encoded SVG element or URL for SVG file + * @readonly + * @member {string} + */ + this.svg = source; + + /** + * The source scale to apply to render + * @readonly + * @member {number} + */ + this.scale = options.scale || 1; + + /** + * Call when completely loaded + * @private + * @member {function} + */ + this._resolve = null; + + /** + * Promise when loading + * @member {Promise} + * @private + * @default null + */ + this._load = null; + + if (options.autoLoad !== false) + { + this.load(); + } + } + + if ( BaseImageResource ) { SVGResource.__proto__ = BaseImageResource; } + SVGResource.prototype = Object.create( BaseImageResource && BaseImageResource.prototype ); + SVGResource.prototype.constructor = SVGResource; + + SVGResource.prototype.load = function load () + { + var this$1 = this; + + if (this._load) + { + return this._load; + } + + this._load = new Promise(function (resolve) { + // Save this until after load is finished + this$1._resolve = function () { + this$1.resize(this$1.source.width, this$1.source.height); + resolve(this$1); + }; + + // Convert SVG inline string to data-uri + if ((/^\ this.emit('error', this); + + svgXhr.open('GET', this.svg, true); + svgXhr.send(); + }; + + /** + * Loads texture using an SVG string. The original SVG Image is stored as `origSource` and the + * created canvas is the new `source`. The SVG is scaled using `sourceScale`. Called by + * `_loadXhr` or `_loadDataUri`. + * + * @private + * @param {string} svgString SVG source as string + * + * @fires loaded + */ + SVGResource.prototype._loadString = function _loadString (svgString) + { + var svgSize = SVGResource.getSize(svgString); + + // TODO do we need to wait for this to load? + // seems instant! + // + var tempImage = new Image(); + + tempImage.src = "data:image/svg+xml," + svgString; + + var svgWidth = svgSize.width; + var svgHeight = svgSize.height; + + if (!svgWidth || !svgHeight) + { + throw new Error('The SVG image must have width and height defined (in pixels), canvas API needs them.'); + } + + // Scale realWidth and realHeight + this._width = Math.round(svgWidth * this.scale); + this._height = Math.round(svgHeight * this.scale); + + // Create a canvas element + var canvas = this.source; + + canvas.width = this._width; + canvas.height = this._height; + canvas._pixiId = "canvas_" + (uid()); + + // Draw the Svg to the canvas + canvas + .getContext('2d') + .drawImage(tempImage, 0, 0, svgWidth, svgHeight, 0, 0, this.width, this.height); + + this._resolve(); + this._resolve = null; + }; + + /** + * Typedef for Size object. + * + * @memberof PIXI.resources.SVGResource + * @typedef {object} Size + * @property {number} width - Width component + * @property {number} height - Height component + */ + + /** + * Get size from an svg string using regexp. + * + * @method + * @param {string} svgString - a serialized svg element + * @return {PIXI.resources.SVGResource.Size} image extension + */ + SVGResource.getSize = function getSize (svgString) + { + var sizeMatch = SVGResource.SVG_SIZE.exec(svgString); + var size = {}; + + if (sizeMatch) + { + size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[3])); + size[sizeMatch[5]] = Math.round(parseFloat(sizeMatch[7])); + } + + return size; + }; + + /** + * Destroys this texture + * @override + */ + SVGResource.prototype.dispose = function dispose () + { + BaseImageResource.prototype.dispose.call(this); + this._resolve = null; + }; + + /** + * Used to auto-detect the type of resource. + * + * @static + * @param {*} source - The source object + * @param {string} extension - The extension of source, if set + */ + SVGResource.test = function test (source, extension) + { + // url file extension is SVG + return extension === 'svg' + // source is SVG data-uri + || (typeof source === 'string' && source.indexOf('data:image/svg+xml') === 0); + }; + + return SVGResource; + }(BaseImageResource)); + + /** + * RegExp for SVG size. + * + * @static + * @constant {RegExp|string} SVG_SIZE + * @memberof PIXI.resources.SVGResource + * @example <svg width="100" height="100"></svg> + */ + SVGResource.SVG_SIZE = /]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i; // eslint-disable-line max-len + + /** + * Resource type for HTMLVideoElement. + * @class + * @extends PIXI.resources.BaseImageResource + * @memberof PIXI.resources + * @param {HTMLVideoElement|object|string|Array} source - Video element to use. + * @param {object} [options] - Options to use + * @param {boolean} [options.autoLoad=true] - Start loading the video immediately + * @param {boolean} [options.autoPlay=true] - Start playing video immediately + * @param {number} [options.updateFPS=0] - How many times a second to update the texture from the video. + * Leave at 0 to update at every render. + * @param {boolean} [options.crossorigin=true] - Load image using cross origin + */ + var VideoResource = /*@__PURE__*/(function (BaseImageResource) { + function VideoResource(source, options) + { + options = options || {}; + + if (!(source instanceof HTMLVideoElement)) + { + var videoElement = document.createElement('video'); + + videoElement.setAttribute('webkit-playsinline', ''); + videoElement.setAttribute('playsinline', ''); + + if (typeof source === 'string') + { + source = [source]; + } + + BaseImageResource.crossOrigin(videoElement, (source[0].src || source[0]), options.crossorigin); + + // array of objects or strings + for (var i = 0; i < source.length; ++i) + { + var sourceElement = document.createElement('source'); + + var ref = source[i]; + var src = ref.src; + var mime = ref.mime; + + src = src || source[i]; + + var baseSrc = src.split('?').shift().toLowerCase(); + var ext = baseSrc.substr(baseSrc.lastIndexOf('.') + 1); + + mime = mime || ("video/" + ext); + + sourceElement.src = src; + sourceElement.type = mime; + + videoElement.appendChild(sourceElement); + } + + // Override the source + source = videoElement; + } + + BaseImageResource.call(this, source); + + this._autoUpdate = true; + this._isAutoUpdating = false; + this._updateFPS = options.updateFPS || 0; + this._msToNextUpdate = 0; + + /** + * When set to true will automatically play videos used by this texture once + * they are loaded. If false, it will not modify the playing state. + * + * @member {boolean} + * @default true + */ + this.autoPlay = options.autoPlay !== false; + + /** + * Promise when loading + * @member {Promise} + * @private + * @default null + */ + this._load = null; + + /** + * Callback when completed with load. + * @member {function} + * @private + */ + this._resolve = null; + + // Bind for listeners + this._onCanPlay = this._onCanPlay.bind(this); + + if (options.autoLoad !== false) + { + this.load(); + } + } + + if ( BaseImageResource ) { VideoResource.__proto__ = BaseImageResource; } + VideoResource.prototype = Object.create( BaseImageResource && BaseImageResource.prototype ); + VideoResource.prototype.constructor = VideoResource; + + var prototypeAccessors = { autoUpdate: { configurable: true },updateFPS: { configurable: true } }; + + /** + * Trigger updating of the texture + * + * @param {number} [deltaTime=0] - time delta since last tick + */ + VideoResource.prototype.update = function update (deltaTime) + { + if ( deltaTime === void 0 ) { deltaTime = 0; } + + if (!this.destroyed) + { + // account for if video has had its playbackRate changed + var elapsedMS = Ticker.shared.elapsedMS * this.source.playbackRate; + + this._msToNextUpdate = Math.floor(this._msToNextUpdate - elapsedMS); + if (!this._updateFPS || this._msToNextUpdate <= 0) + { + BaseImageResource.prototype.update.call(this, deltaTime); + this._msToNextUpdate = this._updateFPS ? Math.floor(1000 / this._updateFPS) : 0; + } + } + }; + + /** + * Start preloading the video resource. + * + * @protected + * @return {Promise} Handle the validate event + */ + VideoResource.prototype.load = function load () + { + var this$1 = this; + + if (this._load) + { + return this._load; + } + + var source = this.source; + + if ((source.readyState === source.HAVE_ENOUGH_DATA || source.readyState === source.HAVE_FUTURE_DATA) + && source.width && source.height) + { + source.complete = true; + } + + source.addEventListener('play', this._onPlayStart.bind(this)); + source.addEventListener('pause', this._onPlayStop.bind(this)); + + if (!this._isSourceReady()) + { + source.addEventListener('canplay', this._onCanPlay); + source.addEventListener('canplaythrough', this._onCanPlay); + } + else + { + this._onCanPlay(); + } + + this._load = new Promise(function (resolve) { + if (this$1.valid) + { + resolve(this$1); + } + else + { + this$1._resolve = resolve; + + source.load(); + } + }); + + return this._load; + }; + + /** + * Returns true if the underlying source is playing. + * + * @private + * @return {boolean} True if playing. + */ + VideoResource.prototype._isSourcePlaying = function _isSourcePlaying () + { + var source = this.source; + + return (source.currentTime > 0 && source.paused === false && source.ended === false && source.readyState > 2); + }; + + /** + * Returns true if the underlying source is ready for playing. + * + * @private + * @return {boolean} True if ready. + */ + VideoResource.prototype._isSourceReady = function _isSourceReady () + { + return this.source.readyState === 3 || this.source.readyState === 4; + }; + + /** + * Runs the update loop when the video is ready to play + * + * @private + */ + VideoResource.prototype._onPlayStart = function _onPlayStart () + { + // Just in case the video has not received its can play even yet.. + if (!this.valid) + { + this._onCanPlay(); + } + + if (!this._isAutoUpdating && this.autoUpdate) + { + Ticker.shared.add(this.update, this); + this._isAutoUpdating = true; + } + }; + + /** + * Fired when a pause event is triggered, stops the update loop + * + * @private + */ + VideoResource.prototype._onPlayStop = function _onPlayStop () + { + if (this._isAutoUpdating) + { + Ticker.shared.remove(this.update, this); + this._isAutoUpdating = false; + } + }; + + /** + * Fired when the video is loaded and ready to play + * + * @private + */ + VideoResource.prototype._onCanPlay = function _onCanPlay () + { + var ref = this; + var source = ref.source; + + source.removeEventListener('canplay', this._onCanPlay); + source.removeEventListener('canplaythrough', this._onCanPlay); + + var valid = this.valid; + + this.resize(source.videoWidth, source.videoHeight); + + // prevent multiple loaded dispatches.. + if (!valid && this._resolve) + { + this._resolve(this); + this._resolve = null; + } + + if (this._isSourcePlaying()) + { + this._onPlayStart(); + } + else if (this.autoPlay) + { + source.play(); + } + }; + + /** + * Destroys this texture + * @override + */ + VideoResource.prototype.dispose = function dispose () + { + if (this._isAutoUpdating) + { + Ticker.shared.remove(this.update, this); + } + + if (this.source) + { + this.source.pause(); + this.source.src = ''; + this.source.load(); + } + BaseImageResource.prototype.dispose.call(this); + }; + + /** + * Should the base texture automatically update itself, set to true by default + * + * @member {boolean} + */ + prototypeAccessors.autoUpdate.get = function () + { + return this._autoUpdate; + }; + + prototypeAccessors.autoUpdate.set = function (value) // eslint-disable-line require-jsdoc + { + if (value !== this._autoUpdate) + { + this._autoUpdate = value; + + if (!this._autoUpdate && this._isAutoUpdating) + { + Ticker.shared.remove(this.update, this); + this._isAutoUpdating = false; + } + else if (this._autoUpdate && !this._isAutoUpdating) + { + Ticker.shared.add(this.update, this); + this._isAutoUpdating = true; + } + } + }; + + /** + * How many times a second to update the texture from the video. Leave at 0 to update at every render. + * A lower fps can help performance, as updating the texture at 60fps on a 30ps video may not be efficient. + * + * @member {number} + */ + prototypeAccessors.updateFPS.get = function () + { + return this._updateFPS; + }; + + prototypeAccessors.updateFPS.set = function (value) // eslint-disable-line require-jsdoc + { + if (value !== this._updateFPS) + { + this._updateFPS = value; + } + }; + + /** + * Used to auto-detect the type of resource. + * + * @static + * @param {*} source - The source object + * @param {string} extension - The extension of source, if set + * @return {boolean} `true` if video source + */ + VideoResource.test = function test (source, extension) + { + return (source instanceof HTMLVideoElement) + || VideoResource.TYPES.indexOf(extension) > -1; + }; + + Object.defineProperties( VideoResource.prototype, prototypeAccessors ); + + return VideoResource; + }(BaseImageResource)); + + /** + * List of common video file extensions supported by VideoResource. + * @constant + * @member {Array} + * @static + * @readonly + */ + VideoResource.TYPES = ['mp4', 'm4v', 'webm', 'ogg', 'ogv', 'h264', 'avi', 'mov']; + + INSTALLED.push( + ImageResource, + CanvasResource, + VideoResource, + SVGResource, + BufferResource, + CubeResource, + ArrayResource + ); + + var index = ({ + INSTALLED: INSTALLED, + autoDetectResource: autoDetectResource, + ArrayResource: ArrayResource, + BufferResource: BufferResource, + CanvasResource: CanvasResource, + CubeResource: CubeResource, + ImageResource: ImageResource, + SVGResource: SVGResource, + VideoResource: VideoResource, + Resource: Resource, + BaseImageResource: BaseImageResource + }); + + /** + * System is a base class used for extending systems used by the {@link PIXI.Renderer} + * + * @see PIXI.Renderer#addSystem + * @class + * @memberof PIXI + */ + var System = function System(renderer) + { + /** + * The renderer this manager works for. + * + * @member {PIXI.Renderer} + */ + this.renderer = renderer; + + this.renderer.runners.contextChange.add(this); + }; + + /** + * Generic method called when there is a WebGL context change. + * + * @param {WebGLRenderingContext} gl new webgl context + */ + System.prototype.contextChange = function contextChange (gl) // eslint-disable-line no-unused-vars + { + // do some codes init! + }; + + /** + * Generic destroy methods to be overridden by the subclass + */ + System.prototype.destroy = function destroy () + { + this.renderer.runners.contextChange.remove(this); + this.renderer = null; + }; + + /** + * Resource type for DepthTexture. + * @class + * @extends PIXI.resources.BufferResource + * @memberof PIXI.resources + */ + var DepthResource = /*@__PURE__*/(function (BufferResource) { + function DepthResource () { + BufferResource.apply(this, arguments); + } + + if ( BufferResource ) { DepthResource.__proto__ = BufferResource; } + DepthResource.prototype = Object.create( BufferResource && BufferResource.prototype ); + DepthResource.prototype.constructor = DepthResource; + + DepthResource.prototype.upload = function upload (renderer, baseTexture, glTexture) + { + var gl = renderer.gl; + + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.premultiplyAlpha); + + if (glTexture.width === baseTexture.width && glTexture.height === baseTexture.height) + { + gl.texSubImage2D( + baseTexture.target, + 0, + 0, + 0, + baseTexture.width, + baseTexture.height, + baseTexture.format, + baseTexture.type, + this.data + ); + } + else + { + glTexture.width = baseTexture.width; + glTexture.height = baseTexture.height; + + gl.texImage2D( + baseTexture.target, + 0, + gl.DEPTH_COMPONENT16, // Needed for depth to render properly in webgl2.0 + baseTexture.width, + baseTexture.height, + 0, + baseTexture.format, + baseTexture.type, + this.data + ); + } + + return true; + }; + + return DepthResource; + }(BufferResource)); + + /** + * Frame buffer used by the BaseRenderTexture + * + * @class + * @memberof PIXI + */ + var Framebuffer = function Framebuffer(width, height) + { + this.width = Math.ceil(width || 100); + this.height = Math.ceil(height || 100); + + this.stencil = false; + this.depth = false; + + this.dirtyId = 0; + this.dirtyFormat = 0; + this.dirtySize = 0; + + this.depthTexture = null; + this.colorTextures = []; + + this.glFramebuffers = {}; + + this.disposeRunner = new Runner('disposeFramebuffer', 2); + }; + + var prototypeAccessors$1$2 = { colorTexture: { configurable: true } }; + + /** + * Reference to the colorTexture. + * + * @member {PIXI.Texture[]} + * @readonly + */ + prototypeAccessors$1$2.colorTexture.get = function () + { + return this.colorTextures[0]; + }; + + /** + * Add texture to the colorTexture array + * + * @param {number} [index=0] - Index of the array to add the texture to + * @param {PIXI.Texture} [texture] - Texture to add to the array + */ + Framebuffer.prototype.addColorTexture = function addColorTexture (index, texture) + { + if ( index === void 0 ) { index = 0; } + + // TODO add some validation to the texture - same width / height etc? + this.colorTextures[index] = texture || new BaseTexture(null, { scaleMode: 0, + resolution: 1, + mipmap: false, + width: this.width, + height: this.height });// || new Texture(); + + this.dirtyId++; + this.dirtyFormat++; + + return this; + }; + + /** + * Add a depth texture to the frame buffer + * + * @param {PIXI.Texture} [texture] - Texture to add + */ + Framebuffer.prototype.addDepthTexture = function addDepthTexture (texture) + { + /* eslint-disable max-len */ + this.depthTexture = texture || new BaseTexture(new DepthResource(null, { width: this.width, height: this.height }), { scaleMode: 0, + resolution: 1, + width: this.width, + height: this.height, + mipmap: false, + format: FORMATS.DEPTH_COMPONENT, + type: TYPES.UNSIGNED_SHORT });// UNSIGNED_SHORT; + /* eslint-disable max-len */ + this.dirtyId++; + this.dirtyFormat++; + + return this; + }; + + /** + * Enable depth on the frame buffer + */ + Framebuffer.prototype.enableDepth = function enableDepth () + { + this.depth = true; + + this.dirtyId++; + this.dirtyFormat++; + + return this; + }; + + /** + * Enable stencil on the frame buffer + */ + Framebuffer.prototype.enableStencil = function enableStencil () + { + this.stencil = true; + + this.dirtyId++; + this.dirtyFormat++; + + return this; + }; + + /** + * Resize the frame buffer + * + * @param {number} width - Width of the frame buffer to resize to + * @param {number} height - Height of the frame buffer to resize to + */ + Framebuffer.prototype.resize = function resize (width, height) + { + width = Math.ceil(width); + height = Math.ceil(height); + + if (width === this.width && height === this.height) { return; } + + this.width = width; + this.height = height; + + this.dirtyId++; + this.dirtySize++; + + for (var i = 0; i < this.colorTextures.length; i++) + { + var texture = this.colorTextures[i]; + var resolution = texture.resolution; + + // take into acount the fact the texture may have a different resolution.. + texture.setSize(width / resolution, height / resolution); + } + + if (this.depthTexture) + { + var resolution$1 = this.depthTexture.resolution; + + this.depthTexture.setSize(width / resolution$1, height / resolution$1); + } + }; + + /** + * disposes WebGL resources that are connected to this geometry + */ + Framebuffer.prototype.dispose = function dispose () + { + this.disposeRunner.run(this, false); + }; + + Object.defineProperties( Framebuffer.prototype, prototypeAccessors$1$2 ); + + /** + * A BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it. + * + * __Hint__: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded + * otherwise black rectangles will be drawn instead. + * + * A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position + * and rotation of the given Display Objects is ignored. For example: + * + * ```js + * let renderer = PIXI.autoDetectRenderer(); + * let baseRenderTexture = new PIXI.BaseRenderTexture(800, 600); + * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); + * let sprite = PIXI.Sprite.from("spinObj_01.png"); + * + * sprite.position.x = 800/2; + * sprite.position.y = 600/2; + * sprite.anchor.x = 0.5; + * sprite.anchor.y = 0.5; + * + * renderer.render(sprite, renderTexture); + * ``` + * + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform + * + * ```js + * + * sprite.setTransform() + * + * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); + * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture + * ``` + * + * @class + * @extends PIXI.BaseTexture + * @memberof PIXI + */ + var BaseRenderTexture = /*@__PURE__*/(function (BaseTexture) { + function BaseRenderTexture(options) + { + if (typeof options === 'number') + { + /* eslint-disable prefer-rest-params */ + // Backward compatibility of signature + var width$1 = arguments[0]; + var height$1 = arguments[1]; + var scaleMode = arguments[2]; + var resolution = arguments[3]; + + options = { width: width$1, height: height$1, scaleMode: scaleMode, resolution: resolution }; + /* eslint-enable prefer-rest-params */ + } + + BaseTexture.call(this, null, options); + + var ref = options || {}; + var width = ref.width; + var height = ref.height; + + // Set defaults + this.mipmap = false; + this.width = Math.ceil(width) || 100; + this.height = Math.ceil(height) || 100; + this.valid = true; + + /** + * A reference to the canvas render target (we only need one as this can be shared across renderers) + * + * @protected + * @member {object} + */ + this._canvasRenderTarget = null; + + this.clearColor = [0, 0, 0, 0]; + + this.framebuffer = new Framebuffer(this.width * this.resolution, this.height * this.resolution) + .addColorTexture(0, this) + .enableStencil(); + + // TODO - could this be added the systems? + + /** + * The data structure for the stencil masks. + * + * @member {PIXI.Graphics[]} + */ + this.stencilMaskStack = []; + + /** + * The data structure for the filters. + * + * @member {PIXI.Graphics[]} + */ + this.filterStack = [{}]; + } + + if ( BaseTexture ) { BaseRenderTexture.__proto__ = BaseTexture; } + BaseRenderTexture.prototype = Object.create( BaseTexture && BaseTexture.prototype ); + BaseRenderTexture.prototype.constructor = BaseRenderTexture; + + /** + * Resizes the BaseRenderTexture. + * + * @param {number} width - The width to resize to. + * @param {number} height - The height to resize to. + */ + BaseRenderTexture.prototype.resize = function resize (width, height) + { + width = Math.ceil(width); + height = Math.ceil(height); + this.framebuffer.resize(width * this.resolution, height * this.resolution); + }; + + /** + * Frees the texture and framebuffer from WebGL memory without destroying this texture object. + * This means you can still use the texture later which will upload it to GPU + * memory again. + * + * @fires PIXI.BaseTexture#dispose + */ + BaseRenderTexture.prototype.dispose = function dispose () + { + this.framebuffer.dispose(); + + BaseTexture.prototype.dispose.call(this); + }; + + /** + * Destroys this texture. + * + */ + BaseRenderTexture.prototype.destroy = function destroy () + { + BaseTexture.prototype.destroy.call(this, true); + + this.framebuffer = null; + + this.renderer = null; + }; + + return BaseRenderTexture; + }(BaseTexture)); + + /** + * A standard object to store the Uvs of a texture + * + * @class + * @protected + * @memberof PIXI + */ + var TextureUvs = function TextureUvs() + { + this.x0 = 0; + this.y0 = 0; + + this.x1 = 1; + this.y1 = 0; + + this.x2 = 1; + this.y2 = 1; + + this.x3 = 0; + this.y3 = 1; + + this.uvsFloat32 = new Float32Array(8); + }; + + /** + * Sets the texture Uvs based on the given frame information. + * + * @protected + * @param {PIXI.Rectangle} frame - The frame of the texture + * @param {PIXI.Rectangle} baseFrame - The base frame of the texture + * @param {number} rotate - Rotation of frame, see {@link PIXI.GroupD8} + */ + TextureUvs.prototype.set = function set (frame, baseFrame, rotate) + { + var tw = baseFrame.width; + var th = baseFrame.height; + + if (rotate) + { + // width and height div 2 div baseFrame size + var w2 = frame.width / 2 / tw; + var h2 = frame.height / 2 / th; + + // coordinates of center + var cX = (frame.x / tw) + w2; + var cY = (frame.y / th) + h2; + + rotate = GroupD8.add(rotate, GroupD8.NW); // NW is top-left corner + this.x0 = cX + (w2 * GroupD8.uX(rotate)); + this.y0 = cY + (h2 * GroupD8.uY(rotate)); + + rotate = GroupD8.add(rotate, 2); // rotate 90 degrees clockwise + this.x1 = cX + (w2 * GroupD8.uX(rotate)); + this.y1 = cY + (h2 * GroupD8.uY(rotate)); + + rotate = GroupD8.add(rotate, 2); + this.x2 = cX + (w2 * GroupD8.uX(rotate)); + this.y2 = cY + (h2 * GroupD8.uY(rotate)); + + rotate = GroupD8.add(rotate, 2); + this.x3 = cX + (w2 * GroupD8.uX(rotate)); + this.y3 = cY + (h2 * GroupD8.uY(rotate)); + } + else + { + this.x0 = frame.x / tw; + this.y0 = frame.y / th; + + this.x1 = (frame.x + frame.width) / tw; + this.y1 = frame.y / th; + + this.x2 = (frame.x + frame.width) / tw; + this.y2 = (frame.y + frame.height) / th; + + this.x3 = frame.x / tw; + this.y3 = (frame.y + frame.height) / th; + } + + this.uvsFloat32[0] = this.x0; + this.uvsFloat32[1] = this.y0; + this.uvsFloat32[2] = this.x1; + this.uvsFloat32[3] = this.y1; + this.uvsFloat32[4] = this.x2; + this.uvsFloat32[5] = this.y2; + this.uvsFloat32[6] = this.x3; + this.uvsFloat32[7] = this.y3; + }; + + var DEFAULT_UVS = new TextureUvs(); + + /** + * A texture stores the information that represents an image or part of an image. + * + * It cannot be added to the display list directly; instead use it as the texture for a Sprite. + * If no frame is provided for a texture, then the whole image is used. + * + * You can directly create a texture from an image and then reuse it multiple times like this : + * + * ```js + * let texture = PIXI.Texture.from('assets/image.png'); + * let sprite1 = new PIXI.Sprite(texture); + * let sprite2 = new PIXI.Sprite(texture); + * ``` + * + * Textures made from SVGs, loaded or not, cannot be used before the file finishes processing. + * You can check for this by checking the sprite's _textureID property. + * ```js + * var texture = PIXI.Texture.from('assets/image.svg'); + * var sprite1 = new PIXI.Sprite(texture); + * //sprite1._textureID should not be undefined if the texture has finished processing the SVG file + * ``` + * You can use a ticker or rAF to ensure your sprites load the finished textures after processing. See issue #3068. + * + * @class + * @extends PIXI.utils.EventEmitter + * @memberof PIXI + */ + var Texture = /*@__PURE__*/(function (EventEmitter) { + function Texture(baseTexture, frame, orig, trim, rotate, anchor) + { + EventEmitter.call(this); + + /** + * Does this Texture have any frame data assigned to it? + * + * @member {boolean} + */ + this.noFrame = false; + + if (!frame) + { + this.noFrame = true; + frame = new Rectangle(0, 0, 1, 1); + } + + if (baseTexture instanceof Texture) + { + baseTexture = baseTexture.baseTexture; + } + + /** + * The base texture that this texture uses. + * + * @member {PIXI.BaseTexture} + */ + this.baseTexture = baseTexture; + + /** + * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, + * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases) + * + * @member {PIXI.Rectangle} + */ + this._frame = frame; + + /** + * This is the trimmed area of original texture, before it was put in atlas + * Please call `updateUvs()` after you change coordinates of `trim` manually. + * + * @member {PIXI.Rectangle} + */ + this.trim = trim; + + /** + * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. + * + * @member {boolean} + */ + this.valid = false; + + /** + * This will let a renderer know that a texture has been updated (used mainly for WebGL uv updates) + * + * @member {boolean} + */ + this.requiresUpdate = false; + + /** + * The WebGL UV data cache. Can be used as quad UV + * + * @member {PIXI.TextureUvs} + * @protected + */ + this._uvs = DEFAULT_UVS; + + /** + * Default TextureMatrix instance for this texture + * By default that object is not created because its heavy + * + * @member {PIXI.TextureMatrix} + */ + this.uvMatrix = null; + + /** + * This is the area of original texture, before it was put in atlas + * + * @member {PIXI.Rectangle} + */ + this.orig = orig || frame;// new Rectangle(0, 0, 1, 1); + + this._rotate = Number(rotate || 0); + + if (rotate === true) + { + // this is old texturepacker legacy, some games/libraries are passing "true" for rotated textures + this._rotate = 2; + } + else if (this._rotate % 2 !== 0) + { + throw new Error('attempt to use diamond-shaped UVs. If you are sure, set rotation manually'); + } + + if (baseTexture.valid) + { + if (this.noFrame) + { + frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height); + + // if there is no frame we should monitor for any base texture changes.. + baseTexture.on('update', this.onBaseTextureUpdated, this); + } + + this.frame = frame; + } + else + { + baseTexture.once('loaded', this.onBaseTextureUpdated, this); + } + + /** + * Anchor point that is used as default if sprite is created with this texture. + * Changing the `defaultAnchor` at a later point of time will not update Sprite's anchor point. + * @member {PIXI.Point} + * @default {0,0} + */ + this.defaultAnchor = anchor ? new Point(anchor.x, anchor.y) : new Point(0, 0); + + /** + * Update ID is observed by sprites and TextureMatrix instances. + * Call updateUvs() to increment it. + * + * @member {number} + * @protected + */ + + this._updateID = 0; + + /** + * The ids under which this Texture has been added to the texture cache. This is + * automatically set as long as Texture.addToCache is used, but may not be set if a + * Texture is added directly to the TextureCache array. + * + * @member {string[]} + */ + this.textureCacheIds = []; + } + + if ( EventEmitter ) { Texture.__proto__ = EventEmitter; } + Texture.prototype = Object.create( EventEmitter && EventEmitter.prototype ); + Texture.prototype.constructor = Texture; + + var prototypeAccessors = { frame: { configurable: true },rotate: { configurable: true },width: { configurable: true },height: { configurable: true } }; + + /** + * Updates this texture on the gpu. + * + */ + Texture.prototype.update = function update () + { + this.baseTexture.update(); + }; + + /** + * Called when the base texture is updated + * + * @protected + * @param {PIXI.BaseTexture} baseTexture - The base texture. + */ + Texture.prototype.onBaseTextureUpdated = function onBaseTextureUpdated (baseTexture) + { + this._updateID++; + + // TODO this code looks confusing.. boo to abusing getters and setters! + if (this.noFrame) + { + this.frame = new Rectangle(0, 0, baseTexture.width, baseTexture.height); + } + else + { + this.frame = this._frame; + // TODO maybe watch out for the no frame option + // updating the texture will should update the frame if it was set to no frame.. + } + + this.emit('update', this); + }; + + /** + * Destroys this texture + * + * @param {boolean} [destroyBase=false] Whether to destroy the base texture as well + */ + Texture.prototype.destroy = function destroy (destroyBase) + { + if (this.baseTexture) + { + if (destroyBase) + { + // delete the texture if it exists in the texture cache.. + // this only needs to be removed if the base texture is actually destroyed too.. + if (TextureCache[this.baseTexture.imageUrl]) + { + Texture.removeFromCache(this.baseTexture.imageUrl); + } + + this.baseTexture.destroy(); + } + + this.baseTexture.off('update', this.onBaseTextureUpdated, this); + + this.baseTexture = null; + } + + this._frame = null; + this._uvs = null; + this.trim = null; + this.orig = null; + + this.valid = false; + + Texture.removeFromCache(this); + this.textureCacheIds = null; + }; + + /** + * Creates a new texture object that acts the same as this one. + * + * @return {PIXI.Texture} The new texture + */ + Texture.prototype.clone = function clone () + { + return new Texture(this.baseTexture, this.frame, this.orig, this.trim, this.rotate, this.defaultAnchor); + }; + + /** + * Updates the internal WebGL UV cache. Use it after you change `frame` or `trim` of the texture. + * Call it after changing the frame + */ + Texture.prototype.updateUvs = function updateUvs () + { + if (this._uvs === DEFAULT_UVS) + { + this._uvs = new TextureUvs(); + } + + this._uvs.set(this._frame, this.baseTexture, this.rotate); + + this._updateID++; + }; + + /** + * Helper function that creates a new Texture based on the source you provide. + * The source can be - frame id, image url, video url, canvas element, video element, base texture + * + * @static + * @param {number|string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|PIXI.BaseTexture} source + * Source to create texture from + * @param {object} [options] See {@link PIXI.BaseTexture}'s constructor for options. + * @return {PIXI.Texture} The newly created texture + */ + Texture.from = function from (source, options) + { + if ( options === void 0 ) { options = {}; } + + var cacheId = null; + + if (typeof source === 'string') + { + cacheId = source; + } + else + { + if (!source._pixiId) + { + source._pixiId = "pixiid_" + (uid()); + } + + cacheId = source._pixiId; + } + + var texture = TextureCache[cacheId]; + + if (!texture) + { + if (!options.resolution) + { + options.resolution = getResolutionOfUrl(source); + } + + texture = new Texture(new BaseTexture(source, options)); + texture.baseTexture.cacheId = cacheId; + + BaseTexture.addToCache(texture.baseTexture, cacheId); + Texture.addToCache(texture, cacheId); + } + + // lets assume its a base texture! + return texture; + }; + + /** + * Create a new Texture with a BufferResource from a Float32Array. + * RGBA values are floats from 0 to 1. + * @static + * @param {Float32Array|Uint8Array} buffer The optional array to use, if no data + * is provided, a new Float32Array is created. + * @param {number} width - Width of the resource + * @param {number} height - Height of the resource + * @param {object} [options] See {@link PIXI.BaseTexture}'s constructor for options. + * @return {PIXI.Texture} The resulting new BaseTexture + */ + Texture.fromBuffer = function fromBuffer (buffer, width, height, options) + { + return new Texture(BaseTexture.fromBuffer(buffer, width, height, options)); + }; + + /** + * Create a texture from a source and add to the cache. + * + * @static + * @param {HTMLImageElement|HTMLCanvasElement} source - The input source. + * @param {String} imageUrl - File name of texture, for cache and resolving resolution. + * @param {String} [name] - Human readable name for the texture cache. If no name is + * specified, only `imageUrl` will be used as the cache ID. + * @return {PIXI.Texture} Output texture + */ + Texture.fromLoader = function fromLoader (source, imageUrl, name) + { + var resource = new ImageResource(source); + + resource.url = imageUrl; + + var baseTexture = new BaseTexture(resource, { + scaleMode: settings.SCALE_MODE, + resolution: getResolutionOfUrl(imageUrl), + }); + + var texture = new Texture(baseTexture); + + // No name, use imageUrl instead + if (!name) + { + name = imageUrl; + } + + // lets also add the frame to pixi's global cache for 'fromLoader' function + BaseTexture.addToCache(texture.baseTexture, name); + Texture.addToCache(texture, name); + + // also add references by url if they are different. + if (name !== imageUrl) + { + BaseTexture.addToCache(texture.baseTexture, imageUrl); + Texture.addToCache(texture, imageUrl); + } + + return texture; + }; + + /** + * Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object. + * + * @static + * @param {PIXI.Texture} texture - The Texture to add to the cache. + * @param {string} id - The id that the Texture will be stored against. + */ + Texture.addToCache = function addToCache (texture, id) + { + if (id) + { + if (texture.textureCacheIds.indexOf(id) === -1) + { + texture.textureCacheIds.push(id); + } + + if (TextureCache[id]) + { + // eslint-disable-next-line no-console + console.warn(("Texture added to the cache with an id [" + id + "] that already had an entry")); + } + + TextureCache[id] = texture; + } + }; + + /** + * Remove a Texture from the global TextureCache. + * + * @static + * @param {string|PIXI.Texture} texture - id of a Texture to be removed, or a Texture instance itself + * @return {PIXI.Texture|null} The Texture that was removed + */ + Texture.removeFromCache = function removeFromCache (texture) + { + if (typeof texture === 'string') + { + var textureFromCache = TextureCache[texture]; + + if (textureFromCache) + { + var index = textureFromCache.textureCacheIds.indexOf(texture); + + if (index > -1) + { + textureFromCache.textureCacheIds.splice(index, 1); + } + + delete TextureCache[texture]; + + return textureFromCache; + } + } + else if (texture && texture.textureCacheIds) + { + for (var i = 0; i < texture.textureCacheIds.length; ++i) + { + // Check that texture matches the one being passed in before deleting it from the cache. + if (TextureCache[texture.textureCacheIds[i]] === texture) + { + delete TextureCache[texture.textureCacheIds[i]]; + } + } + + texture.textureCacheIds.length = 0; + + return texture; + } + + return null; + }; + + /** + * The frame specifies the region of the base texture that this texture uses. + * Please call `updateUvs()` after you change coordinates of `frame` manually. + * + * @member {PIXI.Rectangle} + */ + prototypeAccessors.frame.get = function () + { + return this._frame; + }; + + prototypeAccessors.frame.set = function (frame) // eslint-disable-line require-jsdoc + { + this._frame = frame; + + this.noFrame = false; + + var x = frame.x; + var y = frame.y; + var width = frame.width; + var height = frame.height; + var xNotFit = x + width > this.baseTexture.width; + var yNotFit = y + height > this.baseTexture.height; + + if (xNotFit || yNotFit) + { + var relationship = xNotFit && yNotFit ? 'and' : 'or'; + var errorX = "X: " + x + " + " + width + " = " + (x + width) + " > " + (this.baseTexture.width); + var errorY = "Y: " + y + " + " + height + " = " + (y + height) + " > " + (this.baseTexture.height); + + throw new Error('Texture Error: frame does not fit inside the base Texture dimensions: ' + + errorX + " " + relationship + " " + errorY); + } + + this.valid = width && height && this.baseTexture.valid; + + if (!this.trim && !this.rotate) + { + this.orig = frame; + } + + if (this.valid) + { + this.updateUvs(); + } + }; + + /** + * Indicates whether the texture is rotated inside the atlas + * set to 2 to compensate for texture packer rotation + * set to 6 to compensate for spine packer rotation + * can be used to rotate or mirror sprites + * See {@link PIXI.GroupD8} for explanation + * + * @member {number} + */ + prototypeAccessors.rotate.get = function () + { + return this._rotate; + }; + + prototypeAccessors.rotate.set = function (rotate) // eslint-disable-line require-jsdoc + { + this._rotate = rotate; + if (this.valid) + { + this.updateUvs(); + } + }; + + /** + * The width of the Texture in pixels. + * + * @member {number} + */ + prototypeAccessors.width.get = function () + { + return this.orig.width; + }; + + /** + * The height of the Texture in pixels. + * + * @member {number} + */ + prototypeAccessors.height.get = function () + { + return this.orig.height; + }; + + Object.defineProperties( Texture.prototype, prototypeAccessors ); + + return Texture; + }(eventemitter3)); + + function createWhiteTexture() + { + var canvas = document.createElement('canvas'); + + canvas.width = 16; + canvas.height = 16; + + var context = canvas.getContext('2d'); + + context.fillStyle = 'white'; + context.fillRect(0, 0, 16, 16); + + return new Texture(new BaseTexture(new CanvasResource(canvas))); + } + + function removeAllHandlers(tex) + { + tex.destroy = function _emptyDestroy() { /* empty */ }; + tex.on = function _emptyOn() { /* empty */ }; + tex.once = function _emptyOnce() { /* empty */ }; + tex.emit = function _emptyEmit() { /* empty */ }; + } + + /** + * An empty texture, used often to not have to create multiple empty textures. + * Can not be destroyed. + * + * @static + * @constant + * @member {PIXI.Texture} + */ + Texture.EMPTY = new Texture(new BaseTexture()); + removeAllHandlers(Texture.EMPTY); + removeAllHandlers(Texture.EMPTY.baseTexture); + + /** + * A white texture of 10x10 size, used for graphics and other things + * Can not be destroyed. + * + * @static + * @constant + * @member {PIXI.Texture} + */ + Texture.WHITE = createWhiteTexture(); + removeAllHandlers(Texture.WHITE); + removeAllHandlers(Texture.WHITE.baseTexture); + + /** + * A RenderTexture is a special texture that allows any PixiJS display object to be rendered to it. + * + * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded + * otherwise black rectangles will be drawn instead. + * + * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: + * + * ```js + * let renderer = PIXI.autoDetectRenderer(); + * let renderTexture = PIXI.RenderTexture.create(800, 600); + * let sprite = PIXI.Sprite.from("spinObj_01.png"); + * + * sprite.position.x = 800/2; + * sprite.position.y = 600/2; + * sprite.anchor.x = 0.5; + * sprite.anchor.y = 0.5; + * + * renderer.render(sprite, renderTexture); + * ``` + * + * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 + * you can clear the transform + * + * ```js + * + * sprite.setTransform() + * + * let renderTexture = new PIXI.RenderTexture.create(100, 100); + * + * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture + * ``` + * + * @class + * @extends PIXI.Texture + * @memberof PIXI + */ + var RenderTexture = /*@__PURE__*/(function (Texture) { + function RenderTexture(baseRenderTexture, frame) + { + // support for legacy.. + var _legacyRenderer = null; + + if (!(baseRenderTexture instanceof BaseRenderTexture)) + { + /* eslint-disable prefer-rest-params, no-console */ + var width = arguments[1]; + var height = arguments[2]; + var scaleMode = arguments[3]; + var resolution = arguments[4]; + + // we have an old render texture.. + console.warn(("Please use RenderTexture.create(" + width + ", " + height + ") instead of the ctor directly.")); + _legacyRenderer = arguments[0]; + /* eslint-enable prefer-rest-params, no-console */ + + frame = null; + baseRenderTexture = new BaseRenderTexture({ + width: width, + height: height, + scaleMode: scaleMode, + resolution: resolution, + }); + } + + /** + * The base texture object that this texture uses + * + * @member {BaseTexture} + */ + Texture.call(this, baseRenderTexture, frame); + + this.legacyRenderer = _legacyRenderer; + + /** + * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. + * + * @member {boolean} + */ + this.valid = true; + + /** + * FilterSystem temporary storage + * @protected + * @member {PIXI.Rectangle} + */ + this.filterFrame = null; + + /** + * The key for pooled texture of FilterSystem + * @protected + * @member {string} + */ + this.filterPoolKey = null; + + this.updateUvs(); + } + + if ( Texture ) { RenderTexture.__proto__ = Texture; } + RenderTexture.prototype = Object.create( Texture && Texture.prototype ); + RenderTexture.prototype.constructor = RenderTexture; + + /** + * Resizes the RenderTexture. + * + * @param {number} width - The width to resize to. + * @param {number} height - The height to resize to. + * @param {boolean} [resizeBaseTexture=true] - Should the baseTexture.width and height values be resized as well? + */ + RenderTexture.prototype.resize = function resize (width, height, resizeBaseTexture) + { + if ( resizeBaseTexture === void 0 ) { resizeBaseTexture = true; } + + width = Math.ceil(width); + height = Math.ceil(height); + + // TODO - could be not required.. + this.valid = (width > 0 && height > 0); + + this._frame.width = this.orig.width = width; + this._frame.height = this.orig.height = height; + + if (resizeBaseTexture) + { + this.baseTexture.resize(width, height); + } + + this.updateUvs(); + }; + + /** + * A short hand way of creating a render texture. + * + * @param {object} [options] - Options + * @param {number} [options.width=100] - The width of the render texture + * @param {number} [options.height=100] - The height of the render texture + * @param {number} [options.scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values + * @param {number} [options.resolution=1] - The resolution / device pixel ratio of the texture being generated + * @return {PIXI.RenderTexture} The new render texture + */ + RenderTexture.create = function create (options) + { + // fallback, old-style: create(width, height, scaleMode, resolution) + if (typeof options === 'number') + { + /* eslint-disable prefer-rest-params */ + options = { + width: options, + height: arguments[1], + scaleMode: arguments[2], + resolution: arguments[3], + }; + /* eslint-enable prefer-rest-params */ + } + + return new RenderTexture(new BaseRenderTexture(options)); + }; + + return RenderTexture; + }(Texture)); + + /* eslint-disable max-len */ + + /** + * Holds the information for a single attribute structure required to render geometry. + * + * This does not contain the actual data, but instead has a buffer id that maps to a {@link PIXI.Buffer} + * This can include anything from positions, uvs, normals, colors etc. + * + * @class + * @memberof PIXI + */ + var Attribute = function Attribute(buffer, size, normalized, type, stride, start, instance) + { + if ( normalized === void 0 ) { normalized = false; } + if ( type === void 0 ) { type = 5126; } + + this.buffer = buffer; + this.size = size; + this.normalized = normalized; + this.type = type; + this.stride = stride; + this.start = start; + this.instance = instance; + }; + + /** + * Destroys the Attribute. + */ + Attribute.prototype.destroy = function destroy () + { + this.buffer = null; + }; + + /** + * Helper function that creates an Attribute based on the information provided + * + * @static + * @param {string} buffer the id of the buffer that this attribute will look for + * @param {Number} [size=2] the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2 + * @param {Number} [stride=0] How far apart (in floats) the start of each value is. (used for interleaving data) + * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) + * @param {Boolean} [normalized=false] should the data be normalized. + * + * @returns {PIXI.Attribute} A new {@link PIXI.Attribute} based on the information provided + */ + Attribute.from = function from (buffer, size, normalized, type, stride) + { + return new Attribute(buffer, size, normalized, type, stride); + }; + + var UID = 0; + /* eslint-disable max-len */ + + /** + * A wrapper for data so that it can be used and uploaded by WebGL + * + * @class + * @memberof PIXI + */ + var Buffer = function Buffer(data, _static, index) + { + if ( _static === void 0 ) { _static = true; } + if ( index === void 0 ) { index = false; } + + /** + * The data in the buffer, as a typed array + * + * @member {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} + */ + this.data = data || new Float32Array(1); + + /** + * A map of renderer IDs to webgl buffer + * + * @private + * @member {object} + */ + this._glBuffers = {}; + + this._updateID = 0; + + this.index = index; + + this.static = _static; + + this.id = UID++; + + this.disposeRunner = new Runner('disposeBuffer', 2); + }; + + // TODO could explore flagging only a partial upload? + /** + * flags this buffer as requiring an upload to the GPU + * @param {ArrayBuffer|SharedArrayBuffer|ArrayBufferView} [data] the data to update in the buffer. + */ + Buffer.prototype.update = function update (data) + { + this.data = data || this.data; + this._updateID++; + }; + + /** + * disposes WebGL resources that are connected to this geometry + */ + Buffer.prototype.dispose = function dispose () + { + this.disposeRunner.run(this, false); + }; + + /** + * Destroys the buffer + */ + Buffer.prototype.destroy = function destroy () + { + this.dispose(); + + this.data = null; + }; + + /** + * Helper function that creates a buffer based on an array or TypedArray + * + * @static + * @param {ArrayBufferView | number[]} data the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array. + * @return {PIXI.Buffer} A new Buffer based on the data provided. + */ + Buffer.from = function from (data) + { + if (data instanceof Array) + { + data = new Float32Array(data); + } + + return new Buffer(data); + }; + + function getBufferType(array) + { + if (array.BYTES_PER_ELEMENT === 4) + { + if (array instanceof Float32Array) + { + return 'Float32Array'; + } + else if (array instanceof Uint32Array) + { + return 'Uint32Array'; + } + + return 'Int32Array'; + } + else if (array.BYTES_PER_ELEMENT === 2) + { + if (array instanceof Uint16Array) + { + return 'Uint16Array'; + } + } + else if (array.BYTES_PER_ELEMENT === 1) + { + if (array instanceof Uint8Array) + { + return 'Uint8Array'; + } + } + + // TODO map out the rest of the array elements! + return null; + } + + /* eslint-disable object-shorthand */ + var map = { + Float32Array: Float32Array, + Uint32Array: Uint32Array, + Int32Array: Int32Array, + Uint8Array: Uint8Array, + }; + + function interleaveTypedArrays(arrays, sizes) + { + var outSize = 0; + var stride = 0; + var views = {}; + + for (var i = 0; i < arrays.length; i++) + { + stride += sizes[i]; + outSize += arrays[i].length; + } + + var buffer = new ArrayBuffer(outSize * 4); + + var out = null; + var littleOffset = 0; + + for (var i$1 = 0; i$1 < arrays.length; i$1++) + { + var size = sizes[i$1]; + var array = arrays[i$1]; + + var type = getBufferType(array); + + if (!views[type]) + { + views[type] = new map[type](buffer); + } + + out = views[type]; + + for (var j = 0; j < array.length; j++) + { + var indexStart = ((j / size | 0) * stride) + littleOffset; + var index = j % size; + + out[indexStart + index] = array[j]; + } + + littleOffset += size; + } + + return new Float32Array(buffer); + } + + var byteSizeMap = { 5126: 4, 5123: 2, 5121: 1 }; + var UID$1 = 0; + + /* eslint-disable object-shorthand */ + var map$1 = { + Float32Array: Float32Array, + Uint32Array: Uint32Array, + Int32Array: Int32Array, + Uint8Array: Uint8Array, + Uint16Array: Uint16Array, + }; + + /* eslint-disable max-len */ + + /** + * The Geometry represents a model. It consists of two components: + * - GeometryStyle - The structure of the model such as the attributes layout + * - GeometryData - the data of the model - this consists of buffers. + * This can include anything from positions, uvs, normals, colors etc. + * + * Geometry can be defined without passing in a style or data if required (thats how I prefer!) + * + * ```js + * let geometry = new PIXI.Geometry(); + * + * geometry.addAttribute('positions', [0, 0, 100, 0, 100, 100, 0, 100], 2); + * geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1],2) + * geometry.addIndex([0,1,2,1,3,2]) + * + * ``` + * @class + * @memberof PIXI + */ + var Geometry = function Geometry(buffers, attributes) + { + if ( buffers === void 0 ) { buffers = []; } + if ( attributes === void 0 ) { attributes = {}; } + + this.buffers = buffers; + + this.indexBuffer = null; + + this.attributes = attributes; + + /** + * A map of renderer IDs to webgl VAOs + * + * @protected + * @type {object} + */ + this.glVertexArrayObjects = {}; + + this.id = UID$1++; + + this.instanced = false; + + this.instanceCount = 1; + + this._size = null; + + this.disposeRunner = new Runner('disposeGeometry', 2); + + /** + * Count of existing (not destroyed) meshes that reference this geometry + * @member {boolean} + */ + this.refCount = 0; + }; + + /** + * + * Adds an attribute to the geometry + * + * @param {String} id - the name of the attribute (matching up to a shader) + * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it. + * @param {Number} [size=0] the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2 + * @param {Boolean} [normalized=false] should the data be normalized. + * @param {Number} [type=PIXI.TYPES.FLOAT] what type of number is the attribute. Check {PIXI.TYPES} to see the ones available + * @param {Number} [stride=0] How far apart (in floats) the start of each value is. (used for interleaving data) + * @param {Number} [start=0] How far into the array to start reading values (used for interleaving data) + * + * @return {PIXI.Geometry} returns self, useful for chaining. + */ + Geometry.prototype.addAttribute = function addAttribute (id, buffer, size, normalized, type, stride, start, instance) + { + if ( normalized === void 0 ) { normalized = false; } + if ( instance === void 0 ) { instance = false; } + + if (!buffer) + { + throw new Error('You must pass a buffer when creating an attribute'); + } + + // check if this is a buffer! + if (!buffer.data) + { + // its an array! + if (buffer instanceof Array) + { + buffer = new Float32Array(buffer); + } + + buffer = new Buffer(buffer); + } + + var ids = id.split('|'); + + if (ids.length > 1) + { + for (var i = 0; i < ids.length; i++) + { + this.addAttribute(ids[i], buffer, size, normalized, type); + } + + return this; + } + + var bufferIndex = this.buffers.indexOf(buffer); + + if (bufferIndex === -1) + { + this.buffers.push(buffer); + bufferIndex = this.buffers.length - 1; + } + + this.attributes[id] = new Attribute(bufferIndex, size, normalized, type, stride, start, instance); + + // assuming that if there is instanced data then this will be drawn with instancing! + this.instanced = this.instanced || instance; + + return this; + }; + + /** + * returns the requested attribute + * + * @param {String} id the name of the attribute required + * @return {PIXI.Attribute} the attribute requested. + */ + Geometry.prototype.getAttribute = function getAttribute (id) + { + return this.attributes[id]; + }; + + /** + * returns the requested buffer + * + * @param {String} id the name of the buffer required + * @return {PIXI.Buffer} the buffer requested. + */ + Geometry.prototype.getBuffer = function getBuffer (id) + { + return this.buffers[this.getAttribute(id).buffer]; + }; + + /** + * + * Adds an index buffer to the geometry + * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer. + * + * @param {PIXI.Buffer} [buffer] the buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. + * @return {PIXI.Geometry} returns self, useful for chaining. + */ + Geometry.prototype.addIndex = function addIndex (buffer) + { + if (!buffer.data) + { + // its an array! + if (buffer instanceof Array) + { + buffer = new Uint16Array(buffer); + } + + buffer = new Buffer(buffer); + } + + buffer.index = true; + this.indexBuffer = buffer; + + if (this.buffers.indexOf(buffer) === -1) + { + this.buffers.push(buffer); + } + + return this; + }; + + /** + * returns the index buffer + * + * @return {PIXI.Buffer} the index buffer. + */ + Geometry.prototype.getIndex = function getIndex () + { + return this.indexBuffer; + }; + + /** + * this function modifies the structure so that all current attributes become interleaved into a single buffer + * This can be useful if your model remains static as it offers a little performance boost + * + * @return {PIXI.Geometry} returns self, useful for chaining. + */ + Geometry.prototype.interleave = function interleave () + { + // a simple check to see if buffers are already interleaved.. + if (this.buffers.length === 1 || (this.buffers.length === 2 && this.indexBuffer)) { return this; } + + // assume already that no buffers are interleaved + var arrays = []; + var sizes = []; + var interleavedBuffer = new Buffer(); + var i; + + for (i in this.attributes) + { + var attribute = this.attributes[i]; + + var buffer = this.buffers[attribute.buffer]; + + arrays.push(buffer.data); + + sizes.push((attribute.size * byteSizeMap[attribute.type]) / 4); + + attribute.buffer = 0; + } + + interleavedBuffer.data = interleaveTypedArrays(arrays, sizes); + + for (i = 0; i < this.buffers.length; i++) + { + if (this.buffers[i] !== this.indexBuffer) + { + this.buffers[i].destroy(); + } + } + + this.buffers = [interleavedBuffer]; + + if (this.indexBuffer) + { + this.buffers.push(this.indexBuffer); + } + + return this; + }; + + Geometry.prototype.getSize = function getSize () + { + for (var i in this.attributes) + { + var attribute = this.attributes[i]; + var buffer = this.buffers[attribute.buffer]; + + return buffer.data.length / ((attribute.stride / 4) || attribute.size); + } + + return 0; + }; + + /** + * disposes WebGL resources that are connected to this geometry + */ + Geometry.prototype.dispose = function dispose () + { + this.disposeRunner.run(this, false); + }; + + /** + * Destroys the geometry. + */ + Geometry.prototype.destroy = function destroy () + { + this.dispose(); + + this.buffers = null; + this.indexBuffer.destroy(); + + this.attributes = null; + }; + + /** + * returns a clone of the geometry + * + * @returns {PIXI.Geometry} a new clone of this geometry + */ + Geometry.prototype.clone = function clone () + { + var geometry = new Geometry(); + + for (var i = 0; i < this.buffers.length; i++) + { + geometry.buffers[i] = new Buffer(this.buffers[i].data.slice()); + } + + for (var i$1 in this.attributes) + { + var attrib = this.attributes[i$1]; + + geometry.attributes[i$1] = new Attribute( + attrib.buffer, + attrib.size, + attrib.normalized, + attrib.type, + attrib.stride, + attrib.start, + attrib.instance + ); + } + + if (this.indexBuffer) + { + geometry.indexBuffer = geometry.buffers[this.buffers.indexOf(this.indexBuffer)]; + geometry.indexBuffer.index = true; + } + + return geometry; + }; + + /** + * merges an array of geometries into a new single one + * geometry attribute styles must match for this operation to work + * + * @param {PIXI.Geometry[]} geometries array of geometries to merge + * @returns {PIXI.Geometry} shiny new geometry! + */ + Geometry.merge = function merge (geometries) + { + // todo add a geometry check! + // also a size check.. cant be too big!] + + var geometryOut = new Geometry(); + + var arrays = []; + var sizes = []; + var offsets = []; + + var geometry; + + // pass one.. get sizes.. + for (var i = 0; i < geometries.length; i++) + { + geometry = geometries[i]; + + for (var j = 0; j < geometry.buffers.length; j++) + { + sizes[j] = sizes[j] || 0; + sizes[j] += geometry.buffers[j].data.length; + offsets[j] = 0; + } + } + + // build the correct size arrays.. + for (var i$1 = 0; i$1 < geometry.buffers.length; i$1++) + { + // TODO types! + arrays[i$1] = new map$1[getBufferType(geometry.buffers[i$1].data)](sizes[i$1]); + geometryOut.buffers[i$1] = new Buffer(arrays[i$1]); + } + + // pass to set data.. + for (var i$2 = 0; i$2 < geometries.length; i$2++) + { + geometry = geometries[i$2]; + + for (var j$1 = 0; j$1 < geometry.buffers.length; j$1++) + { + arrays[j$1].set(geometry.buffers[j$1].data, offsets[j$1]); + offsets[j$1] += geometry.buffers[j$1].data.length; + } + } + + geometryOut.attributes = geometry.attributes; + + if (geometry.indexBuffer) + { + geometryOut.indexBuffer = geometryOut.buffers[geometry.buffers.indexOf(geometry.indexBuffer)]; + geometryOut.indexBuffer.index = true; + + var offset = 0; + var stride = 0; + var offset2 = 0; + var bufferIndexToCount = 0; + + // get a buffer + for (var i$3 = 0; i$3 < geometry.buffers.length; i$3++) + { + if (geometry.buffers[i$3] !== geometry.indexBuffer) + { + bufferIndexToCount = i$3; + break; + } + } + + // figure out the stride of one buffer.. + for (var i$4 in geometry.attributes) + { + var attribute = geometry.attributes[i$4]; + + if ((attribute.buffer | 0) === bufferIndexToCount) + { + stride += ((attribute.size * byteSizeMap[attribute.type]) / 4); + } + } + + // time to off set all indexes.. + for (var i$5 = 0; i$5 < geometries.length; i$5++) + { + var indexBufferData = geometries[i$5].indexBuffer.data; + + for (var j$2 = 0; j$2 < indexBufferData.length; j$2++) + { + geometryOut.indexBuffer.data[j$2 + offset2] += offset; + } + + offset += geometry.buffers[bufferIndexToCount].data.length / (stride); + offset2 += indexBufferData.length; + } + } + + return geometryOut; + }; + + /** + * Helper class to create a quad + * + * @class + * @memberof PIXI + */ + var Quad = /*@__PURE__*/(function (Geometry) { + function Quad() + { + Geometry.call(this); + + this.addAttribute('aVertexPosition', [ + 0, 0, + 1, 0, + 1, 1, + 0, 1 ]) + .addIndex([0, 1, 3, 2]); + } + + if ( Geometry ) { Quad.__proto__ = Geometry; } + Quad.prototype = Object.create( Geometry && Geometry.prototype ); + Quad.prototype.constructor = Quad; + + return Quad; + }(Geometry)); + + /** + * Helper class to create a quad with uvs like in v4 + * + * @class + * @memberof PIXI + */ + var QuadUv = /*@__PURE__*/(function (Geometry) { + function QuadUv() + { + Geometry.call(this); + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = new Float32Array([ + -1, -1, + 1, -1, + 1, 1, + -1, 1 ]); + + /** + * The Uvs of the quad + * + * @member {Float32Array} + */ + this.uvs = new Float32Array([ + 0, 0, + 1, 0, + 1, 1, + 0, 1 ]); + + this.vertexBuffer = new Buffer(this.vertices); + this.uvBuffer = new Buffer(this.uvs); + + this.addAttribute('aVertexPosition', this.vertexBuffer) + .addAttribute('aTextureCoord', this.uvBuffer) + .addIndex([0, 1, 2, 0, 2, 3]); + } + + if ( Geometry ) { QuadUv.__proto__ = Geometry; } + QuadUv.prototype = Object.create( Geometry && Geometry.prototype ); + QuadUv.prototype.constructor = QuadUv; + + /** + * Maps two Rectangle to the quad. + * + * @param {PIXI.Rectangle} targetTextureFrame - the first rectangle + * @param {PIXI.Rectangle} destinationFrame - the second rectangle + * @return {PIXI.Quad} Returns itself. + */ + QuadUv.prototype.map = function map (targetTextureFrame, destinationFrame) + { + var x = 0; // destinationFrame.x / targetTextureFrame.width; + var y = 0; // destinationFrame.y / targetTextureFrame.height; + + this.uvs[0] = x; + this.uvs[1] = y; + + this.uvs[2] = x + (destinationFrame.width / targetTextureFrame.width); + this.uvs[3] = y; + + this.uvs[4] = x + (destinationFrame.width / targetTextureFrame.width); + this.uvs[5] = y + (destinationFrame.height / targetTextureFrame.height); + + this.uvs[6] = x; + this.uvs[7] = y + (destinationFrame.height / targetTextureFrame.height); + + x = destinationFrame.x; + y = destinationFrame.y; + + this.vertices[0] = x; + this.vertices[1] = y; + + this.vertices[2] = x + destinationFrame.width; + this.vertices[3] = y; + + this.vertices[4] = x + destinationFrame.width; + this.vertices[5] = y + destinationFrame.height; + + this.vertices[6] = x; + this.vertices[7] = y + destinationFrame.height; + + this.invalidate(); + + return this; + }; + + /** + * legacy upload method, just marks buffers dirty + * @returns {PIXI.QuadUv} Returns itself. + */ + QuadUv.prototype.invalidate = function invalidate () + { + this.vertexBuffer._updateID++; + this.uvBuffer._updateID++; + + return this; + }; + + return QuadUv; + }(Geometry)); + + var UID$2 = 0; + + /** + * Uniform group holds uniform map and some ID's for work + * + * @class + * @memberof PIXI + */ + var UniformGroup = function UniformGroup(uniforms, _static) + { + /** + * uniform values + * @member {object} + * @readonly + */ + this.uniforms = uniforms; + + /** + * Its a group and not a single uniforms + * @member {boolean} + * @readonly + * @default true + */ + this.group = true; + + // lets generate this when the shader ? + this.syncUniforms = {}; + + /** + * dirty version + * @protected + * @member {number} + */ + this.dirtyId = 0; + + /** + * unique id + * @protected + * @member {number} + */ + this.id = UID$2++; + + /** + * Uniforms wont be changed after creation + * @member {boolean} + */ + this.static = !!_static; + }; + + UniformGroup.prototype.update = function update () + { + this.dirtyId++; + }; + + UniformGroup.prototype.add = function add (name, uniforms, _static) + { + this.uniforms[name] = new UniformGroup(uniforms, _static); + }; + + UniformGroup.from = function from (uniforms, _static) + { + return new UniformGroup(uniforms, _static); + }; + + /** + * System plugin to the renderer to manage filter states. + * + * @class + * @private + */ + var FilterState = function FilterState() + { + this.renderTexture = null; + + /** + * Target of the filters + * We store for case when custom filter wants to know the element it was applied on + * @member {PIXI.DisplayObject} + * @private + */ + this.target = null; + + /** + * Compatibility with PixiJS v4 filters + * @member {boolean} + * @default false + * @private + */ + this.legacy = false; + + /** + * Resolution of filters + * @member {number} + * @default 1 + * @private + */ + this.resolution = 1; + + // next three fields are created only for root + // re-assigned for everything else + + /** + * Source frame + * @member {PIXI.Rectangle} + * @private + */ + this.sourceFrame = new Rectangle(); + + /** + * Destination frame + * @member {PIXI.Rectangle} + * @private + */ + this.destinationFrame = new Rectangle(); + + /** + * Collection of filters + * @member {PIXI.Filter[]} + * @private + */ + this.filters = []; + }; + + /** + * clears the state + * @private + */ + FilterState.prototype.clear = function clear () + { + this.target = null; + this.filters = null; + this.renderTexture = null; + }; + + var screenKey = 'screen'; + + /** + * System plugin to the renderer to manage the filters. + * + * @class + * @memberof PIXI.systems + * @extends PIXI.System + */ + var FilterSystem = /*@__PURE__*/(function (System) { + function FilterSystem(renderer) + { + System.call(this, renderer); + + /** + * List of filters for the FilterSystem + * @member {Object[]} + * @readonly + */ + this.defaultFilterStack = [{}]; + + /** + * stores a bunch of PO2 textures used for filtering + * @member {Object} + */ + this.texturePool = {}; + + /** + * a pool for storing filter states, save us creating new ones each tick + * @member {Object[]} + */ + this.statePool = []; + + /** + * A very simple geometry used when drawing a filter effect to the screen + * @member {PIXI.Quad} + */ + this.quad = new Quad(); + + /** + * Quad UVs + * @member {PIXI.QuadUv} + */ + this.quadUv = new QuadUv(); + + /** + * Temporary rect for maths + * @type {PIXI.Rectangle} + */ + this.tempRect = new Rectangle(); + + /** + * Active state + * @member {object} + */ + this.activeState = {}; + + /** + * This uniform group is attached to filter uniforms when used + * @member {PIXI.UniformGroup} + * @property {PIXI.Rectangle} outputFrame + * @property {Float32Array} inputSize + * @property {Float32Array} inputPixel + * @property {Float32Array} inputClamp + * @property {Number} resolution + * @property {Float32Array} filterArea + * @property {Fload32Array} filterClamp + */ + this.globalUniforms = new UniformGroup({ + outputFrame: this.tempRect, + inputSize: new Float32Array(4), + inputPixel: new Float32Array(4), + inputClamp: new Float32Array(4), + resolution: 1, + + // legacy variables + filterArea: new Float32Array(4), + filterClamp: new Float32Array(4), + }, true); + + this._pixelsWidth = renderer.view.width; + this._pixelsHeight = renderer.view.height; + } + + if ( System ) { FilterSystem.__proto__ = System; } + FilterSystem.prototype = Object.create( System && System.prototype ); + FilterSystem.prototype.constructor = FilterSystem; + + /** + * Adds a new filter to the System. + * + * @param {PIXI.DisplayObject} target - The target of the filter to render. + * @param {PIXI.Filter[]} filters - The filters to apply. + */ + FilterSystem.prototype.push = function push (target, filters) + { + var renderer = this.renderer; + var filterStack = this.defaultFilterStack; + var state = this.statePool.pop() || new FilterState(); + + var resolution = filters[0].resolution; + var padding = filters[0].padding; + var autoFit = filters[0].autoFit; + var legacy = filters[0].legacy; + + for (var i = 1; i < filters.length; i++) + { + var filter = filters[i]; + + // lets use the lowest resolution.. + resolution = Math.min(resolution, filter.resolution); + // and the largest amount of padding! + padding = Math.max(padding, filter.padding); + // only auto fit if all filters are autofit + autoFit = autoFit || filter.autoFit; + + legacy = legacy || filter.legacy; + } + + if (filterStack.length === 1) + { + this.defaultFilterStack[0].renderTexture = renderer.renderTexture.current; + } + + filterStack.push(state); + + state.resolution = resolution; + + state.legacy = legacy; + + state.target = target; + + state.sourceFrame.copyFrom(target.filterArea || target.getBounds(true)); + + state.sourceFrame.pad(padding); + if (autoFit) + { + state.sourceFrame.fit(this.renderer.renderTexture.sourceFrame); + } + + // round to whole number based on resolution + state.sourceFrame.ceil(resolution); + + state.renderTexture = this.getOptimalFilterTexture(state.sourceFrame.width, state.sourceFrame.height, resolution); + state.filters = filters; + + state.destinationFrame.width = state.renderTexture.width; + state.destinationFrame.height = state.renderTexture.height; + + state.renderTexture.filterFrame = state.sourceFrame; + + renderer.renderTexture.bind(state.renderTexture, state.sourceFrame);// /, state.destinationFrame); + renderer.renderTexture.clear(); + }; + + /** + * Pops off the filter and applies it. + * + */ + FilterSystem.prototype.pop = function pop () + { + var filterStack = this.defaultFilterStack; + var state = filterStack.pop(); + var filters = state.filters; + + this.activeState = state; + + var globalUniforms = this.globalUniforms.uniforms; + + globalUniforms.outputFrame = state.sourceFrame; + globalUniforms.resolution = state.resolution; + + var inputSize = globalUniforms.inputSize; + var inputPixel = globalUniforms.inputPixel; + var inputClamp = globalUniforms.inputClamp; + + inputSize[0] = state.destinationFrame.width; + inputSize[1] = state.destinationFrame.height; + inputSize[2] = 1.0 / inputSize[0]; + inputSize[3] = 1.0 / inputSize[1]; + + inputPixel[0] = inputSize[0] * state.resolution; + inputPixel[1] = inputSize[1] * state.resolution; + inputPixel[2] = 1.0 / inputPixel[0]; + inputPixel[3] = 1.0 / inputPixel[1]; + + inputClamp[0] = 0.5 * inputPixel[2]; + inputClamp[1] = 0.5 * inputPixel[3]; + inputClamp[2] = (state.sourceFrame.width * inputSize[2]) - (0.5 * inputPixel[2]); + inputClamp[3] = (state.sourceFrame.height * inputSize[3]) - (0.5 * inputPixel[3]); + + // only update the rect if its legacy.. + if (state.legacy) + { + var filterArea = globalUniforms.filterArea; + + filterArea[0] = state.destinationFrame.width; + filterArea[1] = state.destinationFrame.height; + filterArea[2] = state.sourceFrame.x; + filterArea[3] = state.sourceFrame.y; + + globalUniforms.filterClamp = globalUniforms.inputClamp; + } + + this.globalUniforms.update(); + + var lastState = filterStack[filterStack.length - 1]; + + if (filters.length === 1) + { + filters[0].apply(this, state.renderTexture, lastState.renderTexture, false, state); + + this.returnFilterTexture(state.renderTexture); + } + else + { + var flip = state.renderTexture; + var flop = this.getOptimalFilterTexture( + flip.width, + flip.height, + state.resolution + ); + + flop.filterFrame = flip.filterFrame; + + var i = 0; + + for (i = 0; i < filters.length - 1; ++i) + { + filters[i].apply(this, flip, flop, true, state); + + var t = flip; + + flip = flop; + flop = t; + } + + filters[i].apply(this, flip, lastState.renderTexture, false, state); + + this.returnFilterTexture(flip); + this.returnFilterTexture(flop); + } + + state.clear(); + this.statePool.push(state); + }; + + /** + * Draws a filter. + * + * @param {PIXI.Filter} filter - The filter to draw. + * @param {PIXI.RenderTexture} input - The input render target. + * @param {PIXI.RenderTexture} output - The target to output to. + * @param {boolean} clear - Should the output be cleared before rendering to it + */ + FilterSystem.prototype.applyFilter = function applyFilter (filter, input, output, clear) + { + var renderer = this.renderer; + + renderer.renderTexture.bind(output, output ? output.filterFrame : null); + + if (clear) + { + // gl.disable(gl.SCISSOR_TEST); + renderer.renderTexture.clear(); + // gl.enable(gl.SCISSOR_TEST); + } + + // set the uniforms.. + filter.uniforms.uSampler = input; + filter.uniforms.filterGlobals = this.globalUniforms; + + // TODO make it so that the order of this does not matter.. + // because it does at the moment cos of global uniforms. + // they need to get resynced + + renderer.state.setState(filter.state); + renderer.shader.bind(filter); + + if (filter.legacy) + { + this.quadUv.map(input._frame, input.filterFrame); + + renderer.geometry.bind(this.quadUv); + renderer.geometry.draw(DRAW_MODES.TRIANGLES); + } + else + { + renderer.geometry.bind(this.quad); + renderer.geometry.draw(DRAW_MODES.TRIANGLE_STRIP); + } + }; + + /** + * Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_. + * + * Use `outputMatrix * vTextureCoord` in the shader. + * + * @param {PIXI.Matrix} outputMatrix - The matrix to output to. + * @param {PIXI.Sprite} sprite - The sprite to map to. + * @return {PIXI.Matrix} The mapped matrix. + */ + FilterSystem.prototype.calculateSpriteMatrix = function calculateSpriteMatrix (outputMatrix, sprite) + { + var ref = this.activeState; + var sourceFrame = ref.sourceFrame; + var destinationFrame = ref.destinationFrame; + var ref$1 = sprite._texture; + var orig = ref$1.orig; + var mappedMatrix = outputMatrix.set(destinationFrame.width, 0, 0, + destinationFrame.height, sourceFrame.x, sourceFrame.y); + var worldTransform = sprite.worldTransform.copyTo(Matrix.TEMP_MATRIX); + + worldTransform.invert(); + mappedMatrix.prepend(worldTransform); + mappedMatrix.scale(1.0 / orig.width, 1.0 / orig.height); + mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y); + + return mappedMatrix; + }; + + /** + * Destroys this Filter System. + * + * @param {boolean} [contextLost=false] context was lost, do not free shaders + * + */ + FilterSystem.prototype.destroy = function destroy (contextLost) + { + if ( contextLost === void 0 ) { contextLost = false; } + + if (!contextLost) + { + this.emptyPool(); + } + else + { + this.texturePool = {}; + } + }; + + /** + * Gets a Power-of-Two render texture or fullScreen texture + * + * TODO move to a separate class could be on renderer? + * + * @protected + * @param {number} minWidth - The minimum width of the render texture in real pixels. + * @param {number} minHeight - The minimum height of the render texture in real pixels. + * @param {number} [resolution=1] - The resolution of the render texture. + * @return {PIXI.RenderTexture} The new render texture. + */ + FilterSystem.prototype.getOptimalFilterTexture = function getOptimalFilterTexture (minWidth, minHeight, resolution) + { + if ( resolution === void 0 ) { resolution = 1; } + + var key = screenKey; + + minWidth *= resolution; + minHeight *= resolution; + + if (minWidth !== this._pixelsWidth || minHeight !== this._pixelsHeight) + { + minWidth = nextPow2(minWidth); + minHeight = nextPow2(minHeight); + key = ((minWidth & 0xFFFF) << 16) | (minHeight & 0xFFFF); + } + + if (!this.texturePool[key]) + { + this.texturePool[key] = []; + } + + var renderTexture = this.texturePool[key].pop(); + + if (!renderTexture) + { + // temporary bypass cache.. + // internally - this will cause a texture to be bound.. + renderTexture = RenderTexture.create({ + width: minWidth / resolution, + height: minHeight / resolution, + resolution: resolution, + }); + } + + renderTexture.filterPoolKey = key; + + return renderTexture; + }; + + /** + * Gets extra render texture to use inside current filter + * + * @param {number} resolution resolution of the renderTexture + * @returns {PIXI.RenderTexture} + */ + FilterSystem.prototype.getFilterTexture = function getFilterTexture (resolution) + { + var rt = this.activeState.renderTexture; + + var filterTexture = this.getOptimalFilterTexture(rt.width, rt.height, resolution || rt.baseTexture.resolution); + + filterTexture.filterFrame = rt.filterFrame; + + return filterTexture; + }; + + /** + * Frees a render texture back into the pool. + * + * @param {PIXI.RenderTexture} renderTexture - The renderTarget to free + */ + FilterSystem.prototype.returnFilterTexture = function returnFilterTexture (renderTexture) + { + var key = renderTexture.filterPoolKey; + + renderTexture.filterFrame = null; + this.texturePool[key].push(renderTexture); + }; + + /** + * Empties the texture pool. + * + */ + FilterSystem.prototype.emptyPool = function emptyPool () + { + for (var i in this.texturePool) + { + var textures = this.texturePool[i]; + + if (textures) + { + for (var j = 0; j < textures.length; j++) + { + textures[j].destroy(true); + } + } + } + + this.texturePool = {}; + }; + + FilterSystem.prototype.resize = function resize () + { + var textures = this.texturePool[screenKey]; + + if (textures) + { + for (var j = 0; j < textures.length; j++) + { + textures[j].destroy(true); + } + } + this.texturePool[screenKey] = []; + + this._pixelsWidth = this.renderer.view.width; + this._pixelsHeight = this.renderer.view.height; + }; + + return FilterSystem; + }(System)); + + /** + * Base for a common object renderer that can be used as a system renderer plugin. + * + * @class + * @extends PIXI.System + * @memberof PIXI + */ + var ObjectRenderer = /*@__PURE__*/(function (System) { + function ObjectRenderer () { + System.apply(this, arguments); + } + + if ( System ) { ObjectRenderer.__proto__ = System; } + ObjectRenderer.prototype = Object.create( System && System.prototype ); + ObjectRenderer.prototype.constructor = ObjectRenderer; + + ObjectRenderer.prototype.start = function start () + { + // set the shader.. + }; + + /** + * Stops the renderer + * + */ + ObjectRenderer.prototype.stop = function stop () + { + this.flush(); + }; + + /** + * Stub method for rendering content and emptying the current batch. + * + */ + ObjectRenderer.prototype.flush = function flush () + { + // flush! + }; + + /** + * Renders an object + * + * @param {PIXI.DisplayObject} object - The object to render. + */ + ObjectRenderer.prototype.render = function render (object) // eslint-disable-line no-unused-vars + { + // render the object + }; + + return ObjectRenderer; + }(System)); + + /** + * System plugin to the renderer to manage batching. + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + var BatchSystem = /*@__PURE__*/(function (System) { + function BatchSystem(renderer) + { + System.call(this, renderer); + + /** + * An empty renderer. + * + * @member {PIXI.ObjectRenderer} + */ + this.emptyRenderer = new ObjectRenderer(renderer); + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.ObjectRenderer} + */ + this.currentRenderer = this.emptyRenderer; + } + + if ( System ) { BatchSystem.__proto__ = System; } + BatchSystem.prototype = Object.create( System && System.prototype ); + BatchSystem.prototype.constructor = BatchSystem; + + /** + * Changes the current renderer to the one given in parameter + * + * @param {PIXI.ObjectRenderer} objectRenderer - The object renderer to use. + */ + BatchSystem.prototype.setObjectRenderer = function setObjectRenderer (objectRenderer) + { + if (this.currentRenderer === objectRenderer) + { + return; + } + + this.currentRenderer.stop(); + this.currentRenderer = objectRenderer; + + this.currentRenderer.start(); + }; + + /** + * This should be called if you wish to do some custom rendering + * It will basically render anything that may be batched up such as sprites + */ + BatchSystem.prototype.flush = function flush () + { + this.setObjectRenderer(this.emptyRenderer); + }; + + /** + * Reset the system to an empty renderer + */ + BatchSystem.prototype.reset = function reset () + { + this.setObjectRenderer(this.emptyRenderer); + }; + + return BatchSystem; + }(System)); + + /** + * The maximum support for using WebGL. If a device does not + * support WebGL version, for instance WebGL 2, it will still + * attempt to fallback support to WebGL 1. If you want to + * explicitly remove feature support to target a more stable + * baseline, prefer a lower environment. + * + * Due to {@link https://bugs.chromium.org/p/chromium/issues/detail?id=934823|bug in chromium} + * we disable webgl2 by default for all non-apple mobile devices. + * + * @static + * @name PREFER_ENV + * @memberof PIXI.settings + * @type {number} + * @default PIXI.ENV.WEBGL2 + */ + settings.PREFER_ENV = isMobile_min.any ? ENV.WEBGL : ENV.WEBGL2; + + var CONTEXT_UID = 0; + + /** + * System plugin to the renderer to manage the context. + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + var ContextSystem = /*@__PURE__*/(function (System) { + function ContextSystem(renderer) + { + System.call(this, renderer); + + /** + * Either 1 or 2 to reflect the WebGL version being used + * @member {number} + * @readonly + */ + this.webGLVersion = 1; + + /** + * Extensions being used + * @member {object} + * @readonly + * @property {WEBGL_draw_buffers} drawBuffers - WebGL v1 extension + * @property {WEBGL_depth_texture} depthTexture - WebGL v1 extension + * @property {OES_texture_float} floatTexture - WebGL v1 extension + * @property {WEBGL_lose_context} loseContext - WebGL v1 extension + * @property {OES_vertex_array_object} vertexArrayObject - WebGL v1 extension + */ + this.extensions = {}; + + // Bind functions + this.handleContextLost = this.handleContextLost.bind(this); + this.handleContextRestored = this.handleContextRestored.bind(this); + + renderer.view.addEventListener('webglcontextlost', this.handleContextLost, false); + renderer.view.addEventListener('webglcontextrestored', this.handleContextRestored, false); + } + + if ( System ) { ContextSystem.__proto__ = System; } + ContextSystem.prototype = Object.create( System && System.prototype ); + ContextSystem.prototype.constructor = ContextSystem; + + var prototypeAccessors = { isLost: { configurable: true } }; + + /** + * `true` if the context is lost + * @member {boolean} + * @readonly + */ + prototypeAccessors.isLost.get = function () + { + return (!this.gl || this.gl.isContextLost()); + }; + + /** + * Handle the context change event + * @param {WebGLRenderingContext} gl new webgl context + */ + ContextSystem.prototype.contextChange = function contextChange (gl) + { + this.gl = gl; + + // restore a context if it was previously lost + if (gl.isContextLost() && gl.getExtension('WEBGL_lose_context')) + { + gl.getExtension('WEBGL_lose_context').restoreContext(); + } + }; + + /** + * Initialize the context + * + * @protected + * @param {WebGLRenderingContext} gl - WebGL context + */ + ContextSystem.prototype.initFromContext = function initFromContext (gl) + { + this.gl = gl; + this.validateContext(gl); + this.renderer.gl = gl; + this.renderer.CONTEXT_UID = CONTEXT_UID++; + this.renderer.runners.contextChange.run(gl); + }; + + /** + * Initialize from context options + * + * @protected + * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext + * @param {object} options - context attributes + */ + ContextSystem.prototype.initFromOptions = function initFromOptions (options) + { + var gl = this.createContext(this.renderer.view, options); + + this.initFromContext(gl); + }; + + /** + * Helper class to create a WebGL Context + * + * @param canvas {HTMLCanvasElement} the canvas element that we will get the context from + * @param options {object} An options object that gets passed in to the canvas element containing the context attributes + * @see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext + * @return {WebGLRenderingContext} the WebGL context + */ + ContextSystem.prototype.createContext = function createContext (canvas, options) + { + var gl; + + if (settings.PREFER_ENV >= ENV.WEBGL2) + { + gl = canvas.getContext('webgl2', options); + } + + if (gl) + { + this.webGLVersion = 2; + } + else + { + this.webGLVersion = 1; + + gl = canvas.getContext('webgl', options) + || canvas.getContext('experimental-webgl', options); + + if (!gl) + { + // fail, not able to get a context + throw new Error('This browser does not support WebGL. Try using the canvas renderer'); + } + } + + this.gl = gl; + + this.getExtensions(); + + return gl; + }; + + /** + * Auto-populate the extensions + * + * @protected + */ + ContextSystem.prototype.getExtensions = function getExtensions () + { + // time to set up default extensions that Pixi uses. + var ref = this; + var gl = ref.gl; + + if (this.webGLVersion === 1) + { + Object.assign(this.extensions, { + drawBuffers: gl.getExtension('WEBGL_draw_buffers'), + depthTexture: gl.getExtension('WEBKIT_WEBGL_depth_texture'), + floatTexture: gl.getExtension('OES_texture_float'), + loseContext: gl.getExtension('WEBGL_lose_context'), + vertexArrayObject: gl.getExtension('OES_vertex_array_object') + || gl.getExtension('MOZ_OES_vertex_array_object') + || gl.getExtension('WEBKIT_OES_vertex_array_object'), + }); + } + + // we don't use any specific WebGL 2 ones yet! + }; + + /** + * Handles a lost webgl context + * + * @protected + * @param {WebGLContextEvent} event - The context lost event. + */ + ContextSystem.prototype.handleContextLost = function handleContextLost (event) + { + event.preventDefault(); + }; + + /** + * Handles a restored webgl context + * + * @protected + */ + ContextSystem.prototype.handleContextRestored = function handleContextRestored () + { + this.renderer.runners.contextChange.run(this.gl); + }; + + ContextSystem.prototype.destroy = function destroy () + { + var view = this.renderer.view; + + // remove listeners + view.removeEventListener('webglcontextlost', this.handleContextLost); + view.removeEventListener('webglcontextrestored', this.handleContextRestored); + + this.gl.useProgram(null); + + if (this.extensions.loseContext) + { + this.extensions.loseContext.loseContext(); + } + }; + + /** + * Handle the post-render runner event + * + * @protected + */ + ContextSystem.prototype.postrender = function postrender () + { + this.gl.flush(); + }; + + /** + * Validate context + * + * @protected + * @param {WebGLRenderingContext} gl - Render context + */ + ContextSystem.prototype.validateContext = function validateContext (gl) + { + var attributes = gl.getContextAttributes(); + + // this is going to be fairly simple for now.. but at least we have room to grow! + if (!attributes.stencil) + { + /* eslint-disable max-len */ + + /* eslint-disable no-console */ + console.warn('Provided WebGL context does not have a stencil buffer, masks may not render correctly'); + /* eslint-enable no-console */ + + /* eslint-enable max-len */ + } + }; + + Object.defineProperties( ContextSystem.prototype, prototypeAccessors ); + + return ContextSystem; + }(System)); + + /** + * System plugin to the renderer to manage framebuffers. + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + var FramebufferSystem = /*@__PURE__*/(function (System) { + function FramebufferSystem(renderer) + { + System.call(this, renderer); + + /** + * A list of managed framebuffers + * @member {PIXI.Framebuffer[]} + * @readonly + */ + this.managedFramebuffers = []; + + /** + * Framebuffer value that shows that we don't know what is bound + * @member {Framebuffer} + * @readonly + */ + this.unknownFramebuffer = new Framebuffer(10, 10); + } + + if ( System ) { FramebufferSystem.__proto__ = System; } + FramebufferSystem.prototype = Object.create( System && System.prototype ); + FramebufferSystem.prototype.constructor = FramebufferSystem; + + var prototypeAccessors = { size: { configurable: true } }; + + /** + * Sets up the renderer context and necessary buffers. + */ + FramebufferSystem.prototype.contextChange = function contextChange () + { + var gl = this.gl = this.renderer.gl; + + this.CONTEXT_UID = this.renderer.CONTEXT_UID; + this.current = this.unknownFramebuffer; + this.viewport = new Rectangle(); + this.hasMRT = true; + this.writeDepthTexture = true; + + this.disposeAll(true); + + // webgl2 + if (this.renderer.context.webGLVersion === 1) + { + // webgl 1! + var nativeDrawBuffersExtension = this.renderer.context.extensions.drawBuffers; + var nativeDepthTextureExtension = this.renderer.context.extensions.depthTexture; + + if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) + { + nativeDrawBuffersExtension = null; + nativeDepthTextureExtension = null; + } + + if (nativeDrawBuffersExtension) + { + gl.drawBuffers = function (activeTextures) { return nativeDrawBuffersExtension.drawBuffersWEBGL(activeTextures); }; + } + else + { + this.hasMRT = false; + gl.drawBuffers = function () { + // empty + }; + } + + if (!nativeDepthTextureExtension) + { + this.writeDepthTexture = false; + } + } + }; + + /** + * Bind a framebuffer + * + * @param {PIXI.Framebuffer} framebuffer + * @param {PIXI.Rectangle} [frame] frame, default is framebuffer size + */ + FramebufferSystem.prototype.bind = function bind (framebuffer, frame) + { + var ref = this; + var gl = ref.gl; + + if (framebuffer) + { + // TODO caching layer! + + var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID] || this.initFramebuffer(framebuffer); + + if (this.current !== framebuffer) + { + this.current = framebuffer; + gl.bindFramebuffer(gl.FRAMEBUFFER, fbo.framebuffer); + } + // make sure all textures are unbound.. + + // now check for updates... + if (fbo.dirtyId !== framebuffer.dirtyId) + { + fbo.dirtyId = framebuffer.dirtyId; + + if (fbo.dirtyFormat !== framebuffer.dirtyFormat) + { + fbo.dirtyFormat = framebuffer.dirtyFormat; + this.updateFramebuffer(framebuffer); + } + else if (fbo.dirtySize !== framebuffer.dirtySize) + { + fbo.dirtySize = framebuffer.dirtySize; + this.resizeFramebuffer(framebuffer); + } + } + + for (var i = 0; i < framebuffer.colorTextures.length; i++) + { + if (framebuffer.colorTextures[i].texturePart) + { + this.renderer.texture.unbind(framebuffer.colorTextures[i].texture); + } + else + { + this.renderer.texture.unbind(framebuffer.colorTextures[i]); + } + } + + if (framebuffer.depthTexture) + { + this.renderer.texture.unbind(framebuffer.depthTexture); + } + + if (frame) + { + this.setViewport(frame.x, frame.y, frame.width, frame.height); + } + else + { + this.setViewport(0, 0, framebuffer.width, framebuffer.height); + } + } + else + { + if (this.current) + { + this.current = null; + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + } + + if (frame) + { + this.setViewport(frame.x, frame.y, frame.width, frame.height); + } + else + { + this.setViewport(0, 0, this.renderer.width, this.renderer.height); + } + } + }; + + /** + * Set the WebGLRenderingContext's viewport. + * + * @param {Number} x - X position of viewport + * @param {Number} y - Y position of viewport + * @param {Number} width - Width of viewport + * @param {Number} height - Height of viewport + */ + FramebufferSystem.prototype.setViewport = function setViewport (x, y, width, height) + { + var v = this.viewport; + + if (v.width !== width || v.height !== height || v.x !== x || v.y !== y) + { + v.x = x; + v.y = y; + v.width = width; + v.height = height; + + this.gl.viewport(x, y, width, height); + } + }; + + /** + * Get the size of the current width and height. Returns object with `width` and `height` values. + * + * @member {object} + * @readonly + */ + prototypeAccessors.size.get = function () + { + if (this.current) + { + // TODO store temp + return { x: 0, y: 0, width: this.current.width, height: this.current.height }; + } + + return { x: 0, y: 0, width: this.renderer.width, height: this.renderer.height }; + }; + + /** + * Clear the color of the context + * + * @param {Number} r - Red value from 0 to 1 + * @param {Number} g - Green value from 0 to 1 + * @param {Number} b - Blue value from 0 to 1 + * @param {Number} a - Alpha value from 0 to 1 + */ + FramebufferSystem.prototype.clear = function clear (r, g, b, a) + { + var ref = this; + var gl = ref.gl; + + // TODO clear color can be set only one right? + gl.clearColor(r, g, b, a); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + }; + + /** + * Initialize framebuffer + * + * @protected + * @param {PIXI.Framebuffer} framebuffer + */ + FramebufferSystem.prototype.initFramebuffer = function initFramebuffer (framebuffer) + { + var ref = this; + var gl = ref.gl; + + // TODO - make this a class? + var fbo = { + framebuffer: gl.createFramebuffer(), + stencil: null, + dirtyId: 0, + dirtyFormat: 0, + dirtySize: 0, + }; + + framebuffer.glFramebuffers[this.CONTEXT_UID] = fbo; + + this.managedFramebuffers.push(framebuffer); + framebuffer.disposeRunner.add(this); + + return fbo; + }; + + /** + * Resize the framebuffer + * + * @protected + * @param {PIXI.Framebuffer} framebuffer + */ + FramebufferSystem.prototype.resizeFramebuffer = function resizeFramebuffer (framebuffer) + { + var ref = this; + var gl = ref.gl; + + var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID]; + + if (fbo.stencil) + { + gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.stencil); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, framebuffer.width, framebuffer.height); + } + + var colorTextures = framebuffer.colorTextures; + + for (var i = 0; i < colorTextures.length; i++) + { + this.renderer.texture.bind(colorTextures[i], 0); + } + + if (framebuffer.depthTexture) + { + this.renderer.texture.bind(framebuffer.depthTexture, 0); + } + }; + + /** + * Update the framebuffer + * + * @protected + * @param {PIXI.Framebuffer} framebuffer + */ + FramebufferSystem.prototype.updateFramebuffer = function updateFramebuffer (framebuffer) + { + var ref = this; + var gl = ref.gl; + + var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID]; + + // bind the color texture + var colorTextures = framebuffer.colorTextures; + + var count = colorTextures.length; + + if (!gl.drawBuffers) + { + count = Math.min(count, 1); + } + + var activeTextures = []; + + for (var i = 0; i < count; i++) + { + var texture = framebuffer.colorTextures[i]; + + if (texture.texturePart) + { + this.renderer.texture.bind(texture.texture, 0); + + gl.framebufferTexture2D(gl.FRAMEBUFFER, + gl.COLOR_ATTACHMENT0 + i, + gl.TEXTURE_CUBE_MAP_NEGATIVE_X + texture.side, + texture.texture._glTextures[this.CONTEXT_UID].texture, + 0); + } + else + { + this.renderer.texture.bind(texture, 0); + + gl.framebufferTexture2D(gl.FRAMEBUFFER, + gl.COLOR_ATTACHMENT0 + i, + gl.TEXTURE_2D, + texture._glTextures[this.CONTEXT_UID].texture, + 0); + } + + activeTextures.push(gl.COLOR_ATTACHMENT0 + i); + } + + if (activeTextures.length > 1) + { + gl.drawBuffers(activeTextures); + } + + if (framebuffer.depthTexture) + { + var writeDepthTexture = this.writeDepthTexture; + + if (writeDepthTexture) + { + var depthTexture = framebuffer.depthTexture; + + this.renderer.texture.bind(depthTexture, 0); + + gl.framebufferTexture2D(gl.FRAMEBUFFER, + gl.DEPTH_ATTACHMENT, + gl.TEXTURE_2D, + depthTexture._glTextures[this.CONTEXT_UID].texture, + 0); + } + } + + if (!fbo.stencil && (framebuffer.stencil || framebuffer.depth)) + { + fbo.stencil = gl.createRenderbuffer(); + + gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.stencil); + + // TODO.. this is depth AND stencil? + if (!framebuffer.depthTexture) + { // you can't have both, so one should take priority if enabled + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, fbo.stencil); + } + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, framebuffer.width, framebuffer.height); + // fbo.enableStencil(); + } + }; + + /** + * Disposes framebuffer + * @param {PIXI.Framebuffer} framebuffer framebuffer that has to be disposed of + * @param {boolean} [contextLost=false] If context was lost, we suppress all delete function calls + */ + FramebufferSystem.prototype.disposeFramebuffer = function disposeFramebuffer (framebuffer, contextLost) + { + var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID]; + var gl = this.gl; + + if (!fbo) + { + return; + } + + delete framebuffer.glFramebuffers[this.CONTEXT_UID]; + + var index = this.managedFramebuffers.indexOf(framebuffer); + + if (index >= 0) + { + this.managedFramebuffers.splice(index, 1); + } + + framebuffer.disposeRunner.remove(this); + + if (!contextLost) + { + gl.deleteFramebuffer(fbo.framebuffer); + if (fbo.stencil) + { + gl.deleteRenderbuffer(fbo.stencil); + } + } + }; + + /** + * Disposes all framebuffers, but not textures bound to them + * @param {boolean} [contextLost=false] If context was lost, we suppress all delete function calls + */ + FramebufferSystem.prototype.disposeAll = function disposeAll (contextLost) + { + var list = this.managedFramebuffers; + + this.managedFramebuffers = []; + + for (var i = 0; i < list.count; i++) + { + this.disposeFramebuffer(list[i], contextLost); + } + }; + + /** + * resets framebuffer stored state, binds screen framebuffer + * + * should be called before renderTexture reset() + */ + FramebufferSystem.prototype.reset = function reset () + { + this.current = this.unknownFramebuffer; + this.viewport = new Rectangle(); + }; + + Object.defineProperties( FramebufferSystem.prototype, prototypeAccessors ); + + return FramebufferSystem; + }(System)); + + var GLBuffer = function GLBuffer(buffer) + { + this.buffer = buffer; + this.updateID = -1; + this.byteLength = -1; + this.refCount = 0; + }; + + var byteSizeMap$1 = { 5126: 4, 5123: 2, 5121: 1 }; + + /** + * System plugin to the renderer to manage geometry. + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + var GeometrySystem = /*@__PURE__*/(function (System) { + function GeometrySystem(renderer) + { + System.call(this, renderer); + + this._activeGeometry = null; + this._activeVao = null; + + /** + * `true` if we has `*_vertex_array_object` extension + * @member {boolean} + * @readonly + */ + this.hasVao = true; + + /** + * `true` if has `ANGLE_instanced_arrays` extension + * @member {boolean} + * @readonly + */ + this.hasInstance = true; + + /** + * A cache of currently bound buffer, + * contains only two members with keys ARRAY_BUFFER and ELEMENT_ARRAY_BUFFER + * @member {Object.} + * @readonly + */ + this.boundBuffers = {}; + + /** + * Cache for all geometries by id, used in case renderer gets destroyed or for profiling + * @member {object} + * @readonly + */ + this.managedGeometries = {}; + + /** + * Cache for all buffers by id, used in case renderer gets destroyed or for profiling + * @member {object} + * @readonly + */ + this.managedBuffers = {}; + } + + if ( System ) { GeometrySystem.__proto__ = System; } + GeometrySystem.prototype = Object.create( System && System.prototype ); + GeometrySystem.prototype.constructor = GeometrySystem; + + /** + * Sets up the renderer context and necessary buffers. + */ + GeometrySystem.prototype.contextChange = function contextChange () + { + this.disposeAll(true); + + var gl = this.gl = this.renderer.gl; + + this.CONTEXT_UID = this.renderer.CONTEXT_UID; + + // webgl2 + if (!gl.createVertexArray) + { + // webgl 1! + var nativeVaoExtension = this.renderer.context.extensions.vertexArrayObject; + + if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) + { + nativeVaoExtension = null; + } + + if (nativeVaoExtension) + { + gl.createVertexArray = function () { return nativeVaoExtension.createVertexArrayOES(); }; + + gl.bindVertexArray = function (vao) { return nativeVaoExtension.bindVertexArrayOES(vao); }; + + gl.deleteVertexArray = function (vao) { return nativeVaoExtension.deleteVertexArrayOES(vao); }; + } + else + { + this.hasVao = false; + gl.createVertexArray = function () { + // empty + }; + + gl.bindVertexArray = function () { + // empty + }; + + gl.deleteVertexArray = function () { + // empty + }; + } + } + + if (!gl.vertexAttribDivisor) + { + var instanceExt = gl.getExtension('ANGLE_instanced_arrays'); + + if (instanceExt) + { + gl.vertexAttribDivisor = function (a, b) { return instanceExt.vertexAttribDivisorANGLE(a, b); }; + + gl.drawElementsInstanced = function (a, b, c, d, e) { return instanceExt.drawElementsInstancedANGLE(a, b, c, d, e); }; + + gl.drawArraysInstanced = function (a, b, c, d) { return instanceExt.drawArraysInstancedANGLE(a, b, c, d); }; + } + else + { + this.hasInstance = false; + } + } + }; + + /** + * Binds geometry so that is can be drawn. Creating a Vao if required + * @protected + * @param {PIXI.Geometry} geometry instance of geometry to bind + * @param {PIXI.Shader} shader instance of shader to bind + */ + GeometrySystem.prototype.bind = function bind (geometry, shader) + { + shader = shader || this.renderer.shader.shader; + + var ref = this; + var gl = ref.gl; + + // not sure the best way to address this.. + // currently different shaders require different VAOs for the same geometry + // Still mulling over the best way to solve this one.. + // will likely need to modify the shader attribute locations at run time! + var vaos = geometry.glVertexArrayObjects[this.CONTEXT_UID]; + + if (!vaos) + { + this.managedGeometries[geometry.id] = geometry; + geometry.disposeRunner.add(this); + geometry.glVertexArrayObjects[this.CONTEXT_UID] = vaos = {}; + } + + var vao = vaos[shader.program.id] || this.initGeometryVao(geometry, shader.program); + + this._activeGeometry = geometry; + + if (this._activeVao !== vao) + { + this._activeVao = vao; + + if (this.hasVao) + { + gl.bindVertexArray(vao); + } + else + { + this.activateVao(geometry, shader.program); + } + } + + // TODO - optimise later! + // don't need to loop through if nothing changed! + // maybe look to add an 'autoupdate' to geometry? + this.updateBuffers(); + }; + + /** + * Reset and unbind any active VAO and geometry + */ + GeometrySystem.prototype.reset = function reset () + { + this.unbind(); + }; + + /** + * Update buffers + * @protected + */ + GeometrySystem.prototype.updateBuffers = function updateBuffers () + { + var geometry = this._activeGeometry; + var ref = this; + var gl = ref.gl; + + for (var i = 0; i < geometry.buffers.length; i++) + { + var buffer = geometry.buffers[i]; + + var glBuffer = buffer._glBuffers[this.CONTEXT_UID]; + + if (buffer._updateID !== glBuffer.updateID) + { + glBuffer.updateID = buffer._updateID; + + // TODO can cache this on buffer! maybe added a getter / setter? + var type = buffer.index ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER; + + // TODO this could change if the VAO changes... + // need to come up with a better way to cache.. + // if (this.boundBuffers[type] !== glBuffer) + // { + // this.boundBuffers[type] = glBuffer; + gl.bindBuffer(type, glBuffer.buffer); + // } + + this._boundBuffer = glBuffer; + + if (glBuffer.byteLength >= buffer.data.byteLength) + { + // offset is always zero for now! + gl.bufferSubData(type, 0, buffer.data); + } + else + { + var drawType = buffer.static ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW; + + glBuffer.byteLength = buffer.data.byteLength; + gl.bufferData(type, buffer.data, drawType); + } + } + } + }; + + /** + * Check compability between a geometry and a program + * @protected + * @param {PIXI.Geometry} geometry - Geometry instance + * @param {PIXI.Program} program - Program instance + */ + GeometrySystem.prototype.checkCompatibility = function checkCompatibility (geometry, program) + { + // geometry must have at least all the attributes that the shader requires. + var geometryAttributes = geometry.attributes; + var shaderAttributes = program.attributeData; + + for (var j in shaderAttributes) + { + if (!geometryAttributes[j]) + { + throw new Error(("shader and geometry incompatible, geometry missing the \"" + j + "\" attribute")); + } + } + }; + + /** + * Takes a geometry and program and generates a unique signature for them. + * + * @param {PIXI.Geometry} geometry to get signature from + * @param {PIXI.Program} program to test geometry against + * @returns {String} Unique signature of the geometry and program + * @protected + */ + GeometrySystem.prototype.getSignature = function getSignature (geometry, program) + { + var attribs = geometry.attributes; + var shaderAttributes = program.attributeData; + + var strings = ['g', geometry.id]; + + for (var i in attribs) + { + if (shaderAttributes[i]) + { + strings.push(i); + } + } + + return strings.join('-'); + }; + + /** + * Creates or gets Vao with the same structure as the geometry and stores it on the geometry. + * If vao is created, it is bound automatically. + * + * @protected + * @param {PIXI.Geometry} geometry - Instance of geometry to to generate Vao for + * @param {PIXI.Program} program - Instance of program + */ + GeometrySystem.prototype.initGeometryVao = function initGeometryVao (geometry, program) + { + this.checkCompatibility(geometry, program); + + var gl = this.gl; + var CONTEXT_UID = this.CONTEXT_UID; + + var signature = this.getSignature(geometry, program); + + var vaoObjectHash = geometry.glVertexArrayObjects[this.CONTEXT_UID]; + + var vao = vaoObjectHash[signature]; + + if (vao) + { + // this will give us easy access to the vao + vaoObjectHash[program.id] = vao; + + return vao; + } + + var buffers = geometry.buffers; + var attributes = geometry.attributes; + var tempStride = {}; + var tempStart = {}; + + for (var j in buffers) + { + tempStride[j] = 0; + tempStart[j] = 0; + } + + for (var j$1 in attributes) + { + if (!attributes[j$1].size && program.attributeData[j$1]) + { + attributes[j$1].size = program.attributeData[j$1].size; + } + else if (!attributes[j$1].size) + { + console.warn(("PIXI Geometry attribute '" + j$1 + "' size cannot be determined (likely the bound shader does not have the attribute)")); // eslint-disable-line + } + + tempStride[attributes[j$1].buffer] += attributes[j$1].size * byteSizeMap$1[attributes[j$1].type]; + } + + for (var j$2 in attributes) + { + var attribute = attributes[j$2]; + var attribSize = attribute.size; + + if (attribute.stride === undefined) + { + if (tempStride[attribute.buffer] === attribSize * byteSizeMap$1[attribute.type]) + { + attribute.stride = 0; + } + else + { + attribute.stride = tempStride[attribute.buffer]; + } + } + + if (attribute.start === undefined) + { + attribute.start = tempStart[attribute.buffer]; + + tempStart[attribute.buffer] += attribSize * byteSizeMap$1[attribute.type]; + } + } + + vao = gl.createVertexArray(); + + gl.bindVertexArray(vao); + + // first update - and create the buffers! + // only create a gl buffer if it actually gets + for (var i = 0; i < buffers.length; i++) + { + var buffer = buffers[i]; + + if (!buffer._glBuffers[CONTEXT_UID]) + { + buffer._glBuffers[CONTEXT_UID] = new GLBuffer(gl.createBuffer()); + this.managedBuffers[buffer.id] = buffer; + buffer.disposeRunner.add(this); + } + + buffer._glBuffers[CONTEXT_UID].refCount++; + } + + // TODO - maybe make this a data object? + // lets wait to see if we need to first! + + this.activateVao(geometry, program); + + this._activeVao = vao; + + // add it to the cache! + vaoObjectHash[program.id] = vao; + vaoObjectHash[signature] = vao; + + return vao; + }; + + /** + * Disposes buffer + * @param {PIXI.Buffer} buffer buffer with data + * @param {boolean} [contextLost=false] If context was lost, we suppress deleteVertexArray + */ + GeometrySystem.prototype.disposeBuffer = function disposeBuffer (buffer, contextLost) + { + if (!this.managedBuffers[buffer.id]) + { + return; + } + + delete this.managedBuffers[buffer.id]; + + var glBuffer = buffer._glBuffers[this.CONTEXT_UID]; + var gl = this.gl; + + buffer.disposeRunner.remove(this); + + if (!glBuffer) + { + return; + } + + if (!contextLost) + { + gl.deleteBuffer(glBuffer.buffer); + } + + delete buffer._glBuffers[this.CONTEXT_UID]; + }; + + /** + * Disposes geometry + * @param {PIXI.Geometry} geometry Geometry with buffers. Only VAO will be disposed + * @param {boolean} [contextLost=false] If context was lost, we suppress deleteVertexArray + */ + GeometrySystem.prototype.disposeGeometry = function disposeGeometry (geometry, contextLost) + { + if (!this.managedGeometries[geometry.id]) + { + return; + } + + delete this.managedGeometries[geometry.id]; + + var vaos = geometry.glVertexArrayObjects[this.CONTEXT_UID]; + var gl = this.gl; + var buffers = geometry.buffers; + + geometry.disposeRunner.remove(this); + + if (!vaos) + { + return; + } + + for (var i = 0; i < buffers.length; i++) + { + var buf = buffers[i]._glBuffers[this.CONTEXT_UID]; + + buf.refCount--; + if (buf.refCount === 0 && !contextLost) + { + this.disposeBuffer(buffers[i], contextLost); + } + } + + if (!contextLost) + { + for (var vaoId in vaos) + { + // delete only signatures, everything else are copies + if (vaoId[0] === 'g') + { + var vao = vaos[vaoId]; + + if (this._activeVao === vao) + { + this.unbind(); + } + gl.deleteVertexArray(vao); + } + } + } + + delete geometry.glVertexArrayObjects[this.CONTEXT_UID]; + }; + + /** + * dispose all WebGL resources of all managed geometries and buffers + * @param {boolean} [contextLost=false] If context was lost, we suppress `gl.delete` calls + */ + GeometrySystem.prototype.disposeAll = function disposeAll (contextLost) + { + var all = Object.keys(this.managedGeometries); + + for (var i = 0; i < all.length; i++) + { + this.disposeGeometry(this.managedGeometries[all[i]], contextLost); + } + all = Object.keys(this.managedBuffers); + for (var i$1 = 0; i$1 < all.length; i$1++) + { + this.disposeBuffer(this.managedBuffers[all[i$1]], contextLost); + } + }; + + /** + * Activate vertex array object + * + * @protected + * @param {PIXI.Geometry} geometry - Geometry instance + * @param {PIXI.Program} program - Shader program instance + */ + GeometrySystem.prototype.activateVao = function activateVao (geometry, program) + { + var gl = this.gl; + var CONTEXT_UID = this.CONTEXT_UID; + var buffers = geometry.buffers; + var attributes = geometry.attributes; + + if (geometry.indexBuffer) + { + // first update the index buffer if we have one.. + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, geometry.indexBuffer._glBuffers[CONTEXT_UID].buffer); + } + + var lastBuffer = null; + + // add a new one! + for (var j in attributes) + { + var attribute = attributes[j]; + var buffer = buffers[attribute.buffer]; + var glBuffer = buffer._glBuffers[CONTEXT_UID]; + + if (program.attributeData[j]) + { + if (lastBuffer !== glBuffer) + { + gl.bindBuffer(gl.ARRAY_BUFFER, glBuffer.buffer); + + lastBuffer = glBuffer; + } + + var location = program.attributeData[j].location; + + // TODO introduce state again + // we can optimise this for older devices that have no VAOs + gl.enableVertexAttribArray(location); + + gl.vertexAttribPointer(location, + attribute.size, + attribute.type || gl.FLOAT, + attribute.normalized, + attribute.stride, + attribute.start); + + if (attribute.instance) + { + // TODO calculate instance count based of this... + if (this.hasInstance) + { + gl.vertexAttribDivisor(location, 1); + } + else + { + throw new Error('geometry error, GPU Instancing is not supported on this device'); + } + } + } + } + }; + + /** + * Draw the geometry + * + * @param {Number} type - the type primitive to render + * @param {Number} [size] - the number of elements to be rendered + * @param {Number} [start] - Starting index + * @param {Number} [instanceCount] - the number of instances of the set of elements to execute + */ + GeometrySystem.prototype.draw = function draw (type, size, start, instanceCount) + { + var ref = this; + var gl = ref.gl; + var geometry = this._activeGeometry; + + // TODO.. this should not change so maybe cache the function? + + if (geometry.indexBuffer) + { + if (geometry.instanced) + { + /* eslint-disable max-len */ + gl.drawElementsInstanced(type, size || geometry.indexBuffer.data.length, gl.UNSIGNED_SHORT, (start || 0) * 2, instanceCount || 1); + /* eslint-enable max-len */ + } + else + { + gl.drawElements(type, size || geometry.indexBuffer.data.length, gl.UNSIGNED_SHORT, (start || 0) * 2); + } + } + else if (geometry.instanced) + { + // TODO need a better way to calculate size.. + gl.drawArraysInstanced(type, start, size || geometry.getSize(), instanceCount || 1); + } + else + { + gl.drawArrays(type, start, size || geometry.getSize()); + } + + return this; + }; + + /** + * Unbind/reset everything + * @protected + */ + GeometrySystem.prototype.unbind = function unbind () + { + this.gl.bindVertexArray(null); + this._activeVao = null; + this._activeGeometry = null; + }; + + return GeometrySystem; + }(System)); + + /** + * @method compileProgram + * @private + * @memberof PIXI.glCore.shader + * @param gl {WebGLRenderingContext} The current WebGL context {WebGLProgram} + * @param vertexSrc {string|string[]} The vertex shader source as an array of strings. + * @param fragmentSrc {string|string[]} The fragment shader source as an array of strings. + * @param attributeLocations {Object} An attribute location map that lets you manually set the attribute locations + * @return {WebGLProgram} the shader program + */ + function compileProgram(gl, vertexSrc, fragmentSrc, attributeLocations) + { + var glVertShader = compileShader(gl, gl.VERTEX_SHADER, vertexSrc); + var glFragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSrc); + + var program = gl.createProgram(); + + gl.attachShader(program, glVertShader); + gl.attachShader(program, glFragShader); + + // optionally, set the attributes manually for the program rather than letting WebGL decide.. + if (attributeLocations) + { + for (var i in attributeLocations) + { + gl.bindAttribLocation(program, attributeLocations[i], i); + } + } + + gl.linkProgram(program); + + // if linking fails, then log and cleanup + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + { + console.error('Pixi.js Error: Could not initialize shader.'); + console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); + console.error('gl.getError()', gl.getError()); + + // if there is a program info log, log it + if (gl.getProgramInfoLog(program) !== '') + { + console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); + } + + gl.deleteProgram(program); + program = null; + } + + // clean up some shaders + gl.deleteShader(glVertShader); + gl.deleteShader(glFragShader); + + return program; + } + + /** + * @private + * @param gl {WebGLRenderingContext} The current WebGL context {WebGLProgram} + * @param type {Number} the type, can be either VERTEX_SHADER or FRAGMENT_SHADER + * @param vertexSrc {string|string[]} The vertex shader source as an array of strings. + * @return {WebGLShader} the shader + */ + function compileShader(gl, type, src) + { + var shader = gl.createShader(type); + + gl.shaderSource(shader, src); + gl.compileShader(shader); + + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) + { + console.warn(src); + console.error(gl.getShaderInfoLog(shader)); + + return null; + } + + return shader; + } + + /** + * @method defaultValue + * @memberof PIXI.glCore.shader + * @param type {String} Type of value + * @param size {Number} + * @private + */ + function defaultValue(type, size) + { + switch (type) + { + case 'float': + return 0; + + case 'vec2': + return new Float32Array(2 * size); + + case 'vec3': + return new Float32Array(3 * size); + + case 'vec4': + return new Float32Array(4 * size); + + case 'int': + case 'sampler2D': + case 'sampler2DArray': + return 0; + + case 'ivec2': + return new Int32Array(2 * size); + + case 'ivec3': + return new Int32Array(3 * size); + + case 'ivec4': + return new Int32Array(4 * size); + + case 'bool': + return false; + + case 'bvec2': + + return booleanArray(2 * size); + + case 'bvec3': + return booleanArray(3 * size); + + case 'bvec4': + return booleanArray(4 * size); + + case 'mat2': + return new Float32Array([1, 0, + 0, 1]); + + case 'mat3': + return new Float32Array([1, 0, 0, + 0, 1, 0, + 0, 0, 1]); + + case 'mat4': + return new Float32Array([1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1]); + } + + return null; + } + + function booleanArray(size) + { + var array = new Array(size); + + for (var i = 0; i < array.length; i++) + { + array[i] = false; + } + + return array; + } + + var context = null; + + /** + * returns a little WebGL context to use for program inspection. + * + * @static + * @private + * @returns {webGL-context} a gl context to test with + */ + function getTestContext() + { + if (!context) + { + var canvas = document.createElement('canvas'); + + var gl; + + if (settings.PREFER_ENV >= ENV.WEBGL2) + { + gl = canvas.getContext('webgl2', {}); + } + + if (!gl) + { + gl = canvas.getContext('webgl', {}) + || canvas.getContext('experimental-webgl', {}); + + if (!gl) + { + // fail, not able to get a context + throw new Error('This browser does not support WebGL. Try using the canvas renderer'); + } + else + { + // for shader testing.. + gl.getExtension('WEBGL_draw_buffers'); + } + } + + context = gl; + + return gl; + } + + return context; + } + + var maxFragmentPrecision; + + function getMaxFragmentPrecision() + { + if (!maxFragmentPrecision) + { + maxFragmentPrecision = PRECISION.MEDIUM; + var gl = getTestContext(); + + if (gl) + { + if (gl.getShaderPrecisionFormat) + { + var shaderFragment = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT); + + maxFragmentPrecision = shaderFragment.precision ? PRECISION.HIGH : PRECISION.MEDIUM; + } + } + } + + return maxFragmentPrecision; + } + + /** + * Sets the float precision on the shader, ensuring the device supports the request precision. + * If the precision is already present, it just ensures that the device is able to handle it. + * + * @private + * @param {string} src - The shader source + * @param {string} requestedPrecision - The request float precision of the shader. Options are 'lowp', 'mediump' or 'highp'. + * @param {string} maxSupportedPrecision - The maximum precision the shader supports. + * + * @return {string} modified shader source + */ + function setPrecision(src, requestedPrecision, maxSupportedPrecision) + { + if (src.substring(0, 9) !== 'precision') + { + // no precision supplied, so PixiJS will add the requested level. + var precision = requestedPrecision; + + // If highp is requested but not supported, downgrade precision to a level all devices support. + if (requestedPrecision === PRECISION.HIGH && maxSupportedPrecision !== PRECISION.HIGH) + { + precision = PRECISION.MEDIUM; + } + + return ("precision " + precision + " float;\n" + src); + } + else if (maxSupportedPrecision !== PRECISION.HIGH && src.substring(0, 15) === 'precision highp') + { + // precision was supplied, but at a level this device does not support, so downgrading to mediump. + return src.replace('precision highp', 'precision mediump'); + } + + return src; + } + + var GLSL_TO_SIZE = { + float: 1, + vec2: 2, + vec3: 3, + vec4: 4, + + int: 1, + ivec2: 2, + ivec3: 3, + ivec4: 4, + + bool: 1, + bvec2: 2, + bvec3: 3, + bvec4: 4, + + mat2: 4, + mat3: 9, + mat4: 16, + + sampler2D: 1, + }; + + /** + * @private + * @method mapSize + * @memberof PIXI.glCore.shader + * @param type {String} + * @return {Number} + */ + function mapSize(type) + { + return GLSL_TO_SIZE[type]; + } + + var GL_TABLE = null; + + var GL_TO_GLSL_TYPES = { + FLOAT: 'float', + FLOAT_VEC2: 'vec2', + FLOAT_VEC3: 'vec3', + FLOAT_VEC4: 'vec4', + + INT: 'int', + INT_VEC2: 'ivec2', + INT_VEC3: 'ivec3', + INT_VEC4: 'ivec4', + + BOOL: 'bool', + BOOL_VEC2: 'bvec2', + BOOL_VEC3: 'bvec3', + BOOL_VEC4: 'bvec4', + + FLOAT_MAT2: 'mat2', + FLOAT_MAT3: 'mat3', + FLOAT_MAT4: 'mat4', + + SAMPLER_2D: 'sampler2D', + SAMPLER_CUBE: 'samplerCube', + SAMPLER_2D_ARRAY: 'sampler2DArray', + }; + + function mapType(gl, type) + { + if (!GL_TABLE) + { + var typeNames = Object.keys(GL_TO_GLSL_TYPES); + + GL_TABLE = {}; + + for (var i = 0; i < typeNames.length; ++i) + { + var tn = typeNames[i]; + + GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn]; + } + } + + return GL_TABLE[type]; + } + + // cv = CachedValue + // v = value + // ud = uniformData + // uv = uniformValue + // l = location + var GLSL_TO_SINGLE_SETTERS_CACHED = { + + float: "\n if(cv !== v)\n {\n cv.v = v;\n gl.uniform1f(location, v)\n }", + + vec2: "\n if(cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(location, v[0], v[1])\n }", + + vec3: "\n if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3f(location, v[0], v[1], v[2])\n }", + + vec4: 'gl.uniform4f(location, v[0], v[1], v[2], v[3])', + + int: 'gl.uniform1i(location, v)', + ivec2: 'gl.uniform2i(location, v[0], v[1])', + ivec3: 'gl.uniform3i(location, v[0], v[1], v[2])', + ivec4: 'gl.uniform4i(location, v[0], v[1], v[2], v[3])', + + bool: 'gl.uniform1i(location, v)', + bvec2: 'gl.uniform2i(location, v[0], v[1])', + bvec3: 'gl.uniform3i(location, v[0], v[1], v[2])', + bvec4: 'gl.uniform4i(location, v[0], v[1], v[2], v[3])', + + mat2: 'gl.uniformMatrix2fv(location, false, v)', + mat3: 'gl.uniformMatrix3fv(location, false, v)', + mat4: 'gl.uniformMatrix4fv(location, false, v)', + + sampler2D: 'gl.uniform1i(location, v)', + samplerCube: 'gl.uniform1i(location, v)', + sampler2DArray: 'gl.uniform1i(location, v)', + }; + + var GLSL_TO_ARRAY_SETTERS = { + + float: "gl.uniform1fv(location, v)", + + vec2: "gl.uniform2fv(location, v)", + vec3: "gl.uniform3fv(location, v)", + vec4: 'gl.uniform4fv(location, v)', + + mat4: 'gl.uniformMatrix4fv(location, false, v)', + mat3: 'gl.uniformMatrix3fv(location, false, v)', + mat2: 'gl.uniformMatrix2fv(location, false, v)', + + int: 'gl.uniform1iv(location, v)', + ivec2: 'gl.uniform2iv(location, v)', + ivec3: 'gl.uniform3iv(location, v)', + ivec4: 'gl.uniform4iv(location, v)', + + bool: 'gl.uniform1iv(location, v)', + bvec2: 'gl.uniform2iv(location, v)', + bvec3: 'gl.uniform3iv(location, v)', + bvec4: 'gl.uniform4iv(location, v)', + + sampler2D: 'gl.uniform1iv(location, v)', + samplerCube: 'gl.uniform1iv(location, v)', + sampler2DArray: 'gl.uniform1iv(location, v)', + }; + + function generateUniformsSync(group, uniformData) + { + var textureCount = 0; + var func = "var v = null;\n var cv = null\n var gl = renderer.gl"; + + for (var i in group.uniforms) + { + var data = uniformData[i]; + + if (!data) + { + if (group.uniforms[i].group) + { + func += "\n renderer.shader.syncUniformGroup(uv." + i + ");\n "; + } + + continue; + } + + // TODO && uniformData[i].value !== 0 <-- do we still need this? + if (data.type === 'float' && data.size === 1) + { + func += "\n if(uv." + i + " !== ud." + i + ".value)\n {\n ud." + i + ".value = uv." + i + "\n gl.uniform1f(ud." + i + ".location, uv." + i + ")\n }\n"; + } + /* eslint-disable max-len */ + else if ((data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1 && !data.isArray) + /* eslint-disable max-len */ + { + func += "\n renderer.texture.bind(uv." + i + ", " + textureCount + ");\n\n if(ud." + i + ".value !== " + textureCount + ")\n {\n ud." + i + ".value = " + textureCount + ";\n gl.uniform1i(ud." + i + ".location, " + textureCount + ");\n; // eslint-disable-line max-len\n }\n"; + + textureCount++; + } + else if (data.type === 'mat3' && data.size === 1) + { + if (group.uniforms[i].a !== undefined) + { + // TODO and some smart caching dirty ids here! + func += "\n gl.uniformMatrix3fv(ud." + i + ".location, false, uv." + i + ".toArray(true));\n \n"; + } + else + { + func += "\n gl.uniformMatrix3fv(ud." + i + ".location, false, uv." + i + ");\n \n"; + } + } + else if (data.type === 'vec2' && data.size === 1) + { + // TODO - do we need both here? + // maybe we can get away with only using points? + if (group.uniforms[i].x !== undefined) + { + func += "\n cv = ud." + i + ".value;\n v = uv." + i + ";\n\n if(cv[0] !== v.x || cv[1] !== v.y)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud." + i + ".location, v.x, v.y);\n }\n"; + } + else + { + func += "\n cv = ud." + i + ".value;\n v = uv." + i + ";\n\n if(cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(ud." + i + ".location, v[0], v[1]);\n }\n \n"; + } + } + else if (data.type === 'vec4' && data.size === 1) + { + // TODO - do we need both here? + // maybe we can get away with only using points? + if (group.uniforms[i].width !== undefined) + { + func += "\n cv = ud." + i + ".value;\n v = uv." + i + ";\n\n if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud." + i + ".location, v.x, v.y, v.width, v.height)\n }\n"; + } + else + { + func += "\n cv = ud." + i + ".value;\n v = uv." + i + ";\n\n if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(ud." + i + ".location, v[0], v[1], v[2], v[3])\n }\n \n"; + } + } + else + { + var templateType = (data.size === 1) ? GLSL_TO_SINGLE_SETTERS_CACHED : GLSL_TO_ARRAY_SETTERS; + + var template = templateType[data.type].replace('location', ("ud." + i + ".location")); + + func += "\n cv = ud." + i + ".value;\n v = uv." + i + ";\n " + template + ";\n"; + } + } + + return new Function('ud', 'uv', 'renderer', func); // eslint-disable-line no-new-func + } + + var fragTemplate = [ + 'precision mediump float;', + 'void main(void){', + 'float test = 0.1;', + '%forloop%', + 'gl_FragColor = vec4(0.0);', + '}' ].join('\n'); + + function checkMaxIfStatementsInShader(maxIfs, gl) + { + if (maxIfs === 0) + { + throw new Error('Invalid value of `0` passed to `checkMaxIfStatementsInShader`'); + } + + var shader = gl.createShader(gl.FRAGMENT_SHADER); + + while (true) // eslint-disable-line no-constant-condition + { + var fragmentSrc = fragTemplate.replace(/%forloop%/gi, generateIfTestSrc(maxIfs)); + + gl.shaderSource(shader, fragmentSrc); + gl.compileShader(shader); + + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) + { + maxIfs = (maxIfs / 2) | 0; + } + else + { + // valid! + break; + } + } + + return maxIfs; + } + + function generateIfTestSrc(maxIfs) + { + var src = ''; + + for (var i = 0; i < maxIfs; ++i) + { + if (i > 0) + { + src += '\nelse '; + } + + if (i < maxIfs - 1) + { + src += "if(test == " + i + ".0){}"; + } + } + + return src; + } + + // Cache the result to prevent running this over and over + var unsafeEval; + + /** + * Not all platforms allow to generate function code (e.g., `new Function`). + * this provides the platform-level detection. + * + * @private + * @returns {boolean} + */ + function unsafeEvalSupported() + { + if (typeof unsafeEval === 'boolean') + { + return unsafeEval; + } + + try + { + /* eslint-disable no-new-func */ + var func = new Function('param1', 'param2', 'param3', 'return param1[param2] === param3;'); + /* eslint-enable no-new-func */ + + unsafeEval = func({ a: 'b' }, 'a', 'b') === true; + } + catch (e) + { + unsafeEval = false; + } + + return unsafeEval; + } + + var defaultFragment = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor *= texture2D(uSampler, vTextureCoord);\n}"; + + var defaultVertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n"; + + // import * as from '../systems/shader/shader'; + + var UID$3 = 0; + + var nameCache = {}; + + /** + * Helper class to create a shader program. + * + * @class + * @memberof PIXI + */ + var Program = function Program(vertexSrc, fragmentSrc, name) + { + if ( name === void 0 ) { name = 'pixi-shader'; } + + this.id = UID$3++; + + /** + * The vertex shader. + * + * @member {string} + */ + this.vertexSrc = vertexSrc || Program.defaultVertexSrc; + + /** + * The fragment shader. + * + * @member {string} + */ + this.fragmentSrc = fragmentSrc || Program.defaultFragmentSrc; + + this.vertexSrc = this.vertexSrc.trim(); + this.fragmentSrc = this.fragmentSrc.trim(); + + if (this.vertexSrc.substring(0, 8) !== '#version') + { + name = name.replace(/\s+/g, '-'); + + if (nameCache[name]) + { + nameCache[name]++; + name += "-" + (nameCache[name]); + } + else + { + nameCache[name] = 1; + } + + this.vertexSrc = "#define SHADER_NAME " + name + "\n" + (this.vertexSrc); + this.fragmentSrc = "#define SHADER_NAME " + name + "\n" + (this.fragmentSrc); + + this.vertexSrc = setPrecision(this.vertexSrc, settings.PRECISION_VERTEX, PRECISION.HIGH); + this.fragmentSrc = setPrecision(this.fragmentSrc, settings.PRECISION_FRAGMENT, getMaxFragmentPrecision()); + } + + // currently this does not extract structs only default types + this.extractData(this.vertexSrc, this.fragmentSrc); + + // this is where we store shader references.. + this.glPrograms = {}; + + this.syncUniforms = null; + }; + + var staticAccessors$3 = { defaultVertexSrc: { configurable: true },defaultFragmentSrc: { configurable: true } }; + + /** + * Extracts the data for a buy creating a small test program + * or reading the src directly. + * @protected + * + * @param {string} [vertexSrc] - The source of the vertex shader. + * @param {string} [fragmentSrc] - The source of the fragment shader. + */ + Program.prototype.extractData = function extractData (vertexSrc, fragmentSrc) + { + var gl = getTestContext(); + + if (gl) + { + var program = compileProgram(gl, vertexSrc, fragmentSrc); + + this.attributeData = this.getAttributeData(program, gl); + this.uniformData = this.getUniformData(program, gl); + + gl.deleteProgram(program); + } + else + { + this.uniformData = {}; + this.attributeData = {}; + } + }; + + /** + * returns the attribute data from the program + * @private + * + * @param {WebGLProgram} [program] - the WebGL program + * @param {WebGLRenderingContext} [gl] - the WebGL context + * + * @returns {object} the attribute data for this program + */ + Program.prototype.getAttributeData = function getAttributeData (program, gl) + { + var attributes = {}; + var attributesArray = []; + + var totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); + + for (var i = 0; i < totalAttributes; i++) + { + var attribData = gl.getActiveAttrib(program, i); + var type = mapType(gl, attribData.type); + + /*eslint-disable */ + var data = { + type: type, + name: attribData.name, + size: mapSize(type), + location: 0, + }; + /* eslint-enable */ + + attributes[attribData.name] = data; + attributesArray.push(data); + } + + attributesArray.sort(function (a, b) { return (a.name > b.name) ? 1 : -1; }); // eslint-disable-line no-confusing-arrow + + for (var i$1 = 0; i$1 < attributesArray.length; i$1++) + { + attributesArray[i$1].location = i$1; + } + + return attributes; + }; + + /** + * returns the uniform data from the program + * @private + * + * @param {webGL-program} [program] - the webgl program + * @param {context} [gl] - the WebGL context + * + * @returns {object} the uniform data for this program + */ + Program.prototype.getUniformData = function getUniformData (program, gl) + { + var uniforms = {}; + + var totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); + + // TODO expose this as a prop? + // const maskRegex = new RegExp('^(projectionMatrix|uSampler|translationMatrix)$'); + // const maskRegex = new RegExp('^(projectionMatrix|uSampler|translationMatrix)$'); + + for (var i = 0; i < totalUniforms; i++) + { + var uniformData = gl.getActiveUniform(program, i); + var name = uniformData.name.replace(/\[.*?\]/, ''); + + var isArray = uniformData.name.match(/\[.*?\]/, ''); + var type = mapType(gl, uniformData.type); + + /*eslint-disable */ + uniforms[name] = { + type: type, + size: uniformData.size, + isArray:isArray, + value: defaultValue(type, uniformData.size), + }; + /* eslint-enable */ + } + + return uniforms; + }; + + /** + * The default vertex shader source + * + * @static + * @constant + * @member {string} + */ + staticAccessors$3.defaultVertexSrc.get = function () + { + return defaultVertex; + }; + + /** + * The default fragment shader source + * + * @static + * @constant + * @member {string} + */ + staticAccessors$3.defaultFragmentSrc.get = function () + { + return defaultFragment; + }; + + /** + * A short hand function to create a program based of a vertex and fragment shader + * this method will also check to see if there is a cached program. + * + * @param {string} [vertexSrc] - The source of the vertex shader. + * @param {string} [fragmentSrc] - The source of the fragment shader. + * @param {object} [uniforms] - Custom uniforms to use to augment the built-in ones. + * + * @returns {PIXI.Program} an shiny new Pixi shader! + */ + Program.from = function from (vertexSrc, fragmentSrc, name) + { + var key = vertexSrc + fragmentSrc; + + var program = ProgramCache[key]; + + if (!program) + { + ProgramCache[key] = program = new Program(vertexSrc, fragmentSrc, name); + } + + return program; + }; + + Object.defineProperties( Program, staticAccessors$3 ); + + /** + * A helper class for shaders + * + * @class + * @memberof PIXI + */ + var Shader = function Shader(program, uniforms) + { + this.program = program; + + // lets see whats been passed in + // uniforms should be converted to a uniform group + if (uniforms) + { + if (uniforms instanceof UniformGroup) + { + this.uniformGroup = uniforms; + } + else + { + this.uniformGroup = new UniformGroup(uniforms); + } + } + else + { + this.uniformGroup = new UniformGroup({}); + } + + // time to build some getters and setters! + // I guess down the line this could sort of generate an instruction list rather than use dirty ids? + // does the trick for now though! + for (var i in program.uniformData) + { + if (this.uniformGroup.uniforms[i] instanceof Array) + { + this.uniformGroup.uniforms[i] = new Float32Array(this.uniformGroup.uniforms[i]); + } + } + }; + + var prototypeAccessors$2$1 = { uniforms: { configurable: true } }; + + // TODO move to shader system.. + Shader.prototype.checkUniformExists = function checkUniformExists (name, group) + { + if (group.uniforms[name]) + { + return true; + } + + for (var i in group.uniforms) + { + var uniform = group.uniforms[i]; + + if (uniform.group) + { + if (this.checkUniformExists(name, uniform)) + { + return true; + } + } + } + + return false; + }; + + Shader.prototype.destroy = function destroy () + { + // usage count on programs? + // remove if not used! + this.uniformGroup = null; + }; + + /** + * Shader uniform values, shortcut for `uniformGroup.uniforms` + * @readonly + * @member {object} + */ + prototypeAccessors$2$1.uniforms.get = function () + { + return this.uniformGroup.uniforms; + }; + + /** + * A short hand function to create a shader based of a vertex and fragment shader + * + * @param {string} [vertexSrc] - The source of the vertex shader. + * @param {string} [fragmentSrc] - The source of the fragment shader. + * @param {object} [uniforms] - Custom uniforms to use to augment the built-in ones. + * + * @returns {PIXI.Shader} an shiny new Pixi shader! + */ + Shader.from = function from (vertexSrc, fragmentSrc, uniforms) + { + var program = Program.from(vertexSrc, fragmentSrc); + + return new Shader(program, uniforms); + }; + + Object.defineProperties( Shader.prototype, prototypeAccessors$2$1 ); + + /* eslint-disable max-len */ + + var BLEND = 0; + var OFFSET = 1; + var CULLING = 2; + var DEPTH_TEST = 3; + var WINDING = 4; + + /** + * This is a WebGL state, and is is passed The WebGL StateManager. + * + * Each mesh rendered may require WebGL to be in a different state. + * For example you may want different blend mode or to enable polygon offsets + * + * @class + * @memberof PIXI + */ + var State = function State() + { + this.data = 0; + + this.blendMode = BLEND_MODES.NORMAL; + this.polygonOffset = 0; + + this.blend = true; + // this.depthTest = true; + }; + + var prototypeAccessors$3$1 = { blend: { configurable: true },offsets: { configurable: true },culling: { configurable: true },depthTest: { configurable: true },clockwiseFrontFace: { configurable: true },blendMode: { configurable: true },polygonOffset: { configurable: true } }; + + /** + * Activates blending of the computed fragment color values + * + * @member {boolean} + */ + prototypeAccessors$3$1.blend.get = function () + { + return !!(this.data & (1 << BLEND)); + }; + + prototypeAccessors$3$1.blend.set = function (value) // eslint-disable-line require-jsdoc + { + if (!!(this.data & (1 << BLEND)) !== value) + { + this.data ^= (1 << BLEND); + } + }; + + /** + * Activates adding an offset to depth values of polygon's fragments + * + * @member {boolean} + * @default false + */ + prototypeAccessors$3$1.offsets.get = function () + { + return !!(this.data & (1 << OFFSET)); + }; + + prototypeAccessors$3$1.offsets.set = function (value) // eslint-disable-line require-jsdoc + { + if (!!(this.data & (1 << OFFSET)) !== value) + { + this.data ^= (1 << OFFSET); + } + }; + + /** + * Activates culling of polygons. + * + * @member {boolean} + * @default false + */ + prototypeAccessors$3$1.culling.get = function () + { + return !!(this.data & (1 << CULLING)); + }; + + prototypeAccessors$3$1.culling.set = function (value) // eslint-disable-line require-jsdoc + { + if (!!(this.data & (1 << CULLING)) !== value) + { + this.data ^= (1 << CULLING); + } + }; + + /** + * Activates depth comparisons and updates to the depth buffer. + * + * @member {boolean} + * @default false + */ + prototypeAccessors$3$1.depthTest.get = function () + { + return !!(this.data & (1 << DEPTH_TEST)); + }; + + prototypeAccessors$3$1.depthTest.set = function (value) // eslint-disable-line require-jsdoc + { + if (!!(this.data & (1 << DEPTH_TEST)) !== value) + { + this.data ^= (1 << DEPTH_TEST); + } + }; + + /** + * Specifies whether or not front or back-facing polygons can be culled. + * @member {boolean} + * @default false + */ + prototypeAccessors$3$1.clockwiseFrontFace.get = function () + { + return !!(this.data & (1 << WINDING)); + }; + + prototypeAccessors$3$1.clockwiseFrontFace.set = function (value) // eslint-disable-line require-jsdoc + { + if (!!(this.data & (1 << WINDING)) !== value) + { + this.data ^= (1 << WINDING); + } + }; + + /** + * The blend mode to be applied when this state is set. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. + * Setting this mode to anything other than NO_BLEND will automatically switch blending on. + * + * @member {boolean} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + prototypeAccessors$3$1.blendMode.get = function () + { + return this._blendMode; + }; + + prototypeAccessors$3$1.blendMode.set = function (value) // eslint-disable-line require-jsdoc + { + this.blend = (value !== BLEND_MODES.NONE); + this._blendMode = value; + }; + + /** + * The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill. + * + * @member {number} + * @default 0 + */ + prototypeAccessors$3$1.polygonOffset.get = function () + { + return this._polygonOffset; + }; + + prototypeAccessors$3$1.polygonOffset.set = function (value) // eslint-disable-line require-jsdoc + { + this.offsets = !!value; + this._polygonOffset = value; + }; + + State.for2d = function for2d () + { + var state = new State(); + + state.depthTest = false; + state.blend = true; + + return state; + }; + + Object.defineProperties( State.prototype, prototypeAccessors$3$1 ); + + var defaultVertex$1 = "attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n"; + + var defaultFragment$1 = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n}\n"; + + /** + * Filter is a special type of WebGL shader that is applied to the screen. + * + * {@link http://pixijs.io/examples/#/filters/blur-filter.js Example} of the + * {@link PIXI.filters.BlurFilter BlurFilter}. + * + * ### Usage + * Filters can be applied to any DisplayObject or Container. + * PixiJS' `FilterSystem` renders the container into temporary Framebuffer, + * then filter renders it to the screen. + * Multiple filters can be added to the `filters` array property and stacked on each other. + * + * ``` + * const filter = new PIXI.Filter(myShaderVert, myShaderFrag, { myUniform: 0.5 }); + * const container = new PIXI.Container(); + * container.filters = [filter]; + * ``` + * + * ### Previous Version Differences + * + * In PixiJS **v3**, a filter was always applied to _whole screen_. + * + * In PixiJS **v4**, a filter can be applied _only part of the screen_. + * Developers had to create a set of uniforms to deal with coordinates. + * + * In PixiJS **v5** combines _both approaches_. + * Developers can use normal coordinates of v3 and then allow filter to use partial Framebuffers, + * bringing those extra uniforms into account. + * + * Also be aware that we have changed default vertex shader, please consult + * {@link https://github.com/pixijs/pixi.js/wiki/v5-Creating-filters Wiki}. + * + * ### Built-in Uniforms + * + * PixiJS viewport uses screen (CSS) coordinates, `(0, 0, renderer.screen.width, renderer.screen.height)`, + * and `projectionMatrix` uniform maps it to the gl viewport. + * + * **uSampler** + * + * The most important uniform is the input texture that container was rendered into. + * _Important note: as with all Framebuffers in PixiJS, both input and output are + * premultiplied by alpha._ + * + * By default, input normalized coordinates are passed to fragment shader with `vTextureCoord`. + * Use it to sample the input. + * + * ``` + * const fragment = ` + * varying vec2 vTextureCoord; + * uniform sampler2D uSampler; + * void main(void) + * { + * gl_FragColor = texture2D(uSampler, vTextureCoord); + * } + * `; + * + * const myFilter = new PIXI.Filter(null, fragment); + * ``` + * + * This filter is just one uniform less than {@link PIXI.filters.AlphaFilter AlphaFilter}. + * + * **outputFrame** + * + * The `outputFrame` holds the rectangle where filter is applied in screen (CSS) coordinates. + * It's the same as `renderer.screen` for a fullscreen filter. + * Only a part of `outputFrame.zw` size of temporary Framebuffer is used, + * `(0, 0, outputFrame.width, outputFrame.height)`, + * + * Filters uses this quad to normalized (0-1) space, its passed into `aVertexPosition` attribute. + * To calculate vertex position in screen space using normalized (0-1) space: + * + * ``` + * vec4 filterVertexPosition( void ) + * { + * vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + * return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); + * } + * ``` + * + * **inputSize** + * + * Temporary framebuffer is different, it can be either the size of screen, either power-of-two. + * The `inputSize.xy` are size of temporary framebuffer that holds input. + * The `inputSize.zw` is inverted, it's a shortcut to evade division inside the shader. + * + * Set `inputSize.xy = outputFrame.zw` for a fullscreen filter. + * + * To calculate input normalized coordinate, you have to map it to filter normalized space. + * Multiply by `outputFrame.zw` to get input coordinate. + * Divide by `inputSize.xy` to get input normalized coordinate. + * + * ``` + * vec2 filterTextureCoord( void ) + * { + * return aVertexPosition * (outputFrame.zw * inputSize.zw); // same as /inputSize.xy + * } + * ``` + * **resolution** + * + * The `resolution` is the ratio of screen (CSS) pixels to real pixels. + * + * **inputPixel** + * + * `inputPixel.xy` is the size of framebuffer in real pixels, same as `inputSize.xy * resolution` + * `inputPixel.zw` is inverted `inputPixel.xy`. + * + * It's handy for filters that use neighbour pixels, like {@link PIXI.filters.FXAAFilter FXAAFilter}. + * + * **inputClamp** + * + * If you try to get info from outside of used part of Framebuffer - you'll get undefined behaviour. + * For displacements, coordinates has to be clamped. + * + * The `inputClamp.xy` is left-top pixel center, you may ignore it, because we use left-top part of Framebuffer + * `inputClamp.zw` is bottom-right pixel center. + * + * ``` + * vec4 color = texture2D(uSampler, clamp(modifigedTextureCoord, inputClamp.xy, inputClamp.zw)) + * ``` + * OR + * ``` + * vec4 color = texture2D(uSampler, min(modifigedTextureCoord, inputClamp.zw)) + * ``` + * + * ### Additional Information + * + * Complete documentation on Filter usage is located in the + * {@link https://github.com/pixijs/pixi.js/wiki/v5-Creating-filters Wiki}. + * + * Since PixiJS only had a handful of built-in filters, additional filters can be downloaded + * {@link https://github.com/pixijs/pixi-filters here} from the PixiJS Filters repository. + * + * @class + * @memberof PIXI + * @extends PIXI.Shader + */ + var Filter = /*@__PURE__*/(function (Shader) { + function Filter(vertexSrc, fragmentSrc, uniforms) + { + var program = Program.from(vertexSrc || Filter.defaultVertexSrc, + fragmentSrc || Filter.defaultFragmentSrc); + + Shader.call(this, program, uniforms); + + /** + * The padding of the filter. Some filters require extra space to breath such as a blur. + * Increasing this will add extra width and height to the bounds of the object that the + * filter is applied to. + * + * @member {number} + */ + this.padding = 0; + + /** + * The resolution of the filter. Setting this to be lower will lower the quality but + * increase the performance of the filter. + * + * @member {number} + */ + this.resolution = settings.FILTER_RESOLUTION; + + /** + * If enabled is true the filter is applied, if false it will not. + * + * @member {boolean} + */ + this.enabled = true; + + /** + * If enabled, PixiJS will fit the filter area into boundaries for better performance. + * Switch it off if it does not work for specific shader. + * + * @member {boolean} + */ + this.autoFit = true; + + /** + * Legacy filters use position and uvs from attributes + * @member {boolean} + * @readonly + */ + this.legacy = !!this.program.attributeData.aTextureCoord; + + /** + * The WebGL state the filter requires to render + * @member {PIXI.State} + */ + this.state = new State(); + } + + if ( Shader ) { Filter.__proto__ = Shader; } + Filter.prototype = Object.create( Shader && Shader.prototype ); + Filter.prototype.constructor = Filter; + + var prototypeAccessors = { blendMode: { configurable: true } }; + var staticAccessors = { defaultVertexSrc: { configurable: true },defaultFragmentSrc: { configurable: true } }; + + /** + * Applies the filter + * + * @param {PIXI.systems.FilterSystem} filterManager - The renderer to retrieve the filter from + * @param {PIXI.RenderTexture} input - The input render target. + * @param {PIXI.RenderTexture} output - The target to output to. + * @param {boolean} clear - Should the output be cleared before rendering to it + * @param {object} [currentState] - It's current state of filter. + * There are some useful properties in the currentState : + * target, filters, sourceFrame, destinationFrame, renderTarget, resolution + */ + Filter.prototype.apply = function apply (filterManager, input, output, clear, currentState) + { + // do as you please! + + filterManager.applyFilter(this, input, output, clear, currentState); + + // or just do a regular render.. + }; + + /** + * Sets the blendmode of the filter + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + */ + prototypeAccessors.blendMode.get = function () + { + return this.state.blendMode; + }; + + prototypeAccessors.blendMode.set = function (value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + }; + + /** + * The default vertex shader source + * + * @static + * @type {string} + * @constant + */ + staticAccessors.defaultVertexSrc.get = function () + { + return defaultVertex$1; + }; + + /** + * The default fragment shader source + * + * @static + * @type {string} + * @constant + */ + staticAccessors.defaultFragmentSrc.get = function () + { + return defaultFragment$1; + }; + + Object.defineProperties( Filter.prototype, prototypeAccessors ); + Object.defineProperties( Filter, staticAccessors ); + + return Filter; + }(Shader)); + + /** + * Used for caching shader IDs + * + * @static + * @type {object} + * @protected + */ + Filter.SOURCE_KEY_MAP = {}; + + var vertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n"; + + var fragment = "varying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform float npmAlpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(maskClamp.x, vMaskCoord.x) +\n step(maskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, maskClamp.z) +\n step(vMaskCoord.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n original *= (alphaMul * masky.r * alpha * clip);\n\n gl_FragColor = original;\n}\n"; + + var tempMat = new Matrix(); + + /** + * Class controls uv mapping from Texture normal space to BaseTexture normal space. + * + * Takes `trim` and `rotate` into account. May contain clamp settings for Meshes and TilingSprite. + * + * Can be used in Texture `uvMatrix` field, or separately, you can use different clamp settings on the same texture. + * If you want to add support for texture region of certain feature or filter, that's what you're looking for. + * + * Takes track of Texture changes through `_lastTextureID` private field. + * Use `update()` method call to track it from outside. + * + * @see PIXI.Texture + * @see PIXI.Mesh + * @see PIXI.TilingSprite + * @class + * @memberof PIXI + */ + var TextureMatrix = function TextureMatrix(texture, clampMargin) + { + this._texture = texture; + + this.mapCoord = new Matrix(); + + this.uClampFrame = new Float32Array(4); + + this.uClampOffset = new Float32Array(2); + + /** + * Tracks Texture frame changes + * @member {number} + * @protected + */ + this._updateID = -1; + + /** + * Changes frame clamping + * Works with TilingSprite and Mesh + * Change to 1.5 if you texture has repeated right and bottom lines, that leads to smoother borders + * + * @default 0 + * @member {number} + */ + this.clampOffset = 0; + + /** + * Changes frame clamping + * Works with TilingSprite and Mesh + * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas + * + * @default 0.5 + * @member {number} + */ + this.clampMargin = (typeof clampMargin === 'undefined') ? 0.5 : clampMargin; + + /** + * If texture size is the same as baseTexture + * @member {boolean} + * @default false + * @readonly + */ + this.isSimple = false; + }; + + var prototypeAccessors$4$1 = { texture: { configurable: true } }; + + /** + * texture property + * @member {PIXI.Texture} + */ + prototypeAccessors$4$1.texture.get = function () + { + return this._texture; + }; + + prototypeAccessors$4$1.texture.set = function (value) // eslint-disable-line require-jsdoc + { + this._texture = value; + this._updateID = -1; + }; + + /** + * Multiplies uvs array to transform + * @param {Float32Array} uvs mesh uvs + * @param {Float32Array} [out=uvs] output + * @returns {Float32Array} output + */ + TextureMatrix.prototype.multiplyUvs = function multiplyUvs (uvs, out) + { + if (out === undefined) + { + out = uvs; + } + + var mat = this.mapCoord; + + for (var i = 0; i < uvs.length; i += 2) + { + var x = uvs[i]; + var y = uvs[i + 1]; + + out[i] = (x * mat.a) + (y * mat.c) + mat.tx; + out[i + 1] = (x * mat.b) + (y * mat.d) + mat.ty; + } + + return out; + }; + + /** + * updates matrices if texture was changed + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + * @returns {boolean} whether or not it was updated + */ + TextureMatrix.prototype.update = function update (forceUpdate) + { + var tex = this._texture; + + if (!tex || !tex.valid) + { + return false; + } + + if (!forceUpdate + && this._updateID === tex._updateID) + { + return false; + } + + this._updateID = tex._updateID; + + var uvs = tex._uvs; + + this.mapCoord.set(uvs.x1 - uvs.x0, uvs.y1 - uvs.y0, uvs.x3 - uvs.x0, uvs.y3 - uvs.y0, uvs.x0, uvs.y0); + + var orig = tex.orig; + var trim = tex.trim; + + if (trim) + { + tempMat.set(orig.width / trim.width, 0, 0, orig.height / trim.height, + -trim.x / trim.width, -trim.y / trim.height); + this.mapCoord.append(tempMat); + } + + var texBase = tex.baseTexture; + var frame = this.uClampFrame; + var margin = this.clampMargin / texBase.resolution; + var offset = this.clampOffset; + + frame[0] = (tex._frame.x + margin + offset) / texBase.width; + frame[1] = (tex._frame.y + margin + offset) / texBase.height; + frame[2] = (tex._frame.x + tex._frame.width - margin + offset) / texBase.width; + frame[3] = (tex._frame.y + tex._frame.height - margin + offset) / texBase.height; + this.uClampOffset[0] = offset / texBase.realWidth; + this.uClampOffset[1] = offset / texBase.realHeight; + + this.isSimple = tex._frame.width === texBase.width + && tex._frame.height === texBase.height + && tex.rotate === 0; + + return true; + }; + + Object.defineProperties( TextureMatrix.prototype, prototypeAccessors$4$1 ); + + /** + * This handles a Sprite acting as a mask, as opposed to a Graphic. + * + * WebGL only. + * + * @class + * @extends PIXI.Filter + * @memberof PIXI + */ + var SpriteMaskFilter = /*@__PURE__*/(function (Filter) { + function SpriteMaskFilter(sprite) + { + var maskMatrix = new Matrix(); + + Filter.call(this, vertex, fragment); + + sprite.renderable = false; + + /** + * Sprite mask + * @member {PIXI.Sprite} + */ + this.maskSprite = sprite; + + /** + * Mask matrix + * @member {PIXI.Matrix} + */ + this.maskMatrix = maskMatrix; + } + + if ( Filter ) { SpriteMaskFilter.__proto__ = Filter; } + SpriteMaskFilter.prototype = Object.create( Filter && Filter.prototype ); + SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; + + /** + * Applies the filter + * + * @param {PIXI.systems.FilterSystem} filterManager - The renderer to retrieve the filter from + * @param {PIXI.RenderTexture} input - The input render target. + * @param {PIXI.RenderTexture} output - The target to output to. + * @param {boolean} clear - Should the output be cleared before rendering to it. + */ + SpriteMaskFilter.prototype.apply = function apply (filterManager, input, output, clear) + { + var maskSprite = this.maskSprite; + var tex = this.maskSprite.texture; + + if (!tex.valid) + { + return; + } + if (!tex.transform) + { + // margin = 0.0, let it bleed a bit, shader code becomes easier + // assuming that atlas textures were made with 1-pixel padding + tex.transform = new TextureMatrix(tex, 0.0); + } + tex.transform.update(); + + this.uniforms.npmAlpha = tex.baseTexture.premultiplyAlpha ? 0.0 : 1.0; + this.uniforms.mask = tex; + // get _normalized sprite texture coords_ and convert them to _normalized atlas texture coords_ with `prepend` + this.uniforms.otherMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, maskSprite) + .prepend(tex.transform.mapCoord); + this.uniforms.alpha = maskSprite.worldAlpha; + this.uniforms.maskClamp = tex.transform.uClampFrame; + + filterManager.applyFilter(this, input, output, clear); + }; + + return SpriteMaskFilter; + }(Filter)); + + /** + * System plugin to the renderer to manage masks. + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + var MaskSystem = /*@__PURE__*/(function (System) { + function MaskSystem(renderer) + { + System.call(this, renderer); + + // TODO - we don't need both! + /** + * `true` if current pushed masked is scissor + * @member {boolean} + * @readonly + */ + this.scissor = false; + + /** + * Mask data + * @member {PIXI.Graphics} + * @readonly + */ + this.scissorData = null; + + /** + * Target to mask + * @member {PIXI.DisplayObject} + * @readonly + */ + this.scissorRenderTarget = null; + + /** + * Enable scissor + * @member {boolean} + * @readonly + */ + this.enableScissor = false; + + /** + * Pool of used sprite mask filters + * @member {PIXI.SpriteMaskFilter[]} + * @readonly + */ + this.alphaMaskPool = []; + + /** + * Current index of alpha mask pool + * @member {number} + * @default 0 + * @readonly + */ + this.alphaMaskIndex = 0; + } + + if ( System ) { MaskSystem.__proto__ = System; } + MaskSystem.prototype = Object.create( System && System.prototype ); + MaskSystem.prototype.constructor = MaskSystem; + + /** + * Applies the Mask and adds it to the current filter stack. + * + * @param {PIXI.DisplayObject} target - Display Object to push the mask to + * @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data. + */ + MaskSystem.prototype.push = function push (target, maskData) + { + // TODO the root check means scissor rect will not + // be used on render textures more info here: + // https://github.com/pixijs/pixi.js/pull/3545 + + if (maskData.isSprite) + { + this.pushSpriteMask(target, maskData); + } + else if (this.enableScissor + && !this.scissor + && this.renderer._activeRenderTarget.root + && !this.renderer.stencil.stencilMaskStack.length + && maskData.isFastRect()) + { + var matrix = maskData.worldTransform; + + var rot = Math.atan2(matrix.b, matrix.a); + + // use the nearest degree! + rot = Math.round(rot * (180 / Math.PI)); + + if (rot % 90) + { + this.pushStencilMask(maskData); + } + else + { + this.pushScissorMask(target, maskData); + } + } + else + { + this.pushStencilMask(maskData); + } + }; + + /** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param {PIXI.DisplayObject} target - Display Object to pop the mask from + * @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data. + */ + MaskSystem.prototype.pop = function pop (target, maskData) + { + if (maskData.isSprite) + { + this.popSpriteMask(target, maskData); + } + else if (this.enableScissor && !this.renderer.stencil.stencilMaskStack.length) + { + this.popScissorMask(target, maskData); + } + else + { + this.popStencilMask(target, maskData); + } + }; + + /** + * Applies the Mask and adds it to the current filter stack. + * + * @param {PIXI.RenderTexture} target - Display Object to push the sprite mask to + * @param {PIXI.Sprite} maskData - Sprite to be used as the mask + */ + MaskSystem.prototype.pushSpriteMask = function pushSpriteMask (target, maskData) + { + var alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex]; + + if (!alphaMaskFilter) + { + alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new SpriteMaskFilter(maskData)]; + } + + alphaMaskFilter[0].resolution = this.renderer.resolution; + alphaMaskFilter[0].maskSprite = maskData; + + var stashFilterArea = target.filterArea; + + target.filterArea = maskData.getBounds(true); + this.renderer.filter.push(target, alphaMaskFilter); + target.filterArea = stashFilterArea; + + this.alphaMaskIndex++; + }; + + /** + * Removes the last filter from the filter stack and doesn't return it. + * + */ + MaskSystem.prototype.popSpriteMask = function popSpriteMask () + { + this.renderer.filter.pop(); + this.alphaMaskIndex--; + }; + + /** + * Applies the Mask and adds it to the current filter stack. + * + * @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data. + */ + MaskSystem.prototype.pushStencilMask = function pushStencilMask (maskData) + { + this.renderer.batch.flush(); + this.renderer.stencil.pushStencil(maskData); + }; + + /** + * Removes the last filter from the filter stack and doesn't return it. + * + */ + MaskSystem.prototype.popStencilMask = function popStencilMask () + { + // this.renderer.currentRenderer.stop(); + this.renderer.stencil.popStencil(); + }; + + /** + * + * @param {PIXI.DisplayObject} target - Display Object to push the mask to + * @param {PIXI.Graphics} maskData - The masking data. + */ + MaskSystem.prototype.pushScissorMask = function pushScissorMask (target, maskData) + { + maskData.renderable = true; + + var renderTarget = this.renderer._activeRenderTarget; + + var bounds = maskData.getBounds(); + + bounds.fit(renderTarget.size); + maskData.renderable = false; + + this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST); + + var resolution = this.renderer.resolution; + + this.renderer.gl.scissor( + bounds.x * resolution, + (renderTarget.root ? renderTarget.size.height - bounds.y - bounds.height : bounds.y) * resolution, + bounds.width * resolution, + bounds.height * resolution + ); + + this.scissorRenderTarget = renderTarget; + this.scissorData = maskData; + this.scissor = true; + }; + + /** + * Pop scissor mask + * + */ + MaskSystem.prototype.popScissorMask = function popScissorMask () + { + this.scissorRenderTarget = null; + this.scissorData = null; + this.scissor = false; + + // must be scissor! + var ref = this.renderer; + var gl = ref.gl; + + gl.disable(gl.SCISSOR_TEST); + }; + + return MaskSystem; + }(System)); + + /** + * System plugin to the renderer to manage stencils (used for masks). + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + var StencilSystem = /*@__PURE__*/(function (System) { + function StencilSystem(renderer) + { + System.call(this, renderer); + + /** + * The mask stack + * @member {PIXI.Graphics[]} + */ + this.stencilMaskStack = []; + } + + if ( System ) { StencilSystem.__proto__ = System; } + StencilSystem.prototype = Object.create( System && System.prototype ); + StencilSystem.prototype.constructor = StencilSystem; + + /** + * Changes the mask stack that is used by this System. + * + * @param {PIXI.Graphics[]} stencilMaskStack - The mask stack + */ + StencilSystem.prototype.setMaskStack = function setMaskStack (stencilMaskStack) + { + var gl = this.renderer.gl; + + if (stencilMaskStack.length !== this.stencilMaskStack.length) + { + if (stencilMaskStack.length === 0) + { + gl.disable(gl.STENCIL_TEST); + } + else + { + gl.enable(gl.STENCIL_TEST); + } + } + + this.stencilMaskStack = stencilMaskStack; + }; + + /** + * Applies the Mask and adds it to the current stencil stack. @alvin + * + * @param {PIXI.Graphics} graphics - The mask + */ + StencilSystem.prototype.pushStencil = function pushStencil (graphics) + { + var gl = this.renderer.gl; + var prevMaskCount = this.stencilMaskStack.length; + + if (prevMaskCount === 0) + { + gl.enable(gl.STENCIL_TEST); + } + + this.stencilMaskStack.push(graphics); + + // Increment the reference stencil value where the new mask overlaps with the old ones. + gl.colorMask(false, false, false, false); + gl.stencilFunc(gl.EQUAL, prevMaskCount, this._getBitwiseMask()); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR); + + graphics.renderable = true; + graphics.render(this.renderer); + this.renderer.batch.flush(); + graphics.renderable = false; + + this._useCurrent(); + }; + + /** + * Removes the last mask from the stencil stack. @alvin + */ + StencilSystem.prototype.popStencil = function popStencil () + { + var gl = this.renderer.gl; + var graphics = this.stencilMaskStack.pop(); + + if (this.stencilMaskStack.length === 0) + { + // the stack is empty! + gl.disable(gl.STENCIL_TEST); + gl.clear(gl.STENCIL_BUFFER_BIT); + gl.clearStencil(0); + } + else + { + // Decrement the reference stencil value where the popped mask overlaps with the other ones + gl.colorMask(false, false, false, false); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR); + + graphics.renderable = true; + graphics.render(this.renderer); + this.renderer.batch.flush(); + graphics.renderable = false; + + this._useCurrent(); + } + }; + + /** + * Setup renderer to use the current stencil data. + * @private + */ + StencilSystem.prototype._useCurrent = function _useCurrent () + { + var gl = this.renderer.gl; + + gl.colorMask(true, true, true, true); + gl.stencilFunc(gl.EQUAL, this.stencilMaskStack.length, this._getBitwiseMask()); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + }; + + /** + * Fill 1s equal to the number of acitve stencil masks. + * @private + * @return {number} The bitwise mask. + */ + StencilSystem.prototype._getBitwiseMask = function _getBitwiseMask () + { + return (1 << this.stencilMaskStack.length) - 1; + }; + + /** + * Destroys the mask stack. + * + */ + StencilSystem.prototype.destroy = function destroy () + { + System.prototype.destroy.call(this, this); + + this.stencilMaskStack = null; + }; + + return StencilSystem; + }(System)); + + /** + * System plugin to the renderer to manage the projection matrix. + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + + var ProjectionSystem = /*@__PURE__*/(function (System) { + function ProjectionSystem(renderer) + { + System.call(this, renderer); + + /** + * Destination frame + * @member {PIXI.Rectangle} + * @readonly + */ + this.destinationFrame = null; + + /** + * Source frame + * @member {PIXI.Rectangle} + * @readonly + */ + this.sourceFrame = null; + + /** + * Default destination frame + * @member {PIXI.Rectangle} + * @readonly + */ + this.defaultFrame = null; + + /** + * Project matrix + * @member {PIXI.Matrix} + * @readonly + */ + this.projectionMatrix = new Matrix(); + + /** + * A transform that will be appended to the projection matrix + * if null, nothing will be applied + * @member {PIXI.Matrix} + */ + this.transform = null; + } + + if ( System ) { ProjectionSystem.__proto__ = System; } + ProjectionSystem.prototype = Object.create( System && System.prototype ); + ProjectionSystem.prototype.constructor = ProjectionSystem; + + /** + * Updates the projection matrix based on a projection frame (which is a rectangle) + * + * @param {PIXI.Rectangle} destinationFrame - The destination frame. + * @param {PIXI.Rectangle} sourceFrame - The source frame. + * @param {Number} resolution - Resolution + * @param {boolean} root - If is root + */ + ProjectionSystem.prototype.update = function update (destinationFrame, sourceFrame, resolution, root) + { + this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame; + this.sourceFrame = sourceFrame || this.sourceFrame || destinationFrame; + + this.calculateProjection(this.destinationFrame, this.sourceFrame, resolution, root); + + if (this.transform) + { + this.projectionMatrix.append(this.transform); + } + + var renderer = this.renderer; + + renderer.globalUniforms.uniforms.projectionMatrix = this.projectionMatrix; + renderer.globalUniforms.update(); + + // this will work for now + // but would be sweet to stick and even on the global uniforms.. + if (renderer.shader.shader) + { + renderer.shader.syncUniformGroup(renderer.shader.shader.uniforms.globals); + } + }; + + /** + * Updates the projection matrix based on a projection frame (which is a rectangle) + * + * @param {PIXI.Rectangle} destinationFrame - The destination frame. + * @param {PIXI.Rectangle} sourceFrame - The source frame. + * @param {Number} resolution - Resolution + * @param {boolean} root - If is root + */ + ProjectionSystem.prototype.calculateProjection = function calculateProjection (destinationFrame, sourceFrame, resolution, root) + { + var pm = this.projectionMatrix; + + // I don't think we will need this line.. + // pm.identity(); + + if (!root) + { + pm.a = (1 / destinationFrame.width * 2) * resolution; + pm.d = (1 / destinationFrame.height * 2) * resolution; + + pm.tx = -1 - (sourceFrame.x * pm.a); + pm.ty = -1 - (sourceFrame.y * pm.d); + } + else + { + pm.a = (1 / destinationFrame.width * 2) * resolution; + pm.d = (-1 / destinationFrame.height * 2) * resolution; + + pm.tx = -1 - (sourceFrame.x * pm.a); + pm.ty = 1 - (sourceFrame.y * pm.d); + } + }; + + /** + * Sets the transform of the active render target to the given matrix + * + * @param {PIXI.Matrix} matrix - The transformation matrix + */ + ProjectionSystem.prototype.setTransform = function setTransform ()// matrix) + { + // this._activeRenderTarget.transform = matrix; + }; + + return ProjectionSystem; + }(System)); + + var tempRect = new Rectangle(); + + /** + * System plugin to the renderer to manage render textures. + * + * Should be added after FramebufferSystem + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + + var RenderTextureSystem = /*@__PURE__*/(function (System) { + function RenderTextureSystem(renderer) + { + System.call(this, renderer); + + /** + * The clear background color as rgba + * @member {number[]} + */ + this.clearColor = renderer._backgroundColorRgba; + + // TODO move this property somewhere else! + /** + * List of masks for the StencilSystem + * @member {PIXI.Graphics[]} + * @readonly + */ + this.defaultMaskStack = []; + + // empty render texture? + /** + * Render texture + * @member {PIXI.RenderTexture} + * @readonly + */ + this.current = null; + + /** + * Source frame + * @member {PIXI.Rectangle} + * @readonly + */ + this.sourceFrame = new Rectangle(); + + /** + * Destination frame + * @member {PIXI.Rectangle} + * @readonly + */ + this.destinationFrame = new Rectangle(); + } + + if ( System ) { RenderTextureSystem.__proto__ = System; } + RenderTextureSystem.prototype = Object.create( System && System.prototype ); + RenderTextureSystem.prototype.constructor = RenderTextureSystem; + + /** + * Bind the current render texture + * @param {PIXI.RenderTexture} renderTexture + * @param {PIXI.Rectangle} sourceFrame + * @param {PIXI.Rectangle} destinationFrame + */ + RenderTextureSystem.prototype.bind = function bind (renderTexture, sourceFrame, destinationFrame) + { + if ( renderTexture === void 0 ) { renderTexture = null; } + + this.current = renderTexture; + + var renderer = this.renderer; + + var resolution; + + if (renderTexture) + { + var baseTexture = renderTexture.baseTexture; + + resolution = baseTexture.resolution; + + if (!destinationFrame) + { + tempRect.width = baseTexture.realWidth; + tempRect.height = baseTexture.realHeight; + + destinationFrame = tempRect; + } + + if (!sourceFrame) + { + sourceFrame = destinationFrame; + } + + this.renderer.framebuffer.bind(baseTexture.framebuffer, destinationFrame); + + this.renderer.projection.update(destinationFrame, sourceFrame, resolution, false); + this.renderer.stencil.setMaskStack(baseTexture.stencilMaskStack); + } + else + { + resolution = this.renderer.resolution; + + // TODO these validation checks happen deeper down.. + // thing they can be avoided.. + if (!destinationFrame) + { + tempRect.width = renderer.width; + tempRect.height = renderer.height; + + destinationFrame = tempRect; + } + + if (!sourceFrame) + { + sourceFrame = destinationFrame; + } + + renderer.framebuffer.bind(null, destinationFrame); + + // TODO store this.. + this.renderer.projection.update(destinationFrame, sourceFrame, resolution, true); + this.renderer.stencil.setMaskStack(this.defaultMaskStack); + } + + this.sourceFrame.copyFrom(sourceFrame); + + this.destinationFrame.x = destinationFrame.x / resolution; + this.destinationFrame.y = destinationFrame.y / resolution; + + this.destinationFrame.width = destinationFrame.width / resolution; + this.destinationFrame.height = destinationFrame.height / resolution; + }; + + /** + * Erases the render texture and fills the drawing area with a colour + * + * @param {number[]} [clearColor] - The color as rgba, default to use the renderer backgroundColor + * @return {PIXI.Renderer} Returns itself. + */ + RenderTextureSystem.prototype.clear = function clear (clearColor) + { + if (this.current) + { + clearColor = clearColor || this.current.baseTexture.clearColor; + } + else + { + clearColor = clearColor || this.clearColor; + } + + this.renderer.framebuffer.clear(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + }; + + RenderTextureSystem.prototype.resize = function resize ()// screenWidth, screenHeight) + { + // resize the root only! + this.bind(null); + }; + + /** + * Resets renderTexture state + */ + RenderTextureSystem.prototype.reset = function reset () + { + this.bind(null); + }; + + return RenderTextureSystem; + }(System)); + + /** + * Helper class to create a WebGL Program + * + * @class + * @memberof PIXI + */ + var GLProgram = function GLProgram(program, uniformData) + { + /** + * The shader program + * + * @member {WebGLProgram} + */ + this.program = program; + + /** + * holds the uniform data which contains uniform locations + * and current uniform values used for caching and preventing unneeded GPU commands + * @member {Object} + */ + this.uniformData = uniformData; + + /** + * uniformGroups holds the various upload functions for the shader. Each uniform group + * and program have a unique upload function generated. + * @member {Object} + */ + this.uniformGroups = {}; + }; + + /** + * Destroys this program + */ + GLProgram.prototype.destroy = function destroy () + { + this.uniformData = null; + this.uniformGroups = null; + this.program = null; + }; + + var UID$4 = 0; + + /** + * System plugin to the renderer to manage shaders. + * + * @class + * @memberof PIXI.systems + * @extends PIXI.System + */ + var ShaderSystem = /*@__PURE__*/(function (System) { + function ShaderSystem(renderer) + { + System.call(this, renderer); + + // Validation check that this environment support `new Function` + this.systemCheck(); + + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ + this.gl = null; + + this.shader = null; + this.program = null; + + /** + * Cache to holds the generated functions. Stored against UniformObjects unique signature + * @type {Object} + * @private + */ + this.cache = {}; + + this.id = UID$4++; + } + + if ( System ) { ShaderSystem.__proto__ = System; } + ShaderSystem.prototype = Object.create( System && System.prototype ); + ShaderSystem.prototype.constructor = ShaderSystem; + + /** + * Overrideable function by `@pixi/unsafe-eval` to silence + * throwing an error if platform doesn't support unsafe-evals. + * + * @private + */ + ShaderSystem.prototype.systemCheck = function systemCheck () + { + if (!unsafeEvalSupported()) + { + throw new Error('Current environment does not allow unsafe-eval, ' + + 'please use @pixi/unsafe-eval module to enable support.'); + } + }; + + ShaderSystem.prototype.contextChange = function contextChange (gl) + { + this.gl = gl; + }; + + /** + * Changes the current shader to the one given in parameter + * + * @param {PIXI.Shader} shader - the new shader + * @param {boolean} dontSync - false if the shader should automatically sync its uniforms. + * @returns {PIXI.GLProgram} the glProgram that belongs to the shader. + */ + ShaderSystem.prototype.bind = function bind (shader, dontSync) + { + shader.uniforms.globals = this.renderer.globalUniforms; + + var program = shader.program; + var glProgram = program.glPrograms[this.renderer.CONTEXT_UID] || this.generateShader(shader); + + this.shader = shader; + + // TODO - some current Pixi plugins bypass this.. so it not safe to use yet.. + if (this.program !== program) + { + this.program = program; + this.gl.useProgram(glProgram.program); + } + + if (!dontSync) + { + this.syncUniformGroup(shader.uniformGroup); + } + + return glProgram; + }; + + /** + * Uploads the uniforms values to the currently bound shader. + * + * @param {object} uniforms - the uniforms values that be applied to the current shader + */ + ShaderSystem.prototype.setUniforms = function setUniforms (uniforms) + { + var shader = this.shader.program; + var glProgram = shader.glPrograms[this.renderer.CONTEXT_UID]; + + shader.syncUniforms(glProgram.uniformData, uniforms, this.renderer); + }; + + ShaderSystem.prototype.syncUniformGroup = function syncUniformGroup (group) + { + var glProgram = this.getglProgram(); + + if (!group.static || group.dirtyId !== glProgram.uniformGroups[group.id]) + { + glProgram.uniformGroups[group.id] = group.dirtyId; + + this.syncUniforms(group, glProgram); + } + }; + + /** + * Overrideable by the @pixi/unsafe-eval package to use static + * syncUnforms instead. + * + * @private + */ + ShaderSystem.prototype.syncUniforms = function syncUniforms (group, glProgram) + { + var syncFunc = group.syncUniforms[this.shader.program.id] || this.createSyncGroups(group); + + syncFunc(glProgram.uniformData, group.uniforms, this.renderer); + }; + + ShaderSystem.prototype.createSyncGroups = function createSyncGroups (group) + { + var id = this.getSignature(group, this.shader.program.uniformData); + + if (!this.cache[id]) + { + this.cache[id] = generateUniformsSync(group, this.shader.program.uniformData); + } + + group.syncUniforms[this.shader.program.id] = this.cache[id]; + + return group.syncUniforms[this.shader.program.id]; + }; + + /** + * Takes a uniform group and data and generates a unique signature for them. + * + * @param {PIXI.UniformGroup} group the uniform group to get signature of + * @param {Object} uniformData uniform information generated by the shader + * @returns {String} Unique signature of the uniform group + * @private + */ + ShaderSystem.prototype.getSignature = function getSignature (group, uniformData) + { + var uniforms = group.uniforms; + + var strings = []; + + for (var i in uniforms) + { + strings.push(i); + + if (uniformData[i]) + { + strings.push(uniformData[i].type); + } + } + + return strings.join('-'); + }; + + /** + * Returns the underlying GLShade rof the currently bound shader. + * This can be handy for when you to have a little more control over the setting of your uniforms. + * + * @return {PIXI.GLProgram} the glProgram for the currently bound Shader for this context + */ + ShaderSystem.prototype.getglProgram = function getglProgram () + { + if (this.shader) + { + return this.shader.program.glPrograms[this.renderer.CONTEXT_UID]; + } + + return null; + }; + + /** + * Generates a glProgram version of the Shader provided. + * + * @private + * @param {PIXI.Shader} shader the shader that the glProgram will be based on. + * @return {PIXI.GLProgram} A shiny new glProgram! + */ + ShaderSystem.prototype.generateShader = function generateShader (shader) + { + var gl = this.gl; + + var program = shader.program; + + var attribMap = {}; + + for (var i in program.attributeData) + { + attribMap[i] = program.attributeData[i].location; + } + + var shaderProgram = compileProgram(gl, program.vertexSrc, program.fragmentSrc, attribMap); + var uniformData = {}; + + for (var i$1 in program.uniformData) + { + var data = program.uniformData[i$1]; + + uniformData[i$1] = { + location: gl.getUniformLocation(shaderProgram, i$1), + value: defaultValue(data.type, data.size), + }; + } + + var glProgram = new GLProgram(shaderProgram, uniformData); + + program.glPrograms[this.renderer.CONTEXT_UID] = glProgram; + + return glProgram; + }; + + /** + * Resets ShaderSystem state, does not affect WebGL state + */ + ShaderSystem.prototype.reset = function reset () + { + this.program = null; + this.shader = null; + }; + + /** + * Destroys this System and removes all its textures + */ + ShaderSystem.prototype.destroy = function destroy () + { + // TODO implement destroy method for ShaderSystem + this.destroyed = true; + }; + + return ShaderSystem; + }(System)); + + /** + * Maps gl blend combinations to WebGL. + * + * @memberof PIXI + * @function mapWebGLBlendModesToPixi + * @private + * @param {WebGLRenderingContext} gl - The rendering context. + * @param {number[][]} [array=[]] - The array to output into. + * @return {number[][]} Mapped modes. + */ + function mapWebGLBlendModesToPixi(gl, array) + { + if ( array === void 0 ) { array = []; } + + // TODO - premultiply alpha would be different. + // add a boolean for that! + array[BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.ADD] = [gl.ONE, gl.DST_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.SCREEN] = [gl.ONE, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.NONE] = [0, 0]; + + // not-premultiplied blend modes + array[BLEND_MODES.NORMAL_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.ADD_NPM] = [gl.SRC_ALPHA, gl.DST_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.SCREEN_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + + // composite operations + array[BLEND_MODES.SRC_IN] = [gl.DST_ALPHA, gl.ZERO]; + array[BLEND_MODES.SRC_OUT] = [gl.ONE_MINUS_DST_ALPHA, gl.ZERO]; + array[BLEND_MODES.SRC_ATOP] = [gl.DST_ALPHA, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.DST_OVER] = [gl.ONE_MINUS_DST_ALPHA, gl.ONE]; + array[BLEND_MODES.DST_IN] = [gl.ZERO, gl.SRC_ALPHA]; + array[BLEND_MODES.DST_OUT] = [gl.ZERO, gl.ONE_MINUS_SRC_ALPHA]; + array[BLEND_MODES.DST_ATOP] = [gl.ONE_MINUS_DST_ALPHA, gl.SRC_ALPHA]; + + // SUBTRACT from flash + array[BLEND_MODES.SUBTRACT] = [gl.ONE, gl.ONE, gl.ONE, gl.ONE, gl.FUNC_REVERSE_SUBTRACT, gl.FUNC_ADD]; + + return array; + } + + var BLEND$1 = 0; + var OFFSET$1 = 1; + var CULLING$1 = 2; + var DEPTH_TEST$1 = 3; + var WINDING$1 = 4; + + /** + * System plugin to the renderer to manage WebGL state machines. + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + var StateSystem = /*@__PURE__*/(function (System) { + function StateSystem(renderer) + { + System.call(this, renderer); + + /** + * GL context + * @member {WebGLRenderingContext} + * @readonly + */ + this.gl = null; + + /** + * State ID + * @member {number} + * @readonly + */ + this.stateId = 0; + + /** + * Polygon offset + * @member {number} + * @readonly + */ + this.polygonOffset = 0; + + /** + * Blend mode + * @member {number} + * @default PIXI.BLEND_MODES.NONE + * @readonly + */ + this.blendMode = BLEND_MODES.NONE; + + /** + * Whether current blend equation is different + * @member {boolean} + * @protected + */ + this._blendEq = false; + + /** + * Collection of calls + * @member {function[]} + * @readonly + */ + this.map = []; + + // map functions for when we set state.. + this.map[BLEND$1] = this.setBlend; + this.map[OFFSET$1] = this.setOffset; + this.map[CULLING$1] = this.setCullFace; + this.map[DEPTH_TEST$1] = this.setDepthTest; + this.map[WINDING$1] = this.setFrontFace; + + /** + * Collection of check calls + * @member {function[]} + * @readonly + */ + this.checks = []; + + /** + * Default WebGL State + * @member {PIXI.State} + * @readonly + */ + this.defaultState = new State(); + this.defaultState.blend = true; + this.defaultState.depth = true; + } + + if ( System ) { StateSystem.__proto__ = System; } + StateSystem.prototype = Object.create( System && System.prototype ); + StateSystem.prototype.constructor = StateSystem; + + StateSystem.prototype.contextChange = function contextChange (gl) + { + this.gl = gl; + + this.blendModes = mapWebGLBlendModesToPixi(gl); + + this.setState(this.defaultState); + + this.reset(); + }; + + /** + * Sets the current state + * + * @param {*} state - The state to set. + */ + StateSystem.prototype.setState = function setState (state) + { + state = state || this.defaultState; + + // TODO maybe to an object check? ( this.state === state )? + if (this.stateId !== state.data) + { + var diff = this.stateId ^ state.data; + var i = 0; + + // order from least to most common + while (diff) + { + if (diff & 1) + { + // state change! + this.map[i].call(this, !!(state.data & (1 << i))); + } + + diff = diff >> 1; + i++; + } + + this.stateId = state.data; + } + + // based on the above settings we check for specific modes.. + // for example if blend is active we check and set the blend modes + // or of polygon offset is active we check the poly depth. + for (var i$1 = 0; i$1 < this.checks.length; i$1++) + { + this.checks[i$1](this, state); + } + }; + + /** + * Sets the state, when previous state is unknown + * + * @param {*} state - The state to set + */ + StateSystem.prototype.forceState = function forceState (state) + { + state = state || this.defaultState; + for (var i = 0; i < this.map.length; i++) + { + this.map[i].call(this, !!(state.data & (1 << i))); + } + for (var i$1 = 0; i$1 < this.checks.length; i$1++) + { + this.checks[i$1](this, state); + } + + this.stateId = state.data; + }; + + /** + * Enables or disabled blending. + * + * @param {boolean} value - Turn on or off webgl blending. + */ + StateSystem.prototype.setBlend = function setBlend (value) + { + this.updateCheck(StateSystem.checkBlendMode, value); + + this.gl[value ? 'enable' : 'disable'](this.gl.BLEND); + }; + + /** + * Enables or disable polygon offset fill + * + * @param {boolean} value - Turn on or off webgl polygon offset testing. + */ + StateSystem.prototype.setOffset = function setOffset (value) + { + this.gl[value ? 'enable' : 'disable'](this.gl.POLYGON_OFFSET_FILL); + }; + + /** + * Sets whether to enable or disable depth test. + * + * @param {boolean} value - Turn on or off webgl depth testing. + */ + StateSystem.prototype.setDepthTest = function setDepthTest (value) + { + this.gl[value ? 'enable' : 'disable'](this.gl.DEPTH_TEST); + }; + + /** + * Sets whether to enable or disable cull face. + * + * @param {boolean} value - Turn on or off webgl cull face. + */ + StateSystem.prototype.setCullFace = function setCullFace (value) + { + this.gl[value ? 'enable' : 'disable'](this.gl.CULL_FACE); + }; + + /** + * Sets the gl front face. + * + * @param {boolean} value - true is clockwise and false is counter-clockwise + */ + StateSystem.prototype.setFrontFace = function setFrontFace (value) + { + this.gl.frontFace(this.gl[value ? 'CW' : 'CCW']); + }; + + /** + * Sets the blend mode. + * + * @param {number} value - The blend mode to set to. + */ + StateSystem.prototype.setBlendMode = function setBlendMode (value) + { + if (value === this.blendMode) + { + return; + } + + this.blendMode = value; + + var mode = this.blendModes[value]; + var gl = this.gl; + + if (mode.length === 2) + { + gl.blendFunc(mode[0], mode[1]); + } + else + { + gl.blendFuncSeparate(mode[0], mode[1], mode[2], mode[3]); + } + if (mode.length === 6) + { + this._blendEq = true; + gl.blendEquationSeparate(mode[4], mode[5]); + } + else if (this._blendEq) + { + this._blendEq = false; + gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD); + } + }; + + /** + * Sets the polygon offset. + * + * @param {number} value - the polygon offset + * @param {number} scale - the polygon offset scale + */ + StateSystem.prototype.setPolygonOffset = function setPolygonOffset (value, scale) + { + this.gl.polygonOffset(value, scale); + }; + + // used + /** + * Resets all the logic and disables the vaos + */ + StateSystem.prototype.reset = function reset () + { + this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, false); + + this.forceState(0); + + this._blendEq = true; + this.blendMode = -1; + this.setBlendMode(0); + }; + + /** + * checks to see which updates should be checked based on which settings have been activated. + * For example, if blend is enabled then we should check the blend modes each time the state is changed + * or if polygon fill is activated then we need to check if the polygon offset changes. + * The idea is that we only check what we have too. + * + * @param {Function} func the checking function to add or remove + * @param {boolean} value should the check function be added or removed. + */ + StateSystem.prototype.updateCheck = function updateCheck (func, value) + { + var index = this.checks.indexOf(func); + + if (value && index === -1) + { + this.checks.push(func); + } + else if (!value && index !== -1) + { + this.checks.splice(index, 1); + } + }; + + /** + * A private little wrapper function that we call to check the blend mode. + * + * @static + * @private + * @param {PIXI.StateSystem} System the System to perform the state check on + * @param {PIXI.State} state the state that the blendMode will pulled from + */ + StateSystem.checkBlendMode = function checkBlendMode (system, state) + { + system.setBlendMode(state.blendMode); + }; + + return StateSystem; + }(System)); + + /** + * System plugin to the renderer to manage texture garbage collection on the GPU, + * ensuring that it does not get clogged up with textures that are no longer being used. + * + * @class + * @memberof PIXI.systems + * @extends PIXI.System + */ + var TextureGCSystem = /*@__PURE__*/(function (System) { + function TextureGCSystem(renderer) + { + System.call(this, renderer); + + /** + * Count + * @member {number} + * @readonly + */ + this.count = 0; + + /** + * Check count + * @member {number} + * @readonly + */ + this.checkCount = 0; + + /** + * Maximum idle time, in seconds + * @member {number} + * @see PIXI.settings.GC_MAX_IDLE + */ + this.maxIdle = settings.GC_MAX_IDLE; + + /** + * Maximum number of itesm to check + * @member {number} + * @see PIXI.settings.GC_MAX_CHECK_COUNT + */ + this.checkCountMax = settings.GC_MAX_CHECK_COUNT; + + /** + * Current garabage collection mode + * @member {PIXI.GC_MODES} + * @see PIXI.settings.GC_MODE + */ + this.mode = settings.GC_MODE; + } + + if ( System ) { TextureGCSystem.__proto__ = System; } + TextureGCSystem.prototype = Object.create( System && System.prototype ); + TextureGCSystem.prototype.constructor = TextureGCSystem; + + /** + * Checks to see when the last time a texture was used + * if the texture has not been used for a specified amount of time it will be removed from the GPU + */ + TextureGCSystem.prototype.postrender = function postrender () + { + this.count++; + + if (this.mode === GC_MODES.MANUAL) + { + return; + } + + this.checkCount++; + + if (this.checkCount > this.checkCountMax) + { + this.checkCount = 0; + + this.run(); + } + }; + + /** + * Checks to see when the last time a texture was used + * if the texture has not been used for a specified amount of time it will be removed from the GPU + */ + TextureGCSystem.prototype.run = function run () + { + var tm = this.renderer.texture; + var managedTextures = tm.managedTextures; + var wasRemoved = false; + + for (var i = 0; i < managedTextures.length; i++) + { + var texture = managedTextures[i]; + + // only supports non generated textures at the moment! + if (!texture.framebuffer && this.count - texture.touched > this.maxIdle) + { + tm.destroyTexture(texture, true); + managedTextures[i] = null; + wasRemoved = true; + } + } + + if (wasRemoved) + { + var j = 0; + + for (var i$1 = 0; i$1 < managedTextures.length; i$1++) + { + if (managedTextures[i$1] !== null) + { + managedTextures[j++] = managedTextures[i$1]; + } + } + + managedTextures.length = j; + } + }; + + /** + * Removes all the textures within the specified displayObject and its children from the GPU + * + * @param {PIXI.DisplayObject} displayObject - the displayObject to remove the textures from. + */ + TextureGCSystem.prototype.unload = function unload (displayObject) + { + var tm = this.renderer.textureSystem; + + // only destroy non generated textures + if (displayObject._texture && displayObject._texture._glRenderTargets) + { + tm.destroyTexture(displayObject._texture); + } + + for (var i = displayObject.children.length - 1; i >= 0; i--) + { + this.unload(displayObject.children[i]); + } + }; + + return TextureGCSystem; + }(System)); + + /** + * Internal texture for WebGL context + * @class + * @memberof PIXI + */ + var GLTexture = function GLTexture(texture) + { + /** + * The WebGL texture + * @member {WebGLTexture} + */ + this.texture = texture; + + this.width = -1; + this.height = -1; + + /** + * Texture contents dirty flag + * @member {number} + */ + this.dirtyId = -1; + + /** + * Texture style dirty flag + * @member {number} + */ + this.dirtyStyleId = -1; + + /** + * Whether mip levels has to be generated + * @member {boolean} + */ + this.mipmap = false; + + /** + * WrapMode copied from baseTexture + * @member {number} + */ + this.wrapMode = 33071; + }; + + /** + * System plugin to the renderer to manage textures. + * + * @class + * @extends PIXI.System + * @memberof PIXI.systems + */ + var TextureSystem = /*@__PURE__*/(function (System) { + function TextureSystem(renderer) + { + System.call(this, renderer); + + // TODO set to max textures... + /** + * Bound textures + * @member {PIXI.BaseTexture[]} + * @readonly + */ + this.boundTextures = []; + /** + * Current location + * @member {number} + * @readonly + */ + this.currentLocation = -1; + + /** + * List of managed textures + * @member {PIXI.BaseTexture[]} + * @readonly + */ + this.managedTextures = []; + + /** + * Did someone temper with textures state? We'll overwrite them when we need to unbind something. + * @member {boolean} + * @private + */ + this._unknownBoundTextures = false; + + /** + * BaseTexture value that shows that we don't know what is bound + * @member {PIXI.BaseTexture} + * @readonly + */ + this.unknownTexture = new BaseTexture(); + } + + if ( System ) { TextureSystem.__proto__ = System; } + TextureSystem.prototype = Object.create( System && System.prototype ); + TextureSystem.prototype.constructor = TextureSystem; + + /** + * Sets up the renderer context and necessary buffers. + */ + TextureSystem.prototype.contextChange = function contextChange () + { + var gl = this.gl = this.renderer.gl; + + this.CONTEXT_UID = this.renderer.CONTEXT_UID; + + this.webGLVersion = this.renderer.context.webGLVersion; + + var maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + + this.boundTextures.length = maxTextures; + + for (var i = 0; i < maxTextures; i++) + { + this.boundTextures[i] = null; + } + + // TODO move this.. to a nice make empty textures class.. + this.emptyTextures = {}; + + var emptyTexture2D = new GLTexture(gl.createTexture()); + + gl.bindTexture(gl.TEXTURE_2D, emptyTexture2D.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(4)); + + this.emptyTextures[gl.TEXTURE_2D] = emptyTexture2D; + this.emptyTextures[gl.TEXTURE_CUBE_MAP] = new GLTexture(gl.createTexture()); + + gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.emptyTextures[gl.TEXTURE_CUBE_MAP].texture); + + for (var i$1 = 0; i$1 < 6; i$1++) + { + gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i$1, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + } + + gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + + for (var i$2 = 0; i$2 < this.boundTextures.length; i$2++) + { + this.bind(null, i$2); + } + }; + + /** + * Bind a texture to a specific location + * + * If you want to unbind something, please use `unbind(texture)` instead of `bind(null, textureLocation)` + * + * @param {PIXI.Texture|PIXI.BaseTexture} texture - Texture to bind + * @param {number} [location=0] - Location to bind at + */ + TextureSystem.prototype.bind = function bind (texture, location) + { + if ( location === void 0 ) { location = 0; } + + var ref = this; + var gl = ref.gl; + + if (texture) + { + texture = texture.baseTexture || texture; + + if (texture.valid) + { + texture.touched = this.renderer.textureGC.count; + + var glTexture = texture._glTextures[this.CONTEXT_UID] || this.initTexture(texture); + + if (this.currentLocation !== location) + { + this.currentLocation = location; + gl.activeTexture(gl.TEXTURE0 + location); + } + + if (this.boundTextures[location] !== texture) + { + gl.bindTexture(texture.target, glTexture.texture); + } + + if (glTexture.dirtyId !== texture.dirtyId) + { + this.updateTexture(texture); + } + + this.boundTextures[location] = texture; + } + } + else + { + if (this.currentLocation !== location) + { + this.currentLocation = location; + gl.activeTexture(gl.TEXTURE0 + location); + } + + gl.bindTexture(gl.TEXTURE_2D, this.emptyTextures[gl.TEXTURE_2D].texture); + this.boundTextures[location] = null; + } + }; + + /** + * Resets texture location and bound textures + * + * Actual `bind(null, i)` calls will be performed at next `unbind()` call + */ + TextureSystem.prototype.reset = function reset () + { + this._unknownBoundTextures = true; + this.currentLocation = -1; + + for (var i = 0; i < this.boundTextures.length; i++) + { + this.boundTextures[i] = this.unknownTexture; + } + }; + + /** + * Unbind a texture + * @param {PIXI.Texture|PIXI.BaseTexture} texture - Texture to bind + */ + TextureSystem.prototype.unbind = function unbind (texture) + { + var ref = this; + var gl = ref.gl; + var boundTextures = ref.boundTextures; + + if (this._unknownBoundTextures) + { + this._unknownBoundTextures = false; + // someone changed webGL state, + // we have to be sure that our texture does not appear in multi-texture renderer samplers + for (var i = 0; i < boundTextures.length; i++) + { + if (boundTextures[i] === this.unknownTexture) + { + this.bind(null, i); + } + } + } + + for (var i$1 = 0; i$1 < boundTextures.length; i$1++) + { + if (boundTextures[i$1] === texture) + { + if (this.currentLocation !== i$1) + { + gl.activeTexture(gl.TEXTURE0 + i$1); + this.currentLocation = i$1; + } + + gl.bindTexture(gl.TEXTURE_2D, this.emptyTextures[texture.target].texture); + boundTextures[i$1] = null; + } + } + }; + + /** + * Initialize a texture + * + * @private + * @param {PIXI.BaseTexture} texture - Texture to initialize + */ + TextureSystem.prototype.initTexture = function initTexture (texture) + { + var glTexture = new GLTexture(this.gl.createTexture()); + + // guarantee an update.. + glTexture.dirtyId = -1; + + texture._glTextures[this.CONTEXT_UID] = glTexture; + + this.managedTextures.push(texture); + texture.on('dispose', this.destroyTexture, this); + + return glTexture; + }; + + /** + * Update a texture + * + * @private + * @param {PIXI.BaseTexture} texture - Texture to initialize + */ + TextureSystem.prototype.updateTexture = function updateTexture (texture) + { + var glTexture = texture._glTextures[this.CONTEXT_UID]; + var renderer = this.renderer; + + if (texture.resource && texture.resource.upload(renderer, texture, glTexture)) + { ; } + else + { + // default, renderTexture-like logic + var width = texture.realWidth; + var height = texture.realHeight; + var gl = renderer.gl; + + if (glTexture.width !== width + || glTexture.height !== height + || glTexture.dirtyId < 0) + { + glTexture.width = width; + glTexture.height = height; + + gl.texImage2D(texture.target, 0, + texture.format, + width, + height, + 0, + texture.format, + texture.type, + null); + } + } + + // lets only update what changes.. + if (texture.dirtyStyleId !== glTexture.dirtyStyleId) + { + this.updateTextureStyle(texture); + } + glTexture.dirtyId = texture.dirtyId; + }; + + /** + * Deletes the texture from WebGL + * + * @private + * @param {PIXI.BaseTexture|PIXI.Texture} texture - the texture to destroy + * @param {boolean} [skipRemove=false] - Whether to skip removing the texture from the TextureManager. + */ + TextureSystem.prototype.destroyTexture = function destroyTexture (texture, skipRemove) + { + var ref = this; + var gl = ref.gl; + + texture = texture.baseTexture || texture; + + if (texture._glTextures[this.renderer.CONTEXT_UID]) + { + this.unbind(texture); + + gl.deleteTexture(texture._glTextures[this.renderer.CONTEXT_UID].texture); + texture.off('dispose', this.destroyTexture, this); + + delete texture._glTextures[this.renderer.CONTEXT_UID]; + + if (!skipRemove) + { + var i = this.managedTextures.indexOf(texture); + + if (i !== -1) + { + removeItems(this.managedTextures, i, 1); + } + } + } + }; + + /** + * Update texture style such as mipmap flag + * + * @private + * @param {PIXI.BaseTexture} texture - Texture to update + */ + TextureSystem.prototype.updateTextureStyle = function updateTextureStyle (texture) + { + var glTexture = texture._glTextures[this.CONTEXT_UID]; + + if (!glTexture) + { + return; + } + + if ((texture.mipmap === MIPMAP_MODES.POW2 || this.webGLVersion !== 2) && !texture.isPowerOfTwo) + { + glTexture.mipmap = 0; + glTexture.wrapMode = WRAP_MODES.CLAMP; + } + else + { + glTexture.mipmap = texture.mipmap >= 1; + glTexture.wrapMode = texture.wrapMode; + } + + if (texture.resource && texture.resource.style(this.renderer, texture, glTexture)) + { ; } + else + { + this.setStyle(texture, glTexture); + } + + glTexture.dirtyStyleId = texture.dirtyStyleId; + }; + + /** + * Set style for texture + * + * @private + * @param {PIXI.BaseTexture} texture - Texture to update + * @param {glTexture} glTexture + */ + TextureSystem.prototype.setStyle = function setStyle (texture, glTexture) + { + var gl = this.gl; + + if (glTexture.mipmap) + { + gl.generateMipmap(texture.target); + } + + gl.texParameteri(texture.target, gl.TEXTURE_WRAP_S, glTexture.wrapMode); + gl.texParameteri(texture.target, gl.TEXTURE_WRAP_T, glTexture.wrapMode); + + if (glTexture.mipmap) + { + /* eslint-disable max-len */ + gl.texParameteri(texture.target, gl.TEXTURE_MIN_FILTER, texture.scaleMode ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + /* eslint-disable max-len */ + } + else + { + gl.texParameteri(texture.target, gl.TEXTURE_MIN_FILTER, texture.scaleMode ? gl.LINEAR : gl.NEAREST); + } + + gl.texParameteri(texture.target, gl.TEXTURE_MAG_FILTER, texture.scaleMode ? gl.LINEAR : gl.NEAREST); + }; + + return TextureSystem; + }(System)); + + /** + * Systems are individual components to the Renderer pipeline. + * @namespace PIXI.systems + */ + + var systems = ({ + FilterSystem: FilterSystem, + BatchSystem: BatchSystem, + ContextSystem: ContextSystem, + FramebufferSystem: FramebufferSystem, + GeometrySystem: GeometrySystem, + MaskSystem: MaskSystem, + StencilSystem: StencilSystem, + ProjectionSystem: ProjectionSystem, + RenderTextureSystem: RenderTextureSystem, + ShaderSystem: ShaderSystem, + StateSystem: StateSystem, + TextureGCSystem: TextureGCSystem, + TextureSystem: TextureSystem + }); + + var tempMatrix = new Matrix(); + + /** + * The AbstractRenderer is the base for a PixiJS Renderer. It is extended by the {@link PIXI.CanvasRenderer} + * and {@link PIXI.Renderer} which can be used for rendering a PixiJS scene. + * + * @abstract + * @class + * @extends PIXI.utils.EventEmitter + * @memberof PIXI + */ + var AbstractRenderer = /*@__PURE__*/(function (EventEmitter) { + function AbstractRenderer(system, options) + { + EventEmitter.call(this); + + // Add the default render options + options = Object.assign({}, settings.RENDER_OPTIONS, options); + + // Deprecation notice for renderer roundPixels option + if (options.roundPixels) + { + settings.ROUND_PIXELS = options.roundPixels; + deprecation('5.0.0', 'Renderer roundPixels option is deprecated, please use PIXI.settings.ROUND_PIXELS', 2); + } + + /** + * The supplied constructor options. + * + * @member {Object} + * @readOnly + */ + this.options = options; + + /** + * The type of the renderer. + * + * @member {number} + * @default PIXI.RENDERER_TYPE.UNKNOWN + * @see PIXI.RENDERER_TYPE + */ + this.type = RENDERER_TYPE.UNKNOWN; + + /** + * Measurements of the screen. (0, 0, screenWidth, screenHeight). + * + * Its safe to use as filterArea or hitArea for the whole stage. + * + * @member {PIXI.Rectangle} + */ + this.screen = new Rectangle(0, 0, options.width, options.height); + + /** + * The canvas element that everything is drawn to. + * + * @member {HTMLCanvasElement} + */ + this.view = options.view || document.createElement('canvas'); + + /** + * The resolution / device pixel ratio of the renderer. + * + * @member {number} + * @default 1 + */ + this.resolution = options.resolution || settings.RESOLUTION; + + /** + * Whether the render view is transparent. + * + * @member {boolean} + */ + this.transparent = options.transparent; + + /** + * Whether CSS dimensions of canvas view should be resized to screen dimensions automatically. + * + * @member {boolean} + */ + this.autoDensity = options.autoDensity || options.autoResize || false; + // autoResize is deprecated, provides fallback support + + /** + * The value of the preserveDrawingBuffer flag affects whether or not the contents of + * the stencil buffer is retained after rendering. + * + * @member {boolean} + */ + this.preserveDrawingBuffer = options.preserveDrawingBuffer; + + /** + * This sets if the CanvasRenderer will clear the canvas or not before the new render pass. + * If the scene is NOT transparent PixiJS will use a canvas sized fillRect operation every + * frame to set the canvas background color. If the scene is transparent PixiJS will use clearRect + * to clear the canvas every frame. Disable this by setting this to false. For example, if + * your game has a canvas filling background image you often don't need this set. + * + * @member {boolean} + * @default + */ + this.clearBeforeRender = options.clearBeforeRender; + + /** + * The background color as a number. + * + * @member {number} + * @protected + */ + this._backgroundColor = 0x000000; + + /** + * The background color as an [R, G, B] array. + * + * @member {number[]} + * @protected + */ + this._backgroundColorRgba = [0, 0, 0, 0]; + + /** + * The background color as a string. + * + * @member {string} + * @protected + */ + this._backgroundColorString = '#000000'; + + this.backgroundColor = options.backgroundColor || this._backgroundColor; // run bg color setter + + /** + * This temporary display object used as the parent of the currently being rendered item. + * + * @member {PIXI.DisplayObject} + * @protected + */ + this._tempDisplayObjectParent = new Container(); + + /** + * The last root object that the renderer tried to render. + * + * @member {PIXI.DisplayObject} + * @protected + */ + this._lastObjectRendered = this._tempDisplayObjectParent; + + /** + * Collection of plugins. + * @readonly + * @member {object} + */ + this.plugins = {}; + } + + if ( EventEmitter ) { AbstractRenderer.__proto__ = EventEmitter; } + AbstractRenderer.prototype = Object.create( EventEmitter && EventEmitter.prototype ); + AbstractRenderer.prototype.constructor = AbstractRenderer; + + var prototypeAccessors = { width: { configurable: true },height: { configurable: true },backgroundColor: { configurable: true } }; + + /** + * Initialize the plugins. + * + * @protected + * @param {object} staticMap - The dictionary of statically saved plugins. + */ + AbstractRenderer.prototype.initPlugins = function initPlugins (staticMap) + { + for (var o in staticMap) + { + this.plugins[o] = new (staticMap[o])(this); + } + }; + + /** + * Same as view.width, actual number of pixels in the canvas by horizontal. + * + * @member {number} + * @readonly + * @default 800 + */ + prototypeAccessors.width.get = function () + { + return this.view.width; + }; + + /** + * Same as view.height, actual number of pixels in the canvas by vertical. + * + * @member {number} + * @readonly + * @default 600 + */ + prototypeAccessors.height.get = function () + { + return this.view.height; + }; + + /** + * Resizes the screen and canvas to the specified width and height. + * Canvas dimensions are multiplied by resolution. + * + * @param {number} screenWidth - The new width of the screen. + * @param {number} screenHeight - The new height of the screen. + */ + AbstractRenderer.prototype.resize = function resize (screenWidth, screenHeight) + { + this.screen.width = screenWidth; + this.screen.height = screenHeight; + + this.view.width = screenWidth * this.resolution; + this.view.height = screenHeight * this.resolution; + + if (this.autoDensity) + { + this.view.style.width = screenWidth + "px"; + this.view.style.height = screenHeight + "px"; + } + }; + + /** + * Useful function that returns a texture of the display object that can then be used to create sprites + * This can be quite useful if your displayObject is complicated and needs to be reused multiple times. + * + * @param {PIXI.DisplayObject} displayObject - The displayObject the object will be generated from. + * @param {number} scaleMode - Should be one of the scaleMode consts. + * @param {number} resolution - The resolution / device pixel ratio of the texture being generated. + * @param {PIXI.Rectangle} [region] - The region of the displayObject, that shall be rendered, + * if no region is specified, defaults to the local bounds of the displayObject. + * @return {PIXI.Texture} A texture of the graphics object. + */ + AbstractRenderer.prototype.generateTexture = function generateTexture (displayObject, scaleMode, resolution, region) + { + region = region || displayObject.getLocalBounds(); + + // minimum texture size is 1x1, 0x0 will throw an error + if (region.width === 0) { region.width = 1; } + if (region.height === 0) { region.height = 1; } + + var renderTexture = RenderTexture.create(region.width | 0, region.height | 0, scaleMode, resolution); + + tempMatrix.tx = -region.x; + tempMatrix.ty = -region.y; + + this.render(displayObject, renderTexture, false, tempMatrix, !!displayObject.parent); + + return renderTexture; + }; + + /** + * Removes everything from the renderer and optionally removes the Canvas DOM element. + * + * @param {boolean} [removeView=false] - Removes the Canvas element from the DOM. + */ + AbstractRenderer.prototype.destroy = function destroy (removeView) + { + for (var o in this.plugins) + { + this.plugins[o].destroy(); + this.plugins[o] = null; + } + + if (removeView && this.view.parentNode) + { + this.view.parentNode.removeChild(this.view); + } + + this.plugins = null; + + this.type = RENDERER_TYPE.UNKNOWN; + + this.view = null; + + this.screen = null; + + this.resolution = 0; + + this.transparent = false; + + this.autoDensity = false; + + this.blendModes = null; + + this.options = null; + + this.preserveDrawingBuffer = false; + this.clearBeforeRender = false; + + this._backgroundColor = 0; + this._backgroundColorRgba = null; + this._backgroundColorString = null; + + this._tempDisplayObjectParent = null; + this._lastObjectRendered = null; + }; + + /** + * The background color to fill if not transparent + * + * @member {number} + */ + prototypeAccessors.backgroundColor.get = function () + { + return this._backgroundColor; + }; + + prototypeAccessors.backgroundColor.set = function (value) // eslint-disable-line require-jsdoc + { + this._backgroundColor = value; + this._backgroundColorString = hex2string(value); + hex2rgb(value, this._backgroundColorRgba); + }; + + Object.defineProperties( AbstractRenderer.prototype, prototypeAccessors ); + + return AbstractRenderer; + }(eventemitter3)); + + /** + * The Renderer draws the scene and all its content onto a WebGL enabled canvas. + * + * This renderer should be used for browsers that support WebGL. + * + * This renderer works by automatically managing WebGLBatchesm, so no need for Sprite Batches or Sprite Clouds. + * Don't forget to add the view to your DOM or you will not see anything! + * + * @class + * @memberof PIXI + * @extends PIXI.AbstractRenderer + */ + var Renderer = /*@__PURE__*/(function (AbstractRenderer) { + function Renderer(options) + { + if ( options === void 0 ) { options = {}; } + + AbstractRenderer.call(this, 'WebGL', options); + + // the options will have been modified here in the super constructor with pixi's default settings.. + options = this.options; + + /** + * The type of this renderer as a standardized const + * + * @member {number} + * @see PIXI.RENDERER_TYPE + */ + this.type = RENDERER_TYPE.WEBGL; + + // this will be set by the contextSystem (this.context) + this.gl = null; + this.CONTEXT_UID = 0; + + // TODO legacy! + + /** + * Internal signal instances of **runner**, these + * are assigned to each system created. + * @see PIXI.Runner + * @name PIXI.Renderer#runners + * @private + * @type {object} + * @readonly + * @property {PIXI.Runner} destroy - Destroy runner + * @property {PIXI.Runner} contextChange - Context change runner + * @property {PIXI.Runner} reset - Reset runner + * @property {PIXI.Runner} update - Update runner + * @property {PIXI.Runner} postrender - Post-render runner + * @property {PIXI.Runner} prerender - Pre-render runner + * @property {PIXI.Runner} resize - Resize runner + */ + this.runners = { + destroy: new Runner('destroy'), + contextChange: new Runner('contextChange', 1), + reset: new Runner('reset'), + update: new Runner('update'), + postrender: new Runner('postrender'), + prerender: new Runner('prerender'), + resize: new Runner('resize', 2), + }; + + /** + * Global uniforms + * @member {PIXI.UniformGroup} + */ + this.globalUniforms = new UniformGroup({ + projectionMatrix: new Matrix(), + }, true); + + /** + * Mask system instance + * @member {PIXI.systems.MaskSystem} mask + * @memberof PIXI.Renderer# + * @readonly + */ + this.addSystem(MaskSystem, 'mask') + /** + * Context system instance + * @member {PIXI.systems.ContextSystem} context + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(ContextSystem, 'context') + /** + * State system instance + * @member {PIXI.systems.StateSystem} state + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(StateSystem, 'state') + /** + * Shader system instance + * @member {PIXI.systems.ShaderSystem} shader + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(ShaderSystem, 'shader') + /** + * Texture system instance + * @member {PIXI.systems.TextureSystem} texture + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(TextureSystem, 'texture') + /** + * Geometry system instance + * @member {PIXI.systems.GeometrySystem} geometry + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(GeometrySystem, 'geometry') + /** + * Framebuffer system instance + * @member {PIXI.systems.FramebufferSystem} framebuffer + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(FramebufferSystem, 'framebuffer') + /** + * Stencil system instance + * @member {PIXI.systems.StencilSystem} stencil + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(StencilSystem, 'stencil') + /** + * Projection system instance + * @member {PIXI.systems.ProjectionSystem} projection + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(ProjectionSystem, 'projection') + /** + * Texture garbage collector system instance + * @member {PIXI.systems.TextureGCSystem} textureGC + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(TextureGCSystem, 'textureGC') + /** + * Filter system instance + * @member {PIXI.systems.FilterSystem} filter + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(FilterSystem, 'filter') + /** + * RenderTexture system instance + * @member {PIXI.systems.RenderTextureSystem} renderTexture + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(RenderTextureSystem, 'renderTexture') + + /** + * Batch system instance + * @member {PIXI.systems.BatchSystem} batch + * @memberof PIXI.Renderer# + * @readonly + */ + .addSystem(BatchSystem, 'batch'); + + this.initPlugins(Renderer.__plugins); + + /** + * The options passed in to create a new WebGL context. + */ + if (options.context) + { + this.context.initFromContext(options.context); + } + else + { + this.context.initFromOptions({ + alpha: this.transparent, + antialias: options.antialias, + premultipliedAlpha: this.transparent && this.transparent !== 'notMultiplied', + stencil: true, + preserveDrawingBuffer: options.preserveDrawingBuffer, + powerPreference: this.options.powerPreference, + }); + } + + /** + * Flag if we are rendering to the screen vs renderTexture + * @member {boolean} + * @readonly + * @default true + */ + this.renderingToScreen = true; + + sayHello(this.context.webGLVersion === 2 ? 'WebGL 2' : 'WebGL 1'); + + this.resize(this.options.width, this.options.height); + } + + if ( AbstractRenderer ) { Renderer.__proto__ = AbstractRenderer; } + Renderer.prototype = Object.create( AbstractRenderer && AbstractRenderer.prototype ); + Renderer.prototype.constructor = Renderer; + + /** + * Add a new system to the renderer. + * @param {Function} ClassRef - Class reference + * @param {string} [name] - Property name for system, if not specified + * will use a static `name` property on the class itself. This + * name will be assigned as s property on the Renderer so make + * sure it doesn't collide with properties on Renderer. + * @return {PIXI.Renderer} Return instance of renderer + */ + Renderer.create = function create (options) + { + if (isWebGLSupported()) + { + return new Renderer(options); + } + + throw new Error('WebGL unsupported in this browser, use "pixi.js-legacy" for fallback canvas2d support.'); + }; + + Renderer.prototype.addSystem = function addSystem (ClassRef, name) + { + if (!name) + { + name = ClassRef.name; + } + + var system = new ClassRef(this); + + if (this[name]) + { + throw new Error(("Whoops! The name \"" + name + "\" is already in use")); + } + + this[name] = system; + + for (var i in this.runners) + { + this.runners[i].add(system); + } + + /** + * Fired after rendering finishes. + * + * @event PIXI.Renderer#postrender + */ + + /** + * Fired before rendering starts. + * + * @event PIXI.Renderer#prerender + */ + + /** + * Fired when the WebGL context is set. + * + * @event PIXI.Renderer#context + * @param {WebGLRenderingContext} gl - WebGL context. + */ + + return this; + }; + + /** + * Renders the object to its WebGL view + * + * @param {PIXI.DisplayObject} displayObject - The object to be rendered. + * @param {PIXI.RenderTexture} [renderTexture] - The render texture to render to. + * @param {boolean} [clear=true] - Should the canvas be cleared before the new render. + * @param {PIXI.Matrix} [transform] - A transform to apply to the render texture before rendering. + * @param {boolean} [skipUpdateTransform=false] - Should we skip the update transform pass? + */ + Renderer.prototype.render = function render (displayObject, renderTexture, clear, transform, skipUpdateTransform) + { + // can be handy to know! + this.renderingToScreen = !renderTexture; + + this.runners.prerender.run(); + this.emit('prerender'); + + // apply a transform at a GPU level + this.projection.transform = transform; + + // no point rendering if our context has been blown up! + if (this.context.isLost) + { + return; + } + + if (!renderTexture) + { + this._lastObjectRendered = displayObject; + } + + if (!skipUpdateTransform) + { + // update the scene graph + var cacheParent = displayObject.parent; + + displayObject.parent = this._tempDisplayObjectParent; + displayObject.updateTransform(); + displayObject.parent = cacheParent; + // displayObject.hitArea = //TODO add a temp hit area + } + + this.renderTexture.bind(renderTexture); + this.batch.currentRenderer.start(); + + if (clear !== undefined ? clear : this.clearBeforeRender) + { + this.renderTexture.clear(); + } + + displayObject.render(this); + + // apply transform.. + this.batch.currentRenderer.flush(); + + if (renderTexture) + { + renderTexture.baseTexture.update(); + } + + this.runners.postrender.run(); + + // reset transform after render + this.projection.transform = null; + + this.emit('postrender'); + }; + + /** + * Resizes the WebGL view to the specified width and height. + * + * @param {number} screenWidth - The new width of the screen. + * @param {number} screenHeight - The new height of the screen. + */ + Renderer.prototype.resize = function resize (screenWidth, screenHeight) + { + AbstractRenderer.prototype.resize.call(this, screenWidth, screenHeight); + + this.runners.resize.run(screenWidth, screenHeight); + }; + + /** + * Resets the WebGL state so you can render things however you fancy! + * + * @return {PIXI.Renderer} Returns itself. + */ + Renderer.prototype.reset = function reset () + { + this.runners.reset.run(); + + return this; + }; + + /** + * Clear the frame buffer + */ + Renderer.prototype.clear = function clear () + { + this.framebuffer.bind(); + this.framebuffer.clear(); + }; + + /** + * Removes everything from the renderer (event listeners, spritebatch, etc...) + * + * @param {boolean} [removeView=false] - Removes the Canvas element from the DOM. + * See: https://github.com/pixijs/pixi.js/issues/2233 + */ + Renderer.prototype.destroy = function destroy (removeView) + { + this.runners.destroy.run(); + + // call base destroy + AbstractRenderer.prototype.destroy.call(this, removeView); + + // TODO nullify all the managers.. + this.gl = null; + }; + + /** + * Collection of installed plugins. These are included by default in PIXI, but can be excluded + * by creating a custom build. Consult the README for more information about creating custom + * builds and excluding plugins. + * @name PIXI.Renderer#plugins + * @type {object} + * @readonly + * @property {PIXI.accessibility.AccessibilityManager} accessibility Support tabbing interactive elements. + * @property {PIXI.extract.Extract} extract Extract image data from renderer. + * @property {PIXI.interaction.InteractionManager} interaction Handles mouse, touch and pointer events. + * @property {PIXI.prepare.Prepare} prepare Pre-render display objects. + */ + + /** + * Adds a plugin to the renderer. + * + * @method + * @param {string} pluginName - The name of the plugin. + * @param {Function} ctor - The constructor function or class for the plugin. + */ + Renderer.registerPlugin = function registerPlugin (pluginName, ctor) + { + Renderer.__plugins = Renderer.__plugins || {}; + Renderer.__plugins[pluginName] = ctor; + }; + + return Renderer; + }(AbstractRenderer)); + + /** + * This helper function will automatically detect which renderer you should be using. + * WebGL is the preferred renderer as it is a lot faster. If WebGL is not supported by + * the browser then this function will return a canvas renderer + * + * @memberof PIXI + * @function autoDetectRenderer + * @param {object} [options] - The optional renderer parameters + * @param {number} [options.width=800] - the width of the renderers view + * @param {number} [options.height=600] - the height of the renderers view + * @param {HTMLCanvasElement} [options.view] - the canvas to use as a view, optional + * @param {boolean} [options.transparent=false] - If the render view is transparent, default false + * @param {boolean} [options.autoDensity=false] - Resizes renderer view in CSS pixels to allow for + * resolutions other than 1 + * @param {boolean} [options.antialias=false] - sets antialias + * @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, enable this if you + * need to call toDataUrl on the webgl context + * @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area + * (shown if not transparent). + * @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or + * not before the new render pass. + * @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2 + * @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present, this + * option only is available when using **pixi.js-legacy** or **@pixi/canvas-renderer** modules, otherwise + * it is ignored. + * @param {boolean} [options.forceFXAA=false] - forces FXAA antialiasing to be used over native. + * FXAA is faster, but may not always look as great **webgl only** + * @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance" + * for devices with dual graphics card **webgl only** + * @return {PIXI.Renderer|PIXI.CanvasRenderer} Returns WebGL renderer if available, otherwise CanvasRenderer + */ + function autoDetectRenderer(options) + { + return Renderer.create(options); + } + + var _default = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}"; + + var defaultFilter = "attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n"; + + /** + * A Texture that depends on six other resources. + * + * @class + * @extends PIXI.BaseTexture + * @memberof PIXI + */ + var CubeTexture = /*@__PURE__*/(function (BaseTexture) { + function CubeTexture () { + BaseTexture.apply(this, arguments); + } + + if ( BaseTexture ) { CubeTexture.__proto__ = BaseTexture; } + CubeTexture.prototype = Object.create( BaseTexture && BaseTexture.prototype ); + CubeTexture.prototype.constructor = CubeTexture; + + CubeTexture.from = function from (resources, options) + { + return new CubeTexture(new CubeResource(resources, options)); + }; + + return CubeTexture; + }(BaseTexture)); + + /** + * Geometry used to batch standard PIXI content (e.g. Mesh, Sprite, Graphics objects). + * + * @class + * @memberof PIXI + */ + var BatchGeometry = /*@__PURE__*/(function (Geometry) { + function BatchGeometry(_static) + { + if ( _static === void 0 ) { _static = false; } + + Geometry.call(this); + + /** + * Buffer used for position, color, texture IDs + * + * @member {PIXI.Buffer} + * @protected + */ + this._buffer = new Buffer(null, _static, false); + + /** + * Index buffer data + * + * @member {PIXI.Buffer} + * @protected + */ + this._indexBuffer = new Buffer(null, _static, true); + + this.addAttribute('aVertexPosition', this._buffer, 2, false, TYPES.FLOAT) + .addAttribute('aTextureCoord', this._buffer, 2, false, TYPES.FLOAT) + .addAttribute('aColor', this._buffer, 4, true, TYPES.UNSIGNED_BYTE) + .addAttribute('aTextureId', this._buffer, 1, true, TYPES.FLOAT) + .addIndex(this._indexBuffer); + } + + if ( Geometry ) { BatchGeometry.__proto__ = Geometry; } + BatchGeometry.prototype = Object.create( Geometry && Geometry.prototype ); + BatchGeometry.prototype.constructor = BatchGeometry; + + return BatchGeometry; + }(Geometry)); + + /** + * Used by the batcher to draw batches. + * Each one of these contains all information required to draw a bound geometry. + * + * @class + * @memberof PIXI + */ + var BatchDrawCall = function BatchDrawCall() + { + this.textures = []; + this.ids = []; + this.blend = 0; + this.textureCount = 0; + this.start = 0; + this.size = 0; + this.type = 4; + }; + + /** + * Used by the BatchRenderer + * + * @class + * @memberof PIXI + */ + var BatchBuffer = function BatchBuffer(size) + { + this.vertices = new ArrayBuffer(size); + + /** + * View on the vertices as a Float32Array for positions + * + * @member {Float32Array} + */ + this.float32View = new Float32Array(this.vertices); + + /** + * View on the vertices as a Uint32Array for uvs + * + * @member {Float32Array} + */ + this.uint32View = new Uint32Array(this.vertices); + }; + + /** + * Destroys the buffer. + * + */ + BatchBuffer.prototype.destroy = function destroy () + { + this.vertices = null; + this.float32View = null; + this.uint32View = null; + }; + + var vertex$1 = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform vec4 tint;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor * tint;\n}\n"; + + var fragTemplate$1 = [ + 'varying vec2 vTextureCoord;', + 'varying vec4 vColor;', + 'varying float vTextureId;', + 'uniform sampler2D uSamplers[%count%];', + + 'void main(void){', + 'vec4 color;', + '%forloop%', + 'gl_FragColor = color * vColor;', + '}' ].join('\n'); + + var defaultGroupCache = {}; + var programCache = {}; + + function generateMultiTextureShader(gl, maxTextures) + { + if (!programCache[maxTextures]) + { + var sampleValues = new Int32Array(maxTextures); + + for (var i = 0; i < maxTextures; i++) + { + sampleValues[i] = i; + } + + defaultGroupCache[maxTextures] = UniformGroup.from({ uSamplers: sampleValues }, true); + + var fragmentSrc = fragTemplate$1; + + fragmentSrc = fragmentSrc.replace(/%count%/gi, maxTextures); + fragmentSrc = fragmentSrc.replace(/%forloop%/gi, generateSampleSrc(maxTextures)); + + programCache[maxTextures] = new Program(vertex$1, fragmentSrc); + } + + var uniforms = { + tint: new Float32Array([1, 1, 1, 1]), + translationMatrix: new Matrix(), + default: defaultGroupCache[maxTextures], + }; + + var shader = new Shader(programCache[maxTextures], uniforms); + + return shader; + } + + function generateSampleSrc(maxTextures) + { + var src = ''; + + src += '\n'; + src += '\n'; + + for (var i = 0; i < maxTextures; i++) + { + if (i > 0) + { + src += '\nelse '; + } + + if (i < maxTextures - 1) + { + src += "if(vTextureId < " + i + ".5)"; + } + + src += '\n{'; + src += "\n\tcolor = texture2D(uSamplers[" + i + "], vTextureCoord);"; + src += '\n}'; + } + + src += '\n'; + src += '\n'; + + return src; + } + + /** + * Renderer dedicated to drawing and batching sprites. + * + * @class + * @protected + * @memberof PIXI + * @extends PIXI.ObjectRenderer + */ + var BatchRenderer = /*@__PURE__*/(function (ObjectRenderer) { + function BatchRenderer(renderer) + { + ObjectRenderer.call(this, renderer); + + /** + * Number of values sent in the vertex buffer. + * aVertexPosition(2), aTextureCoord(1), aColor(1), aTextureId(1) = 5 + * + * @member {number} + */ + this.vertSize = 6; + + /** + * The size of the vertex information in bytes. + * + * @member {number} + */ + this.vertByteSize = this.vertSize * 4; + + /** + * The number of images in the SpriteRenderer before it flushes. + * + * @member {number} + */ + this.size = 2000 * 4;// settings.SPRITE_BATCH_SIZE; // 2000 is a nice balance between mobile / desktop + + this.currentSize = 0; + this.currentIndexSize = 0; + + // the total number of bytes in our batch + // let numVerts = this.size * 4 * this.vertByteSize; + + this.attributeBuffers = {}; + this.aBuffers = {}; + this.iBuffers = {}; + + // this.defualtSpriteIndexBuffer = new Buffer(createIndicesForQuads(this.size), true, true); + + /** + * Holds the defualt indices of the geometry (quads) to draw + * + * @member {Uint16Array} + */ + // const indicies = createIndicesForQuads(this.size); + + // this.defaultQuadIndexBuffer = new Buffer(indicies, true, true); + + this.onlySprites = false; + + /** + * The default shaders that is used if a sprite doesn't have a more specific one. + * there is a shader for each number of textures that can be rendered. + * These shaders will also be generated on the fly as required. + * @member {PIXI.Shader[]} + */ + this.shader = null; + + this.currentIndex = 0; + this.groups = []; + + for (var k = 0; k < this.size / 4; k++) + { + this.groups[k] = new BatchDrawCall(); + } + + this.elements = []; + + this.vaos = []; + + this.vaoMax = 2; + this.vertexCount = 0; + + this.renderer.on('prerender', this.onPrerender, this); + this.state = State.for2d(); + } + + if ( ObjectRenderer ) { BatchRenderer.__proto__ = ObjectRenderer; } + BatchRenderer.prototype = Object.create( ObjectRenderer && ObjectRenderer.prototype ); + BatchRenderer.prototype.constructor = BatchRenderer; + + /** + * Sets up the renderer context and necessary buffers. + */ + BatchRenderer.prototype.contextChange = function contextChange () + { + var gl = this.renderer.gl; + + if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) + { + this.MAX_TEXTURES = 1; + } + else + { + // step 1: first check max textures the GPU can handle. + this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), settings.SPRITE_MAX_TEXTURES); + + // step 2: check the maximum number of if statements the shader can have too.. + this.MAX_TEXTURES = checkMaxIfStatementsInShader(this.MAX_TEXTURES, gl); + } + + // generate generateMultiTextureProgram, may be a better move? + this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES); + + // we use the second shader as the first one depending on your browser may omit aTextureId + // as it is not used by the shader so is optimized out. + for (var i = 0; i < this.vaoMax; i++) + { + /* eslint-disable max-len */ + this.vaos[i] = new BatchGeometry(); + } + }; + + /** + * Called before the renderer starts rendering. + * + */ + BatchRenderer.prototype.onPrerender = function onPrerender () + { + this.vertexCount = 0; + }; + + /** + * Renders the sprite object. + * + * @param {PIXI.Sprite} sprite - the sprite to render when using this spritebatch + */ + BatchRenderer.prototype.render = function render (element) + { + if (!element._texture.valid) + { + return; + } + + if (this.currentSize + (element.vertexData.length / 2) > this.size) + { + this.flush(); + } + + this.elements[this.currentIndex++] = element; + + this.currentSize += element.vertexData.length / 2; + this.currentIndexSize += element.indices.length; + }; + + BatchRenderer.prototype.getIndexBuffer = function getIndexBuffer (size) + { + // 12 indices is enough for 2 quads + var roundedP2 = nextPow2(Math.ceil(size / 12)); + var roundedSizeIndex = log2(roundedP2); + var roundedSize = roundedP2 * 12; + + if (this.iBuffers.length <= roundedSizeIndex) + { + this.iBuffers.length = roundedSizeIndex + 1; + } + + var buffer = this.iBuffers[roundedSizeIndex]; + + if (!buffer) + { + this.iBuffers[roundedSizeIndex] = buffer = new Uint16Array(roundedSize); + } + + return buffer; + }; + + BatchRenderer.prototype.getAttributeBuffer = function getAttributeBuffer (size) + { + // 8 vertices is enough for 2 quads + var roundedP2 = nextPow2(Math.ceil(size / 8)); + var roundedSizeIndex = log2(roundedP2); + var roundedSize = roundedP2 * 8; + + if (this.aBuffers.length <= roundedSizeIndex) + { + this.iBuffers.length = roundedSizeIndex + 1; + } + + var buffer = this.aBuffers[roundedSize]; + + if (!buffer) + { + this.aBuffers[roundedSize] = buffer = new BatchBuffer(roundedSize * this.vertByteSize); + } + + return buffer; + }; + + /** + * Renders the content and empties the current batch. + * + */ + BatchRenderer.prototype.flush = function flush () + { + if (this.currentSize === 0) + { + return; + } + + var gl = this.renderer.gl; + var MAX_TEXTURES = this.MAX_TEXTURES; + + var buffer = this.getAttributeBuffer(this.currentSize); + var indexBuffer = this.getIndexBuffer(this.currentIndexSize); + + var elements = this.elements; + var groups = this.groups; + + var float32View = buffer.float32View; + var uint32View = buffer.uint32View; + + var touch = this.renderer.textureGC.count; + + var index = 0; + var indexCount = 0; + var nextTexture; + var currentTexture; + var groupCount = 0; - /** - * Creates a source used in loading via an element. - * - * @private - * @param {string} type - The element type (video or audio). - * @param {string} url - The source URL to load from. - * @param {string} [mime] - The mime type of the video - * @return {HTMLSourceElement} The source element. - */ + var textureCount = 0; + var currentGroup = groups[0]; + + var blendMode = -1;// premultiplyBlendMode[elements[0]._texture.baseTexture.premultiplyAlpha ? 0 : ][elements[0].blendMode]; + currentGroup.textureCount = 0; + currentGroup.start = 0; + currentGroup.blend = blendMode; - Resource.prototype._createSource = function _createSource(type, url, mime) { - if (!mime) { - mime = type + '/' + this._getExtension(url); - } + var TICK = ++BaseTexture._globalBatch; - var source = document.createElement('source'); + var i; - source.src = url; - source.type = mime; + for (i = 0; i < this.currentIndex; ++i) + { + // upload the sprite elements... + // they have all ready been calculated so we just need to push them into the buffer. - return source; - }; - - /** - * Called if a load errors out. - * - * @param {Event} event - The error event from the element that emits it. - * @private - */ + var sprite = elements[i]; + elements[i] = null; - Resource.prototype._onError = function _onError(event) { - this.abort('Failed to load element using: ' + event.target.nodeName); - }; - - /** - * Called if a load progress event fires for an element or xhr/xdr. - * - * @private - * @param {XMLHttpRequestProgressEvent|Event} event - Progress event. - */ - - - Resource.prototype._onProgress = function _onProgress(event) { - if (event && event.lengthComputable) { - this.onProgress.dispatch(this, event.loaded / event.total); - } - }; - - /** - * Called if a timeout event fires for an element. - * - * @private - */ - - - Resource.prototype._onTimeout = function _onTimeout() { - this.abort('Load timed out.'); - }; - - /** - * Called if an error event fires for xhr/xdr. - * - * @private - */ - - - Resource.prototype._xhrOnError = function _xhrOnError() { - var xhr = this.xhr; - - this.abort(reqType(xhr) + ' Request failed. Status: ' + xhr.status + ', text: "' + xhr.statusText + '"'); - }; - - /** - * Called if an error event fires for xhr/xdr. - * - * @private - */ - - - Resource.prototype._xhrOnTimeout = function _xhrOnTimeout() { - var xhr = this.xhr; - - this.abort(reqType(xhr) + ' Request timed out.'); - }; - - /** - * Called if an abort event fires for xhr/xdr. - * - * @private - */ - - - Resource.prototype._xhrOnAbort = function _xhrOnAbort() { - var xhr = this.xhr; - - this.abort(reqType(xhr) + ' Request was aborted by the user.'); - }; - - /** - * Called when data successfully loads from an xhr/xdr request. - * - * @private - * @param {XMLHttpRequestLoadEvent|Event} event - Load event - */ - - - Resource.prototype._xhrOnLoad = function _xhrOnLoad() { - var xhr = this.xhr; - var text = ''; - var status = typeof xhr.status === 'undefined' ? STATUS_OK : xhr.status; // XDR has no `.status`, assume 200. - - // responseText is accessible only if responseType is '' or 'text' and on older browsers - if (xhr.responseType === '' || xhr.responseType === 'text' || typeof xhr.responseType === 'undefined') { - text = xhr.responseText; - } - - // status can be 0 when using the `file://` protocol so we also check if a response is set. - // If it has a response, we assume 200; otherwise a 0 status code with no contents is an aborted request. - if (status === STATUS_NONE && (text.length > 0 || xhr.responseType === Resource.XHR_RESPONSE_TYPE.BUFFER)) { - status = STATUS_OK; - } - // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request - else if (status === STATUS_IE_BUG_EMPTY) { - status = STATUS_EMPTY; - } - - var statusType = status / 100 | 0; - - if (statusType === STATUS_TYPE_OK) { - // if text, just return it - if (this.xhrType === Resource.XHR_RESPONSE_TYPE.TEXT) { - this.data = text; - this.type = Resource.TYPE.TEXT; - } - // if json, parse into json object - else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON) { - try { - this.data = JSON.parse(text); - this.type = Resource.TYPE.JSON; - } catch (e) { - this.abort('Error trying to parse loaded json: ' + e); - - return; - } - } - // if xml, parse into an xml document or div element - else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) { - try { - if (window.DOMParser) { - var domparser = new DOMParser(); - - this.data = domparser.parseFromString(text, 'text/xml'); - } else { - var div = document.createElement('div'); - - div.innerHTML = text; - - this.data = div; - } - - this.type = Resource.TYPE.XML; - } catch (e) { - this.abort('Error trying to parse loaded xml: ' + e); - - return; - } - } - // other types just return the response - else { - this.data = xhr.response || text; - } - } else { - this.abort('[' + xhr.status + '] ' + xhr.statusText + ': ' + xhr.responseURL); - - return; - } - - this.complete(); - }; - - /** - * Sets the `crossOrigin` property for this resource based on if the url - * for this resource is cross-origin. If crossOrigin was manually set, this - * function does nothing. - * - * @private - * @param {string} url - The url to test. - * @param {object} [loc=window.location] - The location object to test against. - * @return {string} The crossOrigin value to use (or empty string for none). - */ - - - Resource.prototype._determineCrossOrigin = function _determineCrossOrigin(url, loc) { - // data: and javascript: urls are considered same-origin - if (url.indexOf('data:') === 0) { - return ''; - } - - // A sandboxed iframe without the 'allow-same-origin' attribute will have a special - // origin designed not to match window.location.origin, and will always require - // crossOrigin requests regardless of whether the location matches. - if (window.origin !== window.location.origin) { - return 'anonymous'; - } - - // default is window.location - loc = loc || window.location; - - if (!tempAnchor) { - tempAnchor = document.createElement('a'); - } - - // let the browser determine the full href for the url of this resource and then - // parse with the node url lib, we can't use the properties of the anchor element - // because they don't work in IE9 :( - tempAnchor.href = url; - url = (0, _parseUri2.default)(tempAnchor.href, { strictMode: true }); - - var samePort = !url.port && loc.port === '' || url.port === loc.port; - var protocol = url.protocol ? url.protocol + ':' : ''; - - // if cross origin - if (url.host !== loc.hostname || !samePort || protocol !== loc.protocol) { - return 'anonymous'; - } - - return ''; - }; - - /** - * Determines the responseType of an XHR request based on the extension of the - * resource being loaded. - * - * @private - * @return {Resource.XHR_RESPONSE_TYPE} The responseType to use. - */ - - - Resource.prototype._determineXhrType = function _determineXhrType() { - return Resource._xhrTypeMap[this.extension] || Resource.XHR_RESPONSE_TYPE.TEXT; - }; - - /** - * Determines the loadType of a resource based on the extension of the - * resource being loaded. - * - * @private - * @return {Resource.LOAD_TYPE} The loadType to use. - */ - - - Resource.prototype._determineLoadType = function _determineLoadType() { - return Resource._loadTypeMap[this.extension] || Resource.LOAD_TYPE.XHR; - }; - - /** - * Extracts the extension (sans '.') of the file being loaded by the resource. - * - * @private - * @return {string} The extension. - */ - - - Resource.prototype._getExtension = function _getExtension() { - var url = this.url; - var ext = ''; - - if (this.isDataUrl) { - var slashIndex = url.indexOf('/'); - - ext = url.substring(slashIndex + 1, url.indexOf(';', slashIndex)); - } else { - var queryStart = url.indexOf('?'); - var hashStart = url.indexOf('#'); - var index = Math.min(queryStart > -1 ? queryStart : url.length, hashStart > -1 ? hashStart : url.length); - - url = url.substring(0, index); - ext = url.substring(url.lastIndexOf('.') + 1); - } - - return ext.toLowerCase(); - }; - - /** - * Determines the mime type of an XHR request based on the responseType of - * resource being loaded. - * - * @private - * @param {Resource.XHR_RESPONSE_TYPE} type - The type to get a mime type for. - * @return {string} The mime type to use. - */ - - - Resource.prototype._getMimeFromXhrType = function _getMimeFromXhrType(type) { - switch (type) { - case Resource.XHR_RESPONSE_TYPE.BUFFER: - return 'application/octet-binary'; - - case Resource.XHR_RESPONSE_TYPE.BLOB: - return 'application/blob'; - - case Resource.XHR_RESPONSE_TYPE.DOCUMENT: - return 'application/xml'; - - case Resource.XHR_RESPONSE_TYPE.JSON: - return 'application/json'; - - case Resource.XHR_RESPONSE_TYPE.DEFAULT: - case Resource.XHR_RESPONSE_TYPE.TEXT: - /* falls through */ - default: - return 'text/plain'; - } - }; - - _createClass(Resource, [{ - key: 'isDataUrl', - get: function get() { - return this._hasFlag(Resource.STATUS_FLAGS.DATA_URL); - } - - /** - * Describes if this resource has finished loading. Is true when the resource has completely - * loaded. - * - * @readonly - * @member {boolean} - */ - - }, { - key: 'isComplete', - get: function get() { - return this._hasFlag(Resource.STATUS_FLAGS.COMPLETE); - } - - /** - * Describes if this resource is currently loading. Is true when the resource starts loading, - * and is false again when complete. - * - * @readonly - * @member {boolean} - */ - - }, { - key: 'isLoading', - get: function get() { - return this._hasFlag(Resource.STATUS_FLAGS.LOADING); - } - }]); - - return Resource; -}(); - -/** - * The types of resources a resource could represent. - * - * @static - * @readonly - * @enum {number} - */ - - -Resource.STATUS_FLAGS = { - NONE: 0, - DATA_URL: 1 << 0, - COMPLETE: 1 << 1, - LOADING: 1 << 2 -}; - -/** - * The types of resources a resource could represent. - * - * @static - * @readonly - * @enum {number} - */ -Resource.TYPE = { - UNKNOWN: 0, - JSON: 1, - XML: 2, - IMAGE: 3, - AUDIO: 4, - VIDEO: 5, - TEXT: 6 -}; - -/** - * The types of loading a resource can use. - * - * @static - * @readonly - * @enum {number} - */ -Resource.LOAD_TYPE = { - /** Uses XMLHttpRequest to load the resource. */ - XHR: 1, - /** Uses an `Image` object to load the resource. */ - IMAGE: 2, - /** Uses an `Audio` object to load the resource. */ - AUDIO: 3, - /** Uses a `Video` object to load the resource. */ - VIDEO: 4 -}; - -/** - * The XHR ready states, used internally. - * - * @static - * @readonly - * @enum {string} - */ -Resource.XHR_RESPONSE_TYPE = { - /** string */ - DEFAULT: 'text', - /** ArrayBuffer */ - BUFFER: 'arraybuffer', - /** Blob */ - BLOB: 'blob', - /** Document */ - DOCUMENT: 'document', - /** Object */ - JSON: 'json', - /** String */ - TEXT: 'text' -}; - -Resource._loadTypeMap = { - // images - gif: Resource.LOAD_TYPE.IMAGE, - png: Resource.LOAD_TYPE.IMAGE, - bmp: Resource.LOAD_TYPE.IMAGE, - jpg: Resource.LOAD_TYPE.IMAGE, - jpeg: Resource.LOAD_TYPE.IMAGE, - tif: Resource.LOAD_TYPE.IMAGE, - tiff: Resource.LOAD_TYPE.IMAGE, - webp: Resource.LOAD_TYPE.IMAGE, - tga: Resource.LOAD_TYPE.IMAGE, - svg: Resource.LOAD_TYPE.IMAGE, - 'svg+xml': Resource.LOAD_TYPE.IMAGE, // for SVG data urls - - // audio - mp3: Resource.LOAD_TYPE.AUDIO, - ogg: Resource.LOAD_TYPE.AUDIO, - wav: Resource.LOAD_TYPE.AUDIO, - - // videos - mp4: Resource.LOAD_TYPE.VIDEO, - webm: Resource.LOAD_TYPE.VIDEO -}; - -Resource._xhrTypeMap = { - // xml - xhtml: Resource.XHR_RESPONSE_TYPE.DOCUMENT, - html: Resource.XHR_RESPONSE_TYPE.DOCUMENT, - htm: Resource.XHR_RESPONSE_TYPE.DOCUMENT, - xml: Resource.XHR_RESPONSE_TYPE.DOCUMENT, - tmx: Resource.XHR_RESPONSE_TYPE.DOCUMENT, - svg: Resource.XHR_RESPONSE_TYPE.DOCUMENT, - - // This was added to handle Tiled Tileset XML, but .tsx is also a TypeScript React Component. - // Since it is way less likely for people to be loading TypeScript files instead of Tiled files, - // this should probably be fine. - tsx: Resource.XHR_RESPONSE_TYPE.DOCUMENT, - - // images - gif: Resource.XHR_RESPONSE_TYPE.BLOB, - png: Resource.XHR_RESPONSE_TYPE.BLOB, - bmp: Resource.XHR_RESPONSE_TYPE.BLOB, - jpg: Resource.XHR_RESPONSE_TYPE.BLOB, - jpeg: Resource.XHR_RESPONSE_TYPE.BLOB, - tif: Resource.XHR_RESPONSE_TYPE.BLOB, - tiff: Resource.XHR_RESPONSE_TYPE.BLOB, - webp: Resource.XHR_RESPONSE_TYPE.BLOB, - tga: Resource.XHR_RESPONSE_TYPE.BLOB, - - // json - json: Resource.XHR_RESPONSE_TYPE.JSON, - - // text - text: Resource.XHR_RESPONSE_TYPE.TEXT, - txt: Resource.XHR_RESPONSE_TYPE.TEXT, - - // fonts - ttf: Resource.XHR_RESPONSE_TYPE.BUFFER, - otf: Resource.XHR_RESPONSE_TYPE.BUFFER -}; - -// We can't set the `src` attribute to empty string, so on abort we set it to this 1px transparent gif -Resource.EMPTY_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; - -/** - * Quick helper to set a value on one of the extension maps. Ensures there is no - * dot at the start of the extension. - * - * @ignore - * @param {object} map - The map to set on. - * @param {string} extname - The extension (or key) to set. - * @param {number} val - The value to set. - */ -function setExtMap(map, extname, val) { - if (extname && extname.indexOf('.') === 0) { - extname = extname.substring(1); - } - - if (!extname) { - return; - } - - map[extname] = val; -} - -/** - * Quick helper to get string xhr type. - * - * @ignore - * @param {XMLHttpRequest|XDomainRequest} xhr - The request to check. - * @return {string} The type. - */ -function reqType(xhr) { - return xhr.toString().replace('object ', ''); -} - -// Backwards compat -if (typeof module !== 'undefined') { - module.exports.default = Resource; // eslint-disable-line no-undef -} - -},{"mini-signals":5,"parse-uri":7}],34:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.eachSeries = eachSeries; -exports.queue = queue; -/** - * Smaller version of the async library constructs. - * - * @namespace async - */ - -/** - * Noop function - * - * @ignore - * @function - * @memberof async - */ -function _noop() {} /* empty */ - -/** - * Iterates an array in series. - * - * @memberof async - * @param {Array.<*>} array - Array to iterate. - * @param {function} iterator - Function to call for each element. - * @param {function} callback - Function to call when done, or on error. - * @param {boolean} [deferNext=false] - Break synchronous each loop by calling next with a setTimeout of 1. - */ -function eachSeries(array, iterator, callback, deferNext) { - var i = 0; - var len = array.length; - - (function next(err) { - if (err || i === len) { - if (callback) { - callback(err); - } - - return; - } - - if (deferNext) { - setTimeout(function () { - iterator(array[i++], next); - }, 1); - } else { - iterator(array[i++], next); - } - })(); -} - -/** - * Ensures a function is only called once. - * - * @ignore - * @memberof async - * @param {function} fn - The function to wrap. - * @return {function} The wrapping function. - */ -function onlyOnce(fn) { - return function onceWrapper() { - if (fn === null) { - throw new Error('Callback was already called.'); - } - - var callFn = fn; - - fn = null; - callFn.apply(this, arguments); - }; -} - -/** - * Async queue implementation, - * - * @memberof async - * @param {function} worker - The worker function to call for each task. - * @param {number} concurrency - How many workers to run in parrallel. - * @return {*} The async queue object. - */ -function queue(worker, concurrency) { - if (concurrency == null) { - // eslint-disable-line no-eq-null,eqeqeq - concurrency = 1; - } else if (concurrency === 0) { - throw new Error('Concurrency must not be zero'); - } - - var workers = 0; - var q = { - _tasks: [], - concurrency: concurrency, - saturated: _noop, - unsaturated: _noop, - buffer: concurrency / 4, - empty: _noop, - drain: _noop, - error: _noop, - started: false, - paused: false, - push: function push(data, callback) { - _insert(data, false, callback); - }, - kill: function kill() { - workers = 0; - q.drain = _noop; - q.started = false; - q._tasks = []; - }, - unshift: function unshift(data, callback) { - _insert(data, true, callback); - }, - process: function process() { - while (!q.paused && workers < q.concurrency && q._tasks.length) { - var task = q._tasks.shift(); - - if (q._tasks.length === 0) { - q.empty(); - } - - workers += 1; - - if (workers === q.concurrency) { - q.saturated(); - } - - worker(task.data, onlyOnce(_next(task))); - } - }, - length: function length() { - return q._tasks.length; - }, - running: function running() { - return workers; - }, - idle: function idle() { - return q._tasks.length + workers === 0; - }, - pause: function pause() { - if (q.paused === true) { - return; - } - - q.paused = true; - }, - resume: function resume() { - if (q.paused === false) { - return; - } - - q.paused = false; - - // Need to call q.process once per concurrent - // worker to preserve full concurrency after pause - for (var w = 1; w <= q.concurrency; w++) { - q.process(); - } - } - }; - - function _insert(data, insertAtFront, callback) { - if (callback != null && typeof callback !== 'function') { - // eslint-disable-line no-eq-null,eqeqeq - throw new Error('task callback must be a function'); - } - - q.started = true; - - if (data == null && q.idle()) { - // eslint-disable-line no-eq-null,eqeqeq - // call drain immediately if there are no tasks - setTimeout(function () { - return q.drain(); - }, 1); - - return; - } - - var item = { - data: data, - callback: typeof callback === 'function' ? callback : _noop - }; - - if (insertAtFront) { - q._tasks.unshift(item); - } else { - q._tasks.push(item); - } - - setTimeout(function () { - return q.process(); - }, 1); - } - - function _next(task) { - return function next() { - workers -= 1; - - task.callback.apply(task, arguments); - - if (arguments[0] != null) { - // eslint-disable-line no-eq-null,eqeqeq - q.error(arguments[0], task.data); - } - - if (workers <= q.concurrency - q.buffer) { - q.unsaturated(); - } - - if (q.idle()) { - q.drain(); - } - - q.process(); - }; - } - - return q; -} - -},{}],35:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.encodeBinary = encodeBinary; -var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - -/** - * Encodes binary into base64. - * - * @param {string} input The input data to encode. - * @returns {string} The encoded base64 string - */ -function encodeBinary(input) { - var output = ''; - var inx = 0; - - while (inx < input.length) { - // Fill byte buffer array - var bytebuffer = [0, 0, 0]; - var encodedCharIndexes = [0, 0, 0, 0]; - - for (var jnx = 0; jnx < bytebuffer.length; ++jnx) { - if (inx < input.length) { - // throw away high-order byte, as documented at: - // https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data - bytebuffer[jnx] = input.charCodeAt(inx++) & 0xff; - } else { - bytebuffer[jnx] = 0; - } - } - - // Get each encoded character, 6 bits at a time - // index 1: first 6 bits - encodedCharIndexes[0] = bytebuffer[0] >> 2; - - // index 2: second 6 bits (2 least significant bits from input byte 1 + 4 most significant bits from byte 2) - encodedCharIndexes[1] = (bytebuffer[0] & 0x3) << 4 | bytebuffer[1] >> 4; - - // index 3: third 6 bits (4 least significant bits from input byte 2 + 2 most significant bits from byte 3) - encodedCharIndexes[2] = (bytebuffer[1] & 0x0f) << 2 | bytebuffer[2] >> 6; - - // index 3: forth 6 bits (6 least significant bits from input byte 3) - encodedCharIndexes[3] = bytebuffer[2] & 0x3f; - - // Determine whether padding happened, and adjust accordingly - var paddingBytes = inx - (input.length - 1); - - switch (paddingBytes) { - case 2: - // Set last 2 characters to padding char - encodedCharIndexes[3] = 64; - encodedCharIndexes[2] = 64; - break; - - case 1: - // Set last character to padding char - encodedCharIndexes[3] = 64; - break; - - default: - break; // No padding - proceed - } - - // Now we will grab each appropriate character out of our keystring - // based on our index array and append it to the output string - for (var _jnx = 0; _jnx < encodedCharIndexes.length; ++_jnx) { - output += _keyStr.charAt(encodedCharIndexes[_jnx]); - } - } - - return output; -} - -// Backwards compat -if (typeof module !== 'undefined') { - module.exports.default = encodeBinary; // eslint-disable-line no-undef -} - -},{}],36:[function(require,module,exports){ -'use strict'; - -// import Loader from './Loader'; -// import Resource from './Resource'; -// import * as async from './async'; -// import * as b64 from './b64'; - -/* eslint-disable no-undef */ - -var Loader = require('./Loader').Loader; -var Resource = require('./Resource').Resource; -var async = require('./async'); -var b64 = require('./b64'); - -/** - * - * @static - * @memberof Loader - * @member {Class} - */ -Loader.Resource = Resource; - -/** - * - * @static - * @memberof Loader - * @member {Class} - */ -Loader.async = async; - -/** - * - * @static - * @memberof Loader - * @member {Class} - */ -Loader.encodeBinary = b64; - -/** - * - * @deprecated - * @see Loader.encodeBinary - * - * @static - * @memberof Loader - * @member {Class} - */ -Loader.base64 = b64; - -// export manually, and also as default -module.exports = Loader; - -// default & named export -module.exports.Loader = Loader; -module.exports.default = Loader; - -},{"./Loader":32,"./Resource":33,"./async":34,"./b64":35}],37:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.blobMiddlewareFactory = blobMiddlewareFactory; - -var _Resource = require('../../Resource'); - -var _b = require('../../b64'); - -var Url = window.URL || window.webkitURL; - -// a middleware for transforming XHR loaded Blobs into more useful objects -function blobMiddlewareFactory() { - return function blobMiddleware(resource, next) { - if (!resource.data) { - next(); - - return; - } - - // if this was an XHR load of a blob - if (resource.xhr && resource.xhrType === _Resource.Resource.XHR_RESPONSE_TYPE.BLOB) { - // if there is no blob support we probably got a binary string back - if (!window.Blob || typeof resource.data === 'string') { - var type = resource.xhr.getResponseHeader('content-type'); - - // this is an image, convert the binary string into a data url - if (type && type.indexOf('image') === 0) { - resource.data = new Image(); - resource.data.src = 'data:' + type + ';base64,' + (0, _b.encodeBinary)(resource.xhr.responseText); - - resource.type = _Resource.Resource.TYPE.IMAGE; - - // wait until the image loads and then callback - resource.data.onload = function () { - resource.data.onload = null; - - next(); - }; - - // next will be called on load - return; - } - } - // if content type says this is an image, then we should transform the blob into an Image object - else if (resource.data.type.indexOf('image') === 0) { - var src = Url.createObjectURL(resource.data); - - resource.blob = resource.data; - resource.data = new Image(); - resource.data.src = src; - - resource.type = _Resource.Resource.TYPE.IMAGE; - - // cleanup the no longer used blob after the image loads - // TODO: Is this correct? Will the image be invalid after revoking? - resource.data.onload = function () { - Url.revokeObjectURL(src); - resource.data.onload = null; - - next(); - }; - - // next will be called on load. - return; - } - } - - next(); - }; -} - -},{"../../Resource":33,"../../b64":35}],38:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var punycode = require('punycode'); -var util = require('./util'); - -exports.parse = urlParse; -exports.resolve = urlResolve; -exports.resolveObject = urlResolveObject; -exports.format = urlFormat; - -exports.Url = Url; - -function Url() { - this.protocol = null; - this.slashes = null; - this.auth = null; - this.host = null; - this.port = null; - this.hostname = null; - this.hash = null; - this.search = null; - this.query = null; - this.pathname = null; - this.path = null; - this.href = null; -} - -// Reference: RFC 3986, RFC 1808, RFC 2396 - -// define these here so at least they only have to be -// compiled once on the first module load. -var protocolPattern = /^([a-z0-9.+-]+:)/i, - portPattern = /:[0-9]*$/, - - // Special case for a simple path URL - simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, - - // RFC 2396: characters reserved for delimiting URLs. - // We actually just auto-escape these. - delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], - - // RFC 2396: characters not allowed for various reasons. - unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), - - // Allowed by RFCs, but cause of XSS attacks. Always escape these. - autoEscape = ['\''].concat(unwise), - // Characters that are never ever allowed in a hostname. - // Note that any invalid chars are also handled, but these - // are the ones that are *expected* to be seen, so we fast-path - // them. - nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), - hostEndingChars = ['/', '?', '#'], - hostnameMaxLen = 255, - hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, - hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, - // protocols that can allow "unsafe" and "unwise" chars. - unsafeProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that never have a hostname. - hostlessProtocol = { - 'javascript': true, - 'javascript:': true - }, - // protocols that always contain a // bit. - slashedProtocol = { - 'http': true, - 'https': true, - 'ftp': true, - 'gopher': true, - 'file': true, - 'http:': true, - 'https:': true, - 'ftp:': true, - 'gopher:': true, - 'file:': true - }, - querystring = require('querystring'); - -function urlParse(url, parseQueryString, slashesDenoteHost) { - if (url && util.isObject(url) && url instanceof Url) return url; - - var u = new Url; - u.parse(url, parseQueryString, slashesDenoteHost); - return u; -} - -Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { - if (!util.isString(url)) { - throw new TypeError("Parameter 'url' must be a string, not " + typeof url); - } - - // Copy chrome, IE, opera backslash-handling behavior. - // Back slashes before the query string get converted to forward slashes - // See: https://code.google.com/p/chromium/issues/detail?id=25916 - var queryIndex = url.indexOf('?'), - splitter = - (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', - uSplit = url.split(splitter), - slashRegex = /\\/g; - uSplit[0] = uSplit[0].replace(slashRegex, '/'); - url = uSplit.join(splitter); - - var rest = url; - - // trim before proceeding. - // This is to support parse stuff like " http://foo.com \n" - rest = rest.trim(); - - if (!slashesDenoteHost && url.split('#').length === 1) { - // Try fast path regexp - var simplePath = simplePathPattern.exec(rest); - if (simplePath) { - this.path = rest; - this.href = rest; - this.pathname = simplePath[1]; - if (simplePath[2]) { - this.search = simplePath[2]; - if (parseQueryString) { - this.query = querystring.parse(this.search.substr(1)); - } else { - this.query = this.search.substr(1); - } - } else if (parseQueryString) { - this.search = ''; - this.query = {}; - } - return this; - } - } - - var proto = protocolPattern.exec(rest); - if (proto) { - proto = proto[0]; - var lowerProto = proto.toLowerCase(); - this.protocol = lowerProto; - rest = rest.substr(proto.length); - } - - // figure out if it's got a host - // user@server is *always* interpreted as a hostname, and url - // resolution will treat //foo/bar as host=foo,path=bar because that's - // how the browser resolves relative URLs. - if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { - var slashes = rest.substr(0, 2) === '//'; - if (slashes && !(proto && hostlessProtocol[proto])) { - rest = rest.substr(2); - this.slashes = true; - } - } - - if (!hostlessProtocol[proto] && - (slashes || (proto && !slashedProtocol[proto]))) { - - // there's a hostname. - // the first instance of /, ?, ;, or # ends the host. - // - // If there is an @ in the hostname, then non-host chars *are* allowed - // to the left of the last @ sign, unless some host-ending character - // comes *before* the @-sign. - // URLs are obnoxious. - // - // ex: - // http://a@b@c/ => user:a@b host:c - // http://a@b?@c => user:a host:c path:/?@c - - // v0.12 TODO(isaacs): This is not quite how Chrome does things. - // Review our test case against browsers more comprehensively. - - // find the first instance of any hostEndingChars - var hostEnd = -1; - for (var i = 0; i < hostEndingChars.length; i++) { - var hec = rest.indexOf(hostEndingChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - - // at this point, either we have an explicit point where the - // auth portion cannot go past, or the last @ char is the decider. - var auth, atSign; - if (hostEnd === -1) { - // atSign can be anywhere. - atSign = rest.lastIndexOf('@'); - } else { - // atSign must be in auth portion. - // http://a@b/c@d => host:b auth:a path:/c@d - atSign = rest.lastIndexOf('@', hostEnd); - } - - // Now we have a portion which is definitely the auth. - // Pull that off. - if (atSign !== -1) { - auth = rest.slice(0, atSign); - rest = rest.slice(atSign + 1); - this.auth = decodeURIComponent(auth); - } - - // the host is the remaining to the left of the first non-host char - hostEnd = -1; - for (var i = 0; i < nonHostChars.length; i++) { - var hec = rest.indexOf(nonHostChars[i]); - if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) - hostEnd = hec; - } - // if we still have not hit it, then the entire thing is a host. - if (hostEnd === -1) - hostEnd = rest.length; - - this.host = rest.slice(0, hostEnd); - rest = rest.slice(hostEnd); - - // pull out port. - this.parseHost(); - - // we've indicated that there is a hostname, - // so even if it's empty, it has to be present. - this.hostname = this.hostname || ''; - - // if hostname begins with [ and ends with ] - // assume that it's an IPv6 address. - var ipv6Hostname = this.hostname[0] === '[' && - this.hostname[this.hostname.length - 1] === ']'; - - // validate a little. - if (!ipv6Hostname) { - var hostparts = this.hostname.split(/\./); - for (var i = 0, l = hostparts.length; i < l; i++) { - var part = hostparts[i]; - if (!part) continue; - if (!part.match(hostnamePartPattern)) { - var newpart = ''; - for (var j = 0, k = part.length; j < k; j++) { - if (part.charCodeAt(j) > 127) { - // we replace non-ASCII char with a temporary placeholder - // we need this to make sure size of hostname is not - // broken by replacing non-ASCII by nothing - newpart += 'x'; - } else { - newpart += part[j]; - } - } - // we test again with ASCII char only - if (!newpart.match(hostnamePartPattern)) { - var validParts = hostparts.slice(0, i); - var notHost = hostparts.slice(i + 1); - var bit = part.match(hostnamePartStart); - if (bit) { - validParts.push(bit[1]); - notHost.unshift(bit[2]); - } - if (notHost.length) { - rest = '/' + notHost.join('.') + rest; - } - this.hostname = validParts.join('.'); - break; - } - } - } - } - - if (this.hostname.length > hostnameMaxLen) { - this.hostname = ''; - } else { - // hostnames are always lower case. - this.hostname = this.hostname.toLowerCase(); - } - - if (!ipv6Hostname) { - // IDNA Support: Returns a punycoded representation of "domain". - // It only converts parts of the domain name that - // have non-ASCII characters, i.e. it doesn't matter if - // you call it with a domain that already is ASCII-only. - this.hostname = punycode.toASCII(this.hostname); - } - - var p = this.port ? ':' + this.port : ''; - var h = this.hostname || ''; - this.host = h + p; - this.href += this.host; - - // strip [ and ] from the hostname - // the host field still retains them, though - if (ipv6Hostname) { - this.hostname = this.hostname.substr(1, this.hostname.length - 2); - if (rest[0] !== '/') { - rest = '/' + rest; - } - } - } - - // now rest is set to the post-host stuff. - // chop off any delim chars. - if (!unsafeProtocol[lowerProto]) { - - // First, make 100% sure that any "autoEscape" chars get - // escaped, even if encodeURIComponent doesn't think they - // need to be. - for (var i = 0, l = autoEscape.length; i < l; i++) { - var ae = autoEscape[i]; - if (rest.indexOf(ae) === -1) - continue; - var esc = encodeURIComponent(ae); - if (esc === ae) { - esc = escape(ae); - } - rest = rest.split(ae).join(esc); - } - } - - - // chop off from the tail first. - var hash = rest.indexOf('#'); - if (hash !== -1) { - // got a fragment string. - this.hash = rest.substr(hash); - rest = rest.slice(0, hash); - } - var qm = rest.indexOf('?'); - if (qm !== -1) { - this.search = rest.substr(qm); - this.query = rest.substr(qm + 1); - if (parseQueryString) { - this.query = querystring.parse(this.query); - } - rest = rest.slice(0, qm); - } else if (parseQueryString) { - // no query string, but parseQueryString still requested - this.search = ''; - this.query = {}; - } - if (rest) this.pathname = rest; - if (slashedProtocol[lowerProto] && - this.hostname && !this.pathname) { - this.pathname = '/'; - } - - //to support http.request - if (this.pathname || this.search) { - var p = this.pathname || ''; - var s = this.search || ''; - this.path = p + s; - } - - // finally, reconstruct the href based on what has been validated. - this.href = this.format(); - return this; -}; - -// format a parsed object into a url string -function urlFormat(obj) { - // ensure it's an object, and not a string url. - // If it's an obj, this is a no-op. - // this way, you can call url_format() on strings - // to clean up potentially wonky urls. - if (util.isString(obj)) obj = urlParse(obj); - if (!(obj instanceof Url)) return Url.prototype.format.call(obj); - return obj.format(); -} - -Url.prototype.format = function() { - var auth = this.auth || ''; - if (auth) { - auth = encodeURIComponent(auth); - auth = auth.replace(/%3A/i, ':'); - auth += '@'; - } - - var protocol = this.protocol || '', - pathname = this.pathname || '', - hash = this.hash || '', - host = false, - query = ''; - - if (this.host) { - host = auth + this.host; - } else if (this.hostname) { - host = auth + (this.hostname.indexOf(':') === -1 ? - this.hostname : - '[' + this.hostname + ']'); - if (this.port) { - host += ':' + this.port; - } - } - - if (this.query && - util.isObject(this.query) && - Object.keys(this.query).length) { - query = querystring.stringify(this.query); - } - - var search = this.search || (query && ('?' + query)) || ''; - - if (protocol && protocol.substr(-1) !== ':') protocol += ':'; - - // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. - // unless they had them to begin with. - if (this.slashes || - (!protocol || slashedProtocol[protocol]) && host !== false) { - host = '//' + (host || ''); - if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; - } else if (!host) { - host = ''; - } - - if (hash && hash.charAt(0) !== '#') hash = '#' + hash; - if (search && search.charAt(0) !== '?') search = '?' + search; - - pathname = pathname.replace(/[?#]/g, function(match) { - return encodeURIComponent(match); - }); - search = search.replace('#', '%23'); - - return protocol + host + pathname + search + hash; -}; - -function urlResolve(source, relative) { - return urlParse(source, false, true).resolve(relative); -} - -Url.prototype.resolve = function(relative) { - return this.resolveObject(urlParse(relative, false, true)).format(); -}; - -function urlResolveObject(source, relative) { - if (!source) return relative; - return urlParse(source, false, true).resolveObject(relative); -} - -Url.prototype.resolveObject = function(relative) { - if (util.isString(relative)) { - var rel = new Url(); - rel.parse(relative, false, true); - relative = rel; - } - - var result = new Url(); - var tkeys = Object.keys(this); - for (var tk = 0; tk < tkeys.length; tk++) { - var tkey = tkeys[tk]; - result[tkey] = this[tkey]; - } - - // hash is always overridden, no matter what. - // even href="" will remove it. - result.hash = relative.hash; - - // if the relative url is empty, then there's nothing left to do here. - if (relative.href === '') { - result.href = result.format(); - return result; - } - - // hrefs like //foo/bar always cut to the protocol. - if (relative.slashes && !relative.protocol) { - // take everything except the protocol from relative - var rkeys = Object.keys(relative); - for (var rk = 0; rk < rkeys.length; rk++) { - var rkey = rkeys[rk]; - if (rkey !== 'protocol') - result[rkey] = relative[rkey]; - } - - //urlParse appends trailing / to urls like http://www.example.com - if (slashedProtocol[result.protocol] && - result.hostname && !result.pathname) { - result.path = result.pathname = '/'; - } - - result.href = result.format(); - return result; - } - - if (relative.protocol && relative.protocol !== result.protocol) { - // if it's a known url protocol, then changing - // the protocol does weird things - // first, if it's not file:, then we MUST have a host, - // and if there was a path - // to begin with, then we MUST have a path. - // if it is file:, then the host is dropped, - // because that's known to be hostless. - // anything else is assumed to be absolute. - if (!slashedProtocol[relative.protocol]) { - var keys = Object.keys(relative); - for (var v = 0; v < keys.length; v++) { - var k = keys[v]; - result[k] = relative[k]; - } - result.href = result.format(); - return result; - } - - result.protocol = relative.protocol; - if (!relative.host && !hostlessProtocol[relative.protocol]) { - var relPath = (relative.pathname || '').split('/'); - while (relPath.length && !(relative.host = relPath.shift())); - if (!relative.host) relative.host = ''; - if (!relative.hostname) relative.hostname = ''; - if (relPath[0] !== '') relPath.unshift(''); - if (relPath.length < 2) relPath.unshift(''); - result.pathname = relPath.join('/'); - } else { - result.pathname = relative.pathname; - } - result.search = relative.search; - result.query = relative.query; - result.host = relative.host || ''; - result.auth = relative.auth; - result.hostname = relative.hostname || relative.host; - result.port = relative.port; - // to support http.request - if (result.pathname || result.search) { - var p = result.pathname || ''; - var s = result.search || ''; - result.path = p + s; - } - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; - } - - var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), - isRelAbs = ( - relative.host || - relative.pathname && relative.pathname.charAt(0) === '/' - ), - mustEndAbs = (isRelAbs || isSourceAbs || - (result.host && relative.pathname)), - removeAllDots = mustEndAbs, - srcPath = result.pathname && result.pathname.split('/') || [], - relPath = relative.pathname && relative.pathname.split('/') || [], - psychotic = result.protocol && !slashedProtocol[result.protocol]; - - // if the url is a non-slashed url, then relative - // links like ../.. should be able - // to crawl up to the hostname, as well. This is strange. - // result.protocol has already been set by now. - // Later on, put the first path part into the host field. - if (psychotic) { - result.hostname = ''; - result.port = null; - if (result.host) { - if (srcPath[0] === '') srcPath[0] = result.host; - else srcPath.unshift(result.host); - } - result.host = ''; - if (relative.protocol) { - relative.hostname = null; - relative.port = null; - if (relative.host) { - if (relPath[0] === '') relPath[0] = relative.host; - else relPath.unshift(relative.host); - } - relative.host = null; - } - mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); - } - - if (isRelAbs) { - // it's absolute. - result.host = (relative.host || relative.host === '') ? - relative.host : result.host; - result.hostname = (relative.hostname || relative.hostname === '') ? - relative.hostname : result.hostname; - result.search = relative.search; - result.query = relative.query; - srcPath = relPath; - // fall through to the dot-handling below. - } else if (relPath.length) { - // it's relative - // throw away the existing file, and take the new path instead. - if (!srcPath) srcPath = []; - srcPath.pop(); - srcPath = srcPath.concat(relPath); - result.search = relative.search; - result.query = relative.query; - } else if (!util.isNullOrUndefined(relative.search)) { - // just pull out the search. - // like href='?foo'. - // Put this after the other two cases because it simplifies the booleans - if (psychotic) { - result.hostname = result.host = srcPath.shift(); - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } - result.search = relative.search; - result.query = relative.query; - //to support http.request - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.href = result.format(); - return result; - } - - if (!srcPath.length) { - // no path at all. easy. - // we've already handled the other stuff above. - result.pathname = null; - //to support http.request - if (result.search) { - result.path = '/' + result.search; - } else { - result.path = null; - } - result.href = result.format(); - return result; - } - - // if a url ENDs in . or .., then it must get a trailing slash. - // however, if it ends in anything else non-slashy, - // then it must NOT get a trailing slash. - var last = srcPath.slice(-1)[0]; - var hasTrailingSlash = ( - (result.host || relative.host || srcPath.length > 1) && - (last === '.' || last === '..') || last === ''); - - // strip single dots, resolve double dots to parent dir - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = srcPath.length; i >= 0; i--) { - last = srcPath[i]; - if (last === '.') { - srcPath.splice(i, 1); - } else if (last === '..') { - srcPath.splice(i, 1); - up++; - } else if (up) { - srcPath.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (!mustEndAbs && !removeAllDots) { - for (; up--; up) { - srcPath.unshift('..'); - } - } - - if (mustEndAbs && srcPath[0] !== '' && - (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { - srcPath.unshift(''); - } - - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { - srcPath.push(''); - } - - var isAbsolute = srcPath[0] === '' || - (srcPath[0] && srcPath[0].charAt(0) === '/'); - - // put the host back - if (psychotic) { - result.hostname = result.host = isAbsolute ? '' : - srcPath.length ? srcPath.shift() : ''; - //occationaly the auth can get stuck only in host - //this especially happens in cases like - //url.resolveObject('mailto:local1@domain1', 'local2@domain2') - var authInHost = result.host && result.host.indexOf('@') > 0 ? - result.host.split('@') : false; - if (authInHost) { - result.auth = authInHost.shift(); - result.host = result.hostname = authInHost.shift(); - } - } - - mustEndAbs = mustEndAbs || (result.host && srcPath.length); - - if (mustEndAbs && !isAbsolute) { - srcPath.unshift(''); - } - - if (!srcPath.length) { - result.pathname = null; - result.path = null; - } else { - result.pathname = srcPath.join('/'); - } - - //to support request.http - if (!util.isNull(result.pathname) || !util.isNull(result.search)) { - result.path = (result.pathname ? result.pathname : '') + - (result.search ? result.search : ''); - } - result.auth = relative.auth || result.auth; - result.slashes = result.slashes || relative.slashes; - result.href = result.format(); - return result; -}; - -Url.prototype.parseHost = function() { - var host = this.host; - var port = portPattern.exec(host); - if (port) { - port = port[0]; - if (port !== ':') { - this.port = port.substr(1); - } - host = host.substr(0, host.length - port.length); - } - if (host) this.hostname = host; -}; - -},{"./util":39,"punycode":27,"querystring":30}],39:[function(require,module,exports){ -'use strict'; - -module.exports = { - isString: function(arg) { - return typeof(arg) === 'string'; - }, - isObject: function(arg) { - return typeof(arg) === 'object' && arg !== null; - }, - isNull: function(arg) { - return arg === null; - }, - isNullOrUndefined: function(arg) { - return arg == null; - } -}; - -},{}],40:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -var _ismobilejs = require('ismobilejs'); - -var _ismobilejs2 = _interopRequireDefault(_ismobilejs); - -var _accessibleTarget = require('./accessibleTarget'); - -var _accessibleTarget2 = _interopRequireDefault(_accessibleTarget); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// add some extra variables to the container.. -core.utils.mixins.delayMixin(core.DisplayObject.prototype, _accessibleTarget2.default); - -var KEY_CODE_TAB = 9; - -var DIV_TOUCH_SIZE = 100; -var DIV_TOUCH_POS_X = 0; -var DIV_TOUCH_POS_Y = 0; -var DIV_TOUCH_ZINDEX = 2; - -var DIV_HOOK_SIZE = 1; -var DIV_HOOK_POS_X = -1000; -var DIV_HOOK_POS_Y = -1000; -var DIV_HOOK_ZINDEX = 2; - -/** - * The Accessibility manager recreates the ability to tab and have content read by screen - * readers. This is very important as it can possibly help people with disabilities access pixi - * content. - * - * Much like interaction any DisplayObject can be made accessible. This manager will map the - * events as if the mouse was being used, minimizing the effort required to implement. - * - * An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility - * - * @class - * @memberof PIXI.accessibility - */ - -var AccessibilityManager = function () { - /** - * @param {PIXI.CanvasRenderer|PIXI.WebGLRenderer} renderer - A reference to the current renderer - */ - function AccessibilityManager(renderer) { - _classCallCheck(this, AccessibilityManager); - - if ((_ismobilejs2.default.tablet || _ismobilejs2.default.phone) && !navigator.isCocoonJS) { - this.createTouchHook(); - } - - // first we create a div that will sit over the PixiJS element. This is where the div overlays will go. - var div = document.createElement('div'); - - div.style.width = DIV_TOUCH_SIZE + 'px'; - div.style.height = DIV_TOUCH_SIZE + 'px'; - div.style.position = 'absolute'; - div.style.top = DIV_TOUCH_POS_X + 'px'; - div.style.left = DIV_TOUCH_POS_Y + 'px'; - div.style.zIndex = DIV_TOUCH_ZINDEX; - - /** - * This is the dom element that will sit over the PixiJS element. This is where the div overlays will go. - * - * @type {HTMLElement} - * @private - */ - this.div = div; - - /** - * A simple pool for storing divs. - * - * @type {*} - * @private - */ - this.pool = []; - - /** - * This is a tick used to check if an object is no longer being rendered. - * - * @type {Number} - * @private - */ - this.renderId = 0; - - /** - * Setting this to true will visually show the divs. - * - * @type {boolean} - */ - this.debug = false; - - /** - * The renderer this accessibility manager works for. - * - * @member {PIXI.SystemRenderer} - */ - this.renderer = renderer; - - /** - * The array of currently active accessible items. - * - * @member {Array<*>} - * @private - */ - this.children = []; - - /** - * pre-bind the functions - * - * @private - */ - this._onKeyDown = this._onKeyDown.bind(this); - this._onMouseMove = this._onMouseMove.bind(this); - - /** - * stores the state of the manager. If there are no accessible objects or the mouse is moving, this will be false. - * - * @member {Array<*>} - * @private - */ - this.isActive = false; - this.isMobileAccessabillity = false; - - // let listen for tab.. once pressed we can fire up and show the accessibility layer - window.addEventListener('keydown', this._onKeyDown, false); - } - - /** - * Creates the touch hooks. - * - */ - - - AccessibilityManager.prototype.createTouchHook = function createTouchHook() { - var _this = this; - - var hookDiv = document.createElement('button'); - - hookDiv.style.width = DIV_HOOK_SIZE + 'px'; - hookDiv.style.height = DIV_HOOK_SIZE + 'px'; - hookDiv.style.position = 'absolute'; - hookDiv.style.top = DIV_HOOK_POS_X + 'px'; - hookDiv.style.left = DIV_HOOK_POS_Y + 'px'; - hookDiv.style.zIndex = DIV_HOOK_ZINDEX; - hookDiv.style.backgroundColor = '#FF0000'; - hookDiv.title = 'HOOK DIV'; - - hookDiv.addEventListener('focus', function () { - _this.isMobileAccessabillity = true; - _this.activate(); - document.body.removeChild(hookDiv); - }); - - document.body.appendChild(hookDiv); - }; - - /** - * Activating will cause the Accessibility layer to be shown. This is called when a user - * preses the tab key. - * - * @private - */ - - - AccessibilityManager.prototype.activate = function activate() { - if (this.isActive) { - return; - } - - this.isActive = true; - - window.document.addEventListener('mousemove', this._onMouseMove, true); - window.removeEventListener('keydown', this._onKeyDown, false); - - this.renderer.on('postrender', this.update, this); - - if (this.renderer.view.parentNode) { - this.renderer.view.parentNode.appendChild(this.div); - } - }; - - /** - * Deactivating will cause the Accessibility layer to be hidden. This is called when a user moves - * the mouse. - * - * @private - */ - - - AccessibilityManager.prototype.deactivate = function deactivate() { - if (!this.isActive || this.isMobileAccessabillity) { - return; - } - - this.isActive = false; - - window.document.removeEventListener('mousemove', this._onMouseMove, true); - window.addEventListener('keydown', this._onKeyDown, false); - - this.renderer.off('postrender', this.update); - - if (this.div.parentNode) { - this.div.parentNode.removeChild(this.div); - } - }; - - /** - * This recursive function will run through the scene graph and add any new accessible objects to the DOM layer. - * - * @private - * @param {PIXI.Container} displayObject - The DisplayObject to check. - */ - + nextTexture = sprite._texture.baseTexture; - AccessibilityManager.prototype.updateAccessibleObjects = function updateAccessibleObjects(displayObject) { - if (!displayObject.visible) { - return; - } - - if (displayObject.accessible && displayObject.interactive) { - if (!displayObject._accessibleActive) { - this.addChild(displayObject); - } + var spriteBlendMode = premultiplyBlendMode[nextTexture.premultiplyAlpha ? 1 : 0][sprite.blendMode]; - displayObject.renderId = this.renderId; - } + if (blendMode !== spriteBlendMode) + { + blendMode = spriteBlendMode; - var children = displayObject.children; + // force the batch to break! + currentTexture = null; + textureCount = MAX_TEXTURES; + TICK++; + } - for (var i = 0; i < children.length; i++) { - this.updateAccessibleObjects(children[i]); - } - }; - - /** - * Before each render this function will ensure that all divs are mapped correctly to their DisplayObjects. - * - * @private - */ - - - AccessibilityManager.prototype.update = function update() { - if (!this.renderer.renderingToScreen) { - return; - } - - // update children... - this.updateAccessibleObjects(this.renderer._lastObjectRendered); + if (currentTexture !== nextTexture) + { + currentTexture = nextTexture; - var rect = this.renderer.view.getBoundingClientRect(); - var sx = rect.width / this.renderer.width; - var sy = rect.height / this.renderer.height; + if (nextTexture._batchEnabled !== TICK) + { + if (textureCount === MAX_TEXTURES) + { + TICK++; - var div = this.div; + textureCount = 0; - div.style.left = rect.left + 'px'; - div.style.top = rect.top + 'px'; - div.style.width = this.renderer.width + 'px'; - div.style.height = this.renderer.height + 'px'; + currentGroup.size = indexCount - currentGroup.start; - for (var i = 0; i < this.children.length; i++) { - var child = this.children[i]; + currentGroup = groups[groupCount++]; + currentGroup.textureCount = 0; + currentGroup.blend = blendMode; + currentGroup.start = indexCount; + } - if (child.renderId !== this.renderId) { - child._accessibleActive = false; + nextTexture.touched = touch; + nextTexture._batchEnabled = TICK; + nextTexture._id = textureCount; - core.utils.removeItems(this.children, i, 1); - this.div.removeChild(child._accessibleDiv); - this.pool.push(child._accessibleDiv); - child._accessibleDiv = null; - - i--; - - if (this.children.length === 0) { - this.deactivate(); - } - } else { - // map div to display.. - div = child._accessibleDiv; - var hitArea = child.hitArea; - var wt = child.worldTransform; - - if (child.hitArea) { - div.style.left = (wt.tx + hitArea.x * wt.a) * sx + 'px'; - div.style.top = (wt.ty + hitArea.y * wt.d) * sy + 'px'; - - div.style.width = hitArea.width * wt.a * sx + 'px'; - div.style.height = hitArea.height * wt.d * sy + 'px'; - } else { - hitArea = child.getBounds(); - - this.capHitArea(hitArea); - - div.style.left = hitArea.x * sx + 'px'; - div.style.top = hitArea.y * sy + 'px'; - - div.style.width = hitArea.width * sx + 'px'; - div.style.height = hitArea.height * sy + 'px'; - - // update button titles and hints if they exist and they've changed - if (div.title !== child.accessibleTitle && child.accessibleTitle !== null) { - div.title = child.accessibleTitle; - } - if (div.getAttribute('aria-label') !== child.accessibleHint && child.accessibleHint !== null) { - div.setAttribute('aria-label', child.accessibleHint); - } - } - } - } - - // increment the render id.. - this.renderId++; - }; - - /** - * TODO: docs. - * - * @param {Rectangle} hitArea - TODO docs - */ - - - AccessibilityManager.prototype.capHitArea = function capHitArea(hitArea) { - if (hitArea.x < 0) { - hitArea.width += hitArea.x; - hitArea.x = 0; - } - - if (hitArea.y < 0) { - hitArea.height += hitArea.y; - hitArea.y = 0; - } - - if (hitArea.x + hitArea.width > this.renderer.width) { - hitArea.width = this.renderer.width - hitArea.x; - } - - if (hitArea.y + hitArea.height > this.renderer.height) { - hitArea.height = this.renderer.height - hitArea.y; - } - }; - - /** - * Adds a DisplayObject to the accessibility manager - * - * @private - * @param {DisplayObject} displayObject - The child to make accessible. - */ - - - AccessibilityManager.prototype.addChild = function addChild(displayObject) { - // this.activate(); - - var div = this.pool.pop(); - - if (!div) { - div = document.createElement('button'); - - div.style.width = DIV_TOUCH_SIZE + 'px'; - div.style.height = DIV_TOUCH_SIZE + 'px'; - div.style.backgroundColor = this.debug ? 'rgba(255,0,0,0.5)' : 'transparent'; - div.style.position = 'absolute'; - div.style.zIndex = DIV_TOUCH_ZINDEX; - div.style.borderStyle = 'none'; - - // ARIA attributes ensure that button title and hint updates are announced properly - if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) { - // Chrome doesn't need aria-live to work as intended; in fact it just gets more confused. - div.setAttribute('aria-live', 'off'); - } else { - div.setAttribute('aria-live', 'polite'); - } - - if (navigator.userAgent.match(/rv:.*Gecko\//)) { - // FireFox needs this to announce only the new button name - div.setAttribute('aria-relevant', 'additions'); - } else { - // required by IE, other browsers don't much care - div.setAttribute('aria-relevant', 'text'); - } - - div.addEventListener('click', this._onClick.bind(this)); - div.addEventListener('focus', this._onFocus.bind(this)); - div.addEventListener('focusout', this._onFocusOut.bind(this)); - } - - if (displayObject.accessibleTitle && displayObject.accessibleTitle !== null) { - div.title = displayObject.accessibleTitle; - } else if (!displayObject.accessibleHint || displayObject.accessibleHint === null) { - div.title = 'displayObject ' + displayObject.tabIndex; - } - - if (displayObject.accessibleHint && displayObject.accessibleHint !== null) { - div.setAttribute('aria-label', displayObject.accessibleHint); - } - - // - - displayObject._accessibleActive = true; - displayObject._accessibleDiv = div; - div.displayObject = displayObject; - - this.children.push(displayObject); - this.div.appendChild(displayObject._accessibleDiv); - displayObject._accessibleDiv.tabIndex = displayObject.tabIndex; - }; - - /** - * Maps the div button press to pixi's InteractionManager (click) - * - * @private - * @param {MouseEvent} e - The click event. - */ + currentGroup.textures[currentGroup.textureCount++] = nextTexture; + textureCount++; + } + } + this.packGeometry(sprite, float32View, uint32View, indexBuffer, index, indexCount);// argb, nextTexture._id, float32View, uint32View, indexBuffer, index, indexCount); - AccessibilityManager.prototype._onClick = function _onClick(e) { - var interactionManager = this.renderer.plugins.interaction; + // push a graphics.. + index += (sprite.vertexData.length / 2) * this.vertSize; + indexCount += sprite.indices.length; + } - interactionManager.dispatchEvent(e.target.displayObject, 'click', interactionManager.eventData); - }; + BaseTexture._globalBatch = TICK; - /** - * Maps the div focus events to pixi's InteractionManager (mouseover) - * - * @private - * @param {FocusEvent} e - The focus event. - */ - - - AccessibilityManager.prototype._onFocus = function _onFocus(e) { - if (!e.target.getAttribute('aria-live', 'off')) { - e.target.setAttribute('aria-live', 'assertive'); - } - var interactionManager = this.renderer.plugins.interaction; - - interactionManager.dispatchEvent(e.target.displayObject, 'mouseover', interactionManager.eventData); - }; - - /** - * Maps the div focus events to pixi's InteractionManager (mouseout) - * - * @private - * @param {FocusEvent} e - The focusout event. - */ - - - AccessibilityManager.prototype._onFocusOut = function _onFocusOut(e) { - if (!e.target.getAttribute('aria-live', 'off')) { - e.target.setAttribute('aria-live', 'polite'); - } - var interactionManager = this.renderer.plugins.interaction; - - interactionManager.dispatchEvent(e.target.displayObject, 'mouseout', interactionManager.eventData); - }; - - /** - * Is called when a key is pressed - * - * @private - * @param {KeyboardEvent} e - The keydown event. - */ - - - AccessibilityManager.prototype._onKeyDown = function _onKeyDown(e) { - if (e.keyCode !== KEY_CODE_TAB) { - return; - } - - this.activate(); - }; - - /** - * Is called when the mouse moves across the renderer element - * - * @private - * @param {MouseEvent} e - The mouse event. - */ - - - AccessibilityManager.prototype._onMouseMove = function _onMouseMove(e) { - if (e.movementX === 0 && e.movementY === 0) { - return; - } - - this.deactivate(); - }; - - /** - * Destroys the accessibility manager - * - */ - - - AccessibilityManager.prototype.destroy = function destroy() { - this.div = null; - - for (var i = 0; i < this.children.length; i++) { - this.children[i].div = null; - } - - window.document.removeEventListener('mousemove', this._onMouseMove, true); - window.removeEventListener('keydown', this._onKeyDown); - - this.pool = null; - this.children = null; - this.renderer = null; - }; - - return AccessibilityManager; -}(); - -exports.default = AccessibilityManager; + currentGroup.size = indexCount - currentGroup.start; + // this.indexBuffer.update(); -core.WebGLRenderer.registerPlugin('accessibility', AccessibilityManager); -core.CanvasRenderer.registerPlugin('accessibility', AccessibilityManager); + if (!settings.CAN_UPLOAD_SAME_BUFFER) + { + // this is still needed for IOS performance.. + // it really does not like uploading to the same buffer in a single frame! + if (this.vaoMax <= this.vertexCount) + { + this.vaoMax++; + /* eslint-disable max-len */ + this.vaos[this.vertexCount] = new BatchGeometry(); + } + + this.vaos[this.vertexCount]._buffer.update(buffer.vertices, 0); + this.vaos[this.vertexCount]._indexBuffer.update(indexBuffer, 0); + + // this.vertexBuffers[this.vertexCount].update(buffer.vertices, 0); + this.renderer.geometry.bind(this.vaos[this.vertexCount]); + + this.renderer.geometry.updateBuffers(); + + this.vertexCount++; + } + else + { + // lets use the faster option, always use buffer number 0 + this.vaos[this.vertexCount]._buffer.update(buffer.vertices, 0); + this.vaos[this.vertexCount]._indexBuffer.update(indexBuffer, 0); + + // if (true)// this.spriteOnly) + // { + // this.vaos[this.vertexCount].indexBuffer = this.defualtSpriteIndexBuffer; + // this.vaos[this.vertexCount].buffers[1] = this.defualtSpriteIndexBuffer; + // } + + this.renderer.geometry.updateBuffers(); + } + + // this.renderer.state.set(this.state); + + var textureSystem = this.renderer.texture; + var stateSystem = this.renderer.state; + // e.log(groupCount); + // / render the groups.. + + for (i = 0; i < groupCount; i++) + { + var group = groups[i]; + var groupTextureCount = group.textureCount; + + for (var j = 0; j < groupTextureCount; j++) + { + textureSystem.bind(group.textures[j], j); + group.textures[j] = null; + } + + // this.state.blendMode = group.blend; + // this.state.blend = true; + + // this.renderer.state.setState(this.state); + // set the blend mode.. + stateSystem.setBlendMode(group.blend); + + gl.drawElements(group.type, group.size, gl.UNSIGNED_SHORT, group.start * 2); + } + + // reset elements for the next flush + this.currentIndex = 0; + this.currentSize = 0; + this.currentIndexSize = 0; + }; + + BatchRenderer.prototype.packGeometry = function packGeometry (element, float32View, uint32View, indexBuffer, index, indexCount) + { + var p = index / this.vertSize;// float32View.length / 6 / 2; + var uvs = element.uvs; + var indicies = element.indices;// geometry.getIndex().data;// indicies; + var vertexData = element.vertexData; + var textureId = element._texture.baseTexture._id; + + var alpha = Math.min(element.worldAlpha, 1.0); + + var argb = alpha < 1.0 && element._texture.baseTexture.premultiplyAlpha ? premultiplyTint(element._tintRGB, alpha) + : element._tintRGB + (alpha * 255 << 24); + + // lets not worry about tint! for now.. + for (var i = 0; i < vertexData.length; i += 2) + { + float32View[index++] = vertexData[i]; + float32View[index++] = vertexData[i + 1]; + float32View[index++] = uvs[i]; + float32View[index++] = uvs[i + 1]; + uint32View[index++] = argb; + float32View[index++] = textureId; + } + + for (var i$1 = 0; i$1 < indicies.length; i$1++) + { + indexBuffer[indexCount++] = p + indicies[i$1]; + } + }; + /* + renderQuad(vertexData, uvs, argb, textureId, float32View, uint32View, indexBuffer, index, indexCount) + { + const p = index / 6; + + float32View[index++] = vertexData[0]; + float32View[index++] = vertexData[1]; + float32View[index++] = uvs.x0; + float32View[index++] = uvs.y0; + uint32View[index++] = argb; + float32View[index++] = textureId; + + float32View[index++] = vertexData[2]; + float32View[index++] = vertexData[3]; + float32View[index++] = uvs.x1; + float32View[index++] = uvs.y1; + uint32View[index++] = argb; + float32View[index++] = textureId; + + float32View[index++] = vertexData[4]; + float32View[index++] = vertexData[5]; + float32View[index++] = uvs.x2; + float32View[index++] = uvs.y2; + uint32View[index++] = argb; + float32View[index++] = textureId; + + float32View[index++] = vertexData[6]; + float32View[index++] = vertexData[7]; + float32View[index++] = uvs.x3; + float32View[index++] = uvs.y3; + uint32View[index++] = argb; + float32View[index++] = textureId; + + indexBuffer[indexCount++] = p + 0; + indexBuffer[indexCount++] = p + 1; + indexBuffer[indexCount++] = p + 2; + indexBuffer[indexCount++] = p + 0; + indexBuffer[indexCount++] = p + 2; + indexBuffer[indexCount++] = p + 3; + } + */ + /** + * Starts a new sprite batch. + */ + BatchRenderer.prototype.start = function start () + { + this.renderer.state.setState(this.state); + + this.renderer.shader.bind(this.shader); + + if (settings.CAN_UPLOAD_SAME_BUFFER) + { + // bind buffer #0, we don't need others + this.renderer.geometry.bind(this.vaos[this.vertexCount]); + } + }; + + /** + * Stops and flushes the current batch. + * + */ + BatchRenderer.prototype.stop = function stop () + { + this.flush(); + }; + + /** + * Destroys the SpriteRenderer. + * + */ + BatchRenderer.prototype.destroy = function destroy () + { + for (var i = 0; i < this.vaoMax; i++) + { + // if (this.vertexBuffers[i]) + // { + // this.vertexBuffers[i].destroy(); + // } + if (this.vaos[i]) + { + this.vaos[i].destroy(); + } + } + + if (this.indexBuffer) + { + this.indexBuffer.destroy(); + } + + this.renderer.off('prerender', this.onPrerender, this); + + if (this.shader) + { + this.shader.destroy(); + this.shader = null; + } + + // this.vertexBuffers = null; + this.vaos = null; + this.indexBuffer = null; + this.indices = null; + this.sprites = null; + + // for (let i = 0; i < this.buffers.length; ++i) + // { + // this.buffers[i].destroy(); + // } + + ObjectRenderer.prototype.destroy.call(this); + }; + + return BatchRenderer; + }(ObjectRenderer)); + + /*! + * @pixi/extract - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/extract is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var TEMP_RECT = new Rectangle(); + var BYTES_PER_PIXEL = 4; + + /** + * The extract manager provides functionality to export content from the renderers. + * + * An instance of this class is automatically created by default, and can be found at `renderer.plugins.extract` + * + * @class + * @memberof PIXI.extract + */ + var Extract = function Extract(renderer) + { + this.renderer = renderer; + /** + * Collection of methods for extracting data (image, pixels, etc.) from a display object or render texture + * + * @member {PIXI.extract.Extract} extract + * @memberof PIXI.Renderer# + * @see PIXI.extract.Extract + */ + renderer.extract = this; + }; + + /** + * Will return a HTML Image of the target + * + * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture + * to convert. If left empty will use the main renderer + * @param {string} [format] - Image format, e.g. "image/jpeg" or "image/webp". + * @param {number} [quality] - JPEG or Webp compression from 0 to 1. Default is 0.92. + * @return {HTMLImageElement} HTML Image of the target + */ + Extract.prototype.image = function image (target, format, quality) + { + var image = new Image(); + + image.src = this.base64(target, format, quality); + + return image; + }; + + /** + * Will return a a base64 encoded string of this target. It works by calling + * `Extract.getCanvas` and then running toDataURL on that. + * + * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture + * to convert. If left empty will use the main renderer + * @param {string} [format] - Image format, e.g. "image/jpeg" or "image/webp". + * @param {number} [quality] - JPEG or Webp compression from 0 to 1. Default is 0.92. + * @return {string} A base64 encoded string of the texture. + */ + Extract.prototype.base64 = function base64 (target, format, quality) + { + return this.canvas(target).toDataURL(format, quality); + }; + + /** + * Creates a Canvas element, renders this target to it and then returns it. + * + * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture + * to convert. If left empty will use the main renderer + * @return {HTMLCanvasElement} A Canvas element with the texture rendered on. + */ + Extract.prototype.canvas = function canvas (target) + { + var renderer = this.renderer; + var resolution; + var frame; + var flipY = false; + var renderTexture; + var generated = false; + + if (target) + { + if (target instanceof RenderTexture) + { + renderTexture = target; + } + else + { + renderTexture = this.renderer.generateTexture(target); + generated = true; + } + } + + if (renderTexture) + { + resolution = renderTexture.baseTexture.resolution; + frame = renderTexture.frame; + flipY = false; + renderer.renderTexture.bind(renderTexture); + } + else + { + resolution = this.renderer.resolution; + + flipY = true; + + frame = TEMP_RECT; + frame.width = this.renderer.width; + frame.height = this.renderer.height; + + renderer.renderTexture.bind(null); + } + + var width = frame.width * resolution; + var height = frame.height * resolution; + + var canvasBuffer = new CanvasRenderTarget(width, height, 1); + + var webglPixels = new Uint8Array(BYTES_PER_PIXEL * width * height); + + // read pixels to the array + var gl = renderer.gl; + + gl.readPixels( + frame.x * resolution, + frame.y * resolution, + width, + height, + gl.RGBA, + gl.UNSIGNED_BYTE, + webglPixels + ); + + // add the pixels to the canvas + var canvasData = canvasBuffer.context.getImageData(0, 0, width, height); + + canvasData.data.set(webglPixels); + + canvasBuffer.context.putImageData(canvasData, 0, 0); + + // pulling pixels + if (flipY) + { + canvasBuffer.context.scale(1, -1); + canvasBuffer.context.drawImage(canvasBuffer.canvas, 0, -height); + } + + if (generated) + { + renderTexture.destroy(true); + } + + // send the canvas back.. + return canvasBuffer.canvas; + }; + + /** + * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA + * order, with integer values between 0 and 255 (included). + * + * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture + * to convert. If left empty will use the main renderer + * @return {Uint8ClampedArray} One-dimensional array containing the pixel data of the entire texture + */ + Extract.prototype.pixels = function pixels (target) + { + var renderer = this.renderer; + var resolution; + var frame; + var renderTexture; + var generated = false; + + if (target) + { + if (target instanceof RenderTexture) + { + renderTexture = target; + } + else + { + renderTexture = this.renderer.generateTexture(target); + generated = true; + } + } + + if (renderTexture) + { + resolution = renderTexture.baseTexture.resolution; + frame = renderTexture.frame; + + // bind the buffer + renderer.renderTexture.bind(renderTexture); + } + else + { + resolution = renderer.resolution; + + frame = TEMP_RECT; + frame.width = renderer.width; + frame.height = renderer.height; + + renderer.renderTexture.bind(null); + } + + var width = frame.width * resolution; + var height = frame.height * resolution; + + var webglPixels = new Uint8Array(BYTES_PER_PIXEL * width * height); + + // read pixels to the array + var gl = renderer.gl; + + gl.readPixels( + frame.x * resolution, + frame.y * resolution, + width, + height, + gl.RGBA, + gl.UNSIGNED_BYTE, + webglPixels + ); + + if (generated) + { + renderTexture.destroy(true); + } + + return webglPixels; + }; + + /** + * Destroys the extract + * + */ + Extract.prototype.destroy = function destroy () + { + this.renderer.extract = null; + this.renderer = null; + }; + + var extract_es = ({ + Extract: Extract + }); + + /*! + * @pixi/interaction - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/interaction is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Holds all information related to an Interaction event + * + * @class + * @memberof PIXI.interaction + */ + var InteractionData = function InteractionData() + { + /** + * This point stores the global coords of where the touch/mouse event happened + * + * @member {PIXI.Point} + */ + this.global = new Point(); + + /** + * The target Sprite that was interacted with + * + * @member {PIXI.Sprite} + */ + this.target = null; + + /** + * When passed to an event handler, this will be the original DOM Event that was captured + * + * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent + * @see https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent + * @member {MouseEvent|TouchEvent|PointerEvent} + */ + this.originalEvent = null; + + /** + * Unique identifier for this interaction + * + * @member {number} + */ + this.identifier = null; + + /** + * Indicates whether or not the pointer device that created the event is the primary pointer. + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary + * @type {Boolean} + */ + this.isPrimary = false; + + /** + * Indicates which button was pressed on the mouse or pointer device to trigger the event. + * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button + * @type {number} + */ + this.button = 0; + + /** + * Indicates which buttons are pressed on the mouse or pointer device when the event is triggered. + * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons + * @type {number} + */ + this.buttons = 0; + + /** + * The width of the pointer's contact along the x-axis, measured in CSS pixels. + * radiusX of TouchEvents will be represented by this value. + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width + * @type {number} + */ + this.width = 0; + + /** + * The height of the pointer's contact along the y-axis, measured in CSS pixels. + * radiusY of TouchEvents will be represented by this value. + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height + * @type {number} + */ + this.height = 0; + + /** + * The angle, in degrees, between the pointer device and the screen. + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX + * @type {number} + */ + this.tiltX = 0; + + /** + * The angle, in degrees, between the pointer device and the screen. + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY + * @type {number} + */ + this.tiltY = 0; + + /** + * The type of pointer that triggered the event. + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType + * @type {string} + */ + this.pointerType = null; + + /** + * Pressure applied by the pointing device during the event. A Touch's force property + * will be represented by this value. + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure + * @type {number} + */ + this.pressure = 0; + + /** + * From TouchEvents (not PointerEvents triggered by touches), the rotationAngle of the Touch. + * @see https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle + * @type {number} + */ + this.rotationAngle = 0; + + /** + * Twist of a stylus pointer. + * @see https://w3c.github.io/pointerevents/#pointerevent-interface + * @type {number} + */ + this.twist = 0; + + /** + * Barrel pressure on a stylus pointer. + * @see https://w3c.github.io/pointerevents/#pointerevent-interface + * @type {number} + */ + this.tangentialPressure = 0; + }; + + var prototypeAccessors$6 = { pointerId: { configurable: true } }; + + /** + * The unique identifier of the pointer. It will be the same as `identifier`. + * @readonly + * @member {number} + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId + */ + prototypeAccessors$6.pointerId.get = function () + { + return this.identifier; + }; + + /** + * This will return the local coordinates of the specified displayObject for this InteractionData + * + * @param {PIXI.DisplayObject} displayObject - The DisplayObject that you would like the local + * coords off + * @param {PIXI.Point} [point] - A Point object in which to store the value, optional (otherwise + * will create a new point) + * @param {PIXI.Point} [globalPos] - A Point object containing your custom global coords, optional + * (otherwise will use the current global coords) + * @return {PIXI.Point} A point containing the coordinates of the InteractionData position relative + * to the DisplayObject + */ + InteractionData.prototype.getLocalPosition = function getLocalPosition (displayObject, point, globalPos) + { + return displayObject.worldTransform.applyInverse(globalPos || this.global, point); + }; + + /** + * Copies properties from normalized event data. + * + * @param {Touch|MouseEvent|PointerEvent} event The normalized event data + */ + InteractionData.prototype.copyEvent = function copyEvent (event) + { + // isPrimary should only change on touchstart/pointerdown, so we don't want to overwrite + // it with "false" on later events when our shim for it on touch events might not be + // accurate + if (event.isPrimary) + { + this.isPrimary = true; + } + this.button = event.button; + // event.buttons is not available in all browsers (ie. Safari), but it does have a non-standard + // event.which property instead, which conveys the same information. + this.buttons = Number.isInteger(event.buttons) ? event.buttons : event.which; + this.width = event.width; + this.height = event.height; + this.tiltX = event.tiltX; + this.tiltY = event.tiltY; + this.pointerType = event.pointerType; + this.pressure = event.pressure; + this.rotationAngle = event.rotationAngle; + this.twist = event.twist || 0; + this.tangentialPressure = event.tangentialPressure || 0; + }; + + /** + * Resets the data for pooling. + */ + InteractionData.prototype.reset = function reset () + { + // isPrimary is the only property that we really need to reset - everything else is + // guaranteed to be overwritten + this.isPrimary = false; + }; + + Object.defineProperties( InteractionData.prototype, prototypeAccessors$6 ); + + /** + * Event class that mimics native DOM events. + * + * @class + * @memberof PIXI.interaction + */ + var InteractionEvent = function InteractionEvent() + { + /** + * Whether this event will continue propagating in the tree + * + * @member {boolean} + */ + this.stopped = false; + + /** + * The object which caused this event to be dispatched. + * For listener callback see {@link PIXI.interaction.InteractionEvent.currentTarget}. + * + * @member {PIXI.DisplayObject} + */ + this.target = null; + + /** + * The object whose event listener’s callback is currently being invoked. + * + * @member {PIXI.DisplayObject} + */ + this.currentTarget = null; + + /** + * Type of the event + * + * @member {string} + */ + this.type = null; + + /** + * InteractionData related to this event + * + * @member {PIXI.interaction.InteractionData} + */ + this.data = null; + }; + + /** + * Prevents event from reaching any objects other than the current object. + * + */ + InteractionEvent.prototype.stopPropagation = function stopPropagation () + { + this.stopped = true; + }; + + /** + * Resets the event. + */ + InteractionEvent.prototype.reset = function reset () + { + this.stopped = false; + this.currentTarget = null; + this.target = null; + }; + + /** + * DisplayObjects with the {@link PIXI.interaction.interactiveTarget} mixin use this class to track interactions + * + * @class + * @private + * @memberof PIXI.interaction + */ + var InteractionTrackingData = function InteractionTrackingData(pointerId) + { + this._pointerId = pointerId; + this._flags = InteractionTrackingData.FLAGS.NONE; + }; + + var prototypeAccessors$1$3 = { pointerId: { configurable: true },flags: { configurable: true },none: { configurable: true },over: { configurable: true },rightDown: { configurable: true },leftDown: { configurable: true } }; + + /** + * + * @private + * @param {number} flag - The interaction flag to set + * @param {boolean} yn - Should the flag be set or unset + */ + InteractionTrackingData.prototype._doSet = function _doSet (flag, yn) + { + if (yn) + { + this._flags = this._flags | flag; + } + else + { + this._flags = this._flags & (~flag); + } + }; + + /** + * Unique pointer id of the event + * + * @readonly + * @private + * @member {number} + */ + prototypeAccessors$1$3.pointerId.get = function () + { + return this._pointerId; + }; + + /** + * State of the tracking data, expressed as bit flags + * + * @private + * @member {number} + */ + prototypeAccessors$1$3.flags.get = function () + { + return this._flags; + }; + + prototypeAccessors$1$3.flags.set = function (flags) // eslint-disable-line require-jsdoc + { + this._flags = flags; + }; + + /** + * Is the tracked event inactive (not over or down)? + * + * @private + * @member {number} + */ + prototypeAccessors$1$3.none.get = function () + { + return this._flags === this.constructor.FLAGS.NONE; + }; + + /** + * Is the tracked event over the DisplayObject? + * + * @private + * @member {boolean} + */ + prototypeAccessors$1$3.over.get = function () + { + return (this._flags & this.constructor.FLAGS.OVER) !== 0; + }; + + prototypeAccessors$1$3.over.set = function (yn) // eslint-disable-line require-jsdoc + { + this._doSet(this.constructor.FLAGS.OVER, yn); + }; + + /** + * Did the right mouse button come down in the DisplayObject? + * + * @private + * @member {boolean} + */ + prototypeAccessors$1$3.rightDown.get = function () + { + return (this._flags & this.constructor.FLAGS.RIGHT_DOWN) !== 0; + }; + + prototypeAccessors$1$3.rightDown.set = function (yn) // eslint-disable-line require-jsdoc + { + this._doSet(this.constructor.FLAGS.RIGHT_DOWN, yn); + }; + + /** + * Did the left mouse button come down in the DisplayObject? + * + * @private + * @member {boolean} + */ + prototypeAccessors$1$3.leftDown.get = function () + { + return (this._flags & this.constructor.FLAGS.LEFT_DOWN) !== 0; + }; + + prototypeAccessors$1$3.leftDown.set = function (yn) // eslint-disable-line require-jsdoc + { + this._doSet(this.constructor.FLAGS.LEFT_DOWN, yn); + }; + + Object.defineProperties( InteractionTrackingData.prototype, prototypeAccessors$1$3 ); + + InteractionTrackingData.FLAGS = Object.freeze({ + NONE: 0, + OVER: 1 << 0, + LEFT_DOWN: 1 << 1, + RIGHT_DOWN: 1 << 2, + }); + + /** + * Default property values of interactive objects + * Used by {@link PIXI.interaction.InteractionManager} to automatically give all DisplayObjects these properties + * + * @private + * @name interactiveTarget + * @type {Object} + * @memberof PIXI.interaction + * @example + * function MyObject() {} + * + * Object.assign( + * DisplayObject.prototype, + * PIXI.interaction.interactiveTarget + * ); + */ + var interactiveTarget = { + + /** + * Enable interaction events for the DisplayObject. Touch, pointer and mouse + * events will not be emitted unless `interactive` is set to `true`. + * + * @example + * const sprite = new PIXI.Sprite(texture); + * sprite.interactive = true; + * sprite.on('tap', (event) => { + * //handle event + * }); + * @member {boolean} + * @memberof PIXI.DisplayObject# + */ + interactive: false, + + /** + * Determines if the children to the displayObject can be clicked/touched + * Setting this to false allows PixiJS to bypass a recursive `hitTest` function + * + * @member {boolean} + * @memberof PIXI.Container# + */ + interactiveChildren: true, + + /** + * Interaction shape. Children will be hit first, then this shape will be checked. + * Setting this will cause this shape to be checked in hit tests rather than the displayObject's bounds. + * + * @example + * const sprite = new PIXI.Sprite(texture); + * sprite.interactive = true; + * sprite.hitArea = new PIXI.Rectangle(0, 0, 100, 100); + * @member {PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle} + * @memberof PIXI.DisplayObject# + */ + hitArea: null, + + /** + * If enabled, the mouse cursor use the pointer behavior when hovered over the displayObject if it is interactive + * Setting this changes the 'cursor' property to `'pointer'`. + * + * @example + * const sprite = new PIXI.Sprite(texture); + * sprite.interactive = true; + * sprite.buttonMode = true; + * @member {boolean} + * @memberof PIXI.DisplayObject# + */ + get buttonMode() + { + return this.cursor === 'pointer'; + }, + set buttonMode(value) + { + if (value) + { + this.cursor = 'pointer'; + } + else if (this.cursor === 'pointer') + { + this.cursor = null; + } + }, + + /** + * This defines what cursor mode is used when the mouse cursor + * is hovered over the displayObject. + * + * @example + * const sprite = new PIXI.Sprite(texture); + * sprite.interactive = true; + * sprite.cursor = 'wait'; + * @see https://developer.mozilla.org/en/docs/Web/CSS/cursor + * + * @member {string} + * @memberof PIXI.DisplayObject# + */ + cursor: null, + + /** + * Internal set of all active pointers, by identifier + * + * @member {Map} + * @memberof PIXI.DisplayObject# + * @private + */ + get trackedPointers() + { + if (this._trackedPointers === undefined) { this._trackedPointers = {}; } + + return this._trackedPointers; + }, + + /** + * Map of all tracked pointers, by identifier. Use trackedPointers to access. + * + * @private + * @type {Map} + */ + _trackedPointers: undefined, + }; + + // Mix interactiveTarget into DisplayObject.prototype, + // after deprecation has been handled + DisplayObject.mixin(interactiveTarget); + + var MOUSE_POINTER_ID = 1; + + // helpers for hitTest() - only used inside hitTest() + var hitTestEvent = { + target: null, + data: { + global: null, + }, + }; + + /** + * The interaction manager deals with mouse, touch and pointer events. + * + * Any DisplayObject can be interactive if its `interactive` property is set to true. + * + * This manager also supports multitouch. + * + * An instance of this class is automatically created by default, and can be found at `renderer.plugins.interaction` + * + * @class + * @extends PIXI.utils.EventEmitter + * @memberof PIXI.interaction + */ + var InteractionManager = /*@__PURE__*/(function (EventEmitter) { + function InteractionManager(renderer, options) + { + EventEmitter.call(this); + + options = options || {}; + + /** + * The renderer this interaction manager works for. + * + * @member {PIXI.AbstractRenderer} + */ + this.renderer = renderer; + + /** + * Should default browser actions automatically be prevented. + * Does not apply to pointer events for backwards compatibility + * preventDefault on pointer events stops mouse events from firing + * Thus, for every pointer event, there will always be either a mouse of touch event alongside it. + * + * @member {boolean} + * @default true + */ + this.autoPreventDefault = options.autoPreventDefault !== undefined ? options.autoPreventDefault : true; + + /** + * Frequency in milliseconds that the mousemove, mouseover & mouseout interaction events will be checked. + * + * @member {number} + * @default 10 + */ + this.interactionFrequency = options.interactionFrequency || 10; + + /** + * The mouse data + * + * @member {PIXI.interaction.InteractionData} + */ + this.mouse = new InteractionData(); + this.mouse.identifier = MOUSE_POINTER_ID; + + // setting the mouse to start off far off screen will mean that mouse over does + // not get called before we even move the mouse. + this.mouse.global.set(-999999); + + /** + * Actively tracked InteractionData + * + * @private + * @member {Object.} + */ + this.activeInteractionData = {}; + this.activeInteractionData[MOUSE_POINTER_ID] = this.mouse; + + /** + * Pool of unused InteractionData + * + * @private + * @member {PIXI.interaction.InteractionData[]} + */ + this.interactionDataPool = []; + + /** + * An event data object to handle all the event tracking/dispatching + * + * @member {object} + */ + this.eventData = new InteractionEvent(); + + /** + * The DOM element to bind to. + * + * @protected + * @member {HTMLElement} + */ + this.interactionDOMElement = null; + + /** + * This property determines if mousemove and touchmove events are fired only when the cursor + * is over the object. + * Setting to true will make things work more in line with how the DOM version works. + * Setting to false can make things easier for things like dragging + * It is currently set to false as this is how PixiJS used to work. This will be set to true in + * future versions of pixi. + * + * @member {boolean} + * @default false + */ + this.moveWhenInside = false; + + /** + * Have events been attached to the dom element? + * + * @protected + * @member {boolean} + */ + this.eventsAdded = false; + + /** + * Is the mouse hovering over the renderer? + * + * @protected + * @member {boolean} + */ + this.mouseOverRenderer = false; + + /** + * Does the device support touch events + * https://www.w3.org/TR/touch-events/ + * + * @readonly + * @member {boolean} + */ + this.supportsTouchEvents = 'ontouchstart' in window; + + /** + * Does the device support pointer events + * https://www.w3.org/Submission/pointer-events/ + * + * @readonly + * @member {boolean} + */ + this.supportsPointerEvents = !!window.PointerEvent; + + // this will make it so that you don't have to call bind all the time + + /** + * @private + * @member {Function} + */ + this.onPointerUp = this.onPointerUp.bind(this); + this.processPointerUp = this.processPointerUp.bind(this); + + /** + * @private + * @member {Function} + */ + this.onPointerCancel = this.onPointerCancel.bind(this); + this.processPointerCancel = this.processPointerCancel.bind(this); + + /** + * @private + * @member {Function} + */ + this.onPointerDown = this.onPointerDown.bind(this); + this.processPointerDown = this.processPointerDown.bind(this); + + /** + * @private + * @member {Function} + */ + this.onPointerMove = this.onPointerMove.bind(this); + this.processPointerMove = this.processPointerMove.bind(this); + + /** + * @private + * @member {Function} + */ + this.onPointerOut = this.onPointerOut.bind(this); + this.processPointerOverOut = this.processPointerOverOut.bind(this); + + /** + * @private + * @member {Function} + */ + this.onPointerOver = this.onPointerOver.bind(this); + + /** + * Dictionary of how different cursor modes are handled. Strings are handled as CSS cursor + * values, objects are handled as dictionaries of CSS values for interactionDOMElement, + * and functions are called instead of changing the CSS. + * Default CSS cursor values are provided for 'default' and 'pointer' modes. + * @member {Object.} + */ + this.cursorStyles = { + default: 'inherit', + pointer: 'pointer', + }; + + /** + * The mode of the cursor that is being used. + * The value of this is a key from the cursorStyles dictionary. + * + * @member {string} + */ + this.currentCursorMode = null; + + /** + * Internal cached let. + * + * @private + * @member {string} + */ + this.cursor = null; + + /** + * Internal cached let. + * + * @private + * @member {PIXI.Point} + */ + this._tempPoint = new Point(); + + /** + * The current resolution / device pixel ratio. + * + * @member {number} + * @default 1 + */ + this.resolution = 1; + + /** + * Fired when a pointer device button (usually a mouse left-button) is pressed on the display + * object. + * + * @event PIXI.interaction.InteractionManager#mousedown + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device secondary button (usually a mouse right-button) is pressed + * on the display object. + * + * @event PIXI.interaction.InteractionManager#rightdown + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button (usually a mouse left-button) is released over the display + * object. + * + * @event PIXI.interaction.InteractionManager#mouseup + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device secondary button (usually a mouse right-button) is released + * over the display object. + * + * @event PIXI.interaction.InteractionManager#rightup + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button (usually a mouse left-button) is pressed and released on + * the display object. + * + * @event PIXI.interaction.InteractionManager#click + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device secondary button (usually a mouse right-button) is pressed + * and released on the display object. + * + * @event PIXI.interaction.InteractionManager#rightclick + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button (usually a mouse left-button) is released outside the + * display object that initially registered a + * [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown}. + * + * @event PIXI.interaction.InteractionManager#mouseupoutside + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device secondary button (usually a mouse right-button) is released + * outside the display object that initially registered a + * [rightdown]{@link PIXI.interaction.InteractionManager#event:rightdown}. + * + * @event PIXI.interaction.InteractionManager#rightupoutside + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device (usually a mouse) is moved while over the display object + * + * @event PIXI.interaction.InteractionManager#mousemove + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device (usually a mouse) is moved onto the display object + * + * @event PIXI.interaction.InteractionManager#mouseover + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device (usually a mouse) is moved off the display object + * + * @event PIXI.interaction.InteractionManager#mouseout + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button is pressed on the display object. + * + * @event PIXI.interaction.InteractionManager#pointerdown + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button is released over the display object. + * Not always fired when some buttons are held down while others are released. In those cases, + * use [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown} and + * [mouseup]{@link PIXI.interaction.InteractionManager#event:mouseup} instead. + * + * @event PIXI.interaction.InteractionManager#pointerup + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when the operating system cancels a pointer event + * + * @event PIXI.interaction.InteractionManager#pointercancel + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button is pressed and released on the display object. + * + * @event PIXI.interaction.InteractionManager#pointertap + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button is released outside the display object that initially + * registered a [pointerdown]{@link PIXI.interaction.InteractionManager#event:pointerdown}. + * + * @event PIXI.interaction.InteractionManager#pointerupoutside + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device is moved while over the display object + * + * @event PIXI.interaction.InteractionManager#pointermove + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device is moved onto the display object + * + * @event PIXI.interaction.InteractionManager#pointerover + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device is moved off the display object + * + * @event PIXI.interaction.InteractionManager#pointerout + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is placed on the display object. + * + * @event PIXI.interaction.InteractionManager#touchstart + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is removed from the display object. + * + * @event PIXI.interaction.InteractionManager#touchend + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when the operating system cancels a touch + * + * @event PIXI.interaction.InteractionManager#touchcancel + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is placed and removed from the display object. + * + * @event PIXI.interaction.InteractionManager#tap + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is removed outside of the display object that initially + * registered a [touchstart]{@link PIXI.interaction.InteractionManager#event:touchstart}. + * + * @event PIXI.interaction.InteractionManager#touchendoutside + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is moved along the display object. + * + * @event PIXI.interaction.InteractionManager#touchmove + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button (usually a mouse left-button) is pressed on the display. + * object. DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#mousedown + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device secondary button (usually a mouse right-button) is pressed + * on the display object. DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#rightdown + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button (usually a mouse left-button) is released over the display + * object. DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#mouseup + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device secondary button (usually a mouse right-button) is released + * over the display object. DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#rightup + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button (usually a mouse left-button) is pressed and released on + * the display object. DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#click + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device secondary button (usually a mouse right-button) is pressed + * and released on the display object. DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#rightclick + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button (usually a mouse left-button) is released outside the + * display object that initially registered a + * [mousedown]{@link PIXI.DisplayObject#event:mousedown}. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#mouseupoutside + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device secondary button (usually a mouse right-button) is released + * outside the display object that initially registered a + * [rightdown]{@link PIXI.DisplayObject#event:rightdown}. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#rightupoutside + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device (usually a mouse) is moved while over the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#mousemove + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device (usually a mouse) is moved onto the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#mouseover + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device (usually a mouse) is moved off the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#mouseout + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button is pressed on the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#pointerdown + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button is released over the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#pointerup + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when the operating system cancels a pointer event. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#pointercancel + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button is pressed and released on the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#pointertap + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device button is released outside the display object that initially + * registered a [pointerdown]{@link PIXI.DisplayObject#event:pointerdown}. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#pointerupoutside + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device is moved while over the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#pointermove + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device is moved onto the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#pointerover + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a pointer device is moved off the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#pointerout + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is placed on the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#touchstart + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is removed from the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#touchend + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when the operating system cancels a touch. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#touchcancel + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is placed and removed from the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#tap + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is removed outside of the display object that initially + * registered a [touchstart]{@link PIXI.DisplayObject#event:touchstart}. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#touchendoutside + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + /** + * Fired when a touch point is moved along the display object. + * DisplayObject's `interactive` property must be set to `true` to fire event. + * + * @event PIXI.DisplayObject#touchmove + * @param {PIXI.interaction.InteractionEvent} event - Interaction event + */ + + this.setTargetElement(this.renderer.view, this.renderer.resolution); + } + + if ( EventEmitter ) { InteractionManager.__proto__ = EventEmitter; } + InteractionManager.prototype = Object.create( EventEmitter && EventEmitter.prototype ); + InteractionManager.prototype.constructor = InteractionManager; + + /** + * Hit tests a point against the display tree, returning the first interactive object that is hit. + * + * @param {PIXI.Point} globalPoint - A point to hit test with, in global space. + * @param {PIXI.Container} [root] - The root display object to start from. If omitted, defaults + * to the last rendered root of the associated renderer. + * @return {PIXI.DisplayObject} The hit display object, if any. + */ + InteractionManager.prototype.hitTest = function hitTest (globalPoint, root) + { + // clear the target for our hit test + hitTestEvent.target = null; + // assign the global point + hitTestEvent.data.global = globalPoint; + // ensure safety of the root + if (!root) + { + root = this.renderer._lastObjectRendered; + } + // run the hit test + this.processInteractive(hitTestEvent, root, null, true); + // return our found object - it'll be null if we didn't hit anything + + return hitTestEvent.target; + }; + + /** + * Sets the DOM element which will receive mouse/touch events. This is useful for when you have + * other DOM elements on top of the renderers Canvas element. With this you'll be bale to delegate + * another DOM element to receive those events. + * + * @param {HTMLCanvasElement} element - the DOM element which will receive mouse and touch events. + * @param {number} [resolution=1] - The resolution / device pixel ratio of the new element (relative to the canvas). + */ + InteractionManager.prototype.setTargetElement = function setTargetElement (element, resolution) + { + if ( resolution === void 0 ) { resolution = 1; } + + this.removeEvents(); + + this.interactionDOMElement = element; + + this.resolution = resolution; + + this.addEvents(); + }; + + /** + * Registers all the DOM events + * + * @private + */ + InteractionManager.prototype.addEvents = function addEvents () + { + if (!this.interactionDOMElement) + { + return; + } + + Ticker.system.add(this.update, this, UPDATE_PRIORITY.INTERACTION); + + if (window.navigator.msPointerEnabled) + { + this.interactionDOMElement.style['-ms-content-zooming'] = 'none'; + this.interactionDOMElement.style['-ms-touch-action'] = 'none'; + } + else if (this.supportsPointerEvents) + { + this.interactionDOMElement.style['touch-action'] = 'none'; + } + + /** + * These events are added first, so that if pointer events are normalized, they are fired + * in the same order as non-normalized events. ie. pointer event 1st, mouse / touch 2nd + */ + if (this.supportsPointerEvents) + { + window.document.addEventListener('pointermove', this.onPointerMove, true); + this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, true); + // pointerout is fired in addition to pointerup (for touch events) and pointercancel + // we already handle those, so for the purposes of what we do in onPointerOut, we only + // care about the pointerleave event + this.interactionDOMElement.addEventListener('pointerleave', this.onPointerOut, true); + this.interactionDOMElement.addEventListener('pointerover', this.onPointerOver, true); + window.addEventListener('pointercancel', this.onPointerCancel, true); + window.addEventListener('pointerup', this.onPointerUp, true); + } + else + { + window.document.addEventListener('mousemove', this.onPointerMove, true); + this.interactionDOMElement.addEventListener('mousedown', this.onPointerDown, true); + this.interactionDOMElement.addEventListener('mouseout', this.onPointerOut, true); + this.interactionDOMElement.addEventListener('mouseover', this.onPointerOver, true); + window.addEventListener('mouseup', this.onPointerUp, true); + } + + // always look directly for touch events so that we can provide original data + // In a future version we should change this to being just a fallback and rely solely on + // PointerEvents whenever available + if (this.supportsTouchEvents) + { + this.interactionDOMElement.addEventListener('touchstart', this.onPointerDown, true); + this.interactionDOMElement.addEventListener('touchcancel', this.onPointerCancel, true); + this.interactionDOMElement.addEventListener('touchend', this.onPointerUp, true); + this.interactionDOMElement.addEventListener('touchmove', this.onPointerMove, true); + } + + this.eventsAdded = true; + }; + + /** + * Removes all the DOM events that were previously registered + * + * @private + */ + InteractionManager.prototype.removeEvents = function removeEvents () + { + if (!this.interactionDOMElement) + { + return; + } + + Ticker.system.remove(this.update, this); + + if (window.navigator.msPointerEnabled) + { + this.interactionDOMElement.style['-ms-content-zooming'] = ''; + this.interactionDOMElement.style['-ms-touch-action'] = ''; + } + else if (this.supportsPointerEvents) + { + this.interactionDOMElement.style['touch-action'] = ''; + } + + if (this.supportsPointerEvents) + { + window.document.removeEventListener('pointermove', this.onPointerMove, true); + this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, true); + this.interactionDOMElement.removeEventListener('pointerleave', this.onPointerOut, true); + this.interactionDOMElement.removeEventListener('pointerover', this.onPointerOver, true); + window.removeEventListener('pointercancel', this.onPointerCancel, true); + window.removeEventListener('pointerup', this.onPointerUp, true); + } + else + { + window.document.removeEventListener('mousemove', this.onPointerMove, true); + this.interactionDOMElement.removeEventListener('mousedown', this.onPointerDown, true); + this.interactionDOMElement.removeEventListener('mouseout', this.onPointerOut, true); + this.interactionDOMElement.removeEventListener('mouseover', this.onPointerOver, true); + window.removeEventListener('mouseup', this.onPointerUp, true); + } + + if (this.supportsTouchEvents) + { + this.interactionDOMElement.removeEventListener('touchstart', this.onPointerDown, true); + this.interactionDOMElement.removeEventListener('touchcancel', this.onPointerCancel, true); + this.interactionDOMElement.removeEventListener('touchend', this.onPointerUp, true); + this.interactionDOMElement.removeEventListener('touchmove', this.onPointerMove, true); + } + + this.interactionDOMElement = null; + + this.eventsAdded = false; + }; + + /** + * Updates the state of interactive objects. + * Invoked by a throttled ticker update from {@link PIXI.Ticker.system}. + * + * @param {number} deltaTime - time delta since last tick + */ + InteractionManager.prototype.update = function update (deltaTime) + { + this._deltaTime += deltaTime; + + if (this._deltaTime < this.interactionFrequency) + { + return; + } + + this._deltaTime = 0; + + if (!this.interactionDOMElement) + { + return; + } + + // if the user move the mouse this check has already been done using the mouse move! + if (this.didMove) + { + this.didMove = false; + + return; + } + + this.cursor = null; + + // Resets the flag as set by a stopPropagation call. This flag is usually reset by a user interaction of any kind, + // but there was a scenario of a display object moving under a static mouse cursor. + // In this case, mouseover and mouseevents would not pass the flag test in dispatchEvent function + for (var k in this.activeInteractionData) + { + // eslint-disable-next-line no-prototype-builtins + if (this.activeInteractionData.hasOwnProperty(k)) + { + var interactionData = this.activeInteractionData[k]; + + if (interactionData.originalEvent && interactionData.pointerType !== 'touch') + { + var interactionEvent = this.configureInteractionEventForDOMEvent( + this.eventData, + interactionData.originalEvent, + interactionData + ); + + this.processInteractive( + interactionEvent, + this.renderer._lastObjectRendered, + this.processPointerOverOut, + true + ); + } + } + } + + this.setCursorMode(this.cursor); + + // TODO + }; + + /** + * Sets the current cursor mode, handling any callbacks or CSS style changes. + * + * @param {string} mode - cursor mode, a key from the cursorStyles dictionary + */ + InteractionManager.prototype.setCursorMode = function setCursorMode (mode) + { + mode = mode || 'default'; + // if the mode didn't actually change, bail early + if (this.currentCursorMode === mode) + { + return; + } + this.currentCursorMode = mode; + var style = this.cursorStyles[mode]; + + // only do things if there is a cursor style for it + if (style) + { + switch (typeof style) + { + case 'string': + // string styles are handled as cursor CSS + this.interactionDOMElement.style.cursor = style; + break; + case 'function': + // functions are just called, and passed the cursor mode + style(mode); + break; + case 'object': + // if it is an object, assume that it is a dictionary of CSS styles, + // apply it to the interactionDOMElement + Object.assign(this.interactionDOMElement.style, style); + break; + } + } + else if (typeof mode === 'string' && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) + { + // if it mode is a string (not a Symbol) and cursorStyles doesn't have any entry + // for the mode, then assume that the dev wants it to be CSS for the cursor. + this.interactionDOMElement.style.cursor = mode; + } + }; + + /** + * Dispatches an event on the display object that was interacted with + * + * @param {PIXI.Container|PIXI.Sprite|PIXI.TilingSprite} displayObject - the display object in question + * @param {string} eventString - the name of the event (e.g, mousedown) + * @param {object} eventData - the event data object + * @private + */ + InteractionManager.prototype.dispatchEvent = function dispatchEvent (displayObject, eventString, eventData) + { + if (!eventData.stopped) + { + eventData.currentTarget = displayObject; + eventData.type = eventString; + + displayObject.emit(eventString, eventData); + + if (displayObject[eventString]) + { + displayObject[eventString](eventData); + } + } + }; + + /** + * Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The + * resulting value is stored in the point. This takes into account the fact that the DOM + * element could be scaled and positioned anywhere on the screen. + * + * @param {PIXI.Point} point - the point that the result will be stored in + * @param {number} x - the x coord of the position to map + * @param {number} y - the y coord of the position to map + */ + InteractionManager.prototype.mapPositionToPoint = function mapPositionToPoint (point, x, y) + { + var rect; + + // IE 11 fix + if (!this.interactionDOMElement.parentElement) + { + rect = { x: 0, y: 0, width: 0, height: 0 }; + } + else + { + rect = this.interactionDOMElement.getBoundingClientRect(); + } + + var resolutionMultiplier = 1.0 / this.resolution; + + point.x = ((x - rect.left) * (this.interactionDOMElement.width / rect.width)) * resolutionMultiplier; + point.y = ((y - rect.top) * (this.interactionDOMElement.height / rect.height)) * resolutionMultiplier; + }; + + /** + * This function is provides a neat way of crawling through the scene graph and running a + * specified function on all interactive objects it finds. It will also take care of hit + * testing the interactive objects and passes the hit across in the function. + * + * @protected + * @param {PIXI.interaction.InteractionEvent} interactionEvent - event containing the point that + * is tested for collision + * @param {PIXI.Container|PIXI.Sprite|PIXI.TilingSprite} displayObject - the displayObject + * that will be hit test (recursively crawls its children) + * @param {Function} [func] - the function that will be called on each interactive object. The + * interactionEvent, displayObject and hit will be passed to the function + * @param {boolean} [hitTest] - this indicates if the objects inside should be hit test against the point + * @param {boolean} [interactive] - Whether the displayObject is interactive + * @return {boolean} returns true if the displayObject hit the point + */ + InteractionManager.prototype.processInteractive = function processInteractive (interactionEvent, displayObject, func, hitTest, interactive) + { + if (!displayObject || !displayObject.visible) + { + return false; + } + + var point = interactionEvent.data.global; + + // Took a little while to rework this function correctly! But now it is done and nice and optimized! ^_^ + // + // This function will now loop through all objects and then only hit test the objects it HAS + // to, not all of them. MUCH faster.. + // An object will be hit test if the following is true: + // + // 1: It is interactive. + // 2: It belongs to a parent that is interactive AND one of the parents children have not already been hit. + // + // As another little optimization once an interactive object has been hit we can carry on + // through the scenegraph, but we know that there will be no more hits! So we can avoid extra hit tests + // A final optimization is that an object is not hit test directly if a child has already been hit. + + interactive = displayObject.interactive || interactive; + + var hit = false; + var interactiveParent = interactive; + + // Flag here can set to false if the event is outside the parents hitArea or mask + var hitTestChildren = true; + + // If there is a hitArea, no need to test against anything else if the pointer is not within the hitArea + // There is also no longer a need to hitTest children. + if (displayObject.hitArea) + { + if (hitTest) + { + displayObject.worldTransform.applyInverse(point, this._tempPoint); + if (!displayObject.hitArea.contains(this._tempPoint.x, this._tempPoint.y)) + { + hitTest = false; + hitTestChildren = false; + } + else + { + hit = true; + } + } + interactiveParent = false; + } + // If there is a mask, no need to hitTest against anything else if the pointer is not within the mask. + // We still want to hitTestChildren, however, to ensure a mouseout can still be generated. + // https://github.com/pixijs/pixi.js/issues/5135 + else if (displayObject._mask) + { + if (hitTest) + { + if (!(displayObject._mask.containsPoint && displayObject._mask.containsPoint(point))) + { + hitTest = false; + } + } + } + + // ** FREE TIP **! If an object is not interactive or has no buttons in it + // (such as a game scene!) set interactiveChildren to false for that displayObject. + // This will allow PixiJS to completely ignore and bypass checking the displayObjects children. + if (hitTestChildren && displayObject.interactiveChildren && displayObject.children) + { + var children = displayObject.children; + + for (var i = children.length - 1; i >= 0; i--) + { + var child = children[i]; + + // time to get recursive.. if this function will return if something is hit.. + var childHit = this.processInteractive(interactionEvent, child, func, hitTest, interactiveParent); + + if (childHit) + { + // its a good idea to check if a child has lost its parent. + // this means it has been removed whilst looping so its best + if (!child.parent) + { + continue; + } + + // we no longer need to hit test any more objects in this container as we we + // now know the parent has been hit + interactiveParent = false; + + // If the child is interactive , that means that the object hit was actually + // interactive and not just the child of an interactive object. + // This means we no longer need to hit test anything else. We still need to run + // through all objects, but we don't need to perform any hit tests. + + if (childHit) + { + if (interactionEvent.target) + { + hitTest = false; + } + hit = true; + } + } + } + } + + // no point running this if the item is not interactive or does not have an interactive parent. + if (interactive) + { + // if we are hit testing (as in we have no hit any objects yet) + // We also don't need to worry about hit testing if once of the displayObjects children + // has already been hit - but only if it was interactive, otherwise we need to keep + // looking for an interactive child, just in case we hit one + if (hitTest && !interactionEvent.target) + { + // already tested against hitArea if it is defined + if (!displayObject.hitArea && displayObject.containsPoint) + { + if (displayObject.containsPoint(point)) + { + hit = true; + } + } + } + + if (displayObject.interactive) + { + if (hit && !interactionEvent.target) + { + interactionEvent.target = displayObject; + } + + if (func) + { + func(interactionEvent, displayObject, !!hit); + } + } + } + + return hit; + }; + + /** + * Is called when the pointer button is pressed down on the renderer element + * + * @private + * @param {PointerEvent} originalEvent - The DOM event of a pointer button being pressed down + */ + InteractionManager.prototype.onPointerDown = function onPointerDown (originalEvent) + { + // if we support touch events, then only use those for touch events, not pointer events + if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') { return; } + + var events = this.normalizeToPointerData(originalEvent); + + /** + * No need to prevent default on natural pointer events, as there are no side effects + * Normalized events, however, may have the double mousedown/touchstart issue on the native android browser, + * so still need to be prevented. + */ + + // Guaranteed that there will be at least one event in events, and all events must have the same pointer type + + if (this.autoPreventDefault && events[0].isNormalized) + { + var cancelable = originalEvent.cancelable || !('cancelable' in originalEvent); + + if (cancelable) + { + originalEvent.preventDefault(); + } + } + + var eventLen = events.length; + + for (var i = 0; i < eventLen; i++) + { + var event = events[i]; + + var interactionData = this.getInteractionDataForPointerId(event); + + var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); + + interactionEvent.data.originalEvent = originalEvent; + + this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerDown, true); + + this.emit('pointerdown', interactionEvent); + if (event.pointerType === 'touch') + { + this.emit('touchstart', interactionEvent); + } + // emit a mouse event for "pen" pointers, the way a browser would emit a fallback event + else if (event.pointerType === 'mouse' || event.pointerType === 'pen') + { + var isRightButton = event.button === 2; + + this.emit(isRightButton ? 'rightdown' : 'mousedown', this.eventData); + } + } + }; + + /** + * Processes the result of the pointer down check and dispatches the event if need be + * + * @private + * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event + * @param {PIXI.Container|PIXI.Sprite|PIXI.TilingSprite} displayObject - The display object that was tested + * @param {boolean} hit - the result of the hit test on the display object + */ + InteractionManager.prototype.processPointerDown = function processPointerDown (interactionEvent, displayObject, hit) + { + var data = interactionEvent.data; + var id = interactionEvent.data.identifier; + + if (hit) + { + if (!displayObject.trackedPointers[id]) + { + displayObject.trackedPointers[id] = new InteractionTrackingData(id); + } + this.dispatchEvent(displayObject, 'pointerdown', interactionEvent); + + if (data.pointerType === 'touch') + { + this.dispatchEvent(displayObject, 'touchstart', interactionEvent); + } + else if (data.pointerType === 'mouse' || data.pointerType === 'pen') + { + var isRightButton = data.button === 2; + + if (isRightButton) + { + displayObject.trackedPointers[id].rightDown = true; + } + else + { + displayObject.trackedPointers[id].leftDown = true; + } + + this.dispatchEvent(displayObject, isRightButton ? 'rightdown' : 'mousedown', interactionEvent); + } + } + }; + + /** + * Is called when the pointer button is released on the renderer element + * + * @private + * @param {PointerEvent} originalEvent - The DOM event of a pointer button being released + * @param {boolean} cancelled - true if the pointer is cancelled + * @param {Function} func - Function passed to {@link processInteractive} + */ + InteractionManager.prototype.onPointerComplete = function onPointerComplete (originalEvent, cancelled, func) + { + var events = this.normalizeToPointerData(originalEvent); + + var eventLen = events.length; + + // if the event wasn't targeting our canvas, then consider it to be pointerupoutside + // in all cases (unless it was a pointercancel) + var eventAppend = originalEvent.target !== this.interactionDOMElement ? 'outside' : ''; + + for (var i = 0; i < eventLen; i++) + { + var event = events[i]; + + var interactionData = this.getInteractionDataForPointerId(event); + + var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); + + interactionEvent.data.originalEvent = originalEvent; + + // perform hit testing for events targeting our canvas or cancel events + this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, func, cancelled || !eventAppend); + + this.emit(cancelled ? 'pointercancel' : ("pointerup" + eventAppend), interactionEvent); + + if (event.pointerType === 'mouse' || event.pointerType === 'pen') + { + var isRightButton = event.button === 2; + + this.emit(isRightButton ? ("rightup" + eventAppend) : ("mouseup" + eventAppend), interactionEvent); + } + else if (event.pointerType === 'touch') + { + this.emit(cancelled ? 'touchcancel' : ("touchend" + eventAppend), interactionEvent); + this.releaseInteractionDataForPointerId(event.pointerId, interactionData); + } + } + }; + + /** + * Is called when the pointer button is cancelled + * + * @private + * @param {PointerEvent} event - The DOM event of a pointer button being released + */ + InteractionManager.prototype.onPointerCancel = function onPointerCancel (event) + { + // if we support touch events, then only use those for touch events, not pointer events + if (this.supportsTouchEvents && event.pointerType === 'touch') { return; } + + this.onPointerComplete(event, true, this.processPointerCancel); + }; + + /** + * Processes the result of the pointer cancel check and dispatches the event if need be + * + * @private + * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event + * @param {PIXI.Container|PIXI.Sprite|PIXI.TilingSprite} displayObject - The display object that was tested + */ + InteractionManager.prototype.processPointerCancel = function processPointerCancel (interactionEvent, displayObject) + { + var data = interactionEvent.data; + + var id = interactionEvent.data.identifier; + + if (displayObject.trackedPointers[id] !== undefined) + { + delete displayObject.trackedPointers[id]; + this.dispatchEvent(displayObject, 'pointercancel', interactionEvent); + + if (data.pointerType === 'touch') + { + this.dispatchEvent(displayObject, 'touchcancel', interactionEvent); + } + } + }; + + /** + * Is called when the pointer button is released on the renderer element + * + * @private + * @param {PointerEvent} event - The DOM event of a pointer button being released + */ + InteractionManager.prototype.onPointerUp = function onPointerUp (event) + { + // if we support touch events, then only use those for touch events, not pointer events + if (this.supportsTouchEvents && event.pointerType === 'touch') { return; } + + this.onPointerComplete(event, false, this.processPointerUp); + }; + + /** + * Processes the result of the pointer up check and dispatches the event if need be + * + * @private + * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event + * @param {PIXI.Container|PIXI.Sprite|PIXI.TilingSprite} displayObject - The display object that was tested + * @param {boolean} hit - the result of the hit test on the display object + */ + InteractionManager.prototype.processPointerUp = function processPointerUp (interactionEvent, displayObject, hit) + { + var data = interactionEvent.data; + + var id = interactionEvent.data.identifier; + + var trackingData = displayObject.trackedPointers[id]; + + var isTouch = data.pointerType === 'touch'; + + var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen'); + // need to track mouse down status in the mouse block so that we can emit + // event in a later block + var isMouseTap = false; + + // Mouse only + if (isMouse) + { + var isRightButton = data.button === 2; + + var flags = InteractionTrackingData.FLAGS; + + var test = isRightButton ? flags.RIGHT_DOWN : flags.LEFT_DOWN; + + var isDown = trackingData !== undefined && (trackingData.flags & test); + + if (hit) + { + this.dispatchEvent(displayObject, isRightButton ? 'rightup' : 'mouseup', interactionEvent); + + if (isDown) + { + this.dispatchEvent(displayObject, isRightButton ? 'rightclick' : 'click', interactionEvent); + // because we can confirm that the mousedown happened on this object, flag for later emit of pointertap + isMouseTap = true; + } + } + else if (isDown) + { + this.dispatchEvent(displayObject, isRightButton ? 'rightupoutside' : 'mouseupoutside', interactionEvent); + } + // update the down state of the tracking data + if (trackingData) + { + if (isRightButton) + { + trackingData.rightDown = false; + } + else + { + trackingData.leftDown = false; + } + } + } + + // Pointers and Touches, and Mouse + if (hit) + { + this.dispatchEvent(displayObject, 'pointerup', interactionEvent); + if (isTouch) { this.dispatchEvent(displayObject, 'touchend', interactionEvent); } + + if (trackingData) + { + // emit pointertap if not a mouse, or if the mouse block decided it was a tap + if (!isMouse || isMouseTap) + { + this.dispatchEvent(displayObject, 'pointertap', interactionEvent); + } + if (isTouch) + { + this.dispatchEvent(displayObject, 'tap', interactionEvent); + // touches are no longer over (if they ever were) when we get the touchend + // so we should ensure that we don't keep pretending that they are + trackingData.over = false; + } + } + } + else if (trackingData) + { + this.dispatchEvent(displayObject, 'pointerupoutside', interactionEvent); + if (isTouch) { this.dispatchEvent(displayObject, 'touchendoutside', interactionEvent); } + } + // Only remove the tracking data if there is no over/down state still associated with it + if (trackingData && trackingData.none) + { + delete displayObject.trackedPointers[id]; + } + }; + + /** + * Is called when the pointer moves across the renderer element + * + * @private + * @param {PointerEvent} originalEvent - The DOM event of a pointer moving + */ + InteractionManager.prototype.onPointerMove = function onPointerMove (originalEvent) + { + // if we support touch events, then only use those for touch events, not pointer events + if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') { return; } + + var events = this.normalizeToPointerData(originalEvent); + + if (events[0].pointerType === 'mouse' || events[0].pointerType === 'pen') + { + this.didMove = true; + + this.cursor = null; + } + + var eventLen = events.length; + + for (var i = 0; i < eventLen; i++) + { + var event = events[i]; + + var interactionData = this.getInteractionDataForPointerId(event); + + var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); + + interactionEvent.data.originalEvent = originalEvent; + + var interactive = event.pointerType === 'touch' ? this.moveWhenInside : true; + + this.processInteractive( + interactionEvent, + this.renderer._lastObjectRendered, + this.processPointerMove, + interactive + ); + this.emit('pointermove', interactionEvent); + if (event.pointerType === 'touch') { this.emit('touchmove', interactionEvent); } + if (event.pointerType === 'mouse' || event.pointerType === 'pen') { this.emit('mousemove', interactionEvent); } + } + + if (events[0].pointerType === 'mouse') + { + this.setCursorMode(this.cursor); + + // TODO BUG for parents interactive object (border order issue) + } + }; + + /** + * Processes the result of the pointer move check and dispatches the event if need be + * + * @private + * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event + * @param {PIXI.Container|PIXI.Sprite|PIXI.TilingSprite} displayObject - The display object that was tested + * @param {boolean} hit - the result of the hit test on the display object + */ + InteractionManager.prototype.processPointerMove = function processPointerMove (interactionEvent, displayObject, hit) + { + var data = interactionEvent.data; + + var isTouch = data.pointerType === 'touch'; + + var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen'); + + if (isMouse) + { + this.processPointerOverOut(interactionEvent, displayObject, hit); + } + + if (!this.moveWhenInside || hit) + { + this.dispatchEvent(displayObject, 'pointermove', interactionEvent); + if (isTouch) { this.dispatchEvent(displayObject, 'touchmove', interactionEvent); } + if (isMouse) { this.dispatchEvent(displayObject, 'mousemove', interactionEvent); } + } + }; + + /** + * Is called when the pointer is moved out of the renderer element + * + * @private + * @param {PointerEvent} originalEvent - The DOM event of a pointer being moved out + */ + InteractionManager.prototype.onPointerOut = function onPointerOut (originalEvent) + { + // if we support touch events, then only use those for touch events, not pointer events + if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') { return; } + + var events = this.normalizeToPointerData(originalEvent); + + // Only mouse and pointer can call onPointerOut, so events will always be length 1 + var event = events[0]; + + if (event.pointerType === 'mouse') + { + this.mouseOverRenderer = false; + this.setCursorMode(null); + } + + var interactionData = this.getInteractionDataForPointerId(event); + + var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); + + interactionEvent.data.originalEvent = event; + + this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerOverOut, false); + + this.emit('pointerout', interactionEvent); + if (event.pointerType === 'mouse' || event.pointerType === 'pen') + { + this.emit('mouseout', interactionEvent); + } + else + { + // we can get touchleave events after touchend, so we want to make sure we don't + // introduce memory leaks + this.releaseInteractionDataForPointerId(interactionData.identifier); + } + }; + + /** + * Processes the result of the pointer over/out check and dispatches the event if need be + * + * @private + * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event + * @param {PIXI.Container|PIXI.Sprite|PIXI.TilingSprite} displayObject - The display object that was tested + * @param {boolean} hit - the result of the hit test on the display object + */ + InteractionManager.prototype.processPointerOverOut = function processPointerOverOut (interactionEvent, displayObject, hit) + { + var data = interactionEvent.data; + + var id = interactionEvent.data.identifier; + + var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen'); + + var trackingData = displayObject.trackedPointers[id]; + + // if we just moused over the display object, then we need to track that state + if (hit && !trackingData) + { + trackingData = displayObject.trackedPointers[id] = new InteractionTrackingData(id); + } + + if (trackingData === undefined) { return; } + + if (hit && this.mouseOverRenderer) + { + if (!trackingData.over) + { + trackingData.over = true; + this.dispatchEvent(displayObject, 'pointerover', interactionEvent); + if (isMouse) + { + this.dispatchEvent(displayObject, 'mouseover', interactionEvent); + } + } + + // only change the cursor if it has not already been changed (by something deeper in the + // display tree) + if (isMouse && this.cursor === null) + { + this.cursor = displayObject.cursor; + } + } + else if (trackingData.over) + { + trackingData.over = false; + this.dispatchEvent(displayObject, 'pointerout', this.eventData); + if (isMouse) + { + this.dispatchEvent(displayObject, 'mouseout', interactionEvent); + } + // if there is no mouse down information for the pointer, then it is safe to delete + if (trackingData.none) + { + delete displayObject.trackedPointers[id]; + } + } + }; + + /** + * Is called when the pointer is moved into the renderer element + * + * @private + * @param {PointerEvent} originalEvent - The DOM event of a pointer button being moved into the renderer view + */ + InteractionManager.prototype.onPointerOver = function onPointerOver (originalEvent) + { + var events = this.normalizeToPointerData(originalEvent); + + // Only mouse and pointer can call onPointerOver, so events will always be length 1 + var event = events[0]; + + var interactionData = this.getInteractionDataForPointerId(event); + + var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); + + interactionEvent.data.originalEvent = event; + + if (event.pointerType === 'mouse') + { + this.mouseOverRenderer = true; + } + + this.emit('pointerover', interactionEvent); + if (event.pointerType === 'mouse' || event.pointerType === 'pen') + { + this.emit('mouseover', interactionEvent); + } + }; + + /** + * Get InteractionData for a given pointerId. Store that data as well + * + * @private + * @param {PointerEvent} event - Normalized pointer event, output from normalizeToPointerData + * @return {PIXI.interaction.InteractionData} - Interaction data for the given pointer identifier + */ + InteractionManager.prototype.getInteractionDataForPointerId = function getInteractionDataForPointerId (event) + { + var pointerId = event.pointerId; + + var interactionData; + + if (pointerId === MOUSE_POINTER_ID || event.pointerType === 'mouse') + { + interactionData = this.mouse; + } + else if (this.activeInteractionData[pointerId]) + { + interactionData = this.activeInteractionData[pointerId]; + } + else + { + interactionData = this.interactionDataPool.pop() || new InteractionData(); + interactionData.identifier = pointerId; + this.activeInteractionData[pointerId] = interactionData; + } + // copy properties from the event, so that we can make sure that touch/pointer specific + // data is available + interactionData.copyEvent(event); + + return interactionData; + }; + + /** + * Return unused InteractionData to the pool, for a given pointerId + * + * @private + * @param {number} pointerId - Identifier from a pointer event + */ + InteractionManager.prototype.releaseInteractionDataForPointerId = function releaseInteractionDataForPointerId (pointerId) + { + var interactionData = this.activeInteractionData[pointerId]; + + if (interactionData) + { + delete this.activeInteractionData[pointerId]; + interactionData.reset(); + this.interactionDataPool.push(interactionData); + } + }; + + /** + * Configure an InteractionEvent to wrap a DOM PointerEvent and InteractionData + * + * @private + * @param {PIXI.interaction.InteractionEvent} interactionEvent - The event to be configured + * @param {PointerEvent} pointerEvent - The DOM event that will be paired with the InteractionEvent + * @param {PIXI.interaction.InteractionData} interactionData - The InteractionData that will be paired + * with the InteractionEvent + * @return {PIXI.interaction.InteractionEvent} the interaction event that was passed in + */ + InteractionManager.prototype.configureInteractionEventForDOMEvent = function configureInteractionEventForDOMEvent (interactionEvent, pointerEvent, interactionData) + { + interactionEvent.data = interactionData; + + this.mapPositionToPoint(interactionData.global, pointerEvent.clientX, pointerEvent.clientY); + + // Not really sure why this is happening, but it's how a previous version handled things + if (pointerEvent.pointerType === 'touch') + { + pointerEvent.globalX = interactionData.global.x; + pointerEvent.globalY = interactionData.global.y; + } + + interactionData.originalEvent = pointerEvent; + interactionEvent.reset(); + + return interactionEvent; + }; + + /** + * Ensures that the original event object contains all data that a regular pointer event would have + * + * @private + * @param {TouchEvent|MouseEvent|PointerEvent} event - The original event data from a touch or mouse event + * @return {PointerEvent[]} An array containing a single normalized pointer event, in the case of a pointer + * or mouse event, or a multiple normalized pointer events if there are multiple changed touches + */ + InteractionManager.prototype.normalizeToPointerData = function normalizeToPointerData (event) + { + var normalizedEvents = []; + + if (this.supportsTouchEvents && event instanceof TouchEvent) + { + for (var i = 0, li = event.changedTouches.length; i < li; i++) + { + var touch = event.changedTouches[i]; + + if (typeof touch.button === 'undefined') { touch.button = event.touches.length ? 1 : 0; } + if (typeof touch.buttons === 'undefined') { touch.buttons = event.touches.length ? 1 : 0; } + if (typeof touch.isPrimary === 'undefined') + { + touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart'; + } + if (typeof touch.width === 'undefined') { touch.width = touch.radiusX || 1; } + if (typeof touch.height === 'undefined') { touch.height = touch.radiusY || 1; } + if (typeof touch.tiltX === 'undefined') { touch.tiltX = 0; } + if (typeof touch.tiltY === 'undefined') { touch.tiltY = 0; } + if (typeof touch.pointerType === 'undefined') { touch.pointerType = 'touch'; } + if (typeof touch.pointerId === 'undefined') { touch.pointerId = touch.identifier || 0; } + if (typeof touch.pressure === 'undefined') { touch.pressure = touch.force || 0.5; } + if (typeof touch.twist === 'undefined') { touch.twist = 0; } + if (typeof touch.tangentialPressure === 'undefined') { touch.tangentialPressure = 0; } + // TODO: Remove these, as layerX/Y is not a standard, is deprecated, has uneven + // support, and the fill ins are not quite the same + // offsetX/Y might be okay, but is not the same as clientX/Y when the canvas's top + // left is not 0,0 on the page + if (typeof touch.layerX === 'undefined') { touch.layerX = touch.offsetX = touch.clientX; } + if (typeof touch.layerY === 'undefined') { touch.layerY = touch.offsetY = touch.clientY; } + + // mark the touch as normalized, just so that we know we did it + touch.isNormalized = true; + + normalizedEvents.push(touch); + } + } + // apparently PointerEvent subclasses MouseEvent, so yay + else if (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof window.PointerEvent))) + { + if (typeof event.isPrimary === 'undefined') { event.isPrimary = true; } + if (typeof event.width === 'undefined') { event.width = 1; } + if (typeof event.height === 'undefined') { event.height = 1; } + if (typeof event.tiltX === 'undefined') { event.tiltX = 0; } + if (typeof event.tiltY === 'undefined') { event.tiltY = 0; } + if (typeof event.pointerType === 'undefined') { event.pointerType = 'mouse'; } + if (typeof event.pointerId === 'undefined') { event.pointerId = MOUSE_POINTER_ID; } + if (typeof event.pressure === 'undefined') { event.pressure = 0.5; } + if (typeof event.twist === 'undefined') { event.twist = 0; } + if (typeof event.tangentialPressure === 'undefined') { event.tangentialPressure = 0; } + + // mark the mouse event as normalized, just so that we know we did it + event.isNormalized = true; + + normalizedEvents.push(event); + } + else + { + normalizedEvents.push(event); + } + + return normalizedEvents; + }; + + /** + * Destroys the interaction manager + * + */ + InteractionManager.prototype.destroy = function destroy () + { + this.removeEvents(); + + this.removeAllListeners(); + + this.renderer = null; + + this.mouse = null; + + this.eventData = null; + + this.interactionDOMElement = null; + + this.onPointerDown = null; + this.processPointerDown = null; + + this.onPointerUp = null; + this.processPointerUp = null; + + this.onPointerCancel = null; + this.processPointerCancel = null; + + this.onPointerMove = null; + this.processPointerMove = null; + + this.onPointerOut = null; + this.processPointerOverOut = null; + + this.onPointerOver = null; + + this._tempPoint = null; + }; + + return InteractionManager; + }(eventemitter3)); + + var interaction_es = ({ + InteractionData: InteractionData, + InteractionEvent: InteractionEvent, + InteractionManager: InteractionManager, + InteractionTrackingData: InteractionTrackingData, + interactiveTarget: interactiveTarget + }); + + /*! + * @pixi/graphics - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/graphics is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Graphics curves resolution settings. If `adaptive` flag is set to `true`, + * the resolution is calculated based on the curve's length to ensure better visual quality. + * Adaptive draw works with `bezierCurveTo` and `quadraticCurveTo`. + * + * @static + * @constant + * @memberof PIXI + * @name GRAPHICS_CURVES + * @type {object} + * @property {boolean} adaptive=false - flag indicating if the resolution should be adaptive + * @property {number} maxLength=10 - maximal length of a single segment of the curve (if adaptive = false, ignored) + * @property {number} minSegments=8 - minimal number of segments in the curve (if adaptive = false, ignored) + * @property {number} maxSegments=2048 - maximal number of segments in the curve (if adaptive = false, ignored) + */ + var GRAPHICS_CURVES = { + adaptive: true, + maxLength: 10, + minSegments: 8, + maxSegments: 2048, + _segmentsCount: function _segmentsCount(length, defaultSegments) + { + if ( defaultSegments === void 0 ) { defaultSegments = 20; } + + if (!this.adaptive) + { + return defaultSegments; + } + + var result = Math.ceil(length / this.maxLength); + + if (result < this.minSegments) + { + result = this.minSegments; + } + else if (result > this.maxSegments) + { + result = this.maxSegments; + } + + return result; + }, + }; + + /** + * Fill style object for Graphics. + * + * @class + * @memberof PIXI + */ + var FillStyle = function FillStyle() + { + this.reset(); + }; + + /** + * Clones the object + * + * @return {PIXI.FillStyle} + */ + FillStyle.prototype.clone = function clone () + { + var obj = new FillStyle(); + + obj.color = this.color; + obj.alpha = this.alpha; + obj.texture = this.texture; + obj.matrix = this.matrix; + obj.visible = this.visible; + + return obj; + }; + + /** + * Reset + */ + FillStyle.prototype.reset = function reset () + { + /** + * The hex color value used when coloring the Graphics object. + * + * @member {number} + * @default 1 + */ + this.color = 0xFFFFFF; + + /** + * The alpha value used when filling the Graphics object. + * + * @member {number} + * @default 1 + */ + this.alpha = 1; + + /** + * The texture to be used for the fill. + * + * @member {string} + * @default 0 + */ + this.texture = Texture.WHITE; + + /** + * The transform aplpied to the texture. + * + * @member {string} + * @default 0 + */ + this.matrix = null; + + /** + * If the current fill is visible. + * + * @member {boolean} + * @default false + */ + this.visible = false; + }; + + /** + * Destroy and don't use after this + */ + FillStyle.prototype.destroy = function destroy () + { + this.texture = null; + this.matrix = null; + }; + + /** + * A class to contain data useful for Graphics objects + * + * @class + * @memberof PIXI + */ + var GraphicsData = function GraphicsData(shape, fillStyle, lineStyle, matrix) + { + if ( fillStyle === void 0 ) { fillStyle = null; } + if ( lineStyle === void 0 ) { lineStyle = null; } + if ( matrix === void 0 ) { matrix = null; } + + /** + * The shape object to draw. + * @member {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} + */ + this.shape = shape; + + /** + * The style of the line. + * @member {PIXI.LineStyle} + */ + this.lineStyle = lineStyle; + + /** + * The style of the fill. + * @member {PIXI.FillStyle} + */ + this.fillStyle = fillStyle; + + /** + * The transform matrix. + * @member {PIXI.Matrix} + */ + this.matrix = matrix; + + /** + * The type of the shape, see the Const.Shapes file for all the existing types, + * @member {number} + */ + this.type = shape.type; + + /** + * The collection of points. + * @member {number[]} + */ + this.points = []; + + /** + * The collection of holes. + * @member {PIXI.GraphicsData[]} + */ + this.holes = []; + }; + + /** + * Creates a new GraphicsData object with the same values as this one. + * + * @return {PIXI.GraphicsData} Cloned GraphicsData object + */ + GraphicsData.prototype.clone = function clone () + { + return new GraphicsData( + this.shape, + this.fillStyle, + this.lineStyle, + this.matrix + ); + }; + + /** + * Destroys the Graphics data. + */ + GraphicsData.prototype.destroy = function destroy () + { + this.shape = null; + this.holes.length = 0; + this.holes = null; + this.points.length = 0; + this.points = null; + this.lineStyle = null; + this.fillStyle = null; + }; + + /** + * Builds a circle to draw + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object to draw + * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape + * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines + */ + var buildCircle = { + + build: function build(graphicsData) + { + // need to convert points to a nice regular data + var circleData = graphicsData.shape; + var points = graphicsData.points; + var x = circleData.x; + var y = circleData.y; + var width; + var height; + + points.length = 0; + + // TODO - bit hacky?? + if (graphicsData.type === SHAPES.CIRC) + { + width = circleData.radius; + height = circleData.radius; + } + else + { + width = circleData.width; + height = circleData.height; + } + + if (width === 0 || height === 0) + { + return; + } + + var totalSegs = Math.floor(30 * Math.sqrt(circleData.radius)) + || Math.floor(15 * Math.sqrt(circleData.width + circleData.height)); + + totalSegs /= 2.3; + + var seg = (Math.PI * 2) / totalSegs; + + for (var i = 0; i < totalSegs; i++) + { + points.push( + x + (Math.sin(-seg * i) * width), + y + (Math.cos(-seg * i) * height) + ); + } + + points.push( + points[0], + points[1] + ); + }, + + triangulate: function triangulate(graphicsData, graphicsGeometry) + { + var points = graphicsData.points; + var verts = graphicsGeometry.points; + var indices = graphicsGeometry.indices; + + var vertPos = verts.length / 2; + var center = vertPos; + + verts.push(graphicsData.shape.x, graphicsData.shape.y); + + for (var i = 0; i < points.length; i += 2) + { + verts.push(points[i], points[i + 1]); + + // add some uvs + indices.push(vertPos++, center, vertPos); + } + }, + }; + + /** + * Builds a line to draw + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties + * @param {PIXI.GraphicsGeometry} graphicsGeometry - Geometry where to append output + */ + function buildLine (graphicsData, graphicsGeometry) + { + if (graphicsData.lineStyle.native) + { + buildNativeLine(graphicsData, graphicsGeometry); + } + else + { + buildLine$1(graphicsData, graphicsGeometry); + } + } + + /** + * Builds a line to draw using the polygon method. + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties + * @param {PIXI.GraphicsGeometry} graphicsGeometry - Geometry where to append output + */ + function buildLine$1(graphicsData, graphicsGeometry) + { + var shape = graphicsData.shape; + var points = graphicsData.points || shape.points.slice(); + + if (points.length === 0) + { + return; + } + // if the line width is an odd number add 0.5 to align to a whole pixel + // commenting this out fixes #711 and #1620 + // if (graphicsData.lineWidth%2) + // { + // for (i = 0; i < points.length; i++) + // { + // points[i] += 0.5; + // } + // } + + var style = graphicsData.lineStyle; + + // get first and last point.. figure out the middle! + var firstPoint = new Point(points[0], points[1]); + var lastPoint = new Point(points[points.length - 2], points[points.length - 1]); + var closedShape = shape.type !== SHAPES.POLY || shape.closeStroke; + var closedPath = firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y; + + // if the first point is the last point - gonna have issues :) + if (closedShape) + { + // need to clone as we are going to slightly modify the shape.. + points = points.slice(); + + if (closedPath) + { + points.pop(); + points.pop(); + lastPoint.set(points[points.length - 2], points[points.length - 1]); + } + + var midPointX = lastPoint.x + ((firstPoint.x - lastPoint.x) * 0.5); + var midPointY = lastPoint.y + ((firstPoint.y - lastPoint.y) * 0.5); + + points.unshift(midPointX, midPointY); + points.push(midPointX, midPointY); + } + + var verts = graphicsGeometry.points; + var length = points.length / 2; + var indexCount = points.length; + var indexStart = verts.length / 2; + + // DRAW the Line + var width = style.width / 2; + + // sort color + var p1x = points[0]; + var p1y = points[1]; + var p2x = points[2]; + var p2y = points[3]; + var p3x = 0; + var p3y = 0; + + var perpx = -(p1y - p2y); + var perpy = p1x - p2x; + var perp2x = 0; + var perp2y = 0; + var perp3x = 0; + var perp3y = 0; + + var dist = Math.sqrt((perpx * perpx) + (perpy * perpy)); + + perpx /= dist; + perpy /= dist; + perpx *= width; + perpy *= width; + + var ratio = style.alignment;// 0.5; + var r1 = (1 - ratio) * 2; + var r2 = ratio * 2; + + // start + verts.push( + p1x - (perpx * r1), + p1y - (perpy * r1)); + + verts.push( + p1x + (perpx * r2), + p1y + (perpy * r2)); + + for (var i = 1; i < length - 1; ++i) + { + p1x = points[(i - 1) * 2]; + p1y = points[((i - 1) * 2) + 1]; + + p2x = points[i * 2]; + p2y = points[(i * 2) + 1]; + + p3x = points[(i + 1) * 2]; + p3y = points[((i + 1) * 2) + 1]; + + perpx = -(p1y - p2y); + perpy = p1x - p2x; + + dist = Math.sqrt((perpx * perpx) + (perpy * perpy)); + perpx /= dist; + perpy /= dist; + perpx *= width; + perpy *= width; + + perp2x = -(p2y - p3y); + perp2y = p2x - p3x; + + dist = Math.sqrt((perp2x * perp2x) + (perp2y * perp2y)); + perp2x /= dist; + perp2y /= dist; + perp2x *= width; + perp2y *= width; + + var a1 = (-perpy + p1y) - (-perpy + p2y); + var b1 = (-perpx + p2x) - (-perpx + p1x); + var c1 = ((-perpx + p1x) * (-perpy + p2y)) - ((-perpx + p2x) * (-perpy + p1y)); + var a2 = (-perp2y + p3y) - (-perp2y + p2y); + var b2 = (-perp2x + p2x) - (-perp2x + p3x); + var c2 = ((-perp2x + p3x) * (-perp2y + p2y)) - ((-perp2x + p2x) * (-perp2y + p3y)); + + var denom = (a1 * b2) - (a2 * b1); + + if (Math.abs(denom) < 0.1) + { + denom += 10.1; + verts.push( + p2x - (perpx * r1), + p2y - (perpy * r1)); + + verts.push( + p2x + (perpx * r2), + p2y + (perpy * r2)); -},{"../core":65,"./accessibleTarget":41,"ismobilejs":4}],41:[function(require,module,exports){ -"use strict"; + continue; + } -exports.__esModule = true; -/** - * Default property values of accessible objects - * used by {@link PIXI.accessibility.AccessibilityManager}. - * - * @function accessibleTarget - * @memberof PIXI.accessibility - * @example - * function MyObject() {} - * - * Object.assign( - * MyObject.prototype, - * PIXI.accessibility.accessibleTarget - * ); - */ -exports.default = { - /** - * Flag for if the object is accessible. If true AccessibilityManager will overlay a - * shadow div with attributes set - * - * @member {boolean} - */ - accessible: false, - - /** - * Sets the title attribute of the shadow div - * If accessibleTitle AND accessibleHint has not been this will default to 'displayObject [tabIndex]' - * - * @member {string} - */ - accessibleTitle: null, - - /** - * Sets the aria-label attribute of the shadow div - * - * @member {string} - */ - accessibleHint: null, - - /** - * @todo Needs docs. - */ - tabIndex: 0, - - /** - * @todo Needs docs. - */ - _accessibleActive: false, - - /** - * @todo Needs docs. - */ - _accessibleDiv: false -}; - -},{}],42:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _accessibleTarget = require('./accessibleTarget'); - -Object.defineProperty(exports, 'accessibleTarget', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_accessibleTarget).default; - } -}); - -var _AccessibilityManager = require('./AccessibilityManager'); - -Object.defineProperty(exports, 'AccessibilityManager', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_AccessibilityManager).default; - } -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"./AccessibilityManager":40,"./accessibleTarget":41}],43:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _autoDetectRenderer = require('./autoDetectRenderer'); - -var _Container = require('./display/Container'); - -var _Container2 = _interopRequireDefault(_Container); - -var _ticker = require('./ticker'); - -var _settings = require('./settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _const = require('./const'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Convenience class to create a new PIXI application. - * This class automatically creates the renderer, ticker - * and root container. - * - * @example - * // Create the application - * const app = new PIXI.Application(); - * - * // Add the view to the DOM - * document.body.appendChild(app.view); - * - * // ex, add display objects - * app.stage.addChild(PIXI.Sprite.fromImage('something.png')); - * - * @class - * @memberof PIXI - */ -var Application = function () { - // eslint-disable-next-line valid-jsdoc - /** - * @param {object} [options] - The optional renderer parameters - * @param {boolean} [options.autoStart=true] - automatically starts the rendering after the construction. - * Note that setting this parameter to false does NOT stop the shared ticker even if you set - * options.sharedTicker to true in case that it is already started. Stop it by your own. - * @param {number} [options.width=800] - the width of the renderers view - * @param {number} [options.height=600] - the height of the renderers view - * @param {HTMLCanvasElement} [options.view] - the canvas to use as a view, optional - * @param {boolean} [options.transparent=false] - If the render view is transparent, default false - * @param {boolean} [options.antialias=false] - sets antialias (only applicable in chrome at the moment) - * @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, enable this if you - * need to call toDataUrl on the webgl context - * @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2 - * @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present - * @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area - * (shown if not transparent). - * @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or - * not before the new render pass. - * @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when rendering, - * stopping pixel interpolation. - * @param {boolean} [options.forceFXAA=false] - forces FXAA antialiasing to be used over native. - * FXAA is faster, but may not always look as great **webgl only** - * @param {boolean} [options.legacy=false] - `true` to ensure compatibility with older / less advanced devices. - * If you experience unexplained flickering try setting this to true. **webgl only** - * @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance" - * for devices with dual graphics card **webgl only** - * @param {boolean} [options.sharedTicker=false] - `true` to use PIXI.ticker.shared, `false` to create new ticker. - * @param {boolean} [options.sharedLoader=false] - `true` to use PIXI.loaders.shared, `false` to create new Loader. - */ - function Application(options, arg2, arg3, arg4, arg5) { - _classCallCheck(this, Application); - - // Support for constructor(width, height, options, noWebGL, useSharedTicker) - if (typeof options === 'number') { - options = Object.assign({ - width: options, - height: arg2 || _settings2.default.RENDER_OPTIONS.height, - forceCanvas: !!arg4, - sharedTicker: !!arg5 - }, arg3); - } - - /** - * The default options, so we mixin functionality later. - * @member {object} - * @protected - */ - this._options = options = Object.assign({ - autoStart: true, - sharedTicker: false, - forceCanvas: false, - sharedLoader: false - }, options); - - /** - * WebGL renderer if available, otherwise CanvasRenderer - * @member {PIXI.WebGLRenderer|PIXI.CanvasRenderer} - */ - this.renderer = (0, _autoDetectRenderer.autoDetectRenderer)(options); - - /** - * The root display container that's rendered. - * @member {PIXI.Container} - */ - this.stage = new _Container2.default(); - - /** - * Internal reference to the ticker - * @member {PIXI.ticker.Ticker} - * @private - */ - this._ticker = null; - - /** - * Ticker for doing render updates. - * @member {PIXI.ticker.Ticker} - * @default PIXI.ticker.shared - */ - this.ticker = options.sharedTicker ? _ticker.shared : new _ticker.Ticker(); - - // Start the rendering - if (options.autoStart) { - this.start(); - } - } - - /** - * Render the current stage. - */ - Application.prototype.render = function render() { - this.renderer.render(this.stage); - }; - - /** - * Convenience method for stopping the render. - */ - - - Application.prototype.stop = function stop() { - this._ticker.stop(); - }; - - /** - * Convenience method for starting the render. - */ - - - Application.prototype.start = function start() { - this._ticker.start(); - }; - - /** - * Reference to the renderer's canvas element. - * @member {HTMLCanvasElement} - * @readonly - */ - - - /** - * Destroy and don't use after this. - * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. - * @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options - * have been set to that value - * @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy - * method called as well. 'stageOptions' will be passed on to those calls. - * @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set - * to true. Should it destroy the texture of the child sprite - * @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set - * to true. Should it destroy the base texture of the child sprite - */ - Application.prototype.destroy = function destroy(removeView, stageOptions) { - if (this._ticker) { - var oldTicker = this._ticker; - - this.ticker = null; - oldTicker.destroy(); - } - - this.stage.destroy(stageOptions); - this.stage = null; - - this.renderer.destroy(removeView); - this.renderer = null; - - this._options = null; - }; - - _createClass(Application, [{ - key: 'ticker', - set: function set(ticker) // eslint-disable-line require-jsdoc - { - if (this._ticker) { - this._ticker.remove(this.render, this); - } - this._ticker = ticker; - if (ticker) { - ticker.add(this.render, this, _const.UPDATE_PRIORITY.LOW); - } - }, - get: function get() // eslint-disable-line require-jsdoc - { - return this._ticker; - } - }, { - key: 'view', - get: function get() { - return this.renderer.view; - } - - /** - * Reference to the renderer's screen rectangle. Its safe to use as filterArea or hitArea for whole screen - * @member {PIXI.Rectangle} - * @readonly - */ - - }, { - key: 'screen', - get: function get() { - return this.renderer.screen; - } - }]); - - return Application; -}(); - -exports.default = Application; - -},{"./autoDetectRenderer":45,"./const":46,"./display/Container":48,"./settings":101,"./ticker":121}],44:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _pixiGlCore = require('pixi-gl-core'); - -var _settings = require('./settings'); - -var _settings2 = _interopRequireDefault(_settings); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -function checkPrecision(src, def) { - if (src instanceof Array) { - if (src[0].substring(0, 9) !== 'precision') { - var copy = src.slice(0); - - copy.unshift('precision ' + def + ' float;'); - - return copy; - } - } else if (src.trim().substring(0, 9) !== 'precision') { - return 'precision ' + def + ' float;\n' + src; - } - - return src; -} - -/** - * Wrapper class, webGL Shader for Pixi. - * Adds precision string if vertexSrc or fragmentSrc have no mention of it. - * - * @class - * @extends GLShader - * @memberof PIXI - */ - -var Shader = function (_GLShader) { - _inherits(Shader, _GLShader); - - /** - * - * @param {WebGLRenderingContext} gl - The current WebGL rendering context - * @param {string|string[]} vertexSrc - The vertex shader source as an array of strings. - * @param {string|string[]} fragmentSrc - The fragment shader source as an array of strings. - * @param {object} [attributeLocations] - A key value pair showing which location eact attribute should sit. - e.g. {position:0, uvs:1}. - * @param {string} [precision] - The float precision of the shader. Options are 'lowp', 'mediump' or 'highp'. - */ - function Shader(gl, vertexSrc, fragmentSrc, attributeLocations, precision) { - _classCallCheck(this, Shader); - - return _possibleConstructorReturn(this, _GLShader.call(this, gl, checkPrecision(vertexSrc, precision || _settings2.default.PRECISION_VERTEX), checkPrecision(fragmentSrc, precision || _settings2.default.PRECISION_FRAGMENT), undefined, attributeLocations)); - } - - return Shader; -}(_pixiGlCore.GLShader); - -exports.default = Shader; - -},{"./settings":101,"pixi-gl-core":15}],45:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.autoDetectRenderer = autoDetectRenderer; - -var _utils = require('./utils'); - -var utils = _interopRequireWildcard(_utils); - -var _CanvasRenderer = require('./renderers/canvas/CanvasRenderer'); - -var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer); - -var _WebGLRenderer = require('./renderers/webgl/WebGLRenderer'); - -var _WebGLRenderer2 = _interopRequireDefault(_WebGLRenderer); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -// eslint-disable-next-line valid-jsdoc -/** - * This helper function will automatically detect which renderer you should be using. - * WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by - * the browser then this function will return a canvas renderer - * - * @memberof PIXI - * @function autoDetectRenderer - * @param {object} [options] - The optional renderer parameters - * @param {number} [options.width=800] - the width of the renderers view - * @param {number} [options.height=600] - the height of the renderers view - * @param {HTMLCanvasElement} [options.view] - the canvas to use as a view, optional - * @param {boolean} [options.transparent=false] - If the render view is transparent, default false - * @param {boolean} [options.antialias=false] - sets antialias (only applicable in chrome at the moment) - * @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, enable this if you - * need to call toDataUrl on the webgl context - * @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area - * (shown if not transparent). - * @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or - * not before the new render pass. - * @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2 - * @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present - * @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when rendering, - * stopping pixel interpolation. - * @param {boolean} [options.forceFXAA=false] - forces FXAA antialiasing to be used over native. - * FXAA is faster, but may not always look as great **webgl only** - * @param {boolean} [options.legacy=false] - `true` to ensure compatibility with older / less advanced devices. - * If you experience unexplained flickering try setting this to true. **webgl only** - * @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance" - * for devices with dual graphics card **webgl only** - * @return {PIXI.WebGLRenderer|PIXI.CanvasRenderer} Returns WebGL renderer if available, otherwise CanvasRenderer - */ -function autoDetectRenderer(options, arg1, arg2, arg3) { - // Backward-compatible support for noWebGL option - var forceCanvas = options && options.forceCanvas; - - if (arg3 !== undefined) { - forceCanvas = arg3; - } - - if (!forceCanvas && utils.isWebGLSupported()) { - return new _WebGLRenderer2.default(options, arg1, arg2); - } - - return new _CanvasRenderer2.default(options, arg1, arg2); -} - -},{"./renderers/canvas/CanvasRenderer":77,"./renderers/webgl/WebGLRenderer":84,"./utils":125}],46:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -/** - * String of the current PIXI version. - * - * @static - * @constant - * @memberof PIXI - * @name VERSION - * @type {string} - */ -var VERSION = exports.VERSION = '4.8.7'; - -/** - * Two Pi. - * - * @static - * @constant - * @memberof PIXI - * @type {number} - */ -var PI_2 = exports.PI_2 = Math.PI * 2; - -/** - * Conversion factor for converting radians to degrees. - * - * @static - * @constant - * @memberof PIXI - * @type {number} - */ -var RAD_TO_DEG = exports.RAD_TO_DEG = 180 / Math.PI; - -/** - * Conversion factor for converting degrees to radians. - * - * @static - * @constant - * @memberof PIXI - * @type {number} - */ -var DEG_TO_RAD = exports.DEG_TO_RAD = Math.PI / 180; - -/** - * Constant to identify the Renderer Type. - * - * @static - * @constant - * @memberof PIXI - * @name RENDERER_TYPE - * @type {object} - * @property {number} UNKNOWN - Unknown render type. - * @property {number} WEBGL - WebGL render type. - * @property {number} CANVAS - Canvas render type. - */ -var RENDERER_TYPE = exports.RENDERER_TYPE = { - UNKNOWN: 0, - WEBGL: 1, - CANVAS: 2 -}; - -/** - * Various blend modes supported by PIXI. - * - * IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes. - * Anything else will silently act like NORMAL. - * - * @static - * @constant - * @memberof PIXI - * @name BLEND_MODES - * @type {object} - * @property {number} NORMAL - * @property {number} ADD - * @property {number} MULTIPLY - * @property {number} SCREEN - * @property {number} OVERLAY - * @property {number} DARKEN - * @property {number} LIGHTEN - * @property {number} COLOR_DODGE - * @property {number} COLOR_BURN - * @property {number} HARD_LIGHT - * @property {number} SOFT_LIGHT - * @property {number} DIFFERENCE - * @property {number} EXCLUSION - * @property {number} HUE - * @property {number} SATURATION - * @property {number} COLOR - * @property {number} LUMINOSITY - */ -var BLEND_MODES = exports.BLEND_MODES = { - NORMAL: 0, - ADD: 1, - MULTIPLY: 2, - SCREEN: 3, - OVERLAY: 4, - DARKEN: 5, - LIGHTEN: 6, - COLOR_DODGE: 7, - COLOR_BURN: 8, - HARD_LIGHT: 9, - SOFT_LIGHT: 10, - DIFFERENCE: 11, - EXCLUSION: 12, - HUE: 13, - SATURATION: 14, - COLOR: 15, - LUMINOSITY: 16, - NORMAL_NPM: 17, - ADD_NPM: 18, - SCREEN_NPM: 19 -}; - -/** - * Various webgl draw modes. These can be used to specify which GL drawMode to use - * under certain situations and renderers. - * - * @static - * @constant - * @memberof PIXI - * @name DRAW_MODES - * @type {object} - * @property {number} POINTS - * @property {number} LINES - * @property {number} LINE_LOOP - * @property {number} LINE_STRIP - * @property {number} TRIANGLES - * @property {number} TRIANGLE_STRIP - * @property {number} TRIANGLE_FAN - */ -var DRAW_MODES = exports.DRAW_MODES = { - POINTS: 0, - LINES: 1, - LINE_LOOP: 2, - LINE_STRIP: 3, - TRIANGLES: 4, - TRIANGLE_STRIP: 5, - TRIANGLE_FAN: 6 -}; - -/** - * The scale modes that are supported by pixi. - * - * The {@link PIXI.settings.SCALE_MODE} scale mode affects the default scaling mode of future operations. - * It can be re-assigned to either LINEAR or NEAREST, depending upon suitability. - * - * @static - * @constant - * @memberof PIXI - * @name SCALE_MODES - * @type {object} - * @property {number} LINEAR Smooth scaling - * @property {number} NEAREST Pixelating scaling - */ -var SCALE_MODES = exports.SCALE_MODES = { - LINEAR: 0, - NEAREST: 1 -}; - -/** - * The wrap modes that are supported by pixi. - * - * The {@link PIXI.settings.WRAP_MODE} wrap mode affects the default wrapping mode of future operations. - * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability. - * If the texture is non power of two then clamp will be used regardless as webGL can - * only use REPEAT if the texture is po2. - * - * This property only affects WebGL. - * - * @static - * @constant - * @name WRAP_MODES - * @memberof PIXI - * @type {object} - * @property {number} CLAMP - The textures uvs are clamped - * @property {number} REPEAT - The texture uvs tile and repeat - * @property {number} MIRRORED_REPEAT - The texture uvs tile and repeat with mirroring - */ -var WRAP_MODES = exports.WRAP_MODES = { - CLAMP: 0, - REPEAT: 1, - MIRRORED_REPEAT: 2 -}; - -/** - * The gc modes that are supported by pixi. - * - * The {@link PIXI.settings.GC_MODE} Garbage Collection mode for PixiJS textures is AUTO - * If set to GC_MODE, the renderer will occasionally check textures usage. If they are not - * used for a specified period of time they will be removed from the GPU. They will of course - * be uploaded again when they are required. This is a silent behind the scenes process that - * should ensure that the GPU does not get filled up. - * - * Handy for mobile devices! - * This property only affects WebGL. - * - * @static - * @constant - * @name GC_MODES - * @memberof PIXI - * @type {object} - * @property {number} AUTO - Garbage collection will happen periodically automatically - * @property {number} MANUAL - Garbage collection will need to be called manually - */ -var GC_MODES = exports.GC_MODES = { - AUTO: 0, - MANUAL: 1 -}; - -/** - * Regexp for image type by extension. - * - * @static - * @constant - * @memberof PIXI - * @type {RegExp|string} - * @example `image.png` - */ -var URL_FILE_EXTENSION = exports.URL_FILE_EXTENSION = /\.(\w{3,4})(?:$|\?|#)/i; - -/** - * Regexp for data URI. - * Based on: {@link https://github.com/ragingwind/data-uri-regex} - * - * @static - * @constant - * @name DATA_URI - * @memberof PIXI - * @type {RegExp|string} - * @example data:image/png;base64 - */ -var DATA_URI = exports.DATA_URI = /^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i; - -/** - * Regexp for SVG size. - * - * @static - * @constant - * @name SVG_SIZE - * @memberof PIXI - * @type {RegExp|string} - * @example <svg width="100" height="100"></svg> - */ -var SVG_SIZE = exports.SVG_SIZE = /]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i; // eslint-disable-line max-len - -/** - * Constants that identify shapes, mainly to prevent `instanceof` calls. - * - * @static - * @constant - * @name SHAPES - * @memberof PIXI - * @type {object} - * @property {number} POLY Polygon - * @property {number} RECT Rectangle - * @property {number} CIRC Circle - * @property {number} ELIP Ellipse - * @property {number} RREC Rounded Rectangle - */ -var SHAPES = exports.SHAPES = { - POLY: 0, - RECT: 1, - CIRC: 2, - ELIP: 3, - RREC: 4 -}; - -/** - * Constants that specify float precision in shaders. - * - * @static - * @constant - * @name PRECISION - * @memberof PIXI - * @type {object} - * @property {string} LOW='lowp' - * @property {string} MEDIUM='mediump' - * @property {string} HIGH='highp' - */ -var PRECISION = exports.PRECISION = { - LOW: 'lowp', - MEDIUM: 'mediump', - HIGH: 'highp' -}; - -/** - * Constants that specify the transform type. - * - * @static - * @constant - * @name TRANSFORM_MODE - * @memberof PIXI - * @type {object} - * @property {number} STATIC - * @property {number} DYNAMIC - */ -var TRANSFORM_MODE = exports.TRANSFORM_MODE = { - STATIC: 0, - DYNAMIC: 1 -}; - -/** - * Constants that define the type of gradient on text. - * - * @static - * @constant - * @name TEXT_GRADIENT - * @memberof PIXI - * @type {object} - * @property {number} LINEAR_VERTICAL Vertical gradient - * @property {number} LINEAR_HORIZONTAL Linear gradient - */ -var TEXT_GRADIENT = exports.TEXT_GRADIENT = { - LINEAR_VERTICAL: 0, - LINEAR_HORIZONTAL: 1 -}; - -/** - * Represents the update priorities used by internal PIXI classes when registered with - * the {@link PIXI.ticker.Ticker} object. Higher priority items are updated first and lower - * priority items, such as render, should go later. - * - * @static - * @constant - * @name UPDATE_PRIORITY - * @memberof PIXI - * @type {object} - * @property {number} INTERACTION=50 Highest priority, used for {@link PIXI.interaction.InteractionManager} - * @property {number} HIGH=25 High priority updating, {@link PIXI.VideoBaseTexture} and {@link PIXI.extras.AnimatedSprite} - * @property {number} NORMAL=0 Default priority for ticker events, see {@link PIXI.ticker.Ticker#add}. - * @property {number} LOW=-25 Low priority used for {@link PIXI.Application} rendering. - * @property {number} UTILITY=-50 Lowest priority used for {@link PIXI.prepare.BasePrepare} utility. - */ -var UPDATE_PRIORITY = exports.UPDATE_PRIORITY = { - INTERACTION: 50, - HIGH: 25, - NORMAL: 0, - LOW: -25, - UTILITY: -50 -}; - -},{}],47:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _math = require('../math'); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * 'Builder' pattern for bounds rectangles - * Axis-Aligned Bounding Box - * It is not a shape! Its mutable thing, no 'EMPTY' or that kind of problems - * - * @class - * @memberof PIXI - */ -var Bounds = function () { - /** - * - */ - function Bounds() { - _classCallCheck(this, Bounds); - - /** - * @member {number} - * @default 0 - */ - this.minX = Infinity; - - /** - * @member {number} - * @default 0 - */ - this.minY = Infinity; - - /** - * @member {number} - * @default 0 - */ - this.maxX = -Infinity; - - /** - * @member {number} - * @default 0 - */ - this.maxY = -Infinity; - - this.rect = null; - } - - /** - * Checks if bounds are empty. - * - * @return {boolean} True if empty. - */ - - - Bounds.prototype.isEmpty = function isEmpty() { - return this.minX > this.maxX || this.minY > this.maxY; - }; - - /** - * Clears the bounds and resets. - * - */ - - - Bounds.prototype.clear = function clear() { - this.updateID++; - - this.minX = Infinity; - this.minY = Infinity; - this.maxX = -Infinity; - this.maxY = -Infinity; - }; - - /** - * Can return Rectangle.EMPTY constant, either construct new rectangle, either use your rectangle - * It is not guaranteed that it will return tempRect - * - * @param {PIXI.Rectangle} rect - temporary object will be used if AABB is not empty - * @returns {PIXI.Rectangle} A rectangle of the bounds - */ - - - Bounds.prototype.getRectangle = function getRectangle(rect) { - if (this.minX > this.maxX || this.minY > this.maxY) { - return _math.Rectangle.EMPTY; - } - - rect = rect || new _math.Rectangle(0, 0, 1, 1); - - rect.x = this.minX; - rect.y = this.minY; - rect.width = this.maxX - this.minX; - rect.height = this.maxY - this.minY; - - return rect; - }; - - /** - * This function should be inlined when its possible. - * - * @param {PIXI.Point} point - The point to add. - */ - - - Bounds.prototype.addPoint = function addPoint(point) { - this.minX = Math.min(this.minX, point.x); - this.maxX = Math.max(this.maxX, point.x); - this.minY = Math.min(this.minY, point.y); - this.maxY = Math.max(this.maxY, point.y); - }; - - /** - * Adds a quad, not transformed - * - * @param {Float32Array} vertices - The verts to add. - */ - - - Bounds.prototype.addQuad = function addQuad(vertices) { - var minX = this.minX; - var minY = this.minY; - var maxX = this.maxX; - var maxY = this.maxY; - - var x = vertices[0]; - var y = vertices[1]; - - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - - x = vertices[2]; - y = vertices[3]; - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - - x = vertices[4]; - y = vertices[5]; - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - - x = vertices[6]; - y = vertices[7]; - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - - this.minX = minX; - this.minY = minY; - this.maxX = maxX; - this.maxY = maxY; - }; - - /** - * Adds sprite frame, transformed. - * - * @param {PIXI.TransformBase} transform - TODO - * @param {number} x0 - TODO - * @param {number} y0 - TODO - * @param {number} x1 - TODO - * @param {number} y1 - TODO - */ - - - Bounds.prototype.addFrame = function addFrame(transform, x0, y0, x1, y1) { - var matrix = transform.worldTransform; - var a = matrix.a; - var b = matrix.b; - var c = matrix.c; - var d = matrix.d; - var tx = matrix.tx; - var ty = matrix.ty; - - var minX = this.minX; - var minY = this.minY; - var maxX = this.maxX; - var maxY = this.maxY; - - var x = a * x0 + c * y0 + tx; - var y = b * x0 + d * y0 + ty; - - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - - x = a * x1 + c * y0 + tx; - y = b * x1 + d * y0 + ty; - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - - x = a * x0 + c * y1 + tx; - y = b * x0 + d * y1 + ty; - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - - x = a * x1 + c * y1 + tx; - y = b * x1 + d * y1 + ty; - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - - this.minX = minX; - this.minY = minY; - this.maxX = maxX; - this.maxY = maxY; - }; - - /** - * Add an array of vertices - * - * @param {PIXI.TransformBase} transform - TODO - * @param {Float32Array} vertices - TODO - * @param {number} beginOffset - TODO - * @param {number} endOffset - TODO - */ - - - Bounds.prototype.addVertices = function addVertices(transform, vertices, beginOffset, endOffset) { - var matrix = transform.worldTransform; - var a = matrix.a; - var b = matrix.b; - var c = matrix.c; - var d = matrix.d; - var tx = matrix.tx; - var ty = matrix.ty; - - var minX = this.minX; - var minY = this.minY; - var maxX = this.maxX; - var maxY = this.maxY; - - for (var i = beginOffset; i < endOffset; i += 2) { - var rawX = vertices[i]; - var rawY = vertices[i + 1]; - var x = a * rawX + c * rawY + tx; - var y = d * rawY + b * rawX + ty; - - minX = x < minX ? x : minX; - minY = y < minY ? y : minY; - maxX = x > maxX ? x : maxX; - maxY = y > maxY ? y : maxY; - } - - this.minX = minX; - this.minY = minY; - this.maxX = maxX; - this.maxY = maxY; - }; - - /** - * Adds other Bounds - * - * @param {PIXI.Bounds} bounds - TODO - */ - - - Bounds.prototype.addBounds = function addBounds(bounds) { - var minX = this.minX; - var minY = this.minY; - var maxX = this.maxX; - var maxY = this.maxY; - - this.minX = bounds.minX < minX ? bounds.minX : minX; - this.minY = bounds.minY < minY ? bounds.minY : minY; - this.maxX = bounds.maxX > maxX ? bounds.maxX : maxX; - this.maxY = bounds.maxY > maxY ? bounds.maxY : maxY; - }; - - /** - * Adds other Bounds, masked with Bounds - * - * @param {PIXI.Bounds} bounds - TODO - * @param {PIXI.Bounds} mask - TODO - */ - - - Bounds.prototype.addBoundsMask = function addBoundsMask(bounds, mask) { - var _minX = bounds.minX > mask.minX ? bounds.minX : mask.minX; - var _minY = bounds.minY > mask.minY ? bounds.minY : mask.minY; - var _maxX = bounds.maxX < mask.maxX ? bounds.maxX : mask.maxX; - var _maxY = bounds.maxY < mask.maxY ? bounds.maxY : mask.maxY; - - if (_minX <= _maxX && _minY <= _maxY) { - var minX = this.minX; - var minY = this.minY; - var maxX = this.maxX; - var maxY = this.maxY; - - this.minX = _minX < minX ? _minX : minX; - this.minY = _minY < minY ? _minY : minY; - this.maxX = _maxX > maxX ? _maxX : maxX; - this.maxY = _maxY > maxY ? _maxY : maxY; - } - }; - - /** - * Adds other Bounds, masked with Rectangle - * - * @param {PIXI.Bounds} bounds - TODO - * @param {PIXI.Rectangle} area - TODO - */ - - - Bounds.prototype.addBoundsArea = function addBoundsArea(bounds, area) { - var _minX = bounds.minX > area.x ? bounds.minX : area.x; - var _minY = bounds.minY > area.y ? bounds.minY : area.y; - var _maxX = bounds.maxX < area.x + area.width ? bounds.maxX : area.x + area.width; - var _maxY = bounds.maxY < area.y + area.height ? bounds.maxY : area.y + area.height; - - if (_minX <= _maxX && _minY <= _maxY) { - var minX = this.minX; - var minY = this.minY; - var maxX = this.maxX; - var maxY = this.maxY; - - this.minX = _minX < minX ? _minX : minX; - this.minY = _minY < minY ? _minY : minY; - this.maxX = _maxX > maxX ? _maxX : maxX; - this.maxY = _maxY > maxY ? _maxY : maxY; - } - }; - - return Bounds; -}(); - -exports.default = Bounds; - -},{"../math":70}],48:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _utils = require('../utils'); - -var _DisplayObject2 = require('./DisplayObject'); - -var _DisplayObject3 = _interopRequireDefault(_DisplayObject2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * A Container represents a collection of display objects. - * It is the base class of all display objects that act as a container for other objects. - * - *```js - * let container = new PIXI.Container(); - * container.addChild(sprite); - * ``` - * - * @class - * @extends PIXI.DisplayObject - * @memberof PIXI - */ -var Container = function (_DisplayObject) { - _inherits(Container, _DisplayObject); - - /** - * - */ - function Container() { - _classCallCheck(this, Container); - - /** - * The array of children of this container. - * - * @member {PIXI.DisplayObject[]} - * @readonly - */ - var _this = _possibleConstructorReturn(this, _DisplayObject.call(this)); - - _this.children = []; - return _this; - } - - /** - * Overridable method that can be used by Container subclasses whenever the children array is modified - * - * @private - */ - - - Container.prototype.onChildrenChange = function onChildrenChange() {} - /* empty */ - - - /** - * Adds one or more children to the container. - * - * Multiple items can be added like so: `myContainer.addChild(thingOne, thingTwo, thingThree)` - * - * @param {...PIXI.DisplayObject} child - The DisplayObject(s) to add to the container - * @return {PIXI.DisplayObject} The first child that was added. - */ - ; - - Container.prototype.addChild = function addChild(child) { - var argumentsLength = arguments.length; - - // if there is only one argument we can bypass looping through the them - if (argumentsLength > 1) { - // loop through the arguments property and add all children - // use it the right way (.length and [i]) so that this function can still be optimised by JS runtimes - for (var i = 0; i < argumentsLength; i++) { - this.addChild(arguments[i]); - } - } else { - // if the child has a parent then lets remove it as PixiJS objects can only exist in one place - if (child.parent) { - child.parent.removeChild(child); - } + var px = ((b1 * c2) - (b2 * c1)) / denom; + var py = ((a2 * c1) - (a1 * c2)) / denom; + var pdist = ((px - p2x) * (px - p2x)) + ((py - p2y) * (py - p2y)); - child.parent = this; - // ensure child transform will be recalculated - child.transform._parentID = -1; + if (pdist > (196 * width * width)) + { + perp3x = perpx - perp2x; + perp3y = perpy - perp2y; + + dist = Math.sqrt((perp3x * perp3x) + (perp3y * perp3y)); + perp3x /= dist; + perp3y /= dist; + perp3x *= width; + perp3y *= width; + + verts.push(p2x - (perp3x * r1), p2y - (perp3y * r1)); + + verts.push(p2x + (perp3x * r2), p2y + (perp3y * r2)); + + verts.push(p2x - (perp3x * r2 * r1), p2y - (perp3y * r1)); + + indexCount++; + } + else + { + verts.push(p2x + ((px - p2x) * r1), p2y + ((py - p2y) * r1)); + + verts.push(p2x - ((px - p2x) * r2), p2y - ((py - p2y) * r2)); + } + } + + p1x = points[(length - 2) * 2]; + p1y = points[((length - 2) * 2) + 1]; + + p2x = points[(length - 1) * 2]; + p2y = points[((length - 1) * 2) + 1]; + + perpx = -(p1y - p2y); + perpy = p1x - p2x; + + dist = Math.sqrt((perpx * perpx) + (perpy * perpy)); + perpx /= dist; + perpy /= dist; + perpx *= width; + perpy *= width; + + verts.push(p2x - (perpx * r1), p2y - (perpy * r1)); + + verts.push(p2x + (perpx * r2), p2y + (perpy * r2)); + + var indices = graphicsGeometry.indices; + + // indices.push(indexStart); + + for (var i$1 = 0; i$1 < indexCount - 2; ++i$1) + { + indices.push(indexStart, indexStart + 1, indexStart + 2); + + indexStart++; + } + } + + /** + * Builds a line to draw using the gl.drawArrays(gl.LINES) method + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties + * @param {PIXI.GraphicsGeometry} graphicsGeometry - Geometry where to append output + */ + function buildNativeLine(graphicsData, graphicsGeometry) + { + var i = 0; + + var points = graphicsData.points || graphicsData.shape.points; + + if (points.length === 0) { return; } + + var verts = graphicsGeometry.points; + var indices = graphicsGeometry.indices; + var length = points.length / 2; + + var indexStart = verts.length / 2; + // sort color + + for (i = 1; i < length; i++) + { + var p1x = points[(i - 1) * 2]; + var p1y = points[((i - 1) * 2) + 1]; + + var p2x = points[i * 2]; + var p2y = points[(i * 2) + 1]; + + verts.push(p1x, p1y); + + verts.push(p2x, p2y); + + indices.push(indexStart++, indexStart++); + } + } + + /** + * Builds a polygon to draw + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties + * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape + * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines + */ + var buildPoly = { + + build: function build(graphicsData) + { + graphicsData.points = graphicsData.shape.points.slice(); + }, + + triangulate: function triangulate(graphicsData, graphicsGeometry) + { + var points = graphicsData.points; + var holes = graphicsData.holes; + var verts = graphicsGeometry.points; + var indices = graphicsGeometry.indices; + + if (points.length >= 6) + { + var holeArray = []; + // Process holes.. + + for (var i = 0; i < holes.length; i++) + { + var hole = holes[i]; + + holeArray.push(points.length / 2); + points = points.concat(hole.points); + } + + // sort color + var triangles = earcut_1(points, holeArray, 2); + + if (!triangles) + { + return; + } + + var vertPos = verts.length / 2; + + for (var i$1 = 0; i$1 < triangles.length; i$1 += 3) + { + indices.push(triangles[i$1] + vertPos); + indices.push(triangles[i$1 + 1] + vertPos); + indices.push(triangles[i$1 + 2] + vertPos); + } + + for (var i$2 = 0; i$2 < points.length; i$2++) + { + verts.push(points[i$2]); + } + } + }, + }; + + /** + * Builds a rectangle to draw + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties + * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape + * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines + */ + var buildRectangle = { + + build: function build(graphicsData) + { + // --- // + // need to convert points to a nice regular data + // + var rectData = graphicsData.shape; + var x = rectData.x; + var y = rectData.y; + var width = rectData.width; + var height = rectData.height; + + var points = graphicsData.points; + + points.length = 0; + + points.push(x, y, + x + width, y, + x + width, y + height, + x, y + height); + }, + + triangulate: function triangulate(graphicsData, graphicsGeometry) + { + var points = graphicsData.points; + var verts = graphicsGeometry.points; + + var vertPos = verts.length / 2; + + verts.push(points[0], points[1], + points[2], points[3], + points[6], points[7], + points[4], points[5]); + + graphicsGeometry.indices.push(vertPos, vertPos + 1, vertPos + 2, + vertPos + 1, vertPos + 2, vertPos + 3); + }, + }; + + /** + * Builds a rounded rectangle to draw + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties + * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape + * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines + */ + var buildRoundedRectangle = { + + build: function build(graphicsData) + { + var rrectData = graphicsData.shape; + var points = graphicsData.points; + var x = rrectData.x; + var y = rrectData.y; + var width = rrectData.width; + var height = rrectData.height; + + var radius = rrectData.radius; + + points.length = 0; + + quadraticBezierCurve(x, y + radius, + x, y, + x + radius, y, + points); + quadraticBezierCurve(x + width - radius, + y, x + width, y, + x + width, y + radius, + points); + quadraticBezierCurve(x + width, y + height - radius, + x + width, y + height, + x + width - radius, y + height, + points); + quadraticBezierCurve(x + radius, y + height, + x, y + height, + x, y + height - radius, + points); + + // this tiny number deals with the issue that occurs when points overlap and earcut fails to triangulate the item. + // TODO - fix this properly, this is not very elegant.. but it works for now. + }, + + triangulate: function triangulate(graphicsData, graphicsGeometry) + { + var points = graphicsData.points; + + var verts = graphicsGeometry.points; + var indices = graphicsGeometry.indices; + + var vecPos = verts.length / 2; + + var triangles = earcut_1(points, null, 2); + + for (var i = 0, j = triangles.length; i < j; i += 3) + { + indices.push(triangles[i] + vecPos); + // indices.push(triangles[i] + vecPos); + indices.push(triangles[i + 1] + vecPos); + // indices.push(triangles[i + 2] + vecPos); + indices.push(triangles[i + 2] + vecPos); + } + + for (var i$1 = 0, j$1 = points.length; i$1 < j$1; i$1++) + { + verts.push(points[i$1], points[++i$1]); + } + }, + }; + + /** + * Calculate a single point for a quadratic bezier curve. + * Utility function used by quadraticBezierCurve. + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {number} n1 - first number + * @param {number} n2 - second number + * @param {number} perc - percentage + * @return {number} the result + * + */ + function getPt(n1, n2, perc) + { + var diff = n2 - n1; + + return n1 + (diff * perc); + } + + /** + * Calculate the points for a quadratic bezier curve. (helper function..) + * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @private + * @param {number} fromX - Origin point x + * @param {number} fromY - Origin point x + * @param {number} cpX - Control point x + * @param {number} cpY - Control point y + * @param {number} toX - Destination point x + * @param {number} toY - Destination point y + * @param {number[]} [out=[]] - The output array to add points into. If not passed, a new array is created. + * @return {number[]} an array of points + */ + function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY, out) + { + if ( out === void 0 ) { out = []; } + + var n = 20; + var points = out; + + var xa = 0; + var ya = 0; + var xb = 0; + var yb = 0; + var x = 0; + var y = 0; + + for (var i = 0, j = 0; i <= n; ++i) + { + j = i / n; + + // The Green Line + xa = getPt(fromX, cpX, j); + ya = getPt(fromY, cpY, j); + xb = getPt(cpX, toX, j); + yb = getPt(cpY, toY, j); + + // The Black Dot + x = getPt(xa, xb, j); + y = getPt(ya, yb, j); + + points.push(x, y); + } + + return points; + } + + var BATCH_POOL = []; + var DRAW_CALL_POOL = []; + + /** + * Map of fill commands for each shape type. + * + * @member {Object} + * @private + */ + var fillCommands = {}; + + fillCommands[SHAPES.POLY] = buildPoly; + fillCommands[SHAPES.CIRC] = buildCircle; + fillCommands[SHAPES.ELIP] = buildCircle; + fillCommands[SHAPES.RECT] = buildRectangle; + fillCommands[SHAPES.RREC] = buildRoundedRectangle; + + /** + * A little internal structure to hold interim batch objects. + * + * @private + */ + var BatchPart = function BatchPart() + { + this.style = null; + this.size = 0; + this.start = 0; + this.attribStart = 0; + this.attribSize = 0; + }; + + /** + * The Graphics class contains methods used to draw primitive shapes such as lines, circles and + * rectangles to the display, and to color and fill them. + * + * GraphicsGeometry is designed to not be continually updating the geometry since it's expensive + * to re-tesselate using **earcut**. Consider using {@link PIXI.Mesh} for this use-case, it's much faster. + * + * @class + * @extends PIXI.BatchGeometry + * @memberof PIXI + */ + var GraphicsGeometry = /*@__PURE__*/(function (BatchGeometry) { + function GraphicsGeometry() + { + BatchGeometry.call(this); + + /** + * An array of points to draw + * + * @member {PIXI.Point[]} + * @protected + */ + this.points = []; + + /** + * The collection of colors + * + * @member {number[]} + * @protected + */ + this.colors = []; + + /** + * The UVs collection + * + * @member {number[]} + * @protected + */ + this.uvs = []; + + /** + * The indices of the vertices + * + * @member {number[]} + * @protected + */ + this.indices = []; + + /** + * Reference to the texture IDs. + * + * @member {number[]} + * @protected + */ + this.textureIds = []; + + /** + * The collection of drawn shapes. + * + * @member {PIXI.GraphicsData[]} + * @protected + */ + this.graphicsData = []; + + /** + * Used to detect if the graphics object has changed. If this is set to true then the graphics + * object will be recalculated. + * + * @member {number} + * @protected + */ + this.dirty = 0; + + /** + * Batches need to regenerated if the geometry is updated. + * + * @member {number} + * @protected + */ + this.batchDirty = -1; + + /** + * Used to check if the cache is dirty. + * + * @member {number} + * @protected + */ + this.cacheDirty = -1; + + /** + * Used to detect if we clear the graphics WebGL data. + * + * @member {number} + * @default 0 + * @protected + */ + this.clearDirty = 0; + + /** + * List of current draw calls drived from the batches. + * + * @member {object[]} + * @protected + */ + this.drawCalls = []; + + /** + * Intermediate abstract format sent to batch system. + * Can be converted to drawCalls or to batchable objects. + * + * @member {object[]} + * @protected + */ + this.batches = []; + + /** + * Index of the current last shape in the stack of calls. + * + * @member {number} + * @protected + */ + this.shapeIndex = 0; + + /** + * Cached bounds. + * + * @member {PIXI.Bounds} + * @protected + */ + this._bounds = new Bounds(); + + /** + * The bounds dirty flag. + * + * @member {number} + * @protected + */ + this.boundsDirty = -1; + + /** + * Padding to add to the bounds. + * + * @member {number} + * @default 0 + */ + this.boundsPadding = 0; + + this.batchable = false; + + this.indicesUint16 = null; + + this.uvsFloat32 = null; + } + + if ( BatchGeometry ) { GraphicsGeometry.__proto__ = BatchGeometry; } + GraphicsGeometry.prototype = Object.create( BatchGeometry && BatchGeometry.prototype ); + GraphicsGeometry.prototype.constructor = GraphicsGeometry; + + var prototypeAccessors = { bounds: { configurable: true } }; + + /** + * Get the current bounds of the graphic geometry. + * + * @member {PIXI.Bounds} + * @readonly + */ + prototypeAccessors.bounds.get = function () + { + if (this.boundsDirty !== this.dirty) + { + this.boundsDirty = this.dirty; + this.calculateBounds(); + } + + return this._bounds; + }; + + /** + * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings. + * + * @return {PIXI.GraphicsGeometry} This GraphicsGeometry object. Good for chaining method calls + */ + GraphicsGeometry.prototype.clear = function clear () + { + if (this.graphicsData.length > 0) + { + this.boundsDirty = -1; + this.dirty++; + this.clearDirty++; + this.batchDirty++; + this.graphicsData.length = 0; + this.shapeIndex = 0; + + this.points.length = 0; + this.colors.length = 0; + this.uvs.length = 0; + this.indices.length = 0; + this.textureIds.length = 0; + + for (var i = 0; i < this.drawCalls.length; i++) + { + this.drawCalls[i].textures.length = 0; + DRAW_CALL_POOL.push(this.drawCalls[i]); + } + + this.drawCalls.length = 0; + + for (var i$1 = 0; i$1 < this.batches.length; i$1++) + { + var batch = this.batches[i$1]; + + batch.start = 0; + batch.attribStart = 0; + batch.style = null; + BATCH_POOL.push(batch); + } + + this.batches.length = 0; + } + + return this; + }; + + /** + * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. + * + * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw. + * @param {PIXI.FillStyle} fillStyle - Defines style of the fill. + * @param {PIXI.LineStyle} lineStyle - Defines style of the lines. + * @param {PIXI.Matrix} matrix - Transform applied to the points of the shape. + * @return {PIXI.GraphicsGeometry} Returns geometry for chaining. + */ + GraphicsGeometry.prototype.drawShape = function drawShape (shape, fillStyle, lineStyle, matrix) + { + var data = new GraphicsData(shape, fillStyle, lineStyle, matrix); + + this.graphicsData.push(data); + this.dirty++; + + return this; + }; + + /** + * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. + * + * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw. + * @param {PIXI.Matrix} matrix - Transform applied to the points of the shape. + * @return {PIXI.GraphicsGeometry} Returns geometry for chaining. + */ + GraphicsGeometry.prototype.drawHole = function drawHole (shape, matrix) + { + if (!this.graphicsData.length) + { + return null; + } + + var data = new GraphicsData(shape, null, null, matrix); + + var lastShape = this.graphicsData[this.graphicsData.length - 1]; + + data.lineStyle = lastShape.lineStyle; + + lastShape.holes.push(data); + + this.dirty++; + + return data; + }; + + /** + * Destroys the Graphics object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + GraphicsGeometry.prototype.destroy = function destroy (options) + { + BatchGeometry.prototype.destroy.call(this, options); + + // destroy each of the GraphicsData objects + for (var i = 0; i < this.graphicsData.length; ++i) + { + this.graphicsData[i].destroy(); + } + + this.points.length = 0; + this.points = null; + this.colors.length = 0; + this.colors = null; + this.uvs.length = 0; + this.uvs = null; + this.indices.length = 0; + this.indices = null; + this.indexBuffer.destroy(); + this.indexBuffer = null; + this.graphicsData.length = 0; + this.graphicsData = null; + this.drawCalls.length = 0; + this.drawCalls = null; + this.batches.length = 0; + this.batches = null; + this._bounds = null; + }; + + /** + * Check to see if a point is contained within this geometry. + * + * @param {PIXI.Point} point - Point to check if it's contained. + * @return {Boolean} `true` if the point is contained within geometry. + */ + GraphicsGeometry.prototype.containsPoint = function containsPoint (point) + { + var graphicsData = this.graphicsData; + + for (var i = 0; i < graphicsData.length; ++i) + { + var data = graphicsData[i]; + + if (!data.fillStyle.visible) + { + continue; + } + + // only deal with fills.. + if (data.shape) + { + if (data.shape.contains(point.x, point.y)) + { + if (data.holes) + { + for (var i$1 = 0; i$1 < data.holes.length; i$1++) + { + var hole = data.holes[i$1]; + + if (hole.shape.contains(point.x, point.y)) + { + return false; + } + } + } + + return true; + } + } + } + + return false; + }; + + /** + * Generates intermediate batch data. Either gets converted to drawCalls + * or used to convert to batch objects directly by the Graphics object. + * @protected + */ + GraphicsGeometry.prototype.updateBatches = function updateBatches () + { + if (this.dirty === this.cacheDirty) { return; } + if (this.graphicsData.length === 0) { return; } + + if (this.dirty !== this.cacheDirty) + { + for (var i = 0; i < this.graphicsData.length; i++) + { + var data = this.graphicsData[i]; + + if (data.fillStyle && !data.fillStyle.texture.baseTexture.valid) { return; } + if (data.lineStyle && !data.lineStyle.texture.baseTexture.valid) { return; } + } + } + + this.cacheDirty = this.dirty; + + var uvs = this.uvs; + + var batchPart = this.batches.pop() + || BATCH_POOL.pop() + || new BatchPart(); + + batchPart.style = batchPart.style + || this.graphicsData[0].fillStyle + || this.graphicsData[0].lineStyle; + + var currentTexture = batchPart.style.texture.baseTexture; + var currentColor = batchPart.style.color + batchPart.style.alpha; + + this.batches.push(batchPart); + + // TODO - this can be simplified + for (var i$1 = this.shapeIndex; i$1 < this.graphicsData.length; i$1++) + { + this.shapeIndex++; + + var data$1 = this.graphicsData[i$1]; + var command = fillCommands[data$1.type]; + + var fillStyle = data$1.fillStyle; + var lineStyle = data$1.lineStyle; + + // build out the shapes points.. + command.build(data$1); + + if (data$1.matrix) + { + this.transformPoints(data$1.points, data$1.matrix); + } + + for (var j = 0; j < 2; j++) + { + var style = (j === 0) ? fillStyle : lineStyle; + + if (!style.visible) { continue; } + + var nextTexture = style.texture.baseTexture; + + if (currentTexture !== nextTexture || (style.color + style.alpha) !== currentColor) + { + // TODO use a const + nextTexture.wrapMode = 10497; + currentTexture = nextTexture; + currentColor = style.color + style.alpha; + + var index$1 = this.indices.length; + var attribIndex = this.points.length / 2; + + batchPart.size = index$1 - batchPart.start; + batchPart.attribSize = attribIndex - batchPart.attribStart; + + if (batchPart.size > 0) + { + batchPart = BATCH_POOL.pop() || new BatchPart(); + + this.batches.push(batchPart); + } + + batchPart.style = style; + batchPart.start = index$1; + batchPart.attribStart = attribIndex; + + // TODO add this to the render part.. + } + + var start = this.points.length / 2; + + if (j === 0) + { + if (data$1.holes.length) + { + this.processHoles(data$1.holes); + + buildPoly.triangulate(data$1, this); + } + else + { + command.triangulate(data$1, this); + } + } + else + { + buildLine(data$1, this); + + for (var i$2 = 0; i$2 < data$1.holes.length; i$2++) + { + buildLine(data$1.holes[i$2], this); + } + } + + var size = (this.points.length / 2) - start; + + this.addUvs(this.points, uvs, style.texture, start, size, style.matrix); + } + } + + var index = this.indices.length; + var attrib = this.points.length / 2; + + batchPart.size = index - batchPart.start; + batchPart.attribSize = attrib - batchPart.attribStart; + this.indicesUint16 = new Uint16Array(this.indices); + + // TODO make this a const.. + this.batchable = this.isBatchable(); + + if (this.batchable) + { + this.batchDirty++; + + this.uvsFloat32 = new Float32Array(this.uvs); + + // offset the indices so that it works with the batcher... + for (var i$3 = 0; i$3 < this.batches.length; i$3++) + { + var batch = this.batches[i$3]; + + for (var j$1 = 0; j$1 < batch.size; j$1++) + { + var index$2 = batch.start + j$1; + + this.indicesUint16[index$2] = this.indicesUint16[index$2] - batch.attribStart; + } + } + } + else + { + this.buildDrawCalls(); + } + }; + + /** + * Checks to see if this graphics geometry can be batched. + * Currently it needs to be small enough and not contain any native lines. + * @protected + */ + GraphicsGeometry.prototype.isBatchable = function isBatchable () + { + var batches = this.batches; + + for (var i = 0; i < batches.length; i++) + { + if (batches[i].style.native) + { + return false; + } + } + + return (this.points.length < GraphicsGeometry.BATCHABLE_SIZE * 2); + }; + + /** + * Converts intermediate batches data to drawCalls. + * @protected + */ + GraphicsGeometry.prototype.buildDrawCalls = function buildDrawCalls () + { + var TICK = ++BaseTexture._globalBatch; + + for (var i = 0; i < this.drawCalls.length; i++) + { + this.drawCalls[i].textures.length = 0; + DRAW_CALL_POOL.push(this.drawCalls[i]); + } + + this.drawCalls.length = 0; + + var uvs = this.uvs; + var colors = this.colors; + var textureIds = this.textureIds; + + var currentGroup = DRAW_CALL_POOL.pop() || new BatchDrawCall(); + + currentGroup.textureCount = 0; + currentGroup.start = 0; + currentGroup.size = 0; + currentGroup.type = DRAW_MODES.TRIANGLES; + + var textureCount = 0; + var currentTexture = null; + var textureId = 0; + var native = false; + var drawMode = DRAW_MODES.TRIANGLES; + + var index = 0; + + this.drawCalls.push(currentGroup); + + // TODO - this can be simplified + for (var i$1 = 0; i$1 < this.batches.length; i$1++) + { + var data = this.batches[i$1]; + + // TODO add some full on MAX_TEXTURE CODE.. + var MAX_TEXTURES = 8; + + var style = data.style; + + var nextTexture = style.texture.baseTexture; + + if (native !== style.native) + { + native = style.native; + drawMode = native ? DRAW_MODES.LINES : DRAW_MODES.TRIANGLES; + + // force the batch to break! + currentTexture = null; + textureCount = MAX_TEXTURES; + TICK++; + } + + if (currentTexture !== nextTexture) + { + currentTexture = nextTexture; + + if (nextTexture._batchEnabled !== TICK) + { + if (textureCount === MAX_TEXTURES) + { + TICK++; + + textureCount = 0; + + if (currentGroup.size > 0) + { + currentGroup = DRAW_CALL_POOL.pop() || new BatchDrawCall(); + this.drawCalls.push(currentGroup); + } + + currentGroup.start = index; + currentGroup.size = 0; + currentGroup.textureCount = 0; + currentGroup.type = drawMode; + } + + // TODO add this to the render part.. + nextTexture.touched = 1;// touch; + nextTexture._batchEnabled = TICK; + nextTexture._id = textureCount; + nextTexture.wrapMode = 10497; + + currentGroup.textures[currentGroup.textureCount++] = nextTexture; + textureCount++; + } + } + + currentGroup.size += data.size; + index += data.size; + + textureId = nextTexture._id; + + this.addColors(colors, style.color, style.alpha, data.attribSize); + this.addTextureIds(textureIds, textureId, data.attribSize); + } + + BaseTexture._globalBatch = TICK; + + // upload.. + // merge for now! + var verts = this.points; + + // verts are 2 positions.. so we * by 3 as there are 6 properties.. then 4 cos its bytes + var glPoints = new ArrayBuffer(verts.length * 3 * 4); + var f32 = new Float32Array(glPoints); + var u32 = new Uint32Array(glPoints); + + var p = 0; + + for (var i$2 = 0; i$2 < verts.length / 2; i$2++) + { + f32[p++] = verts[i$2 * 2]; + f32[p++] = verts[(i$2 * 2) + 1]; + + f32[p++] = uvs[i$2 * 2]; + f32[p++] = uvs[(i$2 * 2) + 1]; + + u32[p++] = colors[i$2]; + + f32[p++] = textureIds[i$2]; + } + + this._buffer.update(glPoints); + this._indexBuffer.update(this.indicesUint16); + }; + + /** + * Process the holes data. + * + * @param {PIXI.GraphicsData[]} holes - Holes to render + * @protected + */ + GraphicsGeometry.prototype.processHoles = function processHoles (holes) + { + for (var i = 0; i < holes.length; i++) + { + var hole = holes[i]; + + var command = fillCommands[hole.type]; + + command.build(hole); + + if (hole.matrix) + { + this.transformPoints(hole.points, hole.matrix); + } + } + }; + + /** + * Update the local bounds of the object. Expensive to use performance-wise. + * @protected + */ + GraphicsGeometry.prototype.calculateBounds = function calculateBounds () + { + var minX = Infinity; + var maxX = -Infinity; + + var minY = Infinity; + var maxY = -Infinity; + + if (this.graphicsData.length) + { + var shape = null; + var x = 0; + var y = 0; + var w = 0; + var h = 0; + + for (var i = 0; i < this.graphicsData.length; i++) + { + var data = this.graphicsData[i]; + + var type = data.type; + var lineWidth = data.lineStyle ? data.lineStyle.width : 0; + + shape = data.shape; + + if (type === SHAPES.RECT || type === SHAPES.RREC) + { + x = shape.x - (lineWidth / 2); + y = shape.y - (lineWidth / 2); + w = shape.width + lineWidth; + h = shape.height + lineWidth; + + minX = x < minX ? x : minX; + maxX = x + w > maxX ? x + w : maxX; + + minY = y < minY ? y : minY; + maxY = y + h > maxY ? y + h : maxY; + } + else if (type === SHAPES.CIRC) + { + x = shape.x; + y = shape.y; + w = shape.radius + (lineWidth / 2); + h = shape.radius + (lineWidth / 2); + + minX = x - w < minX ? x - w : minX; + maxX = x + w > maxX ? x + w : maxX; + + minY = y - h < minY ? y - h : minY; + maxY = y + h > maxY ? y + h : maxY; + } + else if (type === SHAPES.ELIP) + { + x = shape.x; + y = shape.y; + w = shape.width + (lineWidth / 2); + h = shape.height + (lineWidth / 2); + + minX = x - w < minX ? x - w : minX; + maxX = x + w > maxX ? x + w : maxX; + + minY = y - h < minY ? y - h : minY; + maxY = y + h > maxY ? y + h : maxY; + } + else + { + // POLY + var points = shape.points; + var x2 = 0; + var y2 = 0; + var dx = 0; + var dy = 0; + var rw = 0; + var rh = 0; + var cx = 0; + var cy = 0; + + for (var j = 0; j + 2 < points.length; j += 2) + { + x = points[j]; + y = points[j + 1]; + x2 = points[j + 2]; + y2 = points[j + 3]; + dx = Math.abs(x2 - x); + dy = Math.abs(y2 - y); + h = lineWidth; + w = Math.sqrt((dx * dx) + (dy * dy)); + + if (w < 1e-9) + { + continue; + } + + rw = ((h / w * dy) + dx) / 2; + rh = ((h / w * dx) + dy) / 2; + cx = (x2 + x) / 2; + cy = (y2 + y) / 2; + + minX = cx - rw < minX ? cx - rw : minX; + maxX = cx + rw > maxX ? cx + rw : maxX; + + minY = cy - rh < minY ? cy - rh : minY; + maxY = cy + rh > maxY ? cy + rh : maxY; + } + } + } + } + else + { + minX = 0; + maxX = 0; + minY = 0; + maxY = 0; + } + + var padding = this.boundsPadding; + + this._bounds.minX = minX - padding; + this._bounds.maxX = maxX + padding; + + this._bounds.minY = minY - padding; + this._bounds.maxY = maxY + padding; + }; + + /** + * Transform points using matrix. + * + * @protected + * @param {number[]} points - Points to transform + * @param {PIXI.Matrix} matrix - Transform matrix + */ + GraphicsGeometry.prototype.transformPoints = function transformPoints (points, matrix) + { + for (var i = 0; i < points.length / 2; i++) + { + var x = points[(i * 2)]; + var y = points[(i * 2) + 1]; + + points[(i * 2)] = (matrix.a * x) + (matrix.c * y) + matrix.tx; + points[(i * 2) + 1] = (matrix.b * x) + (matrix.d * y) + matrix.ty; + } + }; + + /** + * Add colors. + * + * @protected + * @param {number[]} colors - List of colors to add to + * @param {number} color - Color to add + * @param {number} alpha - Alpha to use + * @param {number} size - Number of colors to add + */ + GraphicsGeometry.prototype.addColors = function addColors (colors, color, alpha, size) + { + // TODO use the premultiply bits Ivan added + var rgb = (color >> 16) + (color & 0xff00) + ((color & 0xff) << 16); + + var rgba = premultiplyTint(rgb, alpha); + + while (size-- > 0) + { + colors.push(rgba); + } + }; + + /** + * Add texture id that the shader/fragment wants to use. + * + * @protected + * @param {number[]} textureIds + * @param {number} id + * @param {number} size + */ + GraphicsGeometry.prototype.addTextureIds = function addTextureIds (textureIds, id, size) + { + while (size-- > 0) + { + textureIds.push(id); + } + }; + + /** + * Generates the UVs for a shape. + * + * @protected + * @param {number[]} verts - Vertices + * @param {number[]} uvs - UVs + * @param {PIXI.Texture} texture - Reference to Texture + * @param {number} start - Index buffer start index. + * @param {number} size - The size/length for index buffer. + * @param {PIXI.Matrix} [matrix] - Optional transform for all points. + */ + GraphicsGeometry.prototype.addUvs = function addUvs (verts, uvs, texture, start, size, matrix) + { + var index = 0; + var uvsStart = uvs.length; + var frame = texture.frame; + + while (index < size) + { + var x = verts[(start + index) * 2]; + var y = verts[((start + index) * 2) + 1]; + + if (matrix) + { + var nx = (matrix.a * x) + (matrix.c * y) + matrix.tx; + + y = (matrix.b * x) + (matrix.d * y) + matrix.ty; + x = nx; + } + + index++; + + uvs.push(x / frame.width, y / frame.height); + } + + var baseTexture = texture.baseTexture; + + if (frame.width < baseTexture.width + || frame.height < baseTexture.height) + { + this.adjustUvs(uvs, texture, uvsStart, size); + } + }; + + /** + * Modify uvs array according to position of texture region + * Does not work with rotated or trimmed textures + * @param {number} uvs array + * @param {PIXI.Texture} texture region + * @param {number} start starting index for uvs + * @param {number} size how many points to adjust + */ + GraphicsGeometry.prototype.adjustUvs = function adjustUvs (uvs, texture, start, size) + { + var baseTexture = texture.baseTexture; + var eps = 1e-6; + var finish = start + (size * 2); + var frame = texture.frame; + var scaleX = frame.width / baseTexture.width; + var scaleY = frame.height / baseTexture.height; + var offsetX = frame.x / frame.width; + var offsetY = frame.y / frame.width; + var minX = Math.floor(uvs[start] + eps); + var minY = Math.floor(uvs[start + 1] + eps); + + for (var i = start + 2; i < finish; i += 2) + { + minX = Math.min(minX, Math.floor(uvs[i] + eps)); + minY = Math.min(minY, Math.floor(uvs[i + 1] + eps)); + } + offsetX -= minX; + offsetY -= minY; + for (var i$1 = start; i$1 < finish; i$1 += 2) + { + uvs[i$1] = (uvs[i$1] + offsetX) * scaleX; + uvs[i$1 + 1] = (uvs[i$1 + 1] + offsetY) * scaleY; + } + }; + + Object.defineProperties( GraphicsGeometry.prototype, prototypeAccessors ); + + return GraphicsGeometry; + }(BatchGeometry)); + + /** + * The maximum number of points to consider an object "batchable", + * able to be batched by the renderer's batch system. + * + * @memberof PIXI.GraphicsGeometry + * @static + * @member {number} BATCHABLE_SIZE + * @default 100 + */ + GraphicsGeometry.BATCHABLE_SIZE = 100; + + /** + * Represents the line style for Graphics. + * @memberof PIXI + * @class + * @extends PIXI.FillStyle + */ + var LineStyle = /*@__PURE__*/(function (FillStyle) { + function LineStyle () { + FillStyle.apply(this, arguments); + } + + if ( FillStyle ) { LineStyle.__proto__ = FillStyle; } + LineStyle.prototype = Object.create( FillStyle && FillStyle.prototype ); + LineStyle.prototype.constructor = LineStyle; + + LineStyle.prototype.clone = function clone () + { + var obj = new LineStyle(); + + obj.color = this.color; + obj.alpha = this.alpha; + obj.texture = this.texture; + obj.matrix = this.matrix; + obj.visible = this.visible; + obj.width = this.width; + obj.alignment = this.alignment; + obj.native = this.native; + + return obj; + }; + /** + * Reset the line style to default. + */ + LineStyle.prototype.reset = function reset () + { + FillStyle.prototype.reset.call(this); + + // Override default line style color + this.color = 0x0; + + /** + * The width (thickness) of any lines drawn. + * + * @member {number} + * @default 0 + */ + this.width = 0; + + /** + * The alignment of any lines drawn (0.5 = middle, 1 = outter, 0 = inner). + * + * @member {number} + * @default 0 + */ + this.alignment = 0.5; + + /** + * If true the lines will be draw using LINES instead of TRIANGLE_STRIP + * + * @member {boolean} + * @default false + */ + this.native = false; + }; + + return LineStyle; + }(FillStyle)); + + /** + * Utilities for bezier curves + * @class + * @private + */ + var BezierUtils = function BezierUtils () {}; + + BezierUtils.curveLength = function curveLength (fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) + { + var n = 10; + var result = 0.0; + var t = 0.0; + var t2 = 0.0; + var t3 = 0.0; + var nt = 0.0; + var nt2 = 0.0; + var nt3 = 0.0; + var x = 0.0; + var y = 0.0; + var dx = 0.0; + var dy = 0.0; + var prevX = fromX; + var prevY = fromY; + + for (var i = 1; i <= n; ++i) + { + t = i / n; + t2 = t * t; + t3 = t2 * t; + nt = (1.0 - t); + nt2 = nt * nt; + nt3 = nt2 * nt; + + x = (nt3 * fromX) + (3.0 * nt2 * t * cpX) + (3.0 * nt * t2 * cpX2) + (t3 * toX); + y = (nt3 * fromY) + (3.0 * nt2 * t * cpY) + (3 * nt * t2 * cpY2) + (t3 * toY); + dx = prevX - x; + dy = prevY - y; + prevX = x; + prevY = y; + + result += Math.sqrt((dx * dx) + (dy * dy)); + } + + return result; + }; + + /** + * Calculate the points for a bezier curve and then draws it. + * + * Ignored from docs since it is not directly exposed. + * + * @ignore + * @param {number} cpX - Control point x + * @param {number} cpY - Control point y + * @param {number} cpX2 - Second Control point x + * @param {number} cpY2 - Second Control point y + * @param {number} toX - Destination point x + * @param {number} toY - Destination point y + * @param {number[]} points - Path array to push points into + */ + BezierUtils.curveTo = function curveTo (cpX, cpY, cpX2, cpY2, toX, toY, points) + { + var fromX = points[points.length - 2]; + var fromY = points[points.length - 1]; + + points.length -= 2; + + var n = GRAPHICS_CURVES._segmentsCount( + BezierUtils.curveLength(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) + ); + + var dt = 0; + var dt2 = 0; + var dt3 = 0; + var t2 = 0; + var t3 = 0; + + points.push(fromX, fromY); + + for (var i = 1, j = 0; i <= n; ++i) + { + j = i / n; + + dt = (1 - j); + dt2 = dt * dt; + dt3 = dt2 * dt; + + t2 = j * j; + t3 = t2 * j; + + points.push( + (dt3 * fromX) + (3 * dt2 * j * cpX) + (3 * dt * t2 * cpX2) + (t3 * toX), + (dt3 * fromY) + (3 * dt2 * j * cpY) + (3 * dt * t2 * cpY2) + (t3 * toY) + ); + } + }; + + /** + * Utilities for quadratic curves + * @class + * @private + */ + var QuadraticUtils = function QuadraticUtils () {}; + + QuadraticUtils.curveLength = function curveLength (fromX, fromY, cpX, cpY, toX, toY) + { + var ax = fromX - (2.0 * cpX) + toX; + var ay = fromY - (2.0 * cpY) + toY; + var bx = (2.0 * cpX) - (2.0 * fromX); + var by = (2.0 * cpY) - (2.0 * fromY); + var a = 4.0 * ((ax * ax) + (ay * ay)); + var b = 4.0 * ((ax * bx) + (ay * by)); + var c = (bx * bx) + (by * by); + + var s = 2.0 * Math.sqrt(a + b + c); + var a2 = Math.sqrt(a); + var a32 = 2.0 * a * a2; + var c2 = 2.0 * Math.sqrt(c); + var ba = b / a2; + + return ( + (a32 * s) + + (a2 * b * (s - c2)) + + ( + ((4.0 * c * a) - (b * b)) + * Math.log(((2.0 * a2) + ba + s) / (ba + c2)) + ) + ) / (4.0 * a32); + }; + + /** + * Calculate the points for a quadratic bezier curve and then draws it. + * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c + * + * @private + * @param {number} cpX - Control point x + * @param {number} cpY - Control point y + * @param {number} toX - Destination point x + * @param {number} toY - Destination point y + * @param {number[]} points - Points to add segments to. + */ + QuadraticUtils.curveTo = function curveTo (cpX, cpY, toX, toY, points) + { + var fromX = points[points.length - 2]; + var fromY = points[points.length - 1]; + + var n = GRAPHICS_CURVES._segmentsCount( + QuadraticUtils.curveLength(fromX, fromY, cpX, cpY, toX, toY) + ); + + var xa = 0; + var ya = 0; + + for (var i = 1; i <= n; ++i) + { + var j = i / n; + + xa = fromX + ((cpX - fromX) * j); + ya = fromY + ((cpY - fromY) * j); + + points.push(xa + (((cpX + ((toX - cpX) * j)) - xa) * j), + ya + (((cpY + ((toY - cpY) * j)) - ya) * j)); + } + }; + + /** + * Utilities for arc curves + * @class + * @private + */ + var ArcUtils = function ArcUtils () {}; + + ArcUtils.curveTo = function curveTo (x1, y1, x2, y2, radius, points) + { + var fromX = points[points.length - 2]; + var fromY = points[points.length - 1]; + + var a1 = fromY - y1; + var b1 = fromX - x1; + var a2 = y2 - y1; + var b2 = x2 - x1; + var mm = Math.abs((a1 * b2) - (b1 * a2)); + + if (mm < 1.0e-8 || radius === 0) + { + if (points[points.length - 2] !== x1 || points[points.length - 1] !== y1) + { + points.push(x1, y1); + } + + return null; + } + + var dd = (a1 * a1) + (b1 * b1); + var cc = (a2 * a2) + (b2 * b2); + var tt = (a1 * a2) + (b1 * b2); + var k1 = radius * Math.sqrt(dd) / mm; + var k2 = radius * Math.sqrt(cc) / mm; + var j1 = k1 * tt / dd; + var j2 = k2 * tt / cc; + var cx = (k1 * b2) + (k2 * b1); + var cy = (k1 * a2) + (k2 * a1); + var px = b1 * (k2 + j1); + var py = a1 * (k2 + j1); + var qx = b2 * (k1 + j2); + var qy = a2 * (k1 + j2); + var startAngle = Math.atan2(py - cy, px - cx); + var endAngle = Math.atan2(qy - cy, qx - cx); + + return { + cx: (cx + x1), + cy: (cy + y1), + radius: radius, + startAngle: startAngle, + endAngle: endAngle, + anticlockwise: (b1 * a2 > b2 * a1), + }; + }; + + /** + * The arc method creates an arc/curve (used to create circles, or parts of circles). + * + * @private + * @param {number} startX - Start x location of arc + * @param {number} startY - Start y location of arc + * @param {number} cx - The x-coordinate of the center of the circle + * @param {number} cy - The y-coordinate of the center of the circle + * @param {number} radius - The radius of the circle + * @param {number} startAngle - The starting angle, in radians (0 is at the 3 o'clock position + * of the arc's circle) + * @param {number} endAngle - The ending angle, in radians + * @param {boolean} anticlockwise - Specifies whether the drawing should be + * counter-clockwise or clockwise. False is default, and indicates clockwise, while true + * indicates counter-clockwise. + * @param {number} n - Number of segments + * @param {number[]} points - Collection of points to add to + */ + ArcUtils.arc = function arc (startX, startY, cx, cy, radius, startAngle, endAngle, anticlockwise, points) + { + var sweep = endAngle - startAngle; + var n = GRAPHICS_CURVES._segmentsCount( + Math.abs(sweep) * radius, + Math.ceil(Math.abs(sweep) / PI_2) * 40 + ); + + var theta = (sweep) / (n * 2); + var theta2 = theta * 2; + var cTheta = Math.cos(theta); + var sTheta = Math.sin(theta); + var segMinus = n - 1; + var remainder = (segMinus % 1) / segMinus; + + for (var i = 0; i <= segMinus; ++i) + { + var real = i + (remainder * i); + var angle = ((theta) + startAngle + (theta2 * real)); + var c = Math.cos(angle); + var s = -Math.sin(angle); + + points.push( + (((cTheta * c) + (sTheta * s)) * radius) + cx, + (((cTheta * -s) + (sTheta * c)) * radius) + cy + ); + } + }; + + /** + * Draw a star shape with an arbitrary number of points. + * + * @class + * @extends PIXI.Polygon + * @memberof PIXI + * @param {number} x - Center X position of the star + * @param {number} y - Center Y position of the star + * @param {number} points - The number of points of the star, must be > 1 + * @param {number} radius - The outer radius of the star + * @param {number} [innerRadius] - The inner radius between points, default half `radius` + * @param {number} [rotation=0] - The rotation of the star in radians, where 0 is vertical + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + var Star = /*@__PURE__*/(function (Polygon) { + function Star(x, y, points, radius, innerRadius, rotation) + { + innerRadius = innerRadius || radius / 2; + + var startAngle = (-1 * Math.PI / 2) + rotation; + var len = points * 2; + var delta = PI_2 / len; + var polygon = []; + + for (var i = 0; i < len; i++) + { + var r = i % 2 ? innerRadius : radius; + var angle = (i * delta) + startAngle; + + polygon.push( + x + (r * Math.cos(angle)), + y + (r * Math.sin(angle)) + ); + } + + Polygon.call(this, polygon); + } + + if ( Polygon ) { Star.__proto__ = Polygon; } + Star.prototype = Object.create( Polygon && Polygon.prototype ); + Star.prototype.constructor = Star; + + return Star; + }(Polygon)); + + var temp = new Float32Array(3); + + // a default shader used by graphics.. + var defaultShader = null; + + /** + * The Graphics class contains methods used to draw primitive shapes such as lines, circles and + * rectangles to the display, and to color and fill them. + * + * Note that because Graphics can share a GraphicsGeometry with other instances, + * it is necessary to call `destroy()` to properly dereference the underlying + * GraphicsGeometry and avoid a memory leak. Alternatively, keep using the same + * Graphics instance and call `clear()` between redraws. + * + * @class + * @extends PIXI.Container + * @memberof PIXI + */ + var Graphics = /*@__PURE__*/(function (Container) { + function Graphics(geometry) + { + if ( geometry === void 0 ) { geometry = null; } + + Container.call(this); + /** + * Includes vertex positions, face indices, normals, colors, UVs, and + * custom attributes within buffers, reducing the cost of passing all + * this data to the GPU. Can be shared between multiple Mesh or Graphics objects. + * @member {PIXI.GraphicsGeometry} + * @readonly + */ + this.geometry = geometry || new GraphicsGeometry(); + + this.geometry.refCount++; + + /** + * Represents the vertex and fragment shaders that processes the geometry and runs on the GPU. + * Can be shared between multiple Graphics objects. + * @member {PIXI.Shader} + */ + this.shader = null; + + /** + * Represents the WebGL state the Graphics required to render, excludes shader and geometry. E.g., + * blend mode, culling, depth testing, direction of rendering triangles, backface, etc. + * @member {PIXI.State} + */ + this.state = State.for2d(); + + /** + * Current fill style + * + * @member {PIXI.FillStyle} + * @protected + */ + this._fillStyle = new FillStyle(); + + /** + * Current line style + * + * @member {PIXI.LineStyle} + * @protected + */ + this._lineStyle = new LineStyle(); + + /** + * Current shape transform matrix. + * + * @member {PIXI.Matrix} + * @protected + */ + this._matrix = null; + + /** + * Current hole mode is enabled. + * + * @member {boolean} + * @default false + * @protected + */ + this._holeMode = false; + + /** + * Current path + * + * @member {PIXI.Polygon} + * @protected + */ + this.currentPath = null; + + /** + * When cacheAsBitmap is set to true the graphics object will be rendered as if it was a sprite. + * This is useful if your graphics element does not change often, as it will speed up the rendering + * of the object in exchange for taking up texture memory. It is also useful if you need the graphics + * object to be anti-aliased, because it will be rendered using canvas. This is not recommended if + * you are constantly redrawing the graphics element. + * + * @name cacheAsBitmap + * @member {boolean} + * @memberof PIXI.Graphics# + * @default false + */ + + /** + * A collections of batches! These can be drawn by the renderer batch system. + * + * @protected + * @member {object[]} + */ + this.batches = []; + + /** + * Update dirty for limiting calculating tints for batches. + * + * @protected + * @member {number} + * @default -1 + */ + this.batchTint = -1; + + /** + * Copy of the object vertex data. + * + * @protected + * @member {Float32Array} + */ + this.vertexData = null; + + this._transformID = -1; + this.batchDirty = -1; + + // Set default + this.tint = 0xFFFFFF; + this.blendMode = BLEND_MODES.NORMAL; + } + + if ( Container ) { Graphics.__proto__ = Container; } + Graphics.prototype = Object.create( Container && Container.prototype ); + Graphics.prototype.constructor = Graphics; + + var prototypeAccessors = { blendMode: { configurable: true },tint: { configurable: true },fill: { configurable: true },line: { configurable: true } }; + + /** + * Creates a new Graphics object with the same values as this one. + * Note that the only the properties of the object are cloned, not its transform (position,scale,etc) + * + * @return {PIXI.Graphics} A clone of the graphics object + */ + Graphics.prototype.clone = function clone () + { + this.finishPoly(); + + return new Graphics(this.geometry); + }; + + /** + * The blend mode to be applied to the graphic shape. Apply a value of + * `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL; + * @see PIXI.BLEND_MODES + */ + prototypeAccessors.blendMode.set = function (value) + { + this.state.blendMode = value; + }; + + prototypeAccessors.blendMode.get = function () + { + return this.state.blendMode; + }; + + /** + * The tint applied to the graphic shape. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @default 0xFFFFFF + */ + prototypeAccessors.tint.get = function () + { + return this._tint; + }; + prototypeAccessors.tint.set = function (value) + { + this._tint = value; + }; + + /** + * The current fill style. + * + * @member {PIXI.FillStyle} + * @readonly + */ + prototypeAccessors.fill.get = function () + { + return this._fillStyle; + }; + + /** + * The current line style. + * + * @member {PIXI.LineStyle} + * @readonly + */ + prototypeAccessors.line.get = function () + { + return this._lineStyle; + }; + + /** + * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() + * method or the drawCircle() method. + * + * @param {number} [width=0] - width of the line to draw, will update the objects stored style + * @param {number} [color=0] - color of the line to draw, will update the objects stored style + * @param {number} [alpha=1] - alpha of the line to draw, will update the objects stored style + * @param {number} [alignment=1] - alignment of the line to draw, (0 = inner, 0.5 = middle, 1 = outter) + * @param {boolean} [native=false] - If true the lines will be draw using LINES instead of TRIANGLE_STRIP + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.lineStyle = function lineStyle (width, color, alpha, alignment, native) + { + if ( width === void 0 ) { width = 0; } + if ( color === void 0 ) { color = 0; } + if ( alpha === void 0 ) { alpha = 1; } + if ( alignment === void 0 ) { alignment = 0.5; } + if ( native === void 0 ) { native = false; } + + this.lineTextureStyle(width, Texture.WHITE, color, alpha, null, alignment, native); + + return this; + }; + + /** + * Like line style but support texture for line fill. + * + * @param {number} [width=0] - width of the line to draw, will update the objects stored style + * @param {PIXI.Texture} [texture=PIXI.Texture.WHITE] - Texture to use + * @param {number} [color=0] - color of the line to draw, will update the objects stored style + * @param {number} [alpha=1] - alpha of the line to draw, will update the objects stored style + * @param {PIXI.Matrix} [matrix=null] Texture matrix to transform texture + * @param {number} [alignment=0.5] - alignment of the line to draw, (0 = inner, 0.5 = middle, 1 = outter) + * @param {boolean} [native=false] - If true the lines will be draw using LINES instead of TRIANGLE_STRIP + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.lineTextureStyle = function lineTextureStyle (width, texture, color, alpha, + matrix, alignment, native) + { + if ( width === void 0 ) { width = 0; } + if ( texture === void 0 ) { texture = Texture.WHITE; } + if ( color === void 0 ) { color = 0xFFFFFF; } + if ( alpha === void 0 ) { alpha = 1; } + if ( matrix === void 0 ) { matrix = null; } + if ( alignment === void 0 ) { alignment = 0.5; } + if ( native === void 0 ) { native = false; } + + if (this.currentPath) + { + this.startPoly(); + } + + var visible = width > 0 && alpha > 0; + + if (!visible) + { + this._lineStyle.reset(); + } + else + { + if (matrix) + { + matrix = matrix.clone(); + matrix.invert(); + } + + Object.assign(this._lineStyle, { + color: color, + width: width, + alpha: alpha, + matrix: matrix, + texture: texture, + alignment: alignment, + native: native, + visible: visible, + }); + } + + return this; + }; + + /** + * Start a polygon object internally + * @protected + */ + Graphics.prototype.startPoly = function startPoly () + { + if (this.currentPath) + { + var points = this.currentPath.points; + var len = this.currentPath.points.length; + + if (len > 2) + { + this.drawShape(this.currentPath); + this.currentPath = new Polygon(); + this.currentPath.closeStroke = false; + this.currentPath.points.push(points[len - 2], points[len - 1]); + } + } + else + { + this.currentPath = new Polygon(); + this.currentPath.closeStroke = false; + } + }; + + /** + * Finish the polygon object. + * @protected + */ + Graphics.prototype.finishPoly = function finishPoly () + { + if (this.currentPath) + { + if (this.currentPath.points.length > 2) + { + this.drawShape(this.currentPath); + this.currentPath = null; + } + else + { + this.currentPath.points.length = 0; + } + } + }; + + /** + * Moves the current drawing position to x, y. + * + * @param {number} x - the X coordinate to move to + * @param {number} y - the Y coordinate to move to + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.moveTo = function moveTo (x, y) + { + this.startPoly(); + this.currentPath.points[0] = x; + this.currentPath.points[1] = y; + + return this; + }; + + /** + * Draws a line using the current line style from the current drawing position to (x, y); + * The current drawing position is then set to (x, y). + * + * @param {number} x - the X coordinate to draw to + * @param {number} y - the Y coordinate to draw to + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.lineTo = function lineTo (x, y) + { + if (!this.currentPath) + { + this.moveTo(0, 0); + } + + // remove duplicates.. + var points = this.currentPath.points; + var fromX = points[points.length - 2]; + var fromY = points[points.length - 1]; + + if (fromX !== x || fromY !== y) + { + points.push(x, y); + } + + return this; + }; + + /** + * Initialize the curve + * + * @protected + * @param {number} [x=0] + * @param {number} [y=0] + */ + Graphics.prototype._initCurve = function _initCurve (x, y) + { + if ( x === void 0 ) { x = 0; } + if ( y === void 0 ) { y = 0; } + + if (this.currentPath) + { + if (this.currentPath.points.length === 0) + { + this.currentPath.points = [x, y]; + } + } + else + { + this.moveTo(x, y); + } + }; + + /** + * Calculate the points for a quadratic bezier curve and then draws it. + * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c + * + * @param {number} cpX - Control point x + * @param {number} cpY - Control point y + * @param {number} toX - Destination point x + * @param {number} toY - Destination point y + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.quadraticCurveTo = function quadraticCurveTo (cpX, cpY, toX, toY) + { + this._initCurve(); + + var points = this.currentPath.points; + + if (points.length === 0) + { + this.moveTo(0, 0); + } + + QuadraticUtils.curveTo(cpX, cpY, toX, toY, points); + + return this; + }; + + /** + * Calculate the points for a bezier curve and then draws it. + * + * @param {number} cpX - Control point x + * @param {number} cpY - Control point y + * @param {number} cpX2 - Second Control point x + * @param {number} cpY2 - Second Control point y + * @param {number} toX - Destination point x + * @param {number} toY - Destination point y + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.bezierCurveTo = function bezierCurveTo (cpX, cpY, cpX2, cpY2, toX, toY) + { + this._initCurve(); + + BezierUtils.curveTo(cpX, cpY, cpX2, cpY2, toX, toY, this.currentPath.points); + + return this; + }; + + /** + * The arcTo() method creates an arc/curve between two tangents on the canvas. + * + * "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google! + * + * @param {number} x1 - The x-coordinate of the beginning of the arc + * @param {number} y1 - The y-coordinate of the beginning of the arc + * @param {number} x2 - The x-coordinate of the end of the arc + * @param {number} y2 - The y-coordinate of the end of the arc + * @param {number} radius - The radius of the arc + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.arcTo = function arcTo (x1, y1, x2, y2, radius) + { + this._initCurve(x1, y1); + + var points = this.currentPath.points; + + var result = ArcUtils.curveTo(x1, y1, x2, y2, radius, points); + + if (result) + { + var cx = result.cx; + var cy = result.cy; + var radius$1 = result.radius; + var startAngle = result.startAngle; + var endAngle = result.endAngle; + var anticlockwise = result.anticlockwise; + + this.arc(cx, cy, radius$1, startAngle, endAngle, anticlockwise); + } + + return this; + }; + + /** + * The arc method creates an arc/curve (used to create circles, or parts of circles). + * + * @param {number} cx - The x-coordinate of the center of the circle + * @param {number} cy - The y-coordinate of the center of the circle + * @param {number} radius - The radius of the circle + * @param {number} startAngle - The starting angle, in radians (0 is at the 3 o'clock position + * of the arc's circle) + * @param {number} endAngle - The ending angle, in radians + * @param {boolean} [anticlockwise=false] - Specifies whether the drawing should be + * counter-clockwise or clockwise. False is default, and indicates clockwise, while true + * indicates counter-clockwise. + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.arc = function arc (cx, cy, radius, startAngle, endAngle, anticlockwise) + { + if ( anticlockwise === void 0 ) { anticlockwise = false; } + + if (startAngle === endAngle) + { + return this; + } + + if (!anticlockwise && endAngle <= startAngle) + { + endAngle += PI_2; + } + else if (anticlockwise && startAngle <= endAngle) + { + startAngle += PI_2; + } + + var sweep = endAngle - startAngle; + + if (sweep === 0) + { + return this; + } + + var startX = cx + (Math.cos(startAngle) * radius); + var startY = cy + (Math.sin(startAngle) * radius); + + // If the currentPath exists, take its points. Otherwise call `moveTo` to start a path. + var points = this.currentPath ? this.currentPath.points : null; + + if (points) + { + // TODO: make a better fix. + + // We check how far our start is from the last existing point + var xDiff = Math.abs(points[points.length - 2] - startX); + var yDiff = Math.abs(points[points.length - 1] - startY); + + if (xDiff < 0.001 && yDiff < 0.001) + { ; } + else + { + points.push(startX, startY); + } + } + else + { + this.moveTo(startX, startY); + points = this.currentPath.points; + } + + ArcUtils.arc(startX, startY, cx, cy, radius, startAngle, endAngle, anticlockwise, points); + + return this; + }; + + /** + * Specifies a simple one-color fill that subsequent calls to other Graphics methods + * (such as lineTo() or drawCircle()) use when drawing. + * + * @param {number} [color=0] - the color of the fill + * @param {number} [alpha=1] - the alpha of the fill + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.beginFill = function beginFill (color, alpha) + { + if ( color === void 0 ) { color = 0; } + if ( alpha === void 0 ) { alpha = 1; } + + return this.beginTextureFill(Texture.WHITE, color, alpha); + }; + + /** + * Begin the texture fill + * + * @param {PIXI.Texture} [texture=PIXI.Texture.WHITE] - Texture to fill + * @param {number} [color=0xffffff] - Background to fill behind texture + * @param {number} [alpha=1] - Alpha of fill + * @param {PIXI.Matrix} [matrix=null] - Transform matrix + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.beginTextureFill = function beginTextureFill (texture, color, alpha, matrix) + { + if ( texture === void 0 ) { texture = Texture.WHITE; } + if ( color === void 0 ) { color = 0xFFFFFF; } + if ( alpha === void 0 ) { alpha = 1; } + if ( matrix === void 0 ) { matrix = null; } + + if (this.currentPath) + { + this.startPoly(); + } + + var visible = alpha > 0; + + if (!visible) + { + this._fillStyle.reset(); + } + else + { + if (matrix) + { + matrix = matrix.clone(); + matrix.invert(); + } + + Object.assign(this._fillStyle, { + color: color, + alpha: alpha, + texture: texture, + matrix: matrix, + visible: visible, + }); + } + + return this; + }; + + /** + * Applies a fill to the lines and shapes that were added since the last call to the beginFill() method. + * + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.endFill = function endFill () + { + this.finishPoly(); + + this._fillStyle.reset(); + + return this; + }; + + /** + * Draws a rectangle shape. + * + * @param {number} x - The X coord of the top-left of the rectangle + * @param {number} y - The Y coord of the top-left of the rectangle + * @param {number} width - The width of the rectangle + * @param {number} height - The height of the rectangle + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.drawRect = function drawRect (x, y, width, height) + { + return this.drawShape(new Rectangle(x, y, width, height)); + }; + + /** + * Draw a rectangle shape with rounded/beveled corners. + * + * @param {number} x - The X coord of the top-left of the rectangle + * @param {number} y - The Y coord of the top-left of the rectangle + * @param {number} width - The width of the rectangle + * @param {number} height - The height of the rectangle + * @param {number} radius - Radius of the rectangle corners + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.drawRoundedRect = function drawRoundedRect (x, y, width, height, radius) + { + return this.drawShape(new RoundedRectangle(x, y, width, height, radius)); + }; + + /** + * Draws a circle. + * + * @param {number} x - The X coordinate of the center of the circle + * @param {number} y - The Y coordinate of the center of the circle + * @param {number} radius - The radius of the circle + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.drawCircle = function drawCircle (x, y, radius) + { + return this.drawShape(new Circle(x, y, radius)); + }; + + /** + * Draws an ellipse. + * + * @param {number} x - The X coordinate of the center of the ellipse + * @param {number} y - The Y coordinate of the center of the ellipse + * @param {number} width - The half width of the ellipse + * @param {number} height - The half height of the ellipse + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.drawEllipse = function drawEllipse (x, y, width, height) + { + return this.drawShape(new Ellipse(x, y, width, height)); + }; + + /** + * Draws a polygon using the given path. + * + * @param {number[]|PIXI.Point[]|PIXI.Polygon} path - The path data used to construct the polygon. + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.drawPolygon = function drawPolygon (path) + { + var arguments$1 = arguments; + + // prevents an argument assignment deopt + // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments + var points = path; + + var closeStroke = true;// !!this._fillStyle; + + // check if data has points.. + if (points.points) + { + closeStroke = points.closeStroke; + points = points.points; + } + + if (!Array.isArray(points)) + { + // prevents an argument leak deopt + // see section 3.2: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments + points = new Array(arguments.length); + + for (var i = 0; i < points.length; ++i) + { + points[i] = arguments$1[i]; // eslint-disable-line prefer-rest-params + } + } + + var shape = new Polygon(points); + + shape.closeStroke = closeStroke; + + this.drawShape(shape); + + return this; + }; + + /** + * Draw any shape. + * + * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - Shape to draw + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.drawShape = function drawShape (shape) + { + if (!this._holeMode) + { + this.geometry.drawShape( + shape, + this._fillStyle.clone(), + this._lineStyle.clone(), + this._matrix + ); + } + else + { + this.geometry.drawHole(shape, this._matrix); + } + + return this; + }; + + /** + * Draw a star shape with an arbitrary number of points. + * + * @param {number} x - Center X position of the star + * @param {number} y - Center Y position of the star + * @param {number} points - The number of points of the star, must be > 1 + * @param {number} radius - The outer radius of the star + * @param {number} [innerRadius] - The inner radius between points, default half `radius` + * @param {number} [rotation=0] - The rotation of the star in radians, where 0 is vertical + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.drawStar = function drawStar (x, y, points, radius, innerRadius, rotation) + { + if ( rotation === void 0 ) { rotation = 0; } + + return this.drawPolygon(new Star(x, y, points, radius, innerRadius, rotation)); + }; + + /** + * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings. + * + * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + */ + Graphics.prototype.clear = function clear () + { + this.geometry.clear(); + + this._matrix = null; + this._holeMode = false; + this.currentPath = null; + this._spriteRect = null; + + return this; + }; + + /** + * True if graphics consists of one rectangle, and thus, can be drawn like a Sprite and + * masked with gl.scissor. + * + * @returns {boolean} True if only 1 rect. + */ + Graphics.prototype.isFastRect = function isFastRect () + { + // will fix this! + return false; + // this.graphicsData.length === 1 + // && this.graphicsData[0].shape.type === SHAPES.RECT + // && !this.graphicsData[0].lineWidth; + }; + + /** + * Renders the object using the WebGL renderer + * + * @protected + * @param {PIXI.Renderer} renderer - The renderer + */ + Graphics.prototype._render = function _render (renderer) + { + this.finishPoly(); + + var geometry = this.geometry; + + // batch part.. + // batch it! + geometry.updateBatches(); + + if (geometry.batchable) + { + if (this.batchDirty !== geometry.batchDirty) + { + this.batches = []; + this.batchTint = -1; + this._transformID = -1; + this.batchDirty = geometry.batchDirty; + + this.vertexData = new Float32Array(geometry.points); + + var blendMode = this.blendMode; + + for (var i = 0; i < geometry.batches.length; i++) + { + var gI = geometry.batches[i]; + + var color = gI.style.color; + + // + (alpha * 255 << 24); + + var vertexData = new Float32Array(this.vertexData.buffer, + gI.attribStart * 4 * 2, + gI.attribSize * 2); + + var uvs = new Float32Array(geometry.uvsFloat32.buffer, + gI.attribStart * 4 * 2, + gI.attribSize * 2); + + var indices = new Uint16Array(geometry.indicesUint16.buffer, + gI.start * 2, + gI.size); + + var batch = { + vertexData: vertexData, + blendMode: blendMode, + indices: indices, + uvs: uvs, + _batchRGB: hex2rgb(color), + _tintRGB: color, + _texture: gI.style.texture, + alpha: gI.style.alpha, + worldAlpha: 1 }; + + this.batches[i] = batch; + } + } + + renderer.batch.setObjectRenderer(renderer.plugins.batch); + + if (this.batches.length) + { + this.calculateVertices(); + this.calculateTints(); + + for (var i$1 = 0; i$1 < this.batches.length; i$1++) + { + var batch$1 = this.batches[i$1]; + + batch$1.worldAlpha = this.worldAlpha * batch$1.alpha; + + renderer.plugins.batch.render(batch$1); + } + } + } + else + { + // no batching... + renderer.batch.flush(); + + if (!this.shader) + { + // if there is no shader here, we can use the default shader. + // and that only gets created if we actually need it.. + if (!defaultShader) + { + var sampleValues = new Int32Array(16); + + for (var i$2 = 0; i$2 < 16; i$2++) + { + sampleValues[i$2] = i$2; + } + + var uniforms = { + tint: new Float32Array([1, 1, 1, 1]), + translationMatrix: new Matrix(), + default: UniformGroup.from({ uSamplers: sampleValues }, true), + }; + + // we can bbase default shader of the batch renderers program + var program = renderer.plugins.batch.shader.program; + + defaultShader = new Shader(program, uniforms); + } + + this.shader = defaultShader; + } + + var uniforms$1 = this.shader.uniforms; + + // lets set the transfomr + uniforms$1.translationMatrix = this.transform.worldTransform; + + var tint = this.tint; + var wa = this.worldAlpha; + + // and then lets set the tint.. + uniforms$1.tint[0] = (((tint >> 16) & 0xFF) / 255) * wa; + uniforms$1.tint[1] = (((tint >> 8) & 0xFF) / 255) * wa; + uniforms$1.tint[2] = ((tint & 0xFF) / 255) * wa; + uniforms$1.tint[3] = wa; + + // the first draw call, we can set the uniforms of the shader directly here. + + // this means that we can tack advantage of the sync function of pixi! + // bind and sync uniforms.. + // there is a way to optimise this.. + renderer.shader.bind(this.shader); + + // then render it + renderer.geometry.bind(geometry, this.shader); + + // set state.. + renderer.state.setState(this.state); + + // then render the rest of them... + for (var i$3 = 0; i$3 < geometry.drawCalls.length; i$3++) + { + var drawCall = geometry.drawCalls[i$3]; + + var groupTextureCount = drawCall.textureCount; + + for (var j = 0; j < groupTextureCount; j++) + { + renderer.texture.bind(drawCall.textures[j], j); + } + + // bind the geometry... + renderer.geometry.draw(drawCall.type, drawCall.size, drawCall.start); + } + } + }; + + /** + * Retrieves the bounds of the graphic shape as a rectangle object + * + * @protected + */ + Graphics.prototype._calculateBounds = function _calculateBounds () + { + this.finishPoly(); + var lb = this.geometry.bounds; + + this._bounds.addFrame(this.transform, lb.minX, lb.minY, lb.maxX, lb.maxY); + }; + + /** + * Tests if a point is inside this graphics object + * + * @param {PIXI.Point} point - the point to test + * @return {boolean} the result of the test + */ + Graphics.prototype.containsPoint = function containsPoint (point) + { + this.worldTransform.applyInverse(point, Graphics._TEMP_POINT); + + return this.geometry.containsPoint(Graphics._TEMP_POINT); + }; + + /** + * Recalcuate the tint by applying tin to batches using Graphics tint. + * @protected + */ + Graphics.prototype.calculateTints = function calculateTints () + { + if (this.batchTint !== this.tint) + { + this.batchTint = this.tint; + + var tintRGB = hex2rgb(this.tint, temp); + + for (var i = 0; i < this.batches.length; i++) + { + var batch = this.batches[i]; + + var batchTint = batch._batchRGB; + + var r = (tintRGB[0] * batchTint[0]) * 255; + var g = (tintRGB[1] * batchTint[1]) * 255; + var b = (tintRGB[2] * batchTint[2]) * 255; + + // TODO Ivan, can this be done in one go? + var color = (r << 16) + (g << 8) + (b | 0); + + batch._tintRGB = (color >> 16) + + (color & 0xff00) + + ((color & 0xff) << 16); + } + } + }; + + /** + * If there's a transform update or a change to the shape of the + * geometry, recaculate the vertices. + * @protected + */ + Graphics.prototype.calculateVertices = function calculateVertices () + { + if (this._transformID === this.transform._worldID) + { + return; + } + + this._transformID = this.transform._worldID; + + var wt = this.transform.worldTransform; + var a = wt.a; + var b = wt.b; + var c = wt.c; + var d = wt.d; + var tx = wt.tx; + var ty = wt.ty; + + var data = this.geometry.points;// batch.vertexDataOriginal; + var vertexData = this.vertexData; + + var count = 0; + + for (var i = 0; i < data.length; i += 2) + { + var x = data[i]; + var y = data[i + 1]; + + vertexData[count++] = (a * x) + (c * y) + tx; + vertexData[count++] = (d * y) + (b * x) + ty; + } + }; + + /** + * Closes the current path. + * + * @return {PIXI.Graphics} Returns itself. + */ + Graphics.prototype.closePath = function closePath () + { + var currentPath = this.currentPath; + + if (currentPath) + { + // we don't need to add extra point in the end because buildLine will take care of that + currentPath.closeStroke = true; + } + + return this; + }; + + /** + * Apply a matrix to the positional data. + * + * @param {PIXI.Matrix} matrix - Matrix to use for transform current shape. + * @return {PIXI.Graphics} Returns itself. + */ + Graphics.prototype.setMatrix = function setMatrix (matrix) + { + this._matrix = matrix; + + return this; + }; + + /** + * Begin adding holes to the last draw shape + * IMPORTANT: holes must be fully inside a shape to work + * Also weirdness ensues if holes overlap! + * Ellipses, Circles, Rectangles and Rounded Rectangles cannot be holes or host for holes in CanvasRenderer, + * please use `moveTo` `lineTo`, `quadraticCurveTo` if you rely on pixi-legacy bundle. + * @return {PIXI.Graphics} Returns itself. + */ + Graphics.prototype.beginHole = function beginHole () + { + this.finishPoly(); + this._holeMode = true; + + return this; + }; + + /** + * End adding holes to the last draw shape + * @return {PIXI.Graphics} Returns itself. + */ + Graphics.prototype.endHole = function endHole () + { + this.finishPoly(); + this._holeMode = false; + + return this; + }; + + /** + * Destroys the Graphics object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + Graphics.prototype.destroy = function destroy (options) + { + Container.prototype.destroy.call(this, options); + + this.geometry.refCount--; + if (this.geometry.refCount === 0) + { + this.geometry.dispose(); + } + + this._matrix = null; + this.currentPath = null; + this._lineStyle.destroy(); + this._lineStyle = null; + this._fillStyle.destroy(); + this._fillStyle = null; + this.geometry = null; + this.shader = null; + this.vertexData = null; + this.batches.length = 0; + this.batches = null; + + Container.prototype.destroy.call(this, options); + }; + + Object.defineProperties( Graphics.prototype, prototypeAccessors ); + + return Graphics; + }(Container)); + + /** + * Temporary point to use for containsPoint + * + * @static + * @private + * @member {PIXI.Point} + */ + Graphics._TEMP_POINT = new Point(); + + /*! + * @pixi/sprite - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/sprite is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var tempPoint = new Point(); + var indices = new Uint16Array([0, 1, 2, 0, 2, 3]); + + /** + * The Sprite object is the base for all textured objects that are rendered to the screen + * + * A sprite can be created directly from an image like this: + * + * ```js + * let sprite = new PIXI.Sprite.from('assets/image.png'); + * ``` + * + * The more efficient way to create sprites is using a {@link PIXI.Spritesheet}, + * as swapping base textures when rendering to the screen is inefficient. + * + * ```js + * PIXI.Loader.shared.add("assets/spritesheet.json").load(setup); + * + * function setup() { + * let sheet = PIXI.Loader.shared.resources["assets/spritesheet.json"].spritesheet; + * let sprite = new PIXI.Sprite(sheet.textures["image.png"]); + * ... + * } + * ``` + * + * @class + * @extends PIXI.Container + * @memberof PIXI + */ + var Sprite = /*@__PURE__*/(function (Container) { + function Sprite(texture) + { + Container.call(this); + + /** + * The anchor sets the origin point of the texture. + * The default is 0,0 or taken from the {@link PIXI.Texture#defaultAnchor|Texture} + * passed to the constructor. A value of 0,0 means the texture's origin is the top left. + * Setting the anchor to 0.5,0.5 means the texture's origin is centered. + * Setting the anchor to 1,1 would mean the texture's origin point will be the bottom right corner. + * Note: Updating the {@link PIXI.Texture#defaultAnchor} after a Texture is + * created does _not_ update the Sprite's anchor values. + * + * @member {PIXI.ObservablePoint} + * @private + */ + this._anchor = new ObservablePoint( + this._onAnchorUpdate, + this, + (texture ? texture.defaultAnchor.x : 0), + (texture ? texture.defaultAnchor.y : 0) + ); + + /** + * The texture that the sprite is using + * + * @private + * @member {PIXI.Texture} + */ + this._texture = null; + + /** + * The width of the sprite (this is initially set by the texture) + * + * @private + * @member {number} + */ + this._width = 0; + + /** + * The height of the sprite (this is initially set by the texture) + * + * @private + * @member {number} + */ + this._height = 0; + + /** + * The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect. + * + * @private + * @member {number} + * @default 0xFFFFFF + */ + this._tint = null; + this._tintRGB = null; + this.tint = 0xFFFFFF; + + /** + * The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + this.blendMode = BLEND_MODES.NORMAL; + + /** + * The shader that will be used to render the sprite. Set to null to remove a current shader. + * + * @member {PIXI.Filter|PIXI.Shader} + */ + this.shader = null; + + /** + * An internal cached value of the tint. + * + * @private + * @member {number} + * @default 0xFFFFFF + */ + this.cachedTint = 0xFFFFFF; + + this.uvs = null; + + // call texture setter + this.texture = texture || Texture.EMPTY; + + /** + * this is used to store the vertex data of the sprite (basically a quad) + * + * @private + * @member {Float32Array} + */ + this.vertexData = new Float32Array(8); + + /** + * This is used to calculate the bounds of the object IF it is a trimmed sprite + * + * @private + * @member {Float32Array} + */ + this.vertexTrimmedData = null; + + this._transformID = -1; + this._textureID = -1; + + this._transformTrimmedID = -1; + this._textureTrimmedID = -1; + + // Batchable stuff.. + // TODO could make this a mixin? + this.indices = indices; + this.size = 4; + this.start = 0; + + /** + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. + * + * @member {string} + * @default 'sprite' + */ + this.pluginName = 'batch'; + + /** + * used to fast check if a sprite is.. a sprite! + * @member {boolean} + */ + this.isSprite = true; + + /** + * Internal roundPixels field + * + * @member {boolean} + * @private + */ + this._roundPixels = settings.ROUND_PIXELS; + } + + if ( Container ) { Sprite.__proto__ = Container; } + Sprite.prototype = Object.create( Container && Container.prototype ); + Sprite.prototype.constructor = Sprite; + + var prototypeAccessors = { roundPixels: { configurable: true },width: { configurable: true },height: { configurable: true },anchor: { configurable: true },tint: { configurable: true },texture: { configurable: true } }; + + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + Sprite.prototype._onTextureUpdate = function _onTextureUpdate () + { + this._textureID = -1; + this._textureTrimmedID = -1; + this.cachedTint = 0xFFFFFF; + + this.uvs = this._texture._uvs.uvsFloat32; + // so if _width is 0 then width was not set.. + if (this._width) + { + this.scale.x = sign(this.scale.x) * this._width / this._texture.orig.width; + } + + if (this._height) + { + this.scale.y = sign(this.scale.y) * this._height / this._texture.orig.height; + } + }; + + /** + * Called when the anchor position updates. + * + * @private + */ + Sprite.prototype._onAnchorUpdate = function _onAnchorUpdate () + { + this._transformID = -1; + this._transformTrimmedID = -1; + }; + + /** + * calculates worldTransform * vertices, store it in vertexData + */ + Sprite.prototype.calculateVertices = function calculateVertices () + { + var texture = this._texture; + + if (this._transformID === this.transform._worldID && this._textureID === texture._updateID) + { + return; + } + + this._transformID = this.transform._worldID; + this._textureID = texture._updateID; + + // set the vertex data + + var wt = this.transform.worldTransform; + var a = wt.a; + var b = wt.b; + var c = wt.c; + var d = wt.d; + var tx = wt.tx; + var ty = wt.ty; + var vertexData = this.vertexData; + var trim = texture.trim; + var orig = texture.orig; + var anchor = this._anchor; + + var w0 = 0; + var w1 = 0; + var h0 = 0; + var h1 = 0; + + if (trim) + { + // if the sprite is trimmed and is not a tilingsprite then we need to add the extra + // space before transforming the sprite coords. + w1 = trim.x - (anchor._x * orig.width); + w0 = w1 + trim.width; + + h1 = trim.y - (anchor._y * orig.height); + h0 = h1 + trim.height; + } + else + { + w1 = -anchor._x * orig.width; + w0 = w1 + orig.width; + + h1 = -anchor._y * orig.height; + h0 = h1 + orig.height; + } + + // xy + vertexData[0] = (a * w1) + (c * h1) + tx; + vertexData[1] = (d * h1) + (b * w1) + ty; + + // xy + vertexData[2] = (a * w0) + (c * h1) + tx; + vertexData[3] = (d * h1) + (b * w0) + ty; + + // xy + vertexData[4] = (a * w0) + (c * h0) + tx; + vertexData[5] = (d * h0) + (b * w0) + ty; + + // xy + vertexData[6] = (a * w1) + (c * h0) + tx; + vertexData[7] = (d * h0) + (b * w1) + ty; + + if (this._roundPixels) + { + for (var i = 0; i < 8; i++) + { + vertexData[i] = Math.round(vertexData[i]); + } + } + }; + + /** + * calculates worldTransform * vertices for a non texture with a trim. store it in vertexTrimmedData + * This is used to ensure that the true width and height of a trimmed texture is respected + */ + Sprite.prototype.calculateTrimmedVertices = function calculateTrimmedVertices () + { + if (!this.vertexTrimmedData) + { + this.vertexTrimmedData = new Float32Array(8); + } + else if (this._transformTrimmedID === this.transform._worldID && this._textureTrimmedID === this._texture._updateID) + { + return; + } + + this._transformTrimmedID = this.transform._worldID; + this._textureTrimmedID = this._texture._updateID; + + // lets do some special trim code! + var texture = this._texture; + var vertexData = this.vertexTrimmedData; + var orig = texture.orig; + var anchor = this._anchor; + + // lets calculate the new untrimmed bounds.. + var wt = this.transform.worldTransform; + var a = wt.a; + var b = wt.b; + var c = wt.c; + var d = wt.d; + var tx = wt.tx; + var ty = wt.ty; + + var w1 = -anchor._x * orig.width; + var w0 = w1 + orig.width; + + var h1 = -anchor._y * orig.height; + var h0 = h1 + orig.height; + + // xy + vertexData[0] = (a * w1) + (c * h1) + tx; + vertexData[1] = (d * h1) + (b * w1) + ty; + + // xy + vertexData[2] = (a * w0) + (c * h1) + tx; + vertexData[3] = (d * h1) + (b * w0) + ty; + + // xy + vertexData[4] = (a * w0) + (c * h0) + tx; + vertexData[5] = (d * h0) + (b * w0) + ty; + + // xy + vertexData[6] = (a * w1) + (c * h0) + tx; + vertexData[7] = (d * h0) + (b * w1) + ty; + }; + + /** + * + * Renders the object using the WebGL renderer + * + * @protected + * @param {PIXI.Renderer} renderer - The webgl renderer to use. + */ + Sprite.prototype._render = function _render (renderer) + { + this.calculateVertices(); + + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); + }; + + /** + * Updates the bounds of the sprite. + * + * @protected + */ + Sprite.prototype._calculateBounds = function _calculateBounds () + { + var trim = this._texture.trim; + var orig = this._texture.orig; + + // First lets check to see if the current texture has a trim.. + if (!trim || (trim.width === orig.width && trim.height === orig.height)) + { + // no trim! lets use the usual calculations.. + this.calculateVertices(); + this._bounds.addQuad(this.vertexData); + } + else + { + // lets calculate a special trimmed bounds... + this.calculateTrimmedVertices(); + this._bounds.addQuad(this.vertexTrimmedData); + } + }; + + /** + * Gets the local bounds of the sprite object. + * + * @param {PIXI.Rectangle} rect - The output rectangle. + * @return {PIXI.Rectangle} The bounds. + */ + Sprite.prototype.getLocalBounds = function getLocalBounds (rect) + { + // we can do a fast local bounds if the sprite has no children! + if (this.children.length === 0) + { + this._bounds.minX = this._texture.orig.width * -this._anchor._x; + this._bounds.minY = this._texture.orig.height * -this._anchor._y; + this._bounds.maxX = this._texture.orig.width * (1 - this._anchor._x); + this._bounds.maxY = this._texture.orig.height * (1 - this._anchor._y); + + if (!rect) + { + if (!this._localBoundsRect) + { + this._localBoundsRect = new Rectangle(); + } + + rect = this._localBoundsRect; + } + + return this._bounds.getRectangle(rect); + } + + return Container.prototype.getLocalBounds.call(this, rect); + }; + + /** + * Tests if a point is inside this sprite + * + * @param {PIXI.Point} point - the point to test + * @return {boolean} the result of the test + */ + Sprite.prototype.containsPoint = function containsPoint (point) + { + this.worldTransform.applyInverse(point, tempPoint); + + var width = this._texture.orig.width; + var height = this._texture.orig.height; + var x1 = -width * this.anchor.x; + var y1 = 0; + + if (tempPoint.x >= x1 && tempPoint.x < x1 + width) + { + y1 = -height * this.anchor.y; + + if (tempPoint.y >= y1 && tempPoint.y < y1 + height) + { + return true; + } + } + + return false; + }; + + /** + * Destroys this sprite and optionally its texture and children + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options + * have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy + * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well + * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well + */ + Sprite.prototype.destroy = function destroy (options) + { + Container.prototype.destroy.call(this, options); + + this._texture.off('update', this._onTextureUpdate, this); + + this._anchor = null; + + var destroyTexture = typeof options === 'boolean' ? options : options && options.texture; + + if (destroyTexture) + { + var destroyBaseTexture = typeof options === 'boolean' ? options : options && options.baseTexture; + + this._texture.destroy(!!destroyBaseTexture); + } + + this._texture = null; + this.shader = null; + }; + + // some helper functions.. + + /** + * Helper function that creates a new sprite based on the source you provide. + * The source can be - frame id, image url, video url, canvas element, video element, base texture + * + * @static + * @param {number|string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source Source to create texture from + * @param {object} [options] See {@link PIXI.BaseTexture}'s constructor for options. + * @return {PIXI.Sprite} The newly created sprite + */ + Sprite.from = function from (source, options) + { + var texture = (source instanceof Texture) + ? source + : new Texture.from(source, options); + + return new Sprite(texture); + }; + + /** + * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. + * Advantages can include sharper image quality (like text) and faster rendering on canvas. + * The main disadvantage is movement of objects may appear less smooth. + * To set the global default, change {@link PIXI.settings.ROUND_PIXELS} + * + * @member {boolean} + * @default false + */ + prototypeAccessors.roundPixels.set = function (value) + { + if (this._roundPixels !== value) + { + this._transformID = -1; + } + this._roundPixels = value; + }; + + prototypeAccessors.roundPixels.get = function () + { + return this._roundPixels; + }; + + /** + * The width of the sprite, setting this will actually modify the scale to achieve the value set + * + * @member {number} + */ + prototypeAccessors.width.get = function () + { + return Math.abs(this.scale.x) * this._texture.orig.width; + }; + + prototypeAccessors.width.set = function (value) // eslint-disable-line require-jsdoc + { + var s = sign(this.scale.x) || 1; + + this.scale.x = s * value / this._texture.orig.width; + this._width = value; + }; + + /** + * The height of the sprite, setting this will actually modify the scale to achieve the value set + * + * @member {number} + */ + prototypeAccessors.height.get = function () + { + return Math.abs(this.scale.y) * this._texture.orig.height; + }; + + prototypeAccessors.height.set = function (value) // eslint-disable-line require-jsdoc + { + var s = sign(this.scale.y) || 1; + + this.scale.y = s * value / this._texture.orig.height; + this._height = value; + }; + + /** + * The anchor sets the origin point of the text. The default value is taken from the {@link PIXI.Texture|Texture} + * and passed to the constructor. + * + * The default is `(0,0)`, this means the text's origin is the top left. + * + * Setting the anchor to `(0.5,0.5)` means the text's origin is centered. + * + * Setting the anchor to `(1,1)` would mean the text's origin point will be the bottom right corner. + * + * If you pass only single parameter, it will set both x and y to the same value as shown in the example below. + * + * @example + * const sprite = new PIXI.Sprite(texture); + * sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5). + * + * @member {PIXI.ObservablePoint} + */ + prototypeAccessors.anchor.get = function () + { + return this._anchor; + }; + + prototypeAccessors.anchor.set = function (value) // eslint-disable-line require-jsdoc + { + this._anchor.copyFrom(value); + }; + + /** + * The tint applied to the sprite. This is a hex value. + * A value of 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @default 0xFFFFFF + */ + prototypeAccessors.tint.get = function () + { + return this._tint; + }; + + prototypeAccessors.tint.set = function (value) // eslint-disable-line require-jsdoc + { + this._tint = value; + this._tintRGB = (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); + }; + + /** + * The texture that the sprite is using + * + * @member {PIXI.Texture} + */ + prototypeAccessors.texture.get = function () + { + return this._texture; + }; + + prototypeAccessors.texture.set = function (value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value || Texture.EMPTY; + this.cachedTint = 0xFFFFFF; + + this._textureID = -1; + this._textureTrimmedID = -1; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + }; + + Object.defineProperties( Sprite.prototype, prototypeAccessors ); + + return Sprite; + }(Container)); + + /*! + * @pixi/text - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/text is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Constants that define the type of gradient on text. + * + * @static + * @constant + * @name TEXT_GRADIENT + * @memberof PIXI + * @type {object} + * @property {number} LINEAR_VERTICAL Vertical gradient + * @property {number} LINEAR_HORIZONTAL Linear gradient + */ + var TEXT_GRADIENT = { + LINEAR_VERTICAL: 0, + LINEAR_HORIZONTAL: 1, + }; + + // disabling eslint for now, going to rewrite this in v5 + + var defaultStyle = { + align: 'left', + breakWords: false, + dropShadow: false, + dropShadowAlpha: 1, + dropShadowAngle: Math.PI / 6, + dropShadowBlur: 0, + dropShadowColor: 'black', + dropShadowDistance: 5, + fill: 'black', + fillGradientType: TEXT_GRADIENT.LINEAR_VERTICAL, + fillGradientStops: [], + fontFamily: 'Arial', + fontSize: 26, + fontStyle: 'normal', + fontVariant: 'normal', + fontWeight: 'normal', + letterSpacing: 0, + lineHeight: 0, + lineJoin: 'miter', + miterLimit: 10, + padding: 0, + stroke: 'black', + strokeThickness: 0, + textBaseline: 'alphabetic', + trim: false, + whiteSpace: 'pre', + wordWrap: false, + wordWrapWidth: 100, + leading: 0, + }; + + var genericFontFamilies = [ + 'serif', + 'sans-serif', + 'monospace', + 'cursive', + 'fantasy', + 'system-ui' ]; + + /** + * A TextStyle Object contains information to decorate a Text objects. + * + * An instance can be shared between multiple Text objects; then changing the style will update all text objects using it. + * + * A tool can be used to generate a text style [here](https://pixijs.io/pixi-text-style). + * + * @class + * @memberof PIXI + */ + var TextStyle = function TextStyle(style) + { + this.styleID = 0; + + this.reset(); + + deepCopyProperties(this, style, style); + }; + + var prototypeAccessors$7 = { align: { configurable: true },breakWords: { configurable: true },dropShadow: { configurable: true },dropShadowAlpha: { configurable: true },dropShadowAngle: { configurable: true },dropShadowBlur: { configurable: true },dropShadowColor: { configurable: true },dropShadowDistance: { configurable: true },fill: { configurable: true },fillGradientType: { configurable: true },fillGradientStops: { configurable: true },fontFamily: { configurable: true },fontSize: { configurable: true },fontStyle: { configurable: true },fontVariant: { configurable: true },fontWeight: { configurable: true },letterSpacing: { configurable: true },lineHeight: { configurable: true },leading: { configurable: true },lineJoin: { configurable: true },miterLimit: { configurable: true },padding: { configurable: true },stroke: { configurable: true },strokeThickness: { configurable: true },textBaseline: { configurable: true },trim: { configurable: true },whiteSpace: { configurable: true },wordWrap: { configurable: true },wordWrapWidth: { configurable: true } }; + + /** + * Creates a new TextStyle object with the same values as this one. + * Note that the only the properties of the object are cloned. + * + * @return {PIXI.TextStyle} New cloned TextStyle object + */ + TextStyle.prototype.clone = function clone () + { + var clonedProperties = {}; + + deepCopyProperties(clonedProperties, this, defaultStyle); + + return new TextStyle(clonedProperties); + }; + + /** + * Resets all properties to the defaults specified in TextStyle.prototype._default + */ + TextStyle.prototype.reset = function reset () + { + deepCopyProperties(this, defaultStyle, defaultStyle); + }; + + /** + * Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * + * @member {string} + */ + prototypeAccessors$7.align.get = function () + { + return this._align; + }; + prototypeAccessors$7.align.set = function (align) // eslint-disable-line require-jsdoc + { + if (this._align !== align) + { + this._align = align; + this.styleID++; + } + }; + + /** + * Indicates if lines can be wrapped within words, it needs wordWrap to be set to true + * + * @member {boolean} + */ + prototypeAccessors$7.breakWords.get = function () + { + return this._breakWords; + }; + prototypeAccessors$7.breakWords.set = function (breakWords) // eslint-disable-line require-jsdoc + { + if (this._breakWords !== breakWords) + { + this._breakWords = breakWords; + this.styleID++; + } + }; + + /** + * Set a drop shadow for the text + * + * @member {boolean} + */ + prototypeAccessors$7.dropShadow.get = function () + { + return this._dropShadow; + }; + prototypeAccessors$7.dropShadow.set = function (dropShadow) // eslint-disable-line require-jsdoc + { + if (this._dropShadow !== dropShadow) + { + this._dropShadow = dropShadow; + this.styleID++; + } + }; + + /** + * Set alpha for the drop shadow + * + * @member {number} + */ + prototypeAccessors$7.dropShadowAlpha.get = function () + { + return this._dropShadowAlpha; + }; + prototypeAccessors$7.dropShadowAlpha.set = function (dropShadowAlpha) // eslint-disable-line require-jsdoc + { + if (this._dropShadowAlpha !== dropShadowAlpha) + { + this._dropShadowAlpha = dropShadowAlpha; + this.styleID++; + } + }; + + /** + * Set a angle of the drop shadow + * + * @member {number} + */ + prototypeAccessors$7.dropShadowAngle.get = function () + { + return this._dropShadowAngle; + }; + prototypeAccessors$7.dropShadowAngle.set = function (dropShadowAngle) // eslint-disable-line require-jsdoc + { + if (this._dropShadowAngle !== dropShadowAngle) + { + this._dropShadowAngle = dropShadowAngle; + this.styleID++; + } + }; + + /** + * Set a shadow blur radius + * + * @member {number} + */ + prototypeAccessors$7.dropShadowBlur.get = function () + { + return this._dropShadowBlur; + }; + prototypeAccessors$7.dropShadowBlur.set = function (dropShadowBlur) // eslint-disable-line require-jsdoc + { + if (this._dropShadowBlur !== dropShadowBlur) + { + this._dropShadowBlur = dropShadowBlur; + this.styleID++; + } + }; + + /** + * A fill style to be used on the dropshadow e.g 'red', '#00FF00' + * + * @member {string|number} + */ + prototypeAccessors$7.dropShadowColor.get = function () + { + return this._dropShadowColor; + }; + prototypeAccessors$7.dropShadowColor.set = function (dropShadowColor) // eslint-disable-line require-jsdoc + { + var outputColor = getColor(dropShadowColor); + if (this._dropShadowColor !== outputColor) + { + this._dropShadowColor = outputColor; + this.styleID++; + } + }; + + /** + * Set a distance of the drop shadow + * + * @member {number} + */ + prototypeAccessors$7.dropShadowDistance.get = function () + { + return this._dropShadowDistance; + }; + prototypeAccessors$7.dropShadowDistance.set = function (dropShadowDistance) // eslint-disable-line require-jsdoc + { + if (this._dropShadowDistance !== dropShadowDistance) + { + this._dropShadowDistance = dropShadowDistance; + this.styleID++; + } + }; + + /** + * A canvas fillstyle that will be used on the text e.g 'red', '#00FF00'. + * Can be an array to create a gradient eg ['#000000','#FFFFFF'] + * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle|MDN} + * + * @member {string|string[]|number|number[]|CanvasGradient|CanvasPattern} + */ + prototypeAccessors$7.fill.get = function () + { + return this._fill; + }; + prototypeAccessors$7.fill.set = function (fill) // eslint-disable-line require-jsdoc + { + var outputColor = getColor(fill); + if (this._fill !== outputColor) + { + this._fill = outputColor; + this.styleID++; + } + }; + + /** + * If fill is an array of colours to create a gradient, this can change the type/direction of the gradient. + * See {@link PIXI.TEXT_GRADIENT} + * + * @member {number} + */ + prototypeAccessors$7.fillGradientType.get = function () + { + return this._fillGradientType; + }; + prototypeAccessors$7.fillGradientType.set = function (fillGradientType) // eslint-disable-line require-jsdoc + { + if (this._fillGradientType !== fillGradientType) + { + this._fillGradientType = fillGradientType; + this.styleID++; + } + }; + + /** + * If fill is an array of colours to create a gradient, this array can set the stop points + * (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them. + * + * @member {number[]} + */ + prototypeAccessors$7.fillGradientStops.get = function () + { + return this._fillGradientStops; + }; + prototypeAccessors$7.fillGradientStops.set = function (fillGradientStops) // eslint-disable-line require-jsdoc + { + if (!areArraysEqual(this._fillGradientStops,fillGradientStops)) + { + this._fillGradientStops = fillGradientStops; + this.styleID++; + } + }; + + /** + * The font family + * + * @member {string|string[]} + */ + prototypeAccessors$7.fontFamily.get = function () + { + return this._fontFamily; + }; + prototypeAccessors$7.fontFamily.set = function (fontFamily) // eslint-disable-line require-jsdoc + { + if (this.fontFamily !== fontFamily) + { + this._fontFamily = fontFamily; + this.styleID++; + } + }; + + /** + * The font size + * (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em') + * + * @member {number|string} + */ + prototypeAccessors$7.fontSize.get = function () + { + return this._fontSize; + }; + prototypeAccessors$7.fontSize.set = function (fontSize) // eslint-disable-line require-jsdoc + { + if (this._fontSize !== fontSize) + { + this._fontSize = fontSize; + this.styleID++; + } + }; + + /** + * The font style + * ('normal', 'italic' or 'oblique') + * + * @member {string} + */ + prototypeAccessors$7.fontStyle.get = function () + { + return this._fontStyle; + }; + prototypeAccessors$7.fontStyle.set = function (fontStyle) // eslint-disable-line require-jsdoc + { + if (this._fontStyle !== fontStyle) + { + this._fontStyle = fontStyle; + this.styleID++; + } + }; + + /** + * The font variant + * ('normal' or 'small-caps') + * + * @member {string} + */ + prototypeAccessors$7.fontVariant.get = function () + { + return this._fontVariant; + }; + prototypeAccessors$7.fontVariant.set = function (fontVariant) // eslint-disable-line require-jsdoc + { + if (this._fontVariant !== fontVariant) + { + this._fontVariant = fontVariant; + this.styleID++; + } + }; + + /** + * The font weight + * ('normal', 'bold', 'bolder', 'lighter' and '100', '200', '300', '400', '500', '600', '700', 800' or '900') + * + * @member {string} + */ + prototypeAccessors$7.fontWeight.get = function () + { + return this._fontWeight; + }; + prototypeAccessors$7.fontWeight.set = function (fontWeight) // eslint-disable-line require-jsdoc + { + if (this._fontWeight !== fontWeight) + { + this._fontWeight = fontWeight; + this.styleID++; + } + }; + + /** + * The amount of spacing between letters, default is 0 + * + * @member {number} + */ + prototypeAccessors$7.letterSpacing.get = function () + { + return this._letterSpacing; + }; + prototypeAccessors$7.letterSpacing.set = function (letterSpacing) // eslint-disable-line require-jsdoc + { + if (this._letterSpacing !== letterSpacing) + { + this._letterSpacing = letterSpacing; + this.styleID++; + } + }; + + /** + * The line height, a number that represents the vertical space that a letter uses + * + * @member {number} + */ + prototypeAccessors$7.lineHeight.get = function () + { + return this._lineHeight; + }; + prototypeAccessors$7.lineHeight.set = function (lineHeight) // eslint-disable-line require-jsdoc + { + if (this._lineHeight !== lineHeight) + { + this._lineHeight = lineHeight; + this.styleID++; + } + }; + + /** + * The space between lines + * + * @member {number} + */ + prototypeAccessors$7.leading.get = function () + { + return this._leading; + }; + prototypeAccessors$7.leading.set = function (leading) // eslint-disable-line require-jsdoc + { + if (this._leading !== leading) + { + this._leading = leading; + this.styleID++; + } + }; + + /** + * The lineJoin property sets the type of corner created, it can resolve spiked text issues. + * Default is 'miter' (creates a sharp corner). + * + * @member {string} + */ + prototypeAccessors$7.lineJoin.get = function () + { + return this._lineJoin; + }; + prototypeAccessors$7.lineJoin.set = function (lineJoin) // eslint-disable-line require-jsdoc + { + if (this._lineJoin !== lineJoin) + { + this._lineJoin = lineJoin; + this.styleID++; + } + }; + + /** + * The miter limit to use when using the 'miter' lineJoin mode + * This can reduce or increase the spikiness of rendered text. + * + * @member {number} + */ + prototypeAccessors$7.miterLimit.get = function () + { + return this._miterLimit; + }; + prototypeAccessors$7.miterLimit.set = function (miterLimit) // eslint-disable-line require-jsdoc + { + if (this._miterLimit !== miterLimit) + { + this._miterLimit = miterLimit; + this.styleID++; + } + }; + + /** + * Occasionally some fonts are cropped. Adding some padding will prevent this from happening + * by adding padding to all sides of the text. + * + * @member {number} + */ + prototypeAccessors$7.padding.get = function () + { + return this._padding; + }; + prototypeAccessors$7.padding.set = function (padding) // eslint-disable-line require-jsdoc + { + if (this._padding !== padding) + { + this._padding = padding; + this.styleID++; + } + }; + + /** + * A canvas fillstyle that will be used on the text stroke + * e.g 'blue', '#FCFF00' + * + * @member {string|number} + */ + prototypeAccessors$7.stroke.get = function () + { + return this._stroke; + }; + prototypeAccessors$7.stroke.set = function (stroke) // eslint-disable-line require-jsdoc + { + var outputColor = getColor(stroke); + if (this._stroke !== outputColor) + { + this._stroke = outputColor; + this.styleID++; + } + }; + + /** + * A number that represents the thickness of the stroke. + * Default is 0 (no stroke) + * + * @member {number} + */ + prototypeAccessors$7.strokeThickness.get = function () + { + return this._strokeThickness; + }; + prototypeAccessors$7.strokeThickness.set = function (strokeThickness) // eslint-disable-line require-jsdoc + { + if (this._strokeThickness !== strokeThickness) + { + this._strokeThickness = strokeThickness; + this.styleID++; + } + }; + + /** + * The baseline of the text that is rendered. + * + * @member {string} + */ + prototypeAccessors$7.textBaseline.get = function () + { + return this._textBaseline; + }; + prototypeAccessors$7.textBaseline.set = function (textBaseline) // eslint-disable-line require-jsdoc + { + if (this._textBaseline !== textBaseline) + { + this._textBaseline = textBaseline; + this.styleID++; + } + }; + + /** + * Trim transparent borders + * + * @member {boolean} + */ + prototypeAccessors$7.trim.get = function () + { + return this._trim; + }; + prototypeAccessors$7.trim.set = function (trim) // eslint-disable-line require-jsdoc + { + if (this._trim !== trim) + { + this._trim = trim; + this.styleID++; + } + }; + + /** + * How newlines and spaces should be handled. + * Default is 'pre' (preserve, preserve). + * + * value | New lines | Spaces + * --- | --- | --- + * 'normal' | Collapse | Collapse + * 'pre' | Preserve | Preserve + * 'pre-line' | Preserve | Collapse + * + * @member {string} + */ + prototypeAccessors$7.whiteSpace.get = function () + { + return this._whiteSpace; + }; + prototypeAccessors$7.whiteSpace.set = function (whiteSpace) // eslint-disable-line require-jsdoc + { + if (this._whiteSpace !== whiteSpace) + { + this._whiteSpace = whiteSpace; + this.styleID++; + } + }; + + /** + * Indicates if word wrap should be used + * + * @member {boolean} + */ + prototypeAccessors$7.wordWrap.get = function () + { + return this._wordWrap; + }; + prototypeAccessors$7.wordWrap.set = function (wordWrap) // eslint-disable-line require-jsdoc + { + if (this._wordWrap !== wordWrap) + { + this._wordWrap = wordWrap; + this.styleID++; + } + }; + + /** + * The width at which text will wrap, it needs wordWrap to be set to true + * + * @member {number} + */ + prototypeAccessors$7.wordWrapWidth.get = function () + { + return this._wordWrapWidth; + }; + prototypeAccessors$7.wordWrapWidth.set = function (wordWrapWidth) // eslint-disable-line require-jsdoc + { + if (this._wordWrapWidth !== wordWrapWidth) + { + this._wordWrapWidth = wordWrapWidth; + this.styleID++; + } + }; + + /** + * Generates a font style string to use for `TextMetrics.measureFont()`. + * + * @return {string} Font style string, for passing to `TextMetrics.measureFont()` + */ + TextStyle.prototype.toFontString = function toFontString () + { + // build canvas api font setting from individual components. Convert a numeric this.fontSize to px + var fontSizeString = (typeof this.fontSize === 'number') ? ((this.fontSize) + "px") : this.fontSize; + + // Clean-up fontFamily property by quoting each font name + // this will support font names with spaces + var fontFamilies = this.fontFamily; + + if (!Array.isArray(this.fontFamily)) + { + fontFamilies = this.fontFamily.split(','); + } + + for (var i = fontFamilies.length - 1; i >= 0; i--) + { + // Trim any extra white-space + var fontFamily = fontFamilies[i].trim(); + + // Check if font already contains strings + if (!(/([\"\'])[^\'\"]+\1/).test(fontFamily) && genericFontFamilies.indexOf(fontFamily) < 0) + { + fontFamily = "\"" + fontFamily + "\""; + } + fontFamilies[i] = fontFamily; + } + + return ((this.fontStyle) + " " + (this.fontVariant) + " " + (this.fontWeight) + " " + fontSizeString + " " + (fontFamilies.join(','))); + }; + + Object.defineProperties( TextStyle.prototype, prototypeAccessors$7 ); + + /** + * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string. + * @private + * @param {number|number[]} color + * @return {string} The color as a string. + */ + function getSingleColor(color) + { + if (typeof color === 'number') + { + return hex2string(color); + } + else if ( typeof color === 'string' ) + { + if ( color.indexOf('0x') === 0 ) + { + color = color.replace('0x', '#'); + } + } + + return color; + } + + /** + * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string. + * This version can also convert array of colors + * @private + * @param {number|number[]} color + * @return {string} The color as a string. + */ + function getColor(color) + { + if (!Array.isArray(color)) + { + return getSingleColor(color); + } + else + { + for (var i = 0; i < color.length; ++i) + { + color[i] = getSingleColor(color[i]); + } + + return color; + } + } + + /** + * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string. + * This version can also convert array of colors + * @private + * @param {Array} array1 First array to compare + * @param {Array} array2 Second array to compare + * @return {boolean} Do the arrays contain the same values in the same order + */ + function areArraysEqual(array1, array2) + { + if (!Array.isArray(array1) || !Array.isArray(array2)) + { + return false; + } + + if (array1.length !== array2.length) + { + return false; + } + + for (var i = 0; i < array1.length; ++i) + { + if (array1[i] !== array2[i]) + { + return false; + } + } + + return true; + } + + /** + * Utility function to ensure that object properties are copied by value, and not by reference + * @private + * @param {Object} target Target object to copy properties into + * @param {Object} source Source object for the properties to copy + * @param {string} propertyObj Object containing properties names we want to loop over + */ + function deepCopyProperties(target, source, propertyObj) { + for (var prop in propertyObj) { + if (Array.isArray(source[prop])) { + target[prop] = source[prop].slice(); + } else { + target[prop] = source[prop]; + } + } + } + + /** + * The TextMetrics object represents the measurement of a block of text with a specified style. + * + * ```js + * let style = new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'}) + * let textMetrics = PIXI.TextMetrics.measureText('Your text', style) + * ``` + * + * @class + * @memberof PIXI + */ + var TextMetrics = function TextMetrics(text, style, width, height, lines, lineWidths, lineHeight, maxLineWidth, fontProperties) + { + this.text = text; + this.style = style; + this.width = width; + this.height = height; + this.lines = lines; + this.lineWidths = lineWidths; + this.lineHeight = lineHeight; + this.maxLineWidth = maxLineWidth; + this.fontProperties = fontProperties; + }; + + /** + * Measures the supplied string of text and returns a Rectangle. + * + * @param {string} text - the text to measure. + * @param {PIXI.TextStyle} style - the text style to use for measuring + * @param {boolean} [wordWrap] - optional override for if word-wrap should be applied to the text. + * @param {HTMLCanvasElement} [canvas] - optional specification of the canvas to use for measuring. + * @return {PIXI.TextMetrics} measured width and height of the text. + */ + TextMetrics.measureText = function measureText (text, style, wordWrap, canvas) + { + if ( canvas === void 0 ) { canvas = TextMetrics._canvas; } + + wordWrap = (wordWrap === undefined || wordWrap === null) ? style.wordWrap : wordWrap; + var font = style.toFontString(); + var fontProperties = TextMetrics.measureFont(font); + + // fallback in case UA disallow canvas data extraction + // (toDataURI, getImageData functions) + if (fontProperties.fontSize === 0) + { + fontProperties.fontSize = style.fontSize; + fontProperties.ascent = style.fontSize; + } + + var context = canvas.getContext('2d'); + + context.font = font; + + var outputText = wordWrap ? TextMetrics.wordWrap(text, style, canvas) : text; + var lines = outputText.split(/(?:\r\n|\r|\n)/); + var lineWidths = new Array(lines.length); + var maxLineWidth = 0; + + for (var i = 0; i < lines.length; i++) + { + var lineWidth = context.measureText(lines[i]).width + ((lines[i].length - 1) * style.letterSpacing); + + lineWidths[i] = lineWidth; + maxLineWidth = Math.max(maxLineWidth, lineWidth); + } + var width = maxLineWidth + style.strokeThickness; + + if (style.dropShadow) + { + width += style.dropShadowDistance; + } + + var lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; + var height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + + ((lines.length - 1) * (lineHeight + style.leading)); + + if (style.dropShadow) + { + height += style.dropShadowDistance; + } + + return new TextMetrics( + text, + style, + width, + height, + lines, + lineWidths, + lineHeight + style.leading, + maxLineWidth, + fontProperties + ); + }; + + /** + * Applies newlines to a string to have it optimally fit into the horizontal + * bounds set by the Text object's wordWrapWidth property. + * + * @private + * @param {string} text - String to apply word wrapping to + * @param {PIXI.TextStyle} style - the style to use when wrapping + * @param {HTMLCanvasElement} [canvas] - optional specification of the canvas to use for measuring. + * @return {string} New string with new lines applied where required + */ + TextMetrics.wordWrap = function wordWrap (text, style, canvas) + { + if ( canvas === void 0 ) { canvas = TextMetrics._canvas; } + + var context = canvas.getContext('2d'); + + var width = 0; + var line = ''; + var lines = ''; + + var cache = {}; + var letterSpacing = style.letterSpacing; + var whiteSpace = style.whiteSpace; + + // How to handle whitespaces + var collapseSpaces = TextMetrics.collapseSpaces(whiteSpace); + var collapseNewlines = TextMetrics.collapseNewlines(whiteSpace); + + // whether or not spaces may be added to the beginning of lines + var canPrependSpaces = !collapseSpaces; + + // There is letterSpacing after every char except the last one + // t_h_i_s_' '_i_s_' '_a_n_' '_e_x_a_m_p_l_e_' '_! + // so for convenience the above needs to be compared to width + 1 extra letterSpace + // t_h_i_s_' '_i_s_' '_a_n_' '_e_x_a_m_p_l_e_' '_!_ + // ________________________________________________ + // And then the final space is simply no appended to each line + var wordWrapWidth = style.wordWrapWidth + letterSpacing; + + // break text into words, spaces and newline chars + var tokens = TextMetrics.tokenize(text); + + for (var i = 0; i < tokens.length; i++) + { + // get the word, space or newlineChar + var token = tokens[i]; + + // if word is a new line + if (TextMetrics.isNewline(token)) + { + // keep the new line + if (!collapseNewlines) + { + lines += TextMetrics.addLine(line); + canPrependSpaces = !collapseSpaces; + line = ''; + width = 0; + continue; + } + + // if we should collapse new lines + // we simply convert it into a space + token = ' '; + } + + // if we should collapse repeated whitespaces + if (collapseSpaces) + { + // check both this and the last tokens for spaces + var currIsBreakingSpace = TextMetrics.isBreakingSpace(token); + var lastIsBreakingSpace = TextMetrics.isBreakingSpace(line[line.length - 1]); + + if (currIsBreakingSpace && lastIsBreakingSpace) + { + continue; + } + } + + // get word width from cache if possible + var tokenWidth = TextMetrics.getFromCache(token, letterSpacing, cache, context); + + // word is longer than desired bounds + if (tokenWidth > wordWrapWidth) + { + // if we are not already at the beginning of a line + if (line !== '') + { + // start newlines for overflow words + lines += TextMetrics.addLine(line); + line = ''; + width = 0; + } + + // break large word over multiple lines + if (TextMetrics.canBreakWords(token, style.breakWords)) + { + // break word into characters + var characters = token.split(''); + + // loop the characters + for (var j = 0; j < characters.length; j++) + { + var char = characters[j]; + + var k = 1; + // we are not at the end of the token + + while (characters[j + k]) + { + var nextChar = characters[j + k]; + var lastChar = char[char.length - 1]; + + // should not split chars + if (!TextMetrics.canBreakChars(lastChar, nextChar, token, j, style.breakWords)) + { + // combine chars & move forward one + char += nextChar; + } + else + { + break; + } + + k++; + } + + j += char.length - 1; + + var characterWidth = TextMetrics.getFromCache(char, letterSpacing, cache, context); + + if (characterWidth + width > wordWrapWidth) + { + lines += TextMetrics.addLine(line); + canPrependSpaces = false; + line = ''; + width = 0; + } + + line += char; + width += characterWidth; + } + } + + // run word out of the bounds + else + { + // if there are words in this line already + // finish that line and start a new one + if (line.length > 0) + { + lines += TextMetrics.addLine(line); + line = ''; + width = 0; + } + + var isLastToken = i === tokens.length - 1; + + // give it its own line if it's not the end + lines += TextMetrics.addLine(token, !isLastToken); + canPrependSpaces = false; + line = ''; + width = 0; + } + } + + // word could fit + else + { + // word won't fit because of existing words + // start a new line + if (tokenWidth + width > wordWrapWidth) + { + // if its a space we don't want it + canPrependSpaces = false; + + // add a new line + lines += TextMetrics.addLine(line); + + // start a new line + line = ''; + width = 0; + } + + // don't add spaces to the beginning of lines + if (line.length > 0 || !TextMetrics.isBreakingSpace(token) || canPrependSpaces) + { + // add the word to the current line + line += token; + + // update width counter + width += tokenWidth; + } + } + } + + lines += TextMetrics.addLine(line, false); + + return lines; + }; + + /** + * Convienience function for logging each line added during the wordWrap + * method + * + * @private + * @param {string} line - The line of text to add + * @param {boolean} newLine - Add new line character to end + * @return {string} A formatted line + */ + TextMetrics.addLine = function addLine (line, newLine) + { + if ( newLine === void 0 ) { newLine = true; } + + line = TextMetrics.trimRight(line); + + line = (newLine) ? (line + "\n") : line; + + return line; + }; + + /** + * Gets & sets the widths of calculated characters in a cache object + * + * @private + * @param {string} key The key + * @param {number} letterSpacing The letter spacing + * @param {object} cache The cache + * @param {CanvasRenderingContext2D} context The canvas context + * @return {number} The from cache. + */ + TextMetrics.getFromCache = function getFromCache (key, letterSpacing, cache, context) + { + var width = cache[key]; + + if (width === undefined) + { + var spacing = ((key.length) * letterSpacing); + + width = context.measureText(key).width + spacing; + cache[key] = width; + } + + return width; + }; + + /** + * Determines whether we should collapse breaking spaces + * + * @private + * @param {string} whiteSpace The TextStyle property whiteSpace + * @return {boolean} should collapse + */ + TextMetrics.collapseSpaces = function collapseSpaces (whiteSpace) + { + return (whiteSpace === 'normal' || whiteSpace === 'pre-line'); + }; + + /** + * Determines whether we should collapse newLine chars + * + * @private + * @param {string} whiteSpace The white space + * @return {boolean} should collapse + */ + TextMetrics.collapseNewlines = function collapseNewlines (whiteSpace) + { + return (whiteSpace === 'normal'); + }; + + /** + * trims breaking whitespaces from string + * + * @private + * @param {string} text The text + * @return {string} trimmed string + */ + TextMetrics.trimRight = function trimRight (text) + { + if (typeof text !== 'string') + { + return ''; + } + + for (var i = text.length - 1; i >= 0; i--) + { + var char = text[i]; + + if (!TextMetrics.isBreakingSpace(char)) + { + break; + } + + text = text.slice(0, -1); + } + + return text; + }; + + /** + * Determines if char is a newline. + * + * @private + * @param {string} char The character + * @return {boolean} True if newline, False otherwise. + */ + TextMetrics.isNewline = function isNewline (char) + { + if (typeof char !== 'string') + { + return false; + } + + return (TextMetrics._newlines.indexOf(char.charCodeAt(0)) >= 0); + }; + + /** + * Determines if char is a breaking whitespace. + * + * @private + * @param {string} char The character + * @return {boolean} True if whitespace, False otherwise. + */ + TextMetrics.isBreakingSpace = function isBreakingSpace (char) + { + if (typeof char !== 'string') + { + return false; + } + + return (TextMetrics._breakingSpaces.indexOf(char.charCodeAt(0)) >= 0); + }; + + /** + * Splits a string into words, breaking-spaces and newLine characters + * + * @private + * @param {string} text The text + * @return {string[]} A tokenized array + */ + TextMetrics.tokenize = function tokenize (text) + { + var tokens = []; + var token = ''; + + if (typeof text !== 'string') + { + return tokens; + } + + for (var i = 0; i < text.length; i++) + { + var char = text[i]; + + if (TextMetrics.isBreakingSpace(char) || TextMetrics.isNewline(char)) + { + if (token !== '') + { + tokens.push(token); + token = ''; + } + + tokens.push(char); + + continue; + } + + token += char; + } + + if (token !== '') + { + tokens.push(token); + } + + return tokens; + }; + + /** + * This method exists to be easily overridden + * It allows one to customise which words should break + * Examples are if the token is CJK or numbers. + * It must return a boolean. + * + * @private + * @param {string} token The token + * @param {boolean} breakWords The style attr break words + * @return {boolean} whether to break word or not + */ + TextMetrics.canBreakWords = function canBreakWords (token, breakWords) + { + return breakWords; + }; + + /** + * This method exists to be easily overridden + * It allows one to determine whether a pair of characters + * should be broken by newlines + * For example certain characters in CJK langs or numbers. + * It must return a boolean. + * + * @private + * @param {string} char The character + * @param {string} nextChar The next character + * @param {string} token The token/word the characters are from + * @param {number} index The index in the token of the char + * @param {boolean} breakWords The style attr break words + * @return {boolean} whether to break word or not + */ + TextMetrics.canBreakChars = function canBreakChars (char, nextChar, token, index, breakWords) // eslint-disable-line no-unused-vars + { + return true; + }; + + /** + * Calculates the ascent, descent and fontSize of a given font-style + * + * @static + * @param {string} font - String representing the style of the font + * @return {PIXI.IFontMetrics} Font properties object + */ + TextMetrics.measureFont = function measureFont (font) + { + // as this method is used for preparing assets, don't recalculate things if we don't need to + if (TextMetrics._fonts[font]) + { + return TextMetrics._fonts[font]; + } + + var properties = {}; + + var canvas = TextMetrics._canvas; + var context = TextMetrics._context; + + context.font = font; + + var metricsString = TextMetrics.METRICS_STRING + TextMetrics.BASELINE_SYMBOL; + var width = Math.ceil(context.measureText(metricsString).width); + var baseline = Math.ceil(context.measureText(TextMetrics.BASELINE_SYMBOL).width); + var height = 2 * baseline; + + baseline = baseline * TextMetrics.BASELINE_MULTIPLIER | 0; + + canvas.width = width; + canvas.height = height; + + context.fillStyle = '#f00'; + context.fillRect(0, 0, width, height); + + context.font = font; + + context.textBaseline = 'alphabetic'; + context.fillStyle = '#000'; + context.fillText(metricsString, 0, baseline); + + var imagedata = context.getImageData(0, 0, width, height).data; + var pixels = imagedata.length; + var line = width * 4; + + var i = 0; + var idx = 0; + var stop = false; + + // ascent. scan from top to bottom until we find a non red pixel + for (i = 0; i < baseline; ++i) + { + for (var j = 0; j < line; j += 4) + { + if (imagedata[idx + j] !== 255) + { + stop = true; + break; + } + } + if (!stop) + { + idx += line; + } + else + { + break; + } + } + + properties.ascent = baseline - i; + + idx = pixels - line; + stop = false; + + // descent. scan from bottom to top until we find a non red pixel + for (i = height; i > baseline; --i) + { + for (var j$1 = 0; j$1 < line; j$1 += 4) + { + if (imagedata[idx + j$1] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx -= line; + } + else + { + break; + } + } + + properties.descent = i - baseline; + properties.fontSize = properties.ascent + properties.descent; + + TextMetrics._fonts[font] = properties; + + return properties; + }; + + /** + * Clear font metrics in metrics cache. + * + * @static + * @param {string} [font] - font name. If font name not set then clear cache for all fonts. + */ + TextMetrics.clearMetrics = function clearMetrics (font) + { + if ( font === void 0 ) { font = ''; } + + if (font) + { + delete TextMetrics._fonts[font]; + } + else + { + TextMetrics._fonts = {}; + } + }; + + /** + * Internal return object for {@link PIXI.TextMetrics.measureFont `TextMetrics.measureFont`}. + * + * @typedef {object} FontMetrics + * @property {number} ascent - The ascent distance + * @property {number} descent - The descent distance + * @property {number} fontSize - Font size from ascent to descent + * @memberof PIXI.TextMetrics + * @private + */ + + var canvas = document.createElement('canvas'); + + canvas.width = canvas.height = 10; + + /** + * Cached canvas element for measuring text + * + * @memberof PIXI.TextMetrics + * @type {HTMLCanvasElement} + * @private + */ + TextMetrics._canvas = canvas; + + /** + * Cache for context to use. + * + * @memberof PIXI.TextMetrics + * @type {CanvasRenderingContext2D} + * @private + */ + TextMetrics._context = canvas.getContext('2d'); + + /** + * Cache of {@see PIXI.TextMetrics.FontMetrics} objects. + * + * @memberof PIXI.TextMetrics + * @type {Object} + * @private + */ + TextMetrics._fonts = {}; + + /** + * String used for calculate font metrics. + * These characters are all tall to help calculate the height required for text. + * + * @static + * @memberof PIXI.TextMetrics + * @name METRICS_STRING + * @type {string} + * @default |ÉqÅ + */ + TextMetrics.METRICS_STRING = '|ÉqÅ'; + + /** + * Baseline symbol for calculate font metrics. + * + * @static + * @memberof PIXI.TextMetrics + * @name BASELINE_SYMBOL + * @type {string} + * @default M + */ + TextMetrics.BASELINE_SYMBOL = 'M'; + + /** + * Baseline multiplier for calculate font metrics. + * + * @static + * @memberof PIXI.TextMetrics + * @name BASELINE_MULTIPLIER + * @type {number} + * @default 1.4 + */ + TextMetrics.BASELINE_MULTIPLIER = 1.4; + + /** + * Cache of new line chars. + * + * @memberof PIXI.TextMetrics + * @type {number[]} + * @private + */ + TextMetrics._newlines = [ + 0x000A, // line feed + 0x000D ]; + + /** + * Cache of breaking spaces. + * + * @memberof PIXI.TextMetrics + * @type {number[]} + * @private + */ + TextMetrics._breakingSpaces = [ + 0x0009, // character tabulation + 0x0020, // space + 0x2000, // en quad + 0x2001, // em quad + 0x2002, // en space + 0x2003, // em space + 0x2004, // three-per-em space + 0x2005, // four-per-em space + 0x2006, // six-per-em space + 0x2008, // punctuation space + 0x2009, // thin space + 0x200A, // hair space + 0x205F, // medium mathematical space + 0x3000 ]; + + /** + * A number, or a string containing a number. + * + * @memberof PIXI + * @typedef IFontMetrics + * @property {number} ascent - Font ascent + * @property {number} descent - Font descent + * @property {number} fontSize - Font size + */ + + /* eslint max-depth: [2, 8] */ + + var defaultDestroyOptions = { + texture: true, + children: false, + baseTexture: true, + }; + + /** + * A Text Object will create a line or multiple lines of text. + * + * The text is created using the [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API). + * + * The primary advantage of this class over BitmapText is that you have great control over the style of the next, + * which you can change at runtime. + * + * The primary disadvantages is that each piece of text has it's own texture, which can use more memory. + * When text changes, this texture has to be re-generated and re-uploaded to the GPU, taking up time. + * + * To split a line you can use '\n' in your text string, or, on the `style` object, + * change its `wordWrap` property to true and and give the `wordWrapWidth` property a value. + * + * A Text can be created directly from a string and a style object, + * which can be generated [here](https://pixijs.io/pixi-text-style). + * + * ```js + * let text = new PIXI.Text('This is a PixiJS text',{fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'}); + * ``` + * + * @class + * @extends PIXI.Sprite + * @memberof PIXI + */ + var Text = /*@__PURE__*/(function (Sprite) { + function Text(text, style, canvas) + { + canvas = canvas || document.createElement('canvas'); + + canvas.width = 3; + canvas.height = 3; + + var texture = Texture.from(canvas); + + texture.orig = new Rectangle(); + texture.trim = new Rectangle(); + + Sprite.call(this, texture); + + /** + * The canvas element that everything is drawn to + * + * @member {HTMLCanvasElement} + */ + this.canvas = canvas; + + /** + * The canvas 2d context that everything is drawn with + * @member {CanvasRenderingContext2D} + */ + this.context = this.canvas.getContext('2d'); + + /** + * The resolution / device pixel ratio of the canvas. + * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually. + * @member {number} + * @default 1 + */ + this._resolution = settings.RESOLUTION; + this._autoResolution = true; + + /** + * Private tracker for the current text. + * + * @member {string} + * @private + */ + this._text = null; + + /** + * Private tracker for the current style. + * + * @member {object} + * @private + */ + this._style = null; + /** + * Private listener to track style changes. + * + * @member {Function} + * @private + */ + this._styleListener = null; + + /** + * Private tracker for the current font. + * + * @member {string} + * @private + */ + this._font = ''; + + this.text = text; + this.style = style; + + this.localStyleID = -1; + } + + if ( Sprite ) { Text.__proto__ = Sprite; } + Text.prototype = Object.create( Sprite && Sprite.prototype ); + Text.prototype.constructor = Text; + + var prototypeAccessors = { width: { configurable: true },height: { configurable: true },style: { configurable: true },text: { configurable: true },resolution: { configurable: true } }; + + /** + * Renders text and updates it when needed. + * + * @private + * @param {boolean} respectDirty - Whether to abort updating the text if the Text isn't dirty and the function is called. + */ + Text.prototype.updateText = function updateText (respectDirty) + { + var style = this._style; + + // check if style has changed.. + if (this.localStyleID !== style.styleID) + { + this.dirty = true; + this.localStyleID = style.styleID; + } + + if (!this.dirty && respectDirty) + { + return; + } + + this._font = this._style.toFontString(); + + var context = this.context; + var measured = TextMetrics.measureText(this._text || ' ', this._style, this._style.wordWrap, this.canvas); + var width = measured.width; + var height = measured.height; + var lines = measured.lines; + var lineHeight = measured.lineHeight; + var lineWidths = measured.lineWidths; + var maxLineWidth = measured.maxLineWidth; + var fontProperties = measured.fontProperties; + + this.canvas.width = Math.ceil((Math.max(1, width) + (style.padding * 2)) * this._resolution); + this.canvas.height = Math.ceil((Math.max(1, height) + (style.padding * 2)) * this._resolution); + + context.scale(this._resolution, this._resolution); + + context.clearRect(0, 0, this.canvas.width, this.canvas.height); + + context.font = this._font; + context.strokeStyle = style.stroke; + context.lineWidth = style.strokeThickness; + context.textBaseline = style.textBaseline; + context.lineJoin = style.lineJoin; + context.miterLimit = style.miterLimit; + + var linePositionX; + var linePositionY; + + if (style.dropShadow) + { + var dropShadowColor = style.dropShadowColor; + var rgb = hex2rgb(typeof dropShadowColor === 'number' ? dropShadowColor : string2hex(dropShadowColor)); + + context.shadowColor = "rgba(" + (rgb[0] * 255) + "," + (rgb[1] * 255) + "," + (rgb[2] * 255) + "," + (style.dropShadowAlpha) + ")"; + context.shadowBlur = style.dropShadowBlur; + context.shadowOffsetX = Math.cos(style.dropShadowAngle) * style.dropShadowDistance; + context.shadowOffsetY = Math.sin(style.dropShadowAngle) * style.dropShadowDistance; + } + else + { + context.shadowColor = 0; + context.shadowBlur = 0; + context.shadowOffsetX = 0; + context.shadowOffsetY = 0; + } + + // set canvas text styles + context.fillStyle = this._generateFillStyle(style, lines); + + // draw lines line by line + for (var i = 0; i < lines.length; i++) + { + linePositionX = style.strokeThickness / 2; + linePositionY = ((style.strokeThickness / 2) + (i * lineHeight)) + fontProperties.ascent; + + if (style.align === 'right') + { + linePositionX += maxLineWidth - lineWidths[i]; + } + else if (style.align === 'center') + { + linePositionX += (maxLineWidth - lineWidths[i]) / 2; + } + + if (style.stroke && style.strokeThickness) + { + this.drawLetterSpacing( + lines[i], + linePositionX + style.padding, + linePositionY + style.padding, + true + ); + } + + if (style.fill) + { + this.drawLetterSpacing( + lines[i], + linePositionX + style.padding, + linePositionY + style.padding + ); + } + } + + this.updateTexture(); + }; + + /** + * Render the text with letter-spacing. + * @param {string} text - The text to draw + * @param {number} x - Horizontal position to draw the text + * @param {number} y - Vertical position to draw the text + * @param {boolean} [isStroke=false] - Is this drawing for the outside stroke of the + * text? If not, it's for the inside fill + * @private + */ + Text.prototype.drawLetterSpacing = function drawLetterSpacing (text, x, y, isStroke) + { + if ( isStroke === void 0 ) { isStroke = false; } + + var style = this._style; + + // letterSpacing of 0 means normal + var letterSpacing = style.letterSpacing; + + if (letterSpacing === 0) + { + if (isStroke) + { + this.context.strokeText(text, x, y); + } + else + { + this.context.fillText(text, x, y); + } + + return; + } + + var currentPosition = x; + + // Using Array.from correctly splits characters whilst keeping emoji together. + // This is not supported on IE as it requires ES6, so regular text splitting occurs. + // This also doesn't account for emoji that are multiple emoji put together to make something else. + // Handling all of this would require a big library itself. + // https://medium.com/@giltayar/iterating-over-emoji-characters-the-es6-way-f06e4589516 + // https://github.com/orling/grapheme-splitter + var stringArray = Array.from ? Array.from(text) : text.split(''); + + for (var i = 0; i < stringArray.length; ++i) + { + var currentChar = stringArray[i]; + + if (isStroke) + { + this.context.strokeText(currentChar, currentPosition, y); + } + else + { + this.context.fillText(currentChar, currentPosition, y); + } + currentPosition += this.context.measureText(currentChar).width + letterSpacing; + } + }; + + /** + * Updates texture size based on canvas size + * + * @private + */ + Text.prototype.updateTexture = function updateTexture () + { + var canvas = this.canvas; + + if (this._style.trim) + { + var trimmed = trimCanvas(canvas); + + if (trimmed.data) + { + canvas.width = trimmed.width; + canvas.height = trimmed.height; + this.context.putImageData(trimmed.data, 0, 0); + } + } + + var texture = this._texture; + var style = this._style; + var padding = style.trim ? 0 : style.padding; + var baseTexture = texture.baseTexture; + + texture.trim.width = texture._frame.width = canvas.width / this._resolution; + texture.trim.height = texture._frame.height = canvas.height / this._resolution; + texture.trim.x = -padding; + texture.trim.y = -padding; + + texture.orig.width = texture._frame.width - (padding * 2); + texture.orig.height = texture._frame.height - (padding * 2); + + // call sprite onTextureUpdate to update scale if _width or _height were set + this._onTextureUpdate(); + + baseTexture.setRealSize(canvas.width, canvas.height, this._resolution); + + this.dirty = false; + }; + + /** + * Renders the object using the WebGL renderer + * + * @param {PIXI.Renderer} renderer - The renderer + */ + Text.prototype.render = function render (renderer) + { + if (this._autoResolution && this._resolution !== renderer.resolution) + { + this._resolution = renderer.resolution; + this.dirty = true; + } + + this.updateText(true); + + Sprite.prototype.render.call(this, renderer); + }; + + /** + * Renders the object using the Canvas renderer + * + * @private + * @param {PIXI.CanvasRenderer} renderer - The renderer + */ + Text.prototype._renderCanvas = function _renderCanvas (renderer) + { + if (this._autoResolution && this._resolution !== renderer.resolution) + { + this._resolution = renderer.resolution; + this.dirty = true; + } + + this.updateText(true); + + Sprite.prototype._renderCanvas.call(this, renderer); + }; + + /** + * Gets the local bounds of the text object. + * + * @param {Rectangle} rect - The output rectangle. + * @return {Rectangle} The bounds. + */ + Text.prototype.getLocalBounds = function getLocalBounds (rect) + { + this.updateText(true); + + return Sprite.prototype.getLocalBounds.call(this, rect); + }; + + /** + * calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account. + * @protected + */ + Text.prototype._calculateBounds = function _calculateBounds () + { + this.updateText(true); + this.calculateVertices(); + // if we have already done this on THIS frame. + this._bounds.addQuad(this.vertexData); + }; + + /** + * Method to be called upon a TextStyle change. + * @private + */ + Text.prototype._onStyleChange = function _onStyleChange () + { + this.dirty = true; + }; + + /** + * Generates the fill style. Can automatically generate a gradient based on the fill style being an array + * + * @private + * @param {object} style - The style. + * @param {string[]} lines - The lines of text. + * @return {string|number|CanvasGradient} The fill style + */ + Text.prototype._generateFillStyle = function _generateFillStyle (style, lines) + { + if (!Array.isArray(style.fill)) + { + return style.fill; + } + + // the gradient will be evenly spaced out according to how large the array is. + // ['#FF0000', '#00FF00', '#0000FF'] would created stops at 0.25, 0.5 and 0.75 + var gradient; + var totalIterations; + var currentIteration; + var stop; + + var width = this.canvas.width / this._resolution; + var height = this.canvas.height / this._resolution; + + // make a copy of the style settings, so we can manipulate them later + var fill = style.fill.slice(); + var fillGradientStops = style.fillGradientStops.slice(); + + // wanting to evenly distribute the fills. So an array of 4 colours should give fills of 0.25, 0.5 and 0.75 + if (!fillGradientStops.length) + { + var lengthPlus1 = fill.length + 1; + + for (var i = 1; i < lengthPlus1; ++i) + { + fillGradientStops.push(i / lengthPlus1); + } + } + + // stop the bleeding of the last gradient on the line above to the top gradient of the this line + // by hard defining the first gradient colour at point 0, and last gradient colour at point 1 + fill.unshift(style.fill[0]); + fillGradientStops.unshift(0); + + fill.push(style.fill[style.fill.length - 1]); + fillGradientStops.push(1); + + if (style.fillGradientType === TEXT_GRADIENT.LINEAR_VERTICAL) + { + // start the gradient at the top center of the canvas, and end at the bottom middle of the canvas + gradient = this.context.createLinearGradient(width / 2, 0, width / 2, height); + + // we need to repeat the gradient so that each individual line of text has the same vertical gradient effect + // ['#FF0000', '#00FF00', '#0000FF'] over 2 lines would create stops at 0.125, 0.25, 0.375, 0.625, 0.75, 0.875 + totalIterations = (fill.length + 1) * lines.length; + currentIteration = 0; + for (var i$1 = 0; i$1 < lines.length; i$1++) + { + currentIteration += 1; + for (var j = 0; j < fill.length; j++) + { + if (typeof fillGradientStops[j] === 'number') + { + stop = (fillGradientStops[j] / lines.length) + (i$1 / lines.length); + } + else + { + stop = currentIteration / totalIterations; + } + gradient.addColorStop(stop, fill[j]); + currentIteration++; + } + } + } + else + { + // start the gradient at the center left of the canvas, and end at the center right of the canvas + gradient = this.context.createLinearGradient(0, height / 2, width, height / 2); + + // can just evenly space out the gradients in this case, as multiple lines makes no difference + // to an even left to right gradient + totalIterations = fill.length + 1; + currentIteration = 1; + + for (var i$2 = 0; i$2 < fill.length; i$2++) + { + if (typeof fillGradientStops[i$2] === 'number') + { + stop = fillGradientStops[i$2]; + } + else + { + stop = currentIteration / totalIterations; + } + gradient.addColorStop(stop, fill[i$2]); + currentIteration++; + } + } + + return gradient; + }; + + /** + * Destroys this text object. + * Note* Unlike a Sprite, a Text object will automatically destroy its baseTexture and texture as + * the majority of the time the texture will not be shared with any other Sprites. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options + * have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have their + * destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=true] - Should it destroy the current texture of the sprite as well + * @param {boolean} [options.baseTexture=true] - Should it destroy the base texture of the sprite as well + */ + Text.prototype.destroy = function destroy (options) + { + if (typeof options === 'boolean') + { + options = { children: options }; + } + + options = Object.assign({}, defaultDestroyOptions, options); + + Sprite.prototype.destroy.call(this, options); + + // make sure to reset the the context and canvas.. dont want this hanging around in memory! + this.context = null; + this.canvas = null; + + this._style = null; + }; + + /** + * The width of the Text, setting this will actually modify the scale to achieve the value set + * + * @member {number} + */ + prototypeAccessors.width.get = function () + { + this.updateText(true); + + return Math.abs(this.scale.x) * this._texture.orig.width; + }; + + prototypeAccessors.width.set = function (value) // eslint-disable-line require-jsdoc + { + this.updateText(true); + + var s = sign(this.scale.x) || 1; + + this.scale.x = s * value / this._texture.orig.width; + this._width = value; + }; + + /** + * The height of the Text, setting this will actually modify the scale to achieve the value set + * + * @member {number} + */ + prototypeAccessors.height.get = function () + { + this.updateText(true); + + return Math.abs(this.scale.y) * this._texture.orig.height; + }; + + prototypeAccessors.height.set = function (value) // eslint-disable-line require-jsdoc + { + this.updateText(true); + + var s = sign(this.scale.y) || 1; + + this.scale.y = s * value / this._texture.orig.height; + this._height = value; + }; + + /** + * Set the style of the text. Set up an event listener to listen for changes on the style + * object and mark the text as dirty. + * + * @member {object|PIXI.TextStyle} + */ + prototypeAccessors.style.get = function () + { + return this._style; + }; + + prototypeAccessors.style.set = function (style) // eslint-disable-line require-jsdoc + { + style = style || {}; + + if (style instanceof TextStyle) + { + this._style = style; + } + else + { + this._style = new TextStyle(style); + } + + this.localStyleID = -1; + this.dirty = true; + }; + + /** + * Set the copy for the text object. To split a line you can use '\n'. + * + * @member {string} + */ + prototypeAccessors.text.get = function () + { + return this._text; + }; + + prototypeAccessors.text.set = function (text) // eslint-disable-line require-jsdoc + { + text = String(text === null || text === undefined ? '' : text); + + if (this._text === text) + { + return; + } + this._text = text; + this.dirty = true; + }; + + /** + * The resolution / device pixel ratio of the canvas. + * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually. + * @member {number} + * @default 1 + */ + prototypeAccessors.resolution.get = function () + { + return this._resolution; + }; + + prototypeAccessors.resolution.set = function (value) // eslint-disable-line require-jsdoc + { + this._autoResolution = false; + + if (this._resolution === value) + { + return; + } + + this._resolution = value; + this.dirty = true; + }; + + Object.defineProperties( Text.prototype, prototypeAccessors ); + + return Text; + }(Sprite)); + + /*! + * @pixi/prepare - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/prepare is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Default number of uploads per frame using prepare plugin. + * + * @static + * @memberof PIXI.settings + * @name UPLOADS_PER_FRAME + * @type {number} + * @default 4 + */ + settings.UPLOADS_PER_FRAME = 4; + + /** + * CountLimiter limits the number of items handled by a {@link PIXI.prepare.BasePrepare} to a specified + * number of items per frame. + * + * @class + * @memberof PIXI.prepare + */ + var CountLimiter = function CountLimiter(maxItemsPerFrame) + { + /** + * The maximum number of items that can be prepared each frame. + * @type {number} + * @private + */ + this.maxItemsPerFrame = maxItemsPerFrame; + /** + * The number of items that can be prepared in the current frame. + * @type {number} + * @private + */ + this.itemsLeft = 0; + }; + + /** + * Resets any counting properties to start fresh on a new frame. + */ + CountLimiter.prototype.beginFrame = function beginFrame () + { + this.itemsLeft = this.maxItemsPerFrame; + }; + + /** + * Checks to see if another item can be uploaded. This should only be called once per item. + * @return {boolean} If the item is allowed to be uploaded. + */ + CountLimiter.prototype.allowedToUpload = function allowedToUpload () + { + return this.itemsLeft-- > 0; + }; + + /** + * The prepare manager provides functionality to upload content to the GPU. + * + * BasePrepare handles basic queuing functionality and is extended by + * {@link PIXI.prepare.Prepare} and {@link PIXI.prepare.CanvasPrepare} + * to provide preparation capabilities specific to their respective renderers. + * + * @example + * // Create a sprite + * const sprite = new PIXI.Sprite.from('something.png'); + * + * // Load object into GPU + * app.renderer.plugins.prepare.upload(sprite, () => { + * + * //Texture(s) has been uploaded to GPU + * app.stage.addChild(sprite); + * + * }) + * + * @abstract + * @class + * @memberof PIXI.prepare + */ + var BasePrepare = function BasePrepare(renderer) + { + var this$1 = this; + + /** + * The limiter to be used to control how quickly items are prepared. + * @type {PIXI.prepare.CountLimiter|PIXI.prepare.TimeLimiter} + */ + this.limiter = new CountLimiter(settings.UPLOADS_PER_FRAME); + + /** + * Reference to the renderer. + * @type {PIXI.AbstractRenderer} + * @protected + */ + this.renderer = renderer; + + /** + * The only real difference between CanvasPrepare and Prepare is what they pass + * to upload hooks. That different parameter is stored here. + * @type {PIXI.prepare.CanvasPrepare|PIXI.Renderer} + * @protected + */ + this.uploadHookHelper = null; + + /** + * Collection of items to uploads at once. + * @type {Array<*>} + * @private + */ + this.queue = []; + + /** + * Collection of additional hooks for finding assets. + * @type {Array} + * @private + */ + this.addHooks = []; + + /** + * Collection of additional hooks for processing assets. + * @type {Array} + * @private + */ + this.uploadHooks = []; + + /** + * Callback to call after completed. + * @type {Array} + * @private + */ + this.completes = []; + + /** + * If prepare is ticking (running). + * @type {boolean} + * @private + */ + this.ticking = false; + + /** + * 'bound' call for prepareItems(). + * @type {Function} + * @private + */ + this.delayedTick = function () { + // unlikely, but in case we were destroyed between tick() and delayedTick() + if (!this$1.queue) + { + return; + } + this$1.prepareItems(); + }; + + // hooks to find the correct texture + this.registerFindHook(findText); + this.registerFindHook(findTextStyle); + this.registerFindHook(findMultipleBaseTextures); + this.registerFindHook(findBaseTexture); + this.registerFindHook(findTexture); + + // upload hooks + this.registerUploadHook(drawText); + this.registerUploadHook(calculateTextStyle); + }; + + /** + * Upload all the textures and graphics to the GPU. + * + * @param {Function|PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item - + * Either the container or display object to search for items to upload, the items to upload themselves, + * or the callback function, if items have been added using `prepare.add`. + * @param {Function} [done] - Optional callback when all queued uploads have completed + */ + BasePrepare.prototype.upload = function upload (item, done) + { + if (typeof item === 'function') + { + done = item; + item = null; + } + + // If a display object, search for items + // that we could upload + if (item) + { + this.add(item); + } + + // Get the items for upload from the display + if (this.queue.length) + { + if (done) + { + this.completes.push(done); + } + + if (!this.ticking) + { + this.ticking = true; + Ticker.system.addOnce(this.tick, this, UPDATE_PRIORITY.UTILITY); + } + } + else if (done) + { + done(); + } + }; + + /** + * Handle tick update + * + * @private + */ + BasePrepare.prototype.tick = function tick () + { + setTimeout(this.delayedTick, 0); + }; + + /** + * Actually prepare items. This is handled outside of the tick because it will take a while + * and we do NOT want to block the current animation frame from rendering. + * + * @private + */ + BasePrepare.prototype.prepareItems = function prepareItems () + { + this.limiter.beginFrame(); + // Upload the graphics + while (this.queue.length && this.limiter.allowedToUpload()) + { + var item = this.queue[0]; + var uploaded = false; + + if (item && !item._destroyed) + { + for (var i = 0, len = this.uploadHooks.length; i < len; i++) + { + if (this.uploadHooks[i](this.uploadHookHelper, item)) + { + this.queue.shift(); + uploaded = true; + break; + } + } + } + + if (!uploaded) + { + this.queue.shift(); + } + } + + // We're finished + if (!this.queue.length) + { + this.ticking = false; + + var completes = this.completes.slice(0); + + this.completes.length = 0; + + for (var i$1 = 0, len$1 = completes.length; i$1 < len$1; i$1++) + { + completes[i$1](); + } + } + else + { + // if we are not finished, on the next rAF do this again + Ticker.system.addOnce(this.tick, this, UPDATE_PRIORITY.UTILITY); + } + }; + + /** + * Adds hooks for finding items. + * + * @param {Function} addHook - Function call that takes two parameters: `item:*, queue:Array` + * function must return `true` if it was able to add item to the queue. + * @return {PIXI.prepare.BasePrepare} Instance of plugin for chaining. + */ + BasePrepare.prototype.registerFindHook = function registerFindHook (addHook) + { + if (addHook) + { + this.addHooks.push(addHook); + } + + return this; + }; + + /** + * Adds hooks for uploading items. + * + * @param {Function} uploadHook - Function call that takes two parameters: `prepare:CanvasPrepare, item:*` and + * function must return `true` if it was able to handle upload of item. + * @return {PIXI.prepare.BasePrepare} Instance of plugin for chaining. + */ + BasePrepare.prototype.registerUploadHook = function registerUploadHook (uploadHook) + { + if (uploadHook) + { + this.uploadHooks.push(uploadHook); + } + + return this; + }; + + /** + * Manually add an item to the uploading queue. + * + * @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text|*} item - Object to + * add to the queue + * @return {PIXI.prepare.BasePrepare} Instance of plugin for chaining. + */ + BasePrepare.prototype.add = function add (item) + { + // Add additional hooks for finding elements on special + // types of objects that + for (var i = 0, len = this.addHooks.length; i < len; i++) + { + if (this.addHooks[i](item, this.queue)) + { + break; + } + } + + // Get children recursively + if (item instanceof Container) + { + for (var i$1 = item.children.length - 1; i$1 >= 0; i$1--) + { + this.add(item.children[i$1]); + } + } + + return this; + }; + + /** + * Destroys the plugin, don't use after this. + * + */ + BasePrepare.prototype.destroy = function destroy () + { + if (this.ticking) + { + Ticker.system.remove(this.tick, this); + } + this.ticking = false; + this.addHooks = null; + this.uploadHooks = null; + this.renderer = null; + this.completes = null; + this.queue = null; + this.limiter = null; + this.uploadHookHelper = null; + }; + + /** + * Built-in hook to find multiple textures from objects like AnimatedSprites. + * + * @private + * @param {PIXI.DisplayObject} item - Display object to check + * @param {Array<*>} queue - Collection of items to upload + * @return {boolean} if a PIXI.Texture object was found. + */ + function findMultipleBaseTextures(item, queue) + { + var result = false; + + // Objects with multiple textures + if (item && item._textures && item._textures.length) + { + for (var i = 0; i < item._textures.length; i++) + { + if (item._textures[i] instanceof Texture) + { + var baseTexture = item._textures[i].baseTexture; + + if (queue.indexOf(baseTexture) === -1) + { + queue.push(baseTexture); + result = true; + } + } + } + } + + return result; + } + + /** + * Built-in hook to find BaseTextures from Sprites. + * + * @private + * @param {PIXI.DisplayObject} item - Display object to check + * @param {Array<*>} queue - Collection of items to upload + * @return {boolean} if a PIXI.Texture object was found. + */ + function findBaseTexture(item, queue) + { + // Objects with textures, like Sprites/Text + if (item instanceof BaseTexture) + { + if (queue.indexOf(item) === -1) + { + queue.push(item); + } + + return true; + } + + return false; + } + + /** + * Built-in hook to find textures from objects. + * + * @private + * @param {PIXI.DisplayObject} item - Display object to check + * @param {Array<*>} queue - Collection of items to upload + * @return {boolean} if a PIXI.Texture object was found. + */ + function findTexture(item, queue) + { + if (item._texture && item._texture instanceof Texture) + { + var texture = item._texture.baseTexture; + + if (queue.indexOf(texture) === -1) + { + queue.push(texture); + } + + return true; + } + + return false; + } + + /** + * Built-in hook to draw PIXI.Text to its texture. + * + * @private + * @param {PIXI.Renderer|PIXI.CanvasPrepare} helper - Not used by this upload handler + * @param {PIXI.DisplayObject} item - Item to check + * @return {boolean} If item was uploaded. + */ + function drawText(helper, item) + { + if (item instanceof Text) + { + // updating text will return early if it is not dirty + item.updateText(true); + + return true; + } + + return false; + } + + /** + * Built-in hook to calculate a text style for a PIXI.Text object. + * + * @private + * @param {PIXI.Renderer|PIXI.CanvasPrepare} helper - Not used by this upload handler + * @param {PIXI.DisplayObject} item - Item to check + * @return {boolean} If item was uploaded. + */ + function calculateTextStyle(helper, item) + { + if (item instanceof TextStyle) + { + var font = item.toFontString(); + + TextMetrics.measureFont(font); + + return true; + } + + return false; + } + + /** + * Built-in hook to find Text objects. + * + * @private + * @param {PIXI.DisplayObject} item - Display object to check + * @param {Array<*>} queue - Collection of items to upload + * @return {boolean} if a PIXI.Text object was found. + */ + function findText(item, queue) + { + if (item instanceof Text) + { + // push the text style to prepare it - this can be really expensive + if (queue.indexOf(item.style) === -1) + { + queue.push(item.style); + } + // also push the text object so that we can render it (to canvas/texture) if needed + if (queue.indexOf(item) === -1) + { + queue.push(item); + } + // also push the Text's texture for upload to GPU + var texture = item._texture.baseTexture; + + if (queue.indexOf(texture) === -1) + { + queue.push(texture); + } + + return true; + } + + return false; + } + + /** + * Built-in hook to find TextStyle objects. + * + * @private + * @param {PIXI.TextStyle} item - Display object to check + * @param {Array<*>} queue - Collection of items to upload + * @return {boolean} if a PIXI.TextStyle object was found. + */ + function findTextStyle(item, queue) + { + if (item instanceof TextStyle) + { + if (queue.indexOf(item) === -1) + { + queue.push(item); + } + + return true; + } + + return false; + } + + /** + * The prepare manager provides functionality to upload content to the GPU. + * + * An instance of this class is automatically created by default, and can be found at `renderer.plugins.prepare` + * + * @class + * @extends PIXI.prepare.BasePrepare + * @memberof PIXI.prepare + */ + var Prepare = /*@__PURE__*/(function (BasePrepare) { + function Prepare(renderer) + { + BasePrepare.call(this, renderer); + + this.uploadHookHelper = this.renderer; + + // Add textures and graphics to upload + this.registerFindHook(findGraphics); + this.registerUploadHook(uploadBaseTextures); + this.registerUploadHook(uploadGraphics); + } + + if ( BasePrepare ) { Prepare.__proto__ = BasePrepare; } + Prepare.prototype = Object.create( BasePrepare && BasePrepare.prototype ); + Prepare.prototype.constructor = Prepare; + + return Prepare; + }(BasePrepare)); + /** + * Built-in hook to upload PIXI.Texture objects to the GPU. + * + * @private + * @param {PIXI.Renderer} renderer - instance of the webgl renderer + * @param {PIXI.DisplayObject} item - Item to check + * @return {boolean} If item was uploaded. + */ + function uploadBaseTextures(renderer, item) + { + if (item instanceof BaseTexture) + { + // if the texture already has a GL texture, then the texture has been prepared or rendered + // before now. If the texture changed, then the changer should be calling texture.update() which + // reuploads the texture without need for preparing it again + if (!item._glTextures[renderer.CONTEXT_UID]) + { + renderer.textureManager.updateTexture(item); + } + + return true; + } + + return false; + } + + /** + * Built-in hook to upload PIXI.Graphics to the GPU. + * + * @private + * @param {PIXI.Renderer} renderer - instance of the webgl renderer + * @param {PIXI.DisplayObject} item - Item to check + * @return {boolean} If item was uploaded. + */ + function uploadGraphics(renderer, item) + { + if (item instanceof Graphics) + { + // if the item is not dirty and already has webgl data, then it got prepared or rendered + // before now and we shouldn't waste time updating it again + if (item.dirty || item.clearDirty || !item._webGL[renderer.plugins.graphics.CONTEXT_UID]) + { + renderer.plugins.graphics.updateGraphics(item); + } + + return true; + } + + return false; + } + + /** + * Built-in hook to find graphics. + * + * @private + * @param {PIXI.DisplayObject} item - Display object to check + * @param {Array<*>} queue - Collection of items to upload + * @return {boolean} if a PIXI.Graphics object was found. + */ + function findGraphics(item, queue) + { + if (item instanceof Graphics) + { + queue.push(item); + + return true; + } + + return false; + } + + /** + * TimeLimiter limits the number of items handled by a {@link PIXI.BasePrepare} to a specified + * number of milliseconds per frame. + * + * @class + * @memberof PIXI.prepare + */ + var TimeLimiter = function TimeLimiter(maxMilliseconds) + { + /** + * The maximum milliseconds that can be spent preparing items each frame. + * @type {number} + * @private + */ + this.maxMilliseconds = maxMilliseconds; + /** + * The start time of the current frame. + * @type {number} + * @private + */ + this.frameStart = 0; + }; + + /** + * Resets any counting properties to start fresh on a new frame. + */ + TimeLimiter.prototype.beginFrame = function beginFrame () + { + this.frameStart = Date.now(); + }; + + /** + * Checks to see if another item can be uploaded. This should only be called once per item. + * @return {boolean} If the item is allowed to be uploaded. + */ + TimeLimiter.prototype.allowedToUpload = function allowedToUpload () + { + return Date.now() - this.frameStart < this.maxMilliseconds; + }; + + var prepare_es = ({ + BasePrepare: BasePrepare, + CountLimiter: CountLimiter, + Prepare: Prepare, + TimeLimiter: TimeLimiter + }); + + /*! + * @pixi/app - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/app is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Convenience class to create a new PIXI application. + * + * This class automatically creates the renderer, ticker and root container. + * + * @example + * // Create the application + * const app = new PIXI.Application(); + * + * // Add the view to the DOM + * document.body.appendChild(app.view); + * + * // ex, add display objects + * app.stage.addChild(PIXI.Sprite.from('something.png')); + * + * @class + * @memberof PIXI + */ + var Application = function Application(options) + { + var this$1 = this; + + // The default options + options = Object.assign({ + forceCanvas: false, + }, options); + + /** + * WebGL renderer if available, otherwise CanvasRenderer. + * @member {PIXI.Renderer|PIXI.CanvasRenderer} + */ + this.renderer = autoDetectRenderer(options); + + /** + * The root display container that's rendered. + * @member {PIXI.Container} + */ + this.stage = new Container(); + + // install plugins here + Application._plugins.forEach(function (plugin) { + plugin.init.call(this$1, options); + }); + }; + + var prototypeAccessors$8 = { view: { configurable: true },screen: { configurable: true } }; + + /** + * Register a middleware plugin for the application + * @static + * @param {PIXI.Application.Plugin} plugin - Plugin being installed + */ + Application.registerPlugin = function registerPlugin (plugin) + { + Application._plugins.push(plugin); + }; + + /** + * Render the current stage. + */ + Application.prototype.render = function render () + { + this.renderer.render(this.stage); + }; + + /** + * Reference to the renderer's canvas element. + * @member {HTMLCanvasElement} + * @readonly + */ + prototypeAccessors$8.view.get = function () + { + return this.renderer.view; + }; + + /** + * Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen. + * @member {PIXI.Rectangle} + * @readonly + */ + prototypeAccessors$8.screen.get = function () + { + return this.renderer.screen; + }; + + /** + * Destroy and don't use after this. + * @param {Boolean} [removeView=false] Automatically remove canvas from DOM. + * @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options + * have been set to that value + * @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy + * method called as well. 'stageOptions' will be passed on to those calls. + * @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set + * to true. Should it destroy the texture of the child sprite + * @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set + * to true. Should it destroy the base texture of the child sprite + */ + Application.prototype.destroy = function destroy (removeView) + { + var this$1 = this; + + // Destroy plugins in the opposite order + // which they were constructed + var plugins = Application._plugins.slice(0); + + plugins.reverse(); + plugins.forEach(function (plugin) { + plugin.destroy.call(this$1); + }); + + this.stage.destroy(); + this.stage = null; + + this.renderer.destroy(removeView); + this.renderer = null; + + this._options = null; + }; + + Object.defineProperties( Application.prototype, prototypeAccessors$8 ); + + /** + * @memberof PIXI.Application + * @typedef {object} Plugin + * @property {function} init - Called when Application is constructed, scoped to Application instance. + * Passes in `options` as the only argument, which are Application constructor options. + * @property {function} destroy - Called when destroying Application, scoped to Application instance + */ + + /** + * Collection of installed plugins. + * @static + * @private + * @type {PIXI.Application.Plugin[]} + */ + Application._plugins = []; + + /** + * Middleware for for Application's resize functionality + * @private + * @class + */ + var ResizePlugin = function ResizePlugin () {}; + + ResizePlugin.init = function init (options) + { + var this$1 = this; + + /** + * The element or window to resize the application to. + * @type {Window|HTMLElement} + * @name resizeTo + * @memberof PIXI.Application# + */ + Object.defineProperty(this, 'resizeTo', + { + set: function set(dom) + { + window.removeEventListener('resize', this.resize); + this._resizeTo = dom; + if (dom) + { + window.addEventListener('resize', this.resize); + this.resize(); + } + }, + get: function get() + { + return this._resizeTo; + }, + }); + + /** + * If `resizeTo` is set, calling this function + * will resize to the width and height of that element. + * @method PIXI.Application#resize + */ + this.resize = function () { + if (this$1._resizeTo) + { + // Resize to the window + if (this$1._resizeTo === window) + { + this$1.renderer.resize( + window.innerWidth, + window.innerHeight + ); + } + // Resize to other HTML entities + else + { + this$1.renderer.resize( + this$1._resizeTo.clientWidth, + this$1._resizeTo.clientHeight + ); + } + } + }; + + // On resize + this._resizeTo = null; + this.resizeTo = options.resizeTo || null; + }; + + /** + * Clean up the ticker, scoped to application + * @static + * @private + */ + ResizePlugin.destroy = function destroy () + { + this.resizeTo = null; + this.resize = null; + }; + + Application.registerPlugin(ResizePlugin); + + var miniSignals = createCommonjsModule(function (module, exports) { + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + + var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) { descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) { defineProperties(Constructor.prototype, protoProps); } if (staticProps) { defineProperties(Constructor, staticProps); } return Constructor; }; })(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + var MiniSignalBinding = (function () { + function MiniSignalBinding(fn, once, thisArg) { + if (once === undefined) { once = false; } + + _classCallCheck(this, MiniSignalBinding); + + this._fn = fn; + this._once = once; + this._thisArg = thisArg; + this._next = this._prev = this._owner = null; + } + + _createClass(MiniSignalBinding, [{ + key: 'detach', + value: function detach() { + if (this._owner === null) { return false; } + this._owner.detach(this); + return true; + } + }]); + + return MiniSignalBinding; + })(); + + function _addMiniSignalBinding(self, node) { + if (!self._head) { + self._head = node; + self._tail = node; + } else { + self._tail._next = node; + node._prev = self._tail; + self._tail = node; + } + + node._owner = self; + + return node; + } + + var MiniSignal = (function () { + function MiniSignal() { + _classCallCheck(this, MiniSignal); + + this._head = this._tail = undefined; + } + + _createClass(MiniSignal, [{ + key: 'handlers', + value: function handlers() { + var exists = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; + + var node = this._head; + + if (exists) { return !!node; } + + var ee = []; + + while (node) { + ee.push(node); + node = node._next; + } + + return ee; + } + }, { + key: 'has', + value: function has(node) { + if (!(node instanceof MiniSignalBinding)) { + throw new Error('MiniSignal#has(): First arg must be a MiniSignalBinding object.'); + } + + return node._owner === this; + } + }, { + key: 'dispatch', + value: function dispatch() { + var arguments$1 = arguments; + + var node = this._head; + + if (!node) { return false; } + + while (node) { + if (node._once) { this.detach(node); } + node._fn.apply(node._thisArg, arguments$1); + node = node._next; + } + + return true; + } + }, { + key: 'add', + value: function add(fn) { + var thisArg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + + if (typeof fn !== 'function') { + throw new Error('MiniSignal#add(): First arg must be a Function.'); + } + return _addMiniSignalBinding(this, new MiniSignalBinding(fn, false, thisArg)); + } + }, { + key: 'once', + value: function once(fn) { + var thisArg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + + if (typeof fn !== 'function') { + throw new Error('MiniSignal#once(): First arg must be a Function.'); + } + return _addMiniSignalBinding(this, new MiniSignalBinding(fn, true, thisArg)); + } + }, { + key: 'detach', + value: function detach(node) { + if (!(node instanceof MiniSignalBinding)) { + throw new Error('MiniSignal#detach(): First arg must be a MiniSignalBinding object.'); + } + if (node._owner !== this) { return this; } + + if (node._prev) { node._prev._next = node._next; } + if (node._next) { node._next._prev = node._prev; } + + if (node === this._head) { + this._head = node._next; + if (node._next === null) { + this._tail = null; + } + } else if (node === this._tail) { + this._tail = node._prev; + this._tail._next = null; + } + + node._owner = null; + return this; + } + }, { + key: 'detachAll', + value: function detachAll() { + var node = this._head; + if (!node) { return this; } + + this._head = this._tail = null; + + while (node) { + node._owner = null; + node = node._next; + } + return this; + } + }]); + + return MiniSignal; + })(); + + MiniSignal.MiniSignalBinding = MiniSignalBinding; + + exports['default'] = MiniSignal; + module.exports = exports['default']; + }); + + var miniSignals$1 = unwrapExports(miniSignals); + + 'use strict'; + + var parseUri = function parseURI (str, opts) { + opts = opts || {}; + + var o = { + key: ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'], + q: { + name: 'queryKey', + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + parser: { + strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, + loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ + } + }; + + var m = o.parser[opts.strictMode ? 'strict' : 'loose'].exec(str); + var uri = {}; + var i = 14; + + while (i--) { uri[o.key[i]] = m[i] || ''; } + + uri[o.q.name] = {}; + uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { + if ($1) { uri[o.q.name][$1] = $2; } + }); + + return uri + }; + + var async = createCommonjsModule(function (module, exports) { + 'use strict'; + + exports.__esModule = true; + exports.eachSeries = eachSeries; + exports.queue = queue; + /** + * Smaller version of the async library constructs. + * + * @namespace async + */ + + /** + * Noop function + * + * @ignore + * @function + * @memberof async + */ + function _noop() {} /* empty */ + + /** + * Iterates an array in series. + * + * @memberof async + * @param {Array.<*>} array - Array to iterate. + * @param {function} iterator - Function to call for each element. + * @param {function} callback - Function to call when done, or on error. + * @param {boolean} [deferNext=false] - Break synchronous each loop by calling next with a setTimeout of 1. + */ + function eachSeries(array, iterator, callback, deferNext) { + var i = 0; + var len = array.length; + + (function next(err) { + if (err || i === len) { + if (callback) { + callback(err); + } + + return; + } + + if (deferNext) { + setTimeout(function () { + iterator(array[i++], next); + }, 1); + } else { + iterator(array[i++], next); + } + })(); + } + + /** + * Ensures a function is only called once. + * + * @ignore + * @memberof async + * @param {function} fn - The function to wrap. + * @return {function} The wrapping function. + */ + function onlyOnce(fn) { + return function onceWrapper() { + if (fn === null) { + throw new Error('Callback was already called.'); + } + + var callFn = fn; + + fn = null; + callFn.apply(this, arguments); + }; + } + + /** + * Async queue implementation, + * + * @memberof async + * @param {function} worker - The worker function to call for each task. + * @param {number} concurrency - How many workers to run in parrallel. + * @return {*} The async queue object. + */ + function queue(worker, concurrency) { + if (concurrency == null) { + // eslint-disable-line no-eq-null,eqeqeq + concurrency = 1; + } else if (concurrency === 0) { + throw new Error('Concurrency must not be zero'); + } + + var workers = 0; + var q = { + _tasks: [], + concurrency: concurrency, + saturated: _noop, + unsaturated: _noop, + buffer: concurrency / 4, + empty: _noop, + drain: _noop, + error: _noop, + started: false, + paused: false, + push: function push(data, callback) { + _insert(data, false, callback); + }, + kill: function kill() { + workers = 0; + q.drain = _noop; + q.started = false; + q._tasks = []; + }, + unshift: function unshift(data, callback) { + _insert(data, true, callback); + }, + process: function process() { + while (!q.paused && workers < q.concurrency && q._tasks.length) { + var task = q._tasks.shift(); + + if (q._tasks.length === 0) { + q.empty(); + } + + workers += 1; + + if (workers === q.concurrency) { + q.saturated(); + } + + worker(task.data, onlyOnce(_next(task))); + } + }, + length: function length() { + return q._tasks.length; + }, + running: function running() { + return workers; + }, + idle: function idle() { + return q._tasks.length + workers === 0; + }, + pause: function pause() { + if (q.paused === true) { + return; + } + + q.paused = true; + }, + resume: function resume() { + if (q.paused === false) { + return; + } + + q.paused = false; + + // Need to call q.process once per concurrent + // worker to preserve full concurrency after pause + for (var w = 1; w <= q.concurrency; w++) { + q.process(); + } + } + }; + + function _insert(data, insertAtFront, callback) { + if (callback != null && typeof callback !== 'function') { + // eslint-disable-line no-eq-null,eqeqeq + throw new Error('task callback must be a function'); + } + + q.started = true; + + if (data == null && q.idle()) { + // eslint-disable-line no-eq-null,eqeqeq + // call drain immediately if there are no tasks + setTimeout(function () { + return q.drain(); + }, 1); + + return; + } + + var item = { + data: data, + callback: typeof callback === 'function' ? callback : _noop + }; + + if (insertAtFront) { + q._tasks.unshift(item); + } else { + q._tasks.push(item); + } + + setTimeout(function () { + return q.process(); + }, 1); + } + + function _next(task) { + return function next() { + workers -= 1; + + task.callback.apply(task, arguments); + + if (arguments[0] != null) { + // eslint-disable-line no-eq-null,eqeqeq + q.error(arguments[0], task.data); + } + + if (workers <= q.concurrency - q.buffer) { + q.unsaturated(); + } + + if (q.idle()) { + q.drain(); + } + + q.process(); + }; + } + + return q; + } + + }); + + var async$1 = unwrapExports(async); + var async_1 = async.eachSeries; + var async_2 = async.queue; + + var Resource_1 = createCommonjsModule(function (module, exports) { + 'use strict'; + + exports.__esModule = true; + exports.Resource = undefined; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) { defineProperties(Constructor.prototype, protoProps); } if (staticProps) { defineProperties(Constructor, staticProps); } return Constructor; }; }(); + + + + var _parseUri2 = _interopRequireDefault(parseUri); + + + + var _miniSignals2 = _interopRequireDefault(miniSignals); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + // tests if CORS is supported in XHR, if not we need to use XDR + var useXdr = !!(window.XDomainRequest && !('withCredentials' in new XMLHttpRequest())); + var tempAnchor = null; + + // some status constants + var STATUS_NONE = 0; + var STATUS_OK = 200; + var STATUS_EMPTY = 204; + var STATUS_IE_BUG_EMPTY = 1223; + var STATUS_TYPE_OK = 2; + + // noop + function _noop() {} /* empty */ + + /** + * Manages the state and loading of a resource and all child resources. + * + * @class + */ + + var Resource = exports.Resource = function () { + /** + * Sets the load type to be used for a specific extension. + * + * @static + * @param {string} extname - The extension to set the type for, e.g. "png" or "fnt" + * @param {Resource.LOAD_TYPE} loadType - The load type to set it to. + */ + Resource.setExtensionLoadType = function setExtensionLoadType(extname, loadType) { + setExtMap(Resource._loadTypeMap, extname, loadType); + }; + + /** + * Sets the load type to be used for a specific extension. + * + * @static + * @param {string} extname - The extension to set the type for, e.g. "png" or "fnt" + * @param {Resource.XHR_RESPONSE_TYPE} xhrType - The xhr type to set it to. + */ + + + Resource.setExtensionXhrType = function setExtensionXhrType(extname, xhrType) { + setExtMap(Resource._xhrTypeMap, extname, xhrType); + }; + + /** + * @param {string} name - The name of the resource to load. + * @param {string|string[]} url - The url for this resource, for audio/video loads you can pass + * an array of sources. + * @param {object} [options] - The options for the load. + * @param {string|boolean} [options.crossOrigin] - Is this request cross-origin? Default is to + * determine automatically. + * @param {number} [options.timeout=0] - A timeout in milliseconds for the load. If the load takes + * longer than this time it is cancelled and the load is considered a failure. If this value is + * set to `0` then there is no explicit timeout. + * @param {Resource.LOAD_TYPE} [options.loadType=Resource.LOAD_TYPE.XHR] - How should this resource + * be loaded? + * @param {Resource.XHR_RESPONSE_TYPE} [options.xhrType=Resource.XHR_RESPONSE_TYPE.DEFAULT] - How + * should the data being loaded be interpreted when using XHR? + * @param {Resource.IMetadata} [options.metadata] - Extra configuration for middleware and the Resource object. + */ + + + function Resource(name, url, options) { + _classCallCheck(this, Resource); + + if (typeof name !== 'string' || typeof url !== 'string') { + throw new Error('Both name and url are required for constructing a resource.'); + } + + options = options || {}; + + /** + * The state flags of this resource. + * + * @private + * @member {number} + */ + this._flags = 0; + + // set data url flag, needs to be set early for some _determineX checks to work. + this._setFlag(Resource.STATUS_FLAGS.DATA_URL, url.indexOf('data:') === 0); + + /** + * The name of this resource. + * + * @readonly + * @member {string} + */ + this.name = name; + + /** + * The url used to load this resource. + * + * @readonly + * @member {string} + */ + this.url = url; + + /** + * The extension used to load this resource. + * + * @readonly + * @member {string} + */ + this.extension = this._getExtension(); + + /** + * The data that was loaded by the resource. + * + * @member {any} + */ + this.data = null; + + /** + * Is this request cross-origin? If unset, determined automatically. + * + * @member {string} + */ + this.crossOrigin = options.crossOrigin === true ? 'anonymous' : options.crossOrigin; + + /** + * A timeout in milliseconds for the load. If the load takes longer than this time + * it is cancelled and the load is considered a failure. If this value is set to `0` + * then there is no explicit timeout. + * + * @member {number} + */ + this.timeout = options.timeout || 0; + + /** + * The method of loading to use for this resource. + * + * @member {Resource.LOAD_TYPE} + */ + this.loadType = options.loadType || this._determineLoadType(); + + /** + * The type used to load the resource via XHR. If unset, determined automatically. + * + * @member {string} + */ + this.xhrType = options.xhrType; + + /** + * Extra info for middleware, and controlling specifics about how the resource loads. + * + * Note that if you pass in a `loadElement`, the Resource class takes ownership of it. + * Meaning it will modify it as it sees fit. + * + * @member {Resource.IMetadata} + */ + this.metadata = options.metadata || {}; + + /** + * The error that occurred while loading (if any). + * + * @readonly + * @member {Error} + */ + this.error = null; + + /** + * The XHR object that was used to load this resource. This is only set + * when `loadType` is `Resource.LOAD_TYPE.XHR`. + * + * @readonly + * @member {XMLHttpRequest} + */ + this.xhr = null; + + /** + * The child resources this resource owns. + * + * @readonly + * @member {Resource[]} + */ + this.children = []; + + /** + * The resource type. + * + * @readonly + * @member {Resource.TYPE} + */ + this.type = Resource.TYPE.UNKNOWN; + + /** + * The progress chunk owned by this resource. + * + * @readonly + * @member {number} + */ + this.progressChunk = 0; + + /** + * The `dequeue` method that will be used a storage place for the async queue dequeue method + * used privately by the loader. + * + * @private + * @member {function} + */ + this._dequeue = _noop; + + /** + * Used a storage place for the on load binding used privately by the loader. + * + * @private + * @member {function} + */ + this._onLoadBinding = null; + + /** + * The timer for element loads to check if they timeout. + * + * @private + * @member {number} + */ + this._elementTimer = 0; + + /** + * The `complete` function bound to this resource's context. + * + * @private + * @member {function} + */ + this._boundComplete = this.complete.bind(this); + + /** + * The `_onError` function bound to this resource's context. + * + * @private + * @member {function} + */ + this._boundOnError = this._onError.bind(this); + + /** + * The `_onProgress` function bound to this resource's context. + * + * @private + * @member {function} + */ + this._boundOnProgress = this._onProgress.bind(this); + + /** + * The `_onTimeout` function bound to this resource's context. + * + * @private + * @member {function} + */ + this._boundOnTimeout = this._onTimeout.bind(this); + + // xhr callbacks + this._boundXhrOnError = this._xhrOnError.bind(this); + this._boundXhrOnTimeout = this._xhrOnTimeout.bind(this); + this._boundXhrOnAbort = this._xhrOnAbort.bind(this); + this._boundXhrOnLoad = this._xhrOnLoad.bind(this); + + /** + * Dispatched when the resource beings to load. + * + * The callback looks like {@link Resource.OnStartSignal}. + * + * @member {Signal} + */ + this.onStart = new _miniSignals2.default(); + + /** + * Dispatched each time progress of this resource load updates. + * Not all resources types and loader systems can support this event + * so sometimes it may not be available. If the resource + * is being loaded on a modern browser, using XHR, and the remote server + * properly sets Content-Length headers, then this will be available. + * + * The callback looks like {@link Resource.OnProgressSignal}. + * + * @member {Signal} + */ + this.onProgress = new _miniSignals2.default(); + + /** + * Dispatched once this resource has loaded, if there was an error it will + * be in the `error` property. + * + * The callback looks like {@link Resource.OnCompleteSignal}. + * + * @member {Signal} + */ + this.onComplete = new _miniSignals2.default(); + + /** + * Dispatched after this resource has had all the *after* middleware run on it. + * + * The callback looks like {@link Resource.OnCompleteSignal}. + * + * @member {Signal} + */ + this.onAfterMiddleware = new _miniSignals2.default(); + } + + /** + * When the resource starts to load. + * + * @memberof Resource + * @callback OnStartSignal + * @param {Resource} resource - The resource that the event happened on. + */ + + /** + * When the resource reports loading progress. + * + * @memberof Resource + * @callback OnProgressSignal + * @param {Resource} resource - The resource that the event happened on. + * @param {number} percentage - The progress of the load in the range [0, 1]. + */ + + /** + * When the resource finishes loading. + * + * @memberof Resource + * @callback OnCompleteSignal + * @param {Resource} resource - The resource that the event happened on. + */ + + /** + * @memberof Resource + * @typedef {object} IMetadata + * @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The + * element to use for loading, instead of creating one. + * @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This + * is useful if you want to pass in a `loadElement` that you already added load sources to. + * @property {string|string[]} [mimeType] - The mime type to use for the source element + * of a video/audio elment. If the urls are an array, you can pass this as an array as well + * where each index is the mime type to use for the corresponding url index. + */ + + /** + * Stores whether or not this url is a data url. + * + * @readonly + * @member {boolean} + */ + + + /** + * Marks the resource as complete. + * + */ + Resource.prototype.complete = function complete() { + this._clearEvents(); + this._finish(); + }; + + /** + * Aborts the loading of this resource, with an optional message. + * + * @param {string} message - The message to use for the error + */ + + + Resource.prototype.abort = function abort(message) { + // abort can be called multiple times, ignore subsequent calls. + if (this.error) { + return; + } + + // store error + this.error = new Error(message); + + // clear events before calling aborts + this._clearEvents(); + + // abort the actual loading + if (this.xhr) { + this.xhr.abort(); + } else if (this.xdr) { + this.xdr.abort(); + } else if (this.data) { + // single source + if (this.data.src) { + this.data.src = Resource.EMPTY_GIF; + } + // multi-source + else { + while (this.data.firstChild) { + this.data.removeChild(this.data.firstChild); + } + } + } + + // done now. + this._finish(); + }; + + /** + * Kicks off loading of this resource. This method is asynchronous. + * + * @param {Resource.OnCompleteSignal} [cb] - Optional callback to call once the resource is loaded. + */ + + + Resource.prototype.load = function load(cb) { + var _this = this; + + if (this.isLoading) { + return; + } + + if (this.isComplete) { + if (cb) { + setTimeout(function () { + return cb(_this); + }, 1); + } + + return; + } else if (cb) { + this.onComplete.once(cb); + } + + this._setFlag(Resource.STATUS_FLAGS.LOADING, true); + + this.onStart.dispatch(this); + + // if unset, determine the value + if (this.crossOrigin === false || typeof this.crossOrigin !== 'string') { + this.crossOrigin = this._determineCrossOrigin(this.url); + } + + switch (this.loadType) { + case Resource.LOAD_TYPE.IMAGE: + this.type = Resource.TYPE.IMAGE; + this._loadElement('image'); + break; + + case Resource.LOAD_TYPE.AUDIO: + this.type = Resource.TYPE.AUDIO; + this._loadSourceElement('audio'); + break; + + case Resource.LOAD_TYPE.VIDEO: + this.type = Resource.TYPE.VIDEO; + this._loadSourceElement('video'); + break; + + case Resource.LOAD_TYPE.XHR: + /* falls through */ + default: + if (useXdr && this.crossOrigin) { + this._loadXdr(); + } else { + this._loadXhr(); + } + break; + } + }; + + /** + * Checks if the flag is set. + * + * @private + * @param {number} flag - The flag to check. + * @return {boolean} True if the flag is set. + */ + + + Resource.prototype._hasFlag = function _hasFlag(flag) { + return (this._flags & flag) !== 0; + }; + + /** + * (Un)Sets the flag. + * + * @private + * @param {number} flag - The flag to (un)set. + * @param {boolean} value - Whether to set or (un)set the flag. + */ + + + Resource.prototype._setFlag = function _setFlag(flag, value) { + this._flags = value ? this._flags | flag : this._flags & ~flag; + }; + + /** + * Clears all the events from the underlying loading source. + * + * @private + */ + + + Resource.prototype._clearEvents = function _clearEvents() { + clearTimeout(this._elementTimer); + + if (this.data && this.data.removeEventListener) { + this.data.removeEventListener('error', this._boundOnError, false); + this.data.removeEventListener('load', this._boundComplete, false); + this.data.removeEventListener('progress', this._boundOnProgress, false); + this.data.removeEventListener('canplaythrough', this._boundComplete, false); + } + + if (this.xhr) { + if (this.xhr.removeEventListener) { + this.xhr.removeEventListener('error', this._boundXhrOnError, false); + this.xhr.removeEventListener('timeout', this._boundXhrOnTimeout, false); + this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false); + this.xhr.removeEventListener('progress', this._boundOnProgress, false); + this.xhr.removeEventListener('load', this._boundXhrOnLoad, false); + } else { + this.xhr.onerror = null; + this.xhr.ontimeout = null; + this.xhr.onprogress = null; + this.xhr.onload = null; + } + } + }; + + /** + * Finalizes the load. + * + * @private + */ + + + Resource.prototype._finish = function _finish() { + if (this.isComplete) { + throw new Error('Complete called again for an already completed resource.'); + } + + this._setFlag(Resource.STATUS_FLAGS.COMPLETE, true); + this._setFlag(Resource.STATUS_FLAGS.LOADING, false); + + this.onComplete.dispatch(this); + }; + + /** + * Loads this resources using an element that has a single source, + * like an HTMLImageElement. + * + * @private + * @param {string} type - The type of element to use. + */ + + + Resource.prototype._loadElement = function _loadElement(type) { + if (this.metadata.loadElement) { + this.data = this.metadata.loadElement; + } else if (type === 'image' && typeof window.Image !== 'undefined') { + this.data = new Image(); + } else { + this.data = document.createElement(type); + } + + if (this.crossOrigin) { + this.data.crossOrigin = this.crossOrigin; + } + + if (!this.metadata.skipSource) { + this.data.src = this.url; + } + + this.data.addEventListener('error', this._boundOnError, false); + this.data.addEventListener('load', this._boundComplete, false); + this.data.addEventListener('progress', this._boundOnProgress, false); + + if (this.timeout) { + this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout); + } + }; + + /** + * Loads this resources using an element that has multiple sources, + * like an HTMLAudioElement or HTMLVideoElement. + * + * @private + * @param {string} type - The type of element to use. + */ + + + Resource.prototype._loadSourceElement = function _loadSourceElement(type) { + if (this.metadata.loadElement) { + this.data = this.metadata.loadElement; + } else if (type === 'audio' && typeof window.Audio !== 'undefined') { + this.data = new Audio(); + } else { + this.data = document.createElement(type); + } + + if (this.data === null) { + this.abort('Unsupported element: ' + type); + + return; + } + + if (this.crossOrigin) { + this.data.crossOrigin = this.crossOrigin; + } + + if (!this.metadata.skipSource) { + // support for CocoonJS Canvas+ runtime, lacks document.createElement('source') + if (navigator.isCocoonJS) { + this.data.src = Array.isArray(this.url) ? this.url[0] : this.url; + } else if (Array.isArray(this.url)) { + var mimeTypes = this.metadata.mimeType; + + for (var i = 0; i < this.url.length; ++i) { + this.data.appendChild(this._createSource(type, this.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes)); + } + } else { + var _mimeTypes = this.metadata.mimeType; + + this.data.appendChild(this._createSource(type, this.url, Array.isArray(_mimeTypes) ? _mimeTypes[0] : _mimeTypes)); + } + } + + this.data.addEventListener('error', this._boundOnError, false); + this.data.addEventListener('load', this._boundComplete, false); + this.data.addEventListener('progress', this._boundOnProgress, false); + this.data.addEventListener('canplaythrough', this._boundComplete, false); + + this.data.load(); + + if (this.timeout) { + this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout); + } + }; + + /** + * Loads this resources using an XMLHttpRequest. + * + * @private + */ + + + Resource.prototype._loadXhr = function _loadXhr() { + // if unset, determine the value + if (typeof this.xhrType !== 'string') { + this.xhrType = this._determineXhrType(); + } + + var xhr = this.xhr = new XMLHttpRequest(); + + // set the request type and url + xhr.open('GET', this.url, true); + + xhr.timeout = this.timeout; + + // load json as text and parse it ourselves. We do this because some browsers + // *cough* safari *cough* can't deal with it. + if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON || this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) { + xhr.responseType = Resource.XHR_RESPONSE_TYPE.TEXT; + } else { + xhr.responseType = this.xhrType; + } + + xhr.addEventListener('error', this._boundXhrOnError, false); + xhr.addEventListener('timeout', this._boundXhrOnTimeout, false); + xhr.addEventListener('abort', this._boundXhrOnAbort, false); + xhr.addEventListener('progress', this._boundOnProgress, false); + xhr.addEventListener('load', this._boundXhrOnLoad, false); + + xhr.send(); + }; + + /** + * Loads this resources using an XDomainRequest. This is here because we need to support IE9 (gross). + * + * @private + */ + + + Resource.prototype._loadXdr = function _loadXdr() { + // if unset, determine the value + if (typeof this.xhrType !== 'string') { + this.xhrType = this._determineXhrType(); + } + + var xdr = this.xhr = new XDomainRequest(); // eslint-disable-line no-undef + + // XDomainRequest has a few quirks. Occasionally it will abort requests + // A way to avoid this is to make sure ALL callbacks are set even if not used + // More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9 + xdr.timeout = this.timeout || 5000; // XDR needs a timeout value or it breaks in IE9 + + xdr.onerror = this._boundXhrOnError; + xdr.ontimeout = this._boundXhrOnTimeout; + xdr.onprogress = this._boundOnProgress; + xdr.onload = this._boundXhrOnLoad; + + xdr.open('GET', this.url, true); + + // Note: The xdr.send() call is wrapped in a timeout to prevent an + // issue with the interface where some requests are lost if multiple + // XDomainRequests are being sent at the same time. + // Some info here: https://github.com/photonstorm/phaser/issues/1248 + setTimeout(function () { + return xdr.send(); + }, 1); + }; - this.children.push(child); + /** + * Creates a source used in loading via an element. + * + * @private + * @param {string} type - The element type (video or audio). + * @param {string} url - The source URL to load from. + * @param {string} [mime] - The mime type of the video + * @return {HTMLSourceElement} The source element. + */ - // ensure bounds will be recalculated - this._boundsID++; - // TODO - lets either do all callbacks or all events.. not both! - this.onChildrenChange(this.children.length - 1); - child.emit('added', this); - } - - return child; - }; - - /** - * Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown - * - * @param {PIXI.DisplayObject} child - The child to add - * @param {number} index - The index to place the child in - * @return {PIXI.DisplayObject} The child that was added. - */ - - - Container.prototype.addChildAt = function addChildAt(child, index) { - if (index < 0 || index > this.children.length) { - throw new Error(child + 'addChildAt: The index ' + index + ' supplied is out of bounds ' + this.children.length); - } - - if (child.parent) { - child.parent.removeChild(child); - } - - child.parent = this; - // ensure child transform will be recalculated - child.transform._parentID = -1; - - this.children.splice(index, 0, child); - - // ensure bounds will be recalculated - this._boundsID++; - - // TODO - lets either do all callbacks or all events.. not both! - this.onChildrenChange(index); - child.emit('added', this); - - return child; - }; - - /** - * Swaps the position of 2 Display Objects within this container. - * - * @param {PIXI.DisplayObject} child - First display object to swap - * @param {PIXI.DisplayObject} child2 - Second display object to swap - */ + Resource.prototype._createSource = function _createSource(type, url, mime) { + if (!mime) { + mime = type + '/' + this._getExtension(url); + } + var source = document.createElement('source'); - Container.prototype.swapChildren = function swapChildren(child, child2) { - if (child === child2) { - return; - } - - var index1 = this.getChildIndex(child); - var index2 = this.getChildIndex(child2); + source.src = url; + source.type = mime; - this.children[index1] = child2; - this.children[index2] = child; - this.onChildrenChange(index1 < index2 ? index1 : index2); - }; - - /** - * Returns the index position of a child DisplayObject instance - * - * @param {PIXI.DisplayObject} child - The DisplayObject instance to identify - * @return {number} The index position of the child display object to identify - */ - - - Container.prototype.getChildIndex = function getChildIndex(child) { - var index = this.children.indexOf(child); + return source; + }; + + /** + * Called if a load errors out. + * + * @param {Event} event - The error event from the element that emits it. + * @private + */ - if (index === -1) { - throw new Error('The supplied DisplayObject must be a child of the caller'); - } - return index; - }; + Resource.prototype._onError = function _onError(event) { + this.abort('Failed to load element using: ' + event.target.nodeName); + }; + + /** + * Called if a load progress event fires for an element or xhr/xdr. + * + * @private + * @param {XMLHttpRequestProgressEvent|Event} event - Progress event. + */ + + + Resource.prototype._onProgress = function _onProgress(event) { + if (event && event.lengthComputable) { + this.onProgress.dispatch(this, event.loaded / event.total); + } + }; + + /** + * Called if a timeout event fires for an element. + * + * @private + */ + + + Resource.prototype._onTimeout = function _onTimeout() { + this.abort('Load timed out.'); + }; + + /** + * Called if an error event fires for xhr/xdr. + * + * @private + */ + + + Resource.prototype._xhrOnError = function _xhrOnError() { + var xhr = this.xhr; + + this.abort(reqType(xhr) + ' Request failed. Status: ' + xhr.status + ', text: "' + xhr.statusText + '"'); + }; + + /** + * Called if an error event fires for xhr/xdr. + * + * @private + */ + + + Resource.prototype._xhrOnTimeout = function _xhrOnTimeout() { + var xhr = this.xhr; + + this.abort(reqType(xhr) + ' Request timed out.'); + }; + + /** + * Called if an abort event fires for xhr/xdr. + * + * @private + */ + + + Resource.prototype._xhrOnAbort = function _xhrOnAbort() { + var xhr = this.xhr; + + this.abort(reqType(xhr) + ' Request was aborted by the user.'); + }; + + /** + * Called when data successfully loads from an xhr/xdr request. + * + * @private + * @param {XMLHttpRequestLoadEvent|Event} event - Load event + */ + + + Resource.prototype._xhrOnLoad = function _xhrOnLoad() { + var xhr = this.xhr; + var text = ''; + var status = typeof xhr.status === 'undefined' ? STATUS_OK : xhr.status; // XDR has no `.status`, assume 200. + + // responseText is accessible only if responseType is '' or 'text' and on older browsers + if (xhr.responseType === '' || xhr.responseType === 'text' || typeof xhr.responseType === 'undefined') { + text = xhr.responseText; + } + + // status can be 0 when using the `file://` protocol so we also check if a response is set. + // If it has a response, we assume 200; otherwise a 0 status code with no contents is an aborted request. + if (status === STATUS_NONE && (text.length > 0 || xhr.responseType === Resource.XHR_RESPONSE_TYPE.BUFFER)) { + status = STATUS_OK; + } + // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request + else if (status === STATUS_IE_BUG_EMPTY) { + status = STATUS_EMPTY; + } + + var statusType = status / 100 | 0; + + if (statusType === STATUS_TYPE_OK) { + // if text, just return it + if (this.xhrType === Resource.XHR_RESPONSE_TYPE.TEXT) { + this.data = text; + this.type = Resource.TYPE.TEXT; + } + // if json, parse into json object + else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON) { + try { + this.data = JSON.parse(text); + this.type = Resource.TYPE.JSON; + } catch (e) { + this.abort('Error trying to parse loaded json: ' + e); + + return; + } + } + // if xml, parse into an xml document or div element + else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) { + try { + if (window.DOMParser) { + var domparser = new DOMParser(); + + this.data = domparser.parseFromString(text, 'text/xml'); + } else { + var div = document.createElement('div'); + + div.innerHTML = text; + + this.data = div; + } + + this.type = Resource.TYPE.XML; + } catch (e) { + this.abort('Error trying to parse loaded xml: ' + e); + + return; + } + } + // other types just return the response + else { + this.data = xhr.response || text; + } + } else { + this.abort('[' + xhr.status + '] ' + xhr.statusText + ': ' + xhr.responseURL); + + return; + } + + this.complete(); + }; + + /** + * Sets the `crossOrigin` property for this resource based on if the url + * for this resource is cross-origin. If crossOrigin was manually set, this + * function does nothing. + * + * @private + * @param {string} url - The url to test. + * @param {object} [loc=window.location] - The location object to test against. + * @return {string} The crossOrigin value to use (or empty string for none). + */ + + + Resource.prototype._determineCrossOrigin = function _determineCrossOrigin(url, loc) { + // data: and javascript: urls are considered same-origin + if (url.indexOf('data:') === 0) { + return ''; + } + + // A sandboxed iframe without the 'allow-same-origin' attribute will have a special + // origin designed not to match window.location.origin, and will always require + // crossOrigin requests regardless of whether the location matches. + if (window.origin !== window.location.origin) { + return 'anonymous'; + } + + // default is window.location + loc = loc || window.location; + + if (!tempAnchor) { + tempAnchor = document.createElement('a'); + } + + // let the browser determine the full href for the url of this resource and then + // parse with the node url lib, we can't use the properties of the anchor element + // because they don't work in IE9 :( + tempAnchor.href = url; + url = (0, _parseUri2.default)(tempAnchor.href, { strictMode: true }); + + var samePort = !url.port && loc.port === '' || url.port === loc.port; + var protocol = url.protocol ? url.protocol + ':' : ''; + + // if cross origin + if (url.host !== loc.hostname || !samePort || protocol !== loc.protocol) { + return 'anonymous'; + } + + return ''; + }; + + /** + * Determines the responseType of an XHR request based on the extension of the + * resource being loaded. + * + * @private + * @return {Resource.XHR_RESPONSE_TYPE} The responseType to use. + */ + + + Resource.prototype._determineXhrType = function _determineXhrType() { + return Resource._xhrTypeMap[this.extension] || Resource.XHR_RESPONSE_TYPE.TEXT; + }; + + /** + * Determines the loadType of a resource based on the extension of the + * resource being loaded. + * + * @private + * @return {Resource.LOAD_TYPE} The loadType to use. + */ + + + Resource.prototype._determineLoadType = function _determineLoadType() { + return Resource._loadTypeMap[this.extension] || Resource.LOAD_TYPE.XHR; + }; + + /** + * Extracts the extension (sans '.') of the file being loaded by the resource. + * + * @private + * @return {string} The extension. + */ + + + Resource.prototype._getExtension = function _getExtension() { + var url = this.url; + var ext = ''; + + if (this.isDataUrl) { + var slashIndex = url.indexOf('/'); + + ext = url.substring(slashIndex + 1, url.indexOf(';', slashIndex)); + } else { + var queryStart = url.indexOf('?'); + var hashStart = url.indexOf('#'); + var index = Math.min(queryStart > -1 ? queryStart : url.length, hashStart > -1 ? hashStart : url.length); + + url = url.substring(0, index); + ext = url.substring(url.lastIndexOf('.') + 1); + } + + return ext.toLowerCase(); + }; + + /** + * Determines the mime type of an XHR request based on the responseType of + * resource being loaded. + * + * @private + * @param {Resource.XHR_RESPONSE_TYPE} type - The type to get a mime type for. + * @return {string} The mime type to use. + */ + + + Resource.prototype._getMimeFromXhrType = function _getMimeFromXhrType(type) { + switch (type) { + case Resource.XHR_RESPONSE_TYPE.BUFFER: + return 'application/octet-binary'; + + case Resource.XHR_RESPONSE_TYPE.BLOB: + return 'application/blob'; + + case Resource.XHR_RESPONSE_TYPE.DOCUMENT: + return 'application/xml'; + + case Resource.XHR_RESPONSE_TYPE.JSON: + return 'application/json'; + + case Resource.XHR_RESPONSE_TYPE.DEFAULT: + case Resource.XHR_RESPONSE_TYPE.TEXT: + /* falls through */ + default: + return 'text/plain'; + } + }; + + _createClass(Resource, [{ + key: 'isDataUrl', + get: function get() { + return this._hasFlag(Resource.STATUS_FLAGS.DATA_URL); + } + + /** + * Describes if this resource has finished loading. Is true when the resource has completely + * loaded. + * + * @readonly + * @member {boolean} + */ + + }, { + key: 'isComplete', + get: function get() { + return this._hasFlag(Resource.STATUS_FLAGS.COMPLETE); + } + + /** + * Describes if this resource is currently loading. Is true when the resource starts loading, + * and is false again when complete. + * + * @readonly + * @member {boolean} + */ + + }, { + key: 'isLoading', + get: function get() { + return this._hasFlag(Resource.STATUS_FLAGS.LOADING); + } + }]); + + return Resource; + }(); + + /** + * The types of resources a resource could represent. + * + * @static + * @readonly + * @enum {number} + */ + + + Resource.STATUS_FLAGS = { + NONE: 0, + DATA_URL: 1 << 0, + COMPLETE: 1 << 1, + LOADING: 1 << 2 + }; + + /** + * The types of resources a resource could represent. + * + * @static + * @readonly + * @enum {number} + */ + Resource.TYPE = { + UNKNOWN: 0, + JSON: 1, + XML: 2, + IMAGE: 3, + AUDIO: 4, + VIDEO: 5, + TEXT: 6 + }; + + /** + * The types of loading a resource can use. + * + * @static + * @readonly + * @enum {number} + */ + Resource.LOAD_TYPE = { + /** Uses XMLHttpRequest to load the resource. */ + XHR: 1, + /** Uses an `Image` object to load the resource. */ + IMAGE: 2, + /** Uses an `Audio` object to load the resource. */ + AUDIO: 3, + /** Uses a `Video` object to load the resource. */ + VIDEO: 4 + }; + + /** + * The XHR ready states, used internally. + * + * @static + * @readonly + * @enum {string} + */ + Resource.XHR_RESPONSE_TYPE = { + /** string */ + DEFAULT: 'text', + /** ArrayBuffer */ + BUFFER: 'arraybuffer', + /** Blob */ + BLOB: 'blob', + /** Document */ + DOCUMENT: 'document', + /** Object */ + JSON: 'json', + /** String */ + TEXT: 'text' + }; + + Resource._loadTypeMap = { + // images + gif: Resource.LOAD_TYPE.IMAGE, + png: Resource.LOAD_TYPE.IMAGE, + bmp: Resource.LOAD_TYPE.IMAGE, + jpg: Resource.LOAD_TYPE.IMAGE, + jpeg: Resource.LOAD_TYPE.IMAGE, + tif: Resource.LOAD_TYPE.IMAGE, + tiff: Resource.LOAD_TYPE.IMAGE, + webp: Resource.LOAD_TYPE.IMAGE, + tga: Resource.LOAD_TYPE.IMAGE, + svg: Resource.LOAD_TYPE.IMAGE, + 'svg+xml': Resource.LOAD_TYPE.IMAGE, // for SVG data urls + + // audio + mp3: Resource.LOAD_TYPE.AUDIO, + ogg: Resource.LOAD_TYPE.AUDIO, + wav: Resource.LOAD_TYPE.AUDIO, + + // videos + mp4: Resource.LOAD_TYPE.VIDEO, + webm: Resource.LOAD_TYPE.VIDEO + }; + + Resource._xhrTypeMap = { + // xml + xhtml: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + html: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + htm: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + xml: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + tmx: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + svg: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + + // This was added to handle Tiled Tileset XML, but .tsx is also a TypeScript React Component. + // Since it is way less likely for people to be loading TypeScript files instead of Tiled files, + // this should probably be fine. + tsx: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + + // images + gif: Resource.XHR_RESPONSE_TYPE.BLOB, + png: Resource.XHR_RESPONSE_TYPE.BLOB, + bmp: Resource.XHR_RESPONSE_TYPE.BLOB, + jpg: Resource.XHR_RESPONSE_TYPE.BLOB, + jpeg: Resource.XHR_RESPONSE_TYPE.BLOB, + tif: Resource.XHR_RESPONSE_TYPE.BLOB, + tiff: Resource.XHR_RESPONSE_TYPE.BLOB, + webp: Resource.XHR_RESPONSE_TYPE.BLOB, + tga: Resource.XHR_RESPONSE_TYPE.BLOB, + + // json + json: Resource.XHR_RESPONSE_TYPE.JSON, + + // text + text: Resource.XHR_RESPONSE_TYPE.TEXT, + txt: Resource.XHR_RESPONSE_TYPE.TEXT, + + // fonts + ttf: Resource.XHR_RESPONSE_TYPE.BUFFER, + otf: Resource.XHR_RESPONSE_TYPE.BUFFER + }; + + // We can't set the `src` attribute to empty string, so on abort we set it to this 1px transparent gif + Resource.EMPTY_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; + + /** + * Quick helper to set a value on one of the extension maps. Ensures there is no + * dot at the start of the extension. + * + * @ignore + * @param {object} map - The map to set on. + * @param {string} extname - The extension (or key) to set. + * @param {number} val - The value to set. + */ + function setExtMap(map, extname, val) { + if (extname && extname.indexOf('.') === 0) { + extname = extname.substring(1); + } + + if (!extname) { + return; + } + + map[extname] = val; + } + + /** + * Quick helper to get string xhr type. + * + * @ignore + * @param {XMLHttpRequest|XDomainRequest} xhr - The request to check. + * @return {string} The type. + */ + function reqType(xhr) { + return xhr.toString().replace('object ', ''); + } + + // Backwards compat + if ('object' !== 'undefined') { + module.exports.default = Resource; // eslint-disable-line no-undef + } + + }); + + var Resource$1 = unwrapExports(Resource_1); + var Resource_2 = Resource_1.Resource; + + var Loader_1 = createCommonjsModule(function (module, exports) { + 'use strict'; + + exports.__esModule = true; + exports.Loader = undefined; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) { defineProperties(Constructor.prototype, protoProps); } if (staticProps) { defineProperties(Constructor, staticProps); } return Constructor; }; }(); + + + + var _miniSignals2 = _interopRequireDefault(miniSignals); + + + + var _parseUri2 = _interopRequireDefault(parseUri); + + + + var async$1 = _interopRequireWildcard(async); + + + + function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + // some constants + var MAX_PROGRESS = 100; + var rgxExtractUrlHash = /(#[\w-]+)?$/; + + /** + * Manages the state and loading of multiple resources to load. + * + * @class + */ + + var Loader = exports.Loader = function () { + /** + * @param {string} [baseUrl=''] - The base url for all resources loaded by this loader. + * @param {number} [concurrency=10] - The number of resources to load concurrently. + */ + function Loader() { + var _this = this; + + var baseUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + var concurrency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; + + _classCallCheck(this, Loader); + + /** + * The base url for all resources loaded by this loader. + * + * @member {string} + */ + this.baseUrl = baseUrl; + + /** + * The progress percent of the loader going through the queue. + * + * @member {number} + */ + this.progress = 0; + + /** + * Loading state of the loader, true if it is currently loading resources. + * + * @member {boolean} + */ + this.loading = false; + + /** + * A querystring to append to every URL added to the loader. + * + * This should be a valid query string *without* the question-mark (`?`). The loader will + * also *not* escape values for you. Make sure to escape your parameters with + * [`encodeURIComponent`](https://mdn.io/encodeURIComponent) before assigning this property. + * + * @example + * const loader = new Loader(); + * + * loader.defaultQueryString = 'user=me&password=secret'; + * + * // This will request 'image.png?user=me&password=secret' + * loader.add('image.png').load(); + * + * loader.reset(); + * + * // This will request 'image.png?v=1&user=me&password=secret' + * loader.add('iamge.png?v=1').load(); + * + * @member {string} + */ + this.defaultQueryString = ''; + + /** + * The middleware to run before loading each resource. + * + * @private + * @member {function[]} + */ + this._beforeMiddleware = []; + + /** + * The middleware to run after loading each resource. + * + * @private + * @member {function[]} + */ + this._afterMiddleware = []; + + /** + * The tracks the resources we are currently completing parsing for. + * + * @private + * @member {Resource[]} + */ + this._resourcesParsing = []; + + /** + * The `_loadResource` function bound with this object context. + * + * @private + * @member {function} + * @param {Resource} r - The resource to load + * @param {Function} d - The dequeue function + * @return {undefined} + */ + this._boundLoadResource = function (r, d) { + return _this._loadResource(r, d); + }; + + /** + * The resources waiting to be loaded. + * + * @private + * @member {Resource[]} + */ + this._queue = async$1.queue(this._boundLoadResource, concurrency); + + this._queue.pause(); + + /** + * All the resources for this loader keyed by name. + * + * @member {object} + */ + this.resources = {}; + + /** + * Dispatched once per loaded or errored resource. + * + * The callback looks like {@link Loader.OnProgressSignal}. + * + * @member {Signal} + */ + this.onProgress = new _miniSignals2.default(); + + /** + * Dispatched once per errored resource. + * + * The callback looks like {@link Loader.OnErrorSignal}. + * + * @member {Signal} + */ + this.onError = new _miniSignals2.default(); + + /** + * Dispatched once per loaded resource. + * + * The callback looks like {@link Loader.OnLoadSignal}. + * + * @member {Signal} + */ + this.onLoad = new _miniSignals2.default(); + + /** + * Dispatched when the loader begins to process the queue. + * + * The callback looks like {@link Loader.OnStartSignal}. + * + * @member {Signal} + */ + this.onStart = new _miniSignals2.default(); + + /** + * Dispatched when the queued resources all load. + * + * The callback looks like {@link Loader.OnCompleteSignal}. + * + * @member {Signal} + */ + this.onComplete = new _miniSignals2.default(); + + // Add default before middleware + for (var i = 0; i < Loader._defaultBeforeMiddleware.length; ++i) { + this.pre(Loader._defaultBeforeMiddleware[i]); + } + + // Add default after middleware + for (var _i = 0; _i < Loader._defaultAfterMiddleware.length; ++_i) { + this.use(Loader._defaultAfterMiddleware[_i]); + } + } + + /** + * When the progress changes the loader and resource are disaptched. + * + * @memberof Loader + * @callback OnProgressSignal + * @param {Loader} loader - The loader the progress is advancing on. + * @param {Resource} resource - The resource that has completed or failed to cause the progress to advance. + */ + + /** + * When an error occurrs the loader and resource are disaptched. + * + * @memberof Loader + * @callback OnErrorSignal + * @param {Loader} loader - The loader the error happened in. + * @param {Resource} resource - The resource that caused the error. + */ + + /** + * When a load completes the loader and resource are disaptched. + * + * @memberof Loader + * @callback OnLoadSignal + * @param {Loader} loader - The loader that laoded the resource. + * @param {Resource} resource - The resource that has completed loading. + */ + + /** + * When the loader starts loading resources it dispatches this callback. + * + * @memberof Loader + * @callback OnStartSignal + * @param {Loader} loader - The loader that has started loading resources. + */ + + /** + * When the loader completes loading resources it dispatches this callback. + * + * @memberof Loader + * @callback OnCompleteSignal + * @param {Loader} loader - The loader that has finished loading resources. + */ + + /** + * Options for a call to `.add()`. + * + * @see Loader#add + * + * @typedef {object} IAddOptions + * @property {string} [name] - The name of the resource to load, if not passed the url is used. + * @property {string} [key] - Alias for `name`. + * @property {string} [url] - The url for this resource, relative to the baseUrl of this loader. + * @property {string|boolean} [crossOrigin] - Is this request cross-origin? Default is to + * determine automatically. + * @property {number} [timeout=0] - A timeout in milliseconds for the load. If the load takes + * longer than this time it is cancelled and the load is considered a failure. If this value is + * set to `0` then there is no explicit timeout. + * @property {Resource.LOAD_TYPE} [loadType=Resource.LOAD_TYPE.XHR] - How should this resource + * be loaded? + * @property {Resource.XHR_RESPONSE_TYPE} [xhrType=Resource.XHR_RESPONSE_TYPE.DEFAULT] - How + * should the data being loaded be interpreted when using XHR? + * @property {Resource.OnCompleteSignal} [onComplete] - Callback to add an an onComplete signal istener. + * @property {Resource.OnCompleteSignal} [callback] - Alias for `onComplete`. + * @property {Resource.IMetadata} [metadata] - Extra configuration for middleware and the Resource object. + */ + + /* eslint-disable require-jsdoc,valid-jsdoc */ + /** + * Adds a resource (or multiple resources) to the loader queue. + * + * This function can take a wide variety of different parameters. The only thing that is always + * required the url to load. All the following will work: + * + * ```js + * loader + * // normal param syntax + * .add('key', 'http://...', function () {}) + * .add('http://...', function () {}) + * .add('http://...') + * + * // object syntax + * .add({ + * name: 'key2', + * url: 'http://...' + * }, function () {}) + * .add({ + * url: 'http://...' + * }, function () {}) + * .add({ + * name: 'key3', + * url: 'http://...' + * onComplete: function () {} + * }) + * .add({ + * url: 'https://...', + * onComplete: function () {}, + * crossOrigin: true + * }) + * + * // you can also pass an array of objects or urls or both + * .add([ + * { name: 'key4', url: 'http://...', onComplete: function () {} }, + * { url: 'http://...', onComplete: function () {} }, + * 'http://...' + * ]) + * + * // and you can use both params and options + * .add('key', 'http://...', { crossOrigin: true }, function () {}) + * .add('http://...', { crossOrigin: true }, function () {}); + * ``` + * + * @function + * @variation 1 + * @param {string} name - The name of the resource to load. + * @param {string} url - The url for this resource, relative to the baseUrl of this loader. + * @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading. + * @return {this} Returns itself. + */ /** + * @function + * @variation 2 + * @param {string} name - The name of the resource to load. + * @param {string} url - The url for this resource, relative to the baseUrl of this loader. + * @param {IAddOptions} [options] - The options for the load. + * @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading. + * @return {this} Returns itself. + */ /** + * @function + * @variation 3 + * @param {string} url - The url for this resource, relative to the baseUrl of this loader. + * @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading. + * @return {this} Returns itself. + */ /** + * @function + * @variation 4 + * @param {string} url - The url for this resource, relative to the baseUrl of this loader. + * @param {IAddOptions} [options] - The options for the load. + * @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading. + * @return {this} Returns itself. + */ /** + * @function + * @variation 5 + * @param {IAddOptions} options - The options for the load. This object must contain a `url` property. + * @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading. + * @return {this} Returns itself. + */ /** + * @function + * @variation 6 + * @param {Array} resources - An array of resources to load, where each is + * either an object with the options or a string url. If you pass an object, it must contain a `url` property. + * @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading. + * @return {this} Returns itself. + */ + + + Loader.prototype.add = function add(name, url, options, cb) { + // special case of an array of objects or urls + if (Array.isArray(name)) { + for (var i = 0; i < name.length; ++i) { + this.add(name[i]); + } + + return this; + } + + // if an object is passed instead of params + if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { + cb = url || name.callback || name.onComplete; + options = name; + url = name.url; + name = name.name || name.key || name.url; + } + + // case where no name is passed shift all args over by one. + if (typeof url !== 'string') { + cb = options; + options = url; + url = name; + } + + // now that we shifted make sure we have a proper url. + if (typeof url !== 'string') { + throw new Error('No url passed to add resource to loader.'); + } + + // options are optional so people might pass a function and no options + if (typeof options === 'function') { + cb = options; + options = null; + } + + // if loading already you can only add resources that have a parent. + if (this.loading && (!options || !options.parentResource)) { + throw new Error('Cannot add resources while the loader is running.'); + } + + // check if resource already exists. + if (this.resources[name]) { + throw new Error('Resource named "' + name + '" already exists.'); + } + + // add base url if this isn't an absolute url + url = this._prepareUrl(url); + + // create the store the resource + this.resources[name] = new Resource_1.Resource(name, url, options); + + if (typeof cb === 'function') { + this.resources[name].onAfterMiddleware.once(cb); + } + + // if actively loading, make sure to adjust progress chunks for that parent and its children + if (this.loading) { + var parent = options.parentResource; + var incompleteChildren = []; + + for (var _i2 = 0; _i2 < parent.children.length; ++_i2) { + if (!parent.children[_i2].isComplete) { + incompleteChildren.push(parent.children[_i2]); + } + } + + var fullChunk = parent.progressChunk * (incompleteChildren.length + 1); // +1 for parent + var eachChunk = fullChunk / (incompleteChildren.length + 2); // +2 for parent & new child + + parent.children.push(this.resources[name]); + parent.progressChunk = eachChunk; + + for (var _i3 = 0; _i3 < incompleteChildren.length; ++_i3) { + incompleteChildren[_i3].progressChunk = eachChunk; + } + + this.resources[name].progressChunk = eachChunk; + } + + // add the resource to the queue + this._queue.push(this.resources[name]); + + return this; + }; + /* eslint-enable require-jsdoc,valid-jsdoc */ + + /** + * Sets up a middleware function that will run *before* the + * resource is loaded. + * + * @param {function} fn - The middleware function to register. + * @return {this} Returns itself. + */ + + + Loader.prototype.pre = function pre(fn) { + this._beforeMiddleware.push(fn); + + return this; + }; + + /** + * Sets up a middleware function that will run *after* the + * resource is loaded. + * + * @param {function} fn - The middleware function to register. + * @return {this} Returns itself. + */ + + + Loader.prototype.use = function use(fn) { + this._afterMiddleware.push(fn); + + return this; + }; + + /** + * Resets the queue of the loader to prepare for a new load. + * + * @return {this} Returns itself. + */ + + + Loader.prototype.reset = function reset() { + this.progress = 0; + this.loading = false; + + this._queue.kill(); + this._queue.pause(); + + // abort all resource loads + for (var k in this.resources) { + var res = this.resources[k]; + + if (res._onLoadBinding) { + res._onLoadBinding.detach(); + } + + if (res.isLoading) { + res.abort(); + } + } + + this.resources = {}; + + return this; + }; + + /** + * Starts loading the queued resources. + * + * @param {function} [cb] - Optional callback that will be bound to the `complete` event. + * @return {this} Returns itself. + */ + + + Loader.prototype.load = function load(cb) { + // register complete callback if they pass one + if (typeof cb === 'function') { + this.onComplete.once(cb); + } + + // if the queue has already started we are done here + if (this.loading) { + return this; + } + + if (this._queue.idle()) { + this._onStart(); + this._onComplete(); + } else { + // distribute progress chunks + var numTasks = this._queue._tasks.length; + var chunk = MAX_PROGRESS / numTasks; + + for (var i = 0; i < this._queue._tasks.length; ++i) { + this._queue._tasks[i].data.progressChunk = chunk; + } + + // notify we are starting + this._onStart(); + + // start loading + this._queue.resume(); + } + + return this; + }; + + /** + * The number of resources to load concurrently. + * + * @member {number} + * @default 10 + */ + + + /** + * Prepares a url for usage based on the configuration of this object + * + * @private + * @param {string} url - The url to prepare. + * @return {string} The prepared url. + */ + Loader.prototype._prepareUrl = function _prepareUrl(url) { + var parsedUrl = (0, _parseUri2.default)(url, { strictMode: true }); + var result = void 0; + + // absolute url, just use it as is. + if (parsedUrl.protocol || !parsedUrl.path || url.indexOf('//') === 0) { + result = url; + } + // if baseUrl doesn't end in slash and url doesn't start with slash, then add a slash inbetween + else if (this.baseUrl.length && this.baseUrl.lastIndexOf('/') !== this.baseUrl.length - 1 && url.charAt(0) !== '/') { + result = this.baseUrl + '/' + url; + } else { + result = this.baseUrl + url; + } + + // if we need to add a default querystring, there is a bit more work + if (this.defaultQueryString) { + var hash = rgxExtractUrlHash.exec(result)[0]; + + result = result.substr(0, result.length - hash.length); + + if (result.indexOf('?') !== -1) { + result += '&' + this.defaultQueryString; + } else { + result += '?' + this.defaultQueryString; + } + + result += hash; + } + + return result; + }; + + /** + * Loads a single resource. + * + * @private + * @param {Resource} resource - The resource to load. + * @param {function} dequeue - The function to call when we need to dequeue this item. + */ + + + Loader.prototype._loadResource = function _loadResource(resource, dequeue) { + var _this2 = this; + + resource._dequeue = dequeue; + + // run before middleware + async$1.eachSeries(this._beforeMiddleware, function (fn, next) { + fn.call(_this2, resource, function () { + // if the before middleware marks the resource as complete, + // break and don't process any more before middleware + next(resource.isComplete ? {} : null); + }); + }, function () { + if (resource.isComplete) { + _this2._onLoad(resource); + } else { + resource._onLoadBinding = resource.onComplete.once(_this2._onLoad, _this2); + resource.load(); + } + }, true); + }; + + /** + * Called once loading has started. + * + * @private + */ + + + Loader.prototype._onStart = function _onStart() { + this.progress = 0; + this.loading = true; + this.onStart.dispatch(this); + }; + + /** + * Called once each resource has loaded. + * + * @private + */ + + + Loader.prototype._onComplete = function _onComplete() { + this.progress = MAX_PROGRESS; + this.loading = false; + this.onComplete.dispatch(this, this.resources); + }; + + /** + * Called each time a resources is loaded. + * + * @private + * @param {Resource} resource - The resource that was loaded + */ + + + Loader.prototype._onLoad = function _onLoad(resource) { + var _this3 = this; + + resource._onLoadBinding = null; + + // remove this resource from the async queue, and add it to our list of resources that are being parsed + this._resourcesParsing.push(resource); + resource._dequeue(); + + // run all the after middleware for this resource + async$1.eachSeries(this._afterMiddleware, function (fn, next) { + fn.call(_this3, resource, next); + }, function () { + resource.onAfterMiddleware.dispatch(resource); + + _this3.progress = Math.min(MAX_PROGRESS, _this3.progress + resource.progressChunk); + _this3.onProgress.dispatch(_this3, resource); + + if (resource.error) { + _this3.onError.dispatch(resource.error, _this3, resource); + } else { + _this3.onLoad.dispatch(_this3, resource); + } + + _this3._resourcesParsing.splice(_this3._resourcesParsing.indexOf(resource), 1); + + // do completion check + if (_this3._queue.idle() && _this3._resourcesParsing.length === 0) { + _this3._onComplete(); + } + }, true); + }; + + _createClass(Loader, [{ + key: 'concurrency', + get: function get() { + return this._queue.concurrency; + } + // eslint-disable-next-line require-jsdoc + , + set: function set(concurrency) { + this._queue.concurrency = concurrency; + } + }]); + + return Loader; + }(); + + /** + * A default array of middleware to run before loading each resource. + * Each of these middlewares are added to any new Loader instances when they are created. + * + * @private + * @member {function[]} + */ + + + Loader._defaultBeforeMiddleware = []; + + /** + * A default array of middleware to run after loading each resource. + * Each of these middlewares are added to any new Loader instances when they are created. + * + * @private + * @member {function[]} + */ + Loader._defaultAfterMiddleware = []; + + /** + * Sets up a middleware function that will run *before* the + * resource is loaded. + * + * @static + * @param {function} fn - The middleware function to register. + * @return {Loader} Returns itself. + */ + Loader.pre = function LoaderPreStatic(fn) { + Loader._defaultBeforeMiddleware.push(fn); + + return Loader; + }; + + /** + * Sets up a middleware function that will run *after* the + * resource is loaded. + * + * @static + * @param {function} fn - The middleware function to register. + * @return {Loader} Returns itself. + */ + Loader.use = function LoaderUseStatic(fn) { + Loader._defaultAfterMiddleware.push(fn); + + return Loader; + }; + + }); + + var Loader = unwrapExports(Loader_1); + var Loader_2 = Loader_1.Loader; + + var b64 = createCommonjsModule(function (module, exports) { + 'use strict'; + + exports.__esModule = true; + exports.encodeBinary = encodeBinary; + var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + /** + * Encodes binary into base64. + * + * @param {string} input The input data to encode. + * @returns {string} The encoded base64 string + */ + function encodeBinary(input) { + var output = ''; + var inx = 0; + + while (inx < input.length) { + // Fill byte buffer array + var bytebuffer = [0, 0, 0]; + var encodedCharIndexes = [0, 0, 0, 0]; + + for (var jnx = 0; jnx < bytebuffer.length; ++jnx) { + if (inx < input.length) { + // throw away high-order byte, as documented at: + // https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data + bytebuffer[jnx] = input.charCodeAt(inx++) & 0xff; + } else { + bytebuffer[jnx] = 0; + } + } + + // Get each encoded character, 6 bits at a time + // index 1: first 6 bits + encodedCharIndexes[0] = bytebuffer[0] >> 2; + + // index 2: second 6 bits (2 least significant bits from input byte 1 + 4 most significant bits from byte 2) + encodedCharIndexes[1] = (bytebuffer[0] & 0x3) << 4 | bytebuffer[1] >> 4; + + // index 3: third 6 bits (4 least significant bits from input byte 2 + 2 most significant bits from byte 3) + encodedCharIndexes[2] = (bytebuffer[1] & 0x0f) << 2 | bytebuffer[2] >> 6; + + // index 3: forth 6 bits (6 least significant bits from input byte 3) + encodedCharIndexes[3] = bytebuffer[2] & 0x3f; + + // Determine whether padding happened, and adjust accordingly + var paddingBytes = inx - (input.length - 1); + + switch (paddingBytes) { + case 2: + // Set last 2 characters to padding char + encodedCharIndexes[3] = 64; + encodedCharIndexes[2] = 64; + break; + + case 1: + // Set last character to padding char + encodedCharIndexes[3] = 64; + break; + + default: + break; // No padding - proceed + } + + // Now we will grab each appropriate character out of our keystring + // based on our index array and append it to the output string + for (var _jnx = 0; _jnx < encodedCharIndexes.length; ++_jnx) { + output += _keyStr.charAt(encodedCharIndexes[_jnx]); + } + } + + return output; + } + + // Backwards compat + if ('object' !== 'undefined') { + module.exports.default = encodeBinary; // eslint-disable-line no-undef + } + + }); + + var b64$1 = unwrapExports(b64); + var b64_1 = b64.encodeBinary; + + 'use strict'; + + // import Loader from './Loader'; + // import Resource from './Resource'; + // import * as async from './async'; + // import * as b64 from './b64'; + + /* eslint-disable no-undef */ + + var Loader$1 = Loader_1.Loader; + var Resource$2 = Resource_1.Resource; + + + + /** + * + * @static + * @memberof Loader + * @member {Class} + */ + Loader$1.Resource = Resource$2; + + /** + * + * @static + * @memberof Loader + * @member {Class} + */ + Loader$1.async = async; + + /** + * + * @static + * @memberof Loader + * @member {Class} + */ + Loader$1.encodeBinary = b64; + + /** + * + * @deprecated + * @see Loader.encodeBinary + * + * @static + * @memberof Loader + * @member {Class} + */ + Loader$1.base64 = b64; + + // export manually, and also as default + var lib = Loader$1; + + // default & named export + var Loader_1$1 = Loader$1; + var default_1$1 = Loader$1; + var lib_1 = lib.Resource; + lib.Loader = Loader_1$1; + lib.default = default_1$1; + + /*! + * @pixi/loaders - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/loaders is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + function unwrapExports$1 (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + function createCommonjsModule$1(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + var parseUri$1 = function parseURI (str, opts) { + opts = opts || {}; + + var o = { + key: ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'], + q: { + name: 'queryKey', + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + parser: { + strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, + loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ + } + }; + + var m = o.parser[opts.strictMode ? 'strict' : 'loose'].exec(str); + var uri = {}; + var i = 14; + + while (i--) { uri[o.key[i]] = m[i] || ''; } + + uri[o.q.name] = {}; + uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { + if ($1) { uri[o.q.name][$1] = $2; } + }); + + return uri + }; + + var miniSignals$2 = createCommonjsModule$1(function (module, exports) { + + Object.defineProperty(exports, '__esModule', { + value: true + }); + + var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) { descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) { defineProperties(Constructor.prototype, protoProps); } if (staticProps) { defineProperties(Constructor, staticProps); } return Constructor; }; })(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + var MiniSignalBinding = (function () { + function MiniSignalBinding(fn, once, thisArg) { + if (once === undefined) { once = false; } + + _classCallCheck(this, MiniSignalBinding); + + this._fn = fn; + this._once = once; + this._thisArg = thisArg; + this._next = this._prev = this._owner = null; + } + + _createClass(MiniSignalBinding, [{ + key: 'detach', + value: function detach() { + if (this._owner === null) { return false; } + this._owner.detach(this); + return true; + } + }]); + + return MiniSignalBinding; + })(); + + function _addMiniSignalBinding(self, node) { + if (!self._head) { + self._head = node; + self._tail = node; + } else { + self._tail._next = node; + node._prev = self._tail; + self._tail = node; + } + + node._owner = self; + + return node; + } + + var MiniSignal = (function () { + function MiniSignal() { + _classCallCheck(this, MiniSignal); + + this._head = this._tail = undefined; + } + + _createClass(MiniSignal, [{ + key: 'handlers', + value: function handlers() { + var exists = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; + + var node = this._head; + + if (exists) { return !!node; } + + var ee = []; + + while (node) { + ee.push(node); + node = node._next; + } + + return ee; + } + }, { + key: 'has', + value: function has(node) { + if (!(node instanceof MiniSignalBinding)) { + throw new Error('MiniSignal#has(): First arg must be a MiniSignalBinding object.'); + } + + return node._owner === this; + } + }, { + key: 'dispatch', + value: function dispatch() { + var arguments$1 = arguments; - /** - * Changes the position of an existing child in the display object container - * - * @param {PIXI.DisplayObject} child - The child DisplayObject instance for which you want to change the index number - * @param {number} index - The resulting index number for the child display object - */ + var node = this._head; + if (!node) { return false; } - Container.prototype.setChildIndex = function setChildIndex(child, index) { - if (index < 0 || index >= this.children.length) { - throw new Error('The index ' + index + ' supplied is out of bounds ' + this.children.length); - } + while (node) { + if (node._once) { this.detach(node); } + node._fn.apply(node._thisArg, arguments$1); + node = node._next; + } + + return true; + } + }, { + key: 'add', + value: function add(fn) { + var thisArg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + + if (typeof fn !== 'function') { + throw new Error('MiniSignal#add(): First arg must be a Function.'); + } + return _addMiniSignalBinding(this, new MiniSignalBinding(fn, false, thisArg)); + } + }, { + key: 'once', + value: function once(fn) { + var thisArg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + + if (typeof fn !== 'function') { + throw new Error('MiniSignal#once(): First arg must be a Function.'); + } + return _addMiniSignalBinding(this, new MiniSignalBinding(fn, true, thisArg)); + } + }, { + key: 'detach', + value: function detach(node) { + if (!(node instanceof MiniSignalBinding)) { + throw new Error('MiniSignal#detach(): First arg must be a MiniSignalBinding object.'); + } + if (node._owner !== this) { return this; } + + if (node._prev) { node._prev._next = node._next; } + if (node._next) { node._next._prev = node._prev; } + + if (node === this._head) { + this._head = node._next; + if (node._next === null) { + this._tail = null; + } + } else if (node === this._tail) { + this._tail = node._prev; + this._tail._next = null; + } + + node._owner = null; + return this; + } + }, { + key: 'detachAll', + value: function detachAll() { + var node = this._head; + if (!node) { return this; } + + this._head = this._tail = null; + + while (node) { + node._owner = null; + node = node._next; + } + return this; + } + }]); + + return MiniSignal; + })(); + + MiniSignal.MiniSignalBinding = MiniSignalBinding; + + exports['default'] = MiniSignal; + module.exports = exports['default']; + }); + + unwrapExports$1(miniSignals$2); + + var Resource_1$1 = createCommonjsModule$1(function (module, exports) { + + exports.__esModule = true; + exports.Resource = undefined; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) { defineProperties(Constructor.prototype, protoProps); } if (staticProps) { defineProperties(Constructor, staticProps); } return Constructor; }; }(); + + + + var _parseUri2 = _interopRequireDefault(parseUri$1); + + + + var _miniSignals2 = _interopRequireDefault(miniSignals$2); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + // tests if CORS is supported in XHR, if not we need to use XDR + var useXdr = !!(window.XDomainRequest && !('withCredentials' in new XMLHttpRequest())); + var tempAnchor = null; + + // some status constants + var STATUS_NONE = 0; + var STATUS_OK = 200; + var STATUS_EMPTY = 204; + var STATUS_IE_BUG_EMPTY = 1223; + var STATUS_TYPE_OK = 2; + + // noop + function _noop() {} /* empty */ + + /** + * Manages the state and loading of a resource and all child resources. + * + * @class + */ + + var Resource = exports.Resource = function () { + /** + * Sets the load type to be used for a specific extension. + * + * @static + * @param {string} extname - The extension to set the type for, e.g. "png" or "fnt" + * @param {Resource.LOAD_TYPE} loadType - The load type to set it to. + */ + Resource.setExtensionLoadType = function setExtensionLoadType(extname, loadType) { + setExtMap(Resource._loadTypeMap, extname, loadType); + }; + + /** + * Sets the load type to be used for a specific extension. + * + * @static + * @param {string} extname - The extension to set the type for, e.g. "png" or "fnt" + * @param {Resource.XHR_RESPONSE_TYPE} xhrType - The xhr type to set it to. + */ + + + Resource.setExtensionXhrType = function setExtensionXhrType(extname, xhrType) { + setExtMap(Resource._xhrTypeMap, extname, xhrType); + }; + + /** + * @param {string} name - The name of the resource to load. + * @param {string|string[]} url - The url for this resource, for audio/video loads you can pass + * an array of sources. + * @param {object} [options] - The options for the load. + * @param {string|boolean} [options.crossOrigin] - Is this request cross-origin? Default is to + * determine automatically. + * @param {number} [options.timeout=0] - A timeout in milliseconds for the load. If the load takes + * longer than this time it is cancelled and the load is considered a failure. If this value is + * set to `0` then there is no explicit timeout. + * @param {Resource.LOAD_TYPE} [options.loadType=Resource.LOAD_TYPE.XHR] - How should this resource + * be loaded? + * @param {Resource.XHR_RESPONSE_TYPE} [options.xhrType=Resource.XHR_RESPONSE_TYPE.DEFAULT] - How + * should the data being loaded be interpreted when using XHR? + * @param {Resource.IMetadata} [options.metadata] - Extra configuration for middleware and the Resource object. + */ + + + function Resource(name, url, options) { + _classCallCheck(this, Resource); + + if (typeof name !== 'string' || typeof url !== 'string') { + throw new Error('Both name and url are required for constructing a resource.'); + } + + options = options || {}; + + /** + * The state flags of this resource. + * + * @private + * @member {number} + */ + this._flags = 0; + + // set data url flag, needs to be set early for some _determineX checks to work. + this._setFlag(Resource.STATUS_FLAGS.DATA_URL, url.indexOf('data:') === 0); + + /** + * The name of this resource. + * + * @readonly + * @member {string} + */ + this.name = name; + + /** + * The url used to load this resource. + * + * @readonly + * @member {string} + */ + this.url = url; + + /** + * The extension used to load this resource. + * + * @readonly + * @member {string} + */ + this.extension = this._getExtension(); + + /** + * The data that was loaded by the resource. + * + * @member {any} + */ + this.data = null; + + /** + * Is this request cross-origin? If unset, determined automatically. + * + * @member {string} + */ + this.crossOrigin = options.crossOrigin === true ? 'anonymous' : options.crossOrigin; + + /** + * A timeout in milliseconds for the load. If the load takes longer than this time + * it is cancelled and the load is considered a failure. If this value is set to `0` + * then there is no explicit timeout. + * + * @member {number} + */ + this.timeout = options.timeout || 0; + + /** + * The method of loading to use for this resource. + * + * @member {Resource.LOAD_TYPE} + */ + this.loadType = options.loadType || this._determineLoadType(); + + /** + * The type used to load the resource via XHR. If unset, determined automatically. + * + * @member {string} + */ + this.xhrType = options.xhrType; + + /** + * Extra info for middleware, and controlling specifics about how the resource loads. + * + * Note that if you pass in a `loadElement`, the Resource class takes ownership of it. + * Meaning it will modify it as it sees fit. + * + * @member {Resource.IMetadata} + */ + this.metadata = options.metadata || {}; + + /** + * The error that occurred while loading (if any). + * + * @readonly + * @member {Error} + */ + this.error = null; + + /** + * The XHR object that was used to load this resource. This is only set + * when `loadType` is `Resource.LOAD_TYPE.XHR`. + * + * @readonly + * @member {XMLHttpRequest} + */ + this.xhr = null; + + /** + * The child resources this resource owns. + * + * @readonly + * @member {Resource[]} + */ + this.children = []; + + /** + * The resource type. + * + * @readonly + * @member {Resource.TYPE} + */ + this.type = Resource.TYPE.UNKNOWN; + + /** + * The progress chunk owned by this resource. + * + * @readonly + * @member {number} + */ + this.progressChunk = 0; + + /** + * The `dequeue` method that will be used a storage place for the async queue dequeue method + * used privately by the loader. + * + * @private + * @member {function} + */ + this._dequeue = _noop; + + /** + * Used a storage place for the on load binding used privately by the loader. + * + * @private + * @member {function} + */ + this._onLoadBinding = null; + + /** + * The timer for element loads to check if they timeout. + * + * @private + * @member {number} + */ + this._elementTimer = 0; + + /** + * The `complete` function bound to this resource's context. + * + * @private + * @member {function} + */ + this._boundComplete = this.complete.bind(this); + + /** + * The `_onError` function bound to this resource's context. + * + * @private + * @member {function} + */ + this._boundOnError = this._onError.bind(this); + + /** + * The `_onProgress` function bound to this resource's context. + * + * @private + * @member {function} + */ + this._boundOnProgress = this._onProgress.bind(this); + + /** + * The `_onTimeout` function bound to this resource's context. + * + * @private + * @member {function} + */ + this._boundOnTimeout = this._onTimeout.bind(this); + + // xhr callbacks + this._boundXhrOnError = this._xhrOnError.bind(this); + this._boundXhrOnTimeout = this._xhrOnTimeout.bind(this); + this._boundXhrOnAbort = this._xhrOnAbort.bind(this); + this._boundXhrOnLoad = this._xhrOnLoad.bind(this); + + /** + * Dispatched when the resource beings to load. + * + * The callback looks like {@link Resource.OnStartSignal}. + * + * @member {Signal} + */ + this.onStart = new _miniSignals2.default(); + + /** + * Dispatched each time progress of this resource load updates. + * Not all resources types and loader systems can support this event + * so sometimes it may not be available. If the resource + * is being loaded on a modern browser, using XHR, and the remote server + * properly sets Content-Length headers, then this will be available. + * + * The callback looks like {@link Resource.OnProgressSignal}. + * + * @member {Signal} + */ + this.onProgress = new _miniSignals2.default(); + + /** + * Dispatched once this resource has loaded, if there was an error it will + * be in the `error` property. + * + * The callback looks like {@link Resource.OnCompleteSignal}. + * + * @member {Signal} + */ + this.onComplete = new _miniSignals2.default(); + + /** + * Dispatched after this resource has had all the *after* middleware run on it. + * + * The callback looks like {@link Resource.OnCompleteSignal}. + * + * @member {Signal} + */ + this.onAfterMiddleware = new _miniSignals2.default(); + } + + /** + * When the resource starts to load. + * + * @memberof Resource + * @callback OnStartSignal + * @param {Resource} resource - The resource that the event happened on. + */ + + /** + * When the resource reports loading progress. + * + * @memberof Resource + * @callback OnProgressSignal + * @param {Resource} resource - The resource that the event happened on. + * @param {number} percentage - The progress of the load in the range [0, 1]. + */ + + /** + * When the resource finishes loading. + * + * @memberof Resource + * @callback OnCompleteSignal + * @param {Resource} resource - The resource that the event happened on. + */ + + /** + * @memberof Resource + * @typedef {object} IMetadata + * @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The + * element to use for loading, instead of creating one. + * @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This + * is useful if you want to pass in a `loadElement` that you already added load sources to. + * @property {string|string[]} [mimeType] - The mime type to use for the source element + * of a video/audio elment. If the urls are an array, you can pass this as an array as well + * where each index is the mime type to use for the corresponding url index. + */ + + /** + * Stores whether or not this url is a data url. + * + * @readonly + * @member {boolean} + */ + + + /** + * Marks the resource as complete. + * + */ + Resource.prototype.complete = function complete() { + this._clearEvents(); + this._finish(); + }; + + /** + * Aborts the loading of this resource, with an optional message. + * + * @param {string} message - The message to use for the error + */ + + + Resource.prototype.abort = function abort(message) { + // abort can be called multiple times, ignore subsequent calls. + if (this.error) { + return; + } + + // store error + this.error = new Error(message); + + // clear events before calling aborts + this._clearEvents(); + + // abort the actual loading + if (this.xhr) { + this.xhr.abort(); + } else if (this.xdr) { + this.xdr.abort(); + } else if (this.data) { + // single source + if (this.data.src) { + this.data.src = Resource.EMPTY_GIF; + } + // multi-source + else { + while (this.data.firstChild) { + this.data.removeChild(this.data.firstChild); + } + } + } + + // done now. + this._finish(); + }; + + /** + * Kicks off loading of this resource. This method is asynchronous. + * + * @param {Resource.OnCompleteSignal} [cb] - Optional callback to call once the resource is loaded. + */ + + + Resource.prototype.load = function load(cb) { + var _this = this; + + if (this.isLoading) { + return; + } + + if (this.isComplete) { + if (cb) { + setTimeout(function () { + return cb(_this); + }, 1); + } + + return; + } else if (cb) { + this.onComplete.once(cb); + } + + this._setFlag(Resource.STATUS_FLAGS.LOADING, true); + + this.onStart.dispatch(this); + + // if unset, determine the value + if (this.crossOrigin === false || typeof this.crossOrigin !== 'string') { + this.crossOrigin = this._determineCrossOrigin(this.url); + } + + switch (this.loadType) { + case Resource.LOAD_TYPE.IMAGE: + this.type = Resource.TYPE.IMAGE; + this._loadElement('image'); + break; + + case Resource.LOAD_TYPE.AUDIO: + this.type = Resource.TYPE.AUDIO; + this._loadSourceElement('audio'); + break; + + case Resource.LOAD_TYPE.VIDEO: + this.type = Resource.TYPE.VIDEO; + this._loadSourceElement('video'); + break; + + case Resource.LOAD_TYPE.XHR: + /* falls through */ + default: + if (useXdr && this.crossOrigin) { + this._loadXdr(); + } else { + this._loadXhr(); + } + break; + } + }; + + /** + * Checks if the flag is set. + * + * @private + * @param {number} flag - The flag to check. + * @return {boolean} True if the flag is set. + */ + + + Resource.prototype._hasFlag = function _hasFlag(flag) { + return (this._flags & flag) !== 0; + }; + + /** + * (Un)Sets the flag. + * + * @private + * @param {number} flag - The flag to (un)set. + * @param {boolean} value - Whether to set or (un)set the flag. + */ + + + Resource.prototype._setFlag = function _setFlag(flag, value) { + this._flags = value ? this._flags | flag : this._flags & ~flag; + }; + + /** + * Clears all the events from the underlying loading source. + * + * @private + */ + + + Resource.prototype._clearEvents = function _clearEvents() { + clearTimeout(this._elementTimer); + + if (this.data && this.data.removeEventListener) { + this.data.removeEventListener('error', this._boundOnError, false); + this.data.removeEventListener('load', this._boundComplete, false); + this.data.removeEventListener('progress', this._boundOnProgress, false); + this.data.removeEventListener('canplaythrough', this._boundComplete, false); + } + + if (this.xhr) { + if (this.xhr.removeEventListener) { + this.xhr.removeEventListener('error', this._boundXhrOnError, false); + this.xhr.removeEventListener('timeout', this._boundXhrOnTimeout, false); + this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false); + this.xhr.removeEventListener('progress', this._boundOnProgress, false); + this.xhr.removeEventListener('load', this._boundXhrOnLoad, false); + } else { + this.xhr.onerror = null; + this.xhr.ontimeout = null; + this.xhr.onprogress = null; + this.xhr.onload = null; + } + } + }; + + /** + * Finalizes the load. + * + * @private + */ + + + Resource.prototype._finish = function _finish() { + if (this.isComplete) { + throw new Error('Complete called again for an already completed resource.'); + } + + this._setFlag(Resource.STATUS_FLAGS.COMPLETE, true); + this._setFlag(Resource.STATUS_FLAGS.LOADING, false); + + this.onComplete.dispatch(this); + }; + + /** + * Loads this resources using an element that has a single source, + * like an HTMLImageElement. + * + * @private + * @param {string} type - The type of element to use. + */ + + + Resource.prototype._loadElement = function _loadElement(type) { + if (this.metadata.loadElement) { + this.data = this.metadata.loadElement; + } else if (type === 'image' && typeof window.Image !== 'undefined') { + this.data = new Image(); + } else { + this.data = document.createElement(type); + } + + if (this.crossOrigin) { + this.data.crossOrigin = this.crossOrigin; + } + + if (!this.metadata.skipSource) { + this.data.src = this.url; + } + + this.data.addEventListener('error', this._boundOnError, false); + this.data.addEventListener('load', this._boundComplete, false); + this.data.addEventListener('progress', this._boundOnProgress, false); + + if (this.timeout) { + this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout); + } + }; + + /** + * Loads this resources using an element that has multiple sources, + * like an HTMLAudioElement or HTMLVideoElement. + * + * @private + * @param {string} type - The type of element to use. + */ + + + Resource.prototype._loadSourceElement = function _loadSourceElement(type) { + if (this.metadata.loadElement) { + this.data = this.metadata.loadElement; + } else if (type === 'audio' && typeof window.Audio !== 'undefined') { + this.data = new Audio(); + } else { + this.data = document.createElement(type); + } + + if (this.data === null) { + this.abort('Unsupported element: ' + type); + + return; + } + + if (this.crossOrigin) { + this.data.crossOrigin = this.crossOrigin; + } + + if (!this.metadata.skipSource) { + // support for CocoonJS Canvas+ runtime, lacks document.createElement('source') + if (navigator.isCocoonJS) { + this.data.src = Array.isArray(this.url) ? this.url[0] : this.url; + } else if (Array.isArray(this.url)) { + var mimeTypes = this.metadata.mimeType; + + for (var i = 0; i < this.url.length; ++i) { + this.data.appendChild(this._createSource(type, this.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes)); + } + } else { + var _mimeTypes = this.metadata.mimeType; + + this.data.appendChild(this._createSource(type, this.url, Array.isArray(_mimeTypes) ? _mimeTypes[0] : _mimeTypes)); + } + } + + this.data.addEventListener('error', this._boundOnError, false); + this.data.addEventListener('load', this._boundComplete, false); + this.data.addEventListener('progress', this._boundOnProgress, false); + this.data.addEventListener('canplaythrough', this._boundComplete, false); + + this.data.load(); + + if (this.timeout) { + this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout); + } + }; + + /** + * Loads this resources using an XMLHttpRequest. + * + * @private + */ + + + Resource.prototype._loadXhr = function _loadXhr() { + // if unset, determine the value + if (typeof this.xhrType !== 'string') { + this.xhrType = this._determineXhrType(); + } + + var xhr = this.xhr = new XMLHttpRequest(); + + // set the request type and url + xhr.open('GET', this.url, true); + + xhr.timeout = this.timeout; + + // load json as text and parse it ourselves. We do this because some browsers + // *cough* safari *cough* can't deal with it. + if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON || this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) { + xhr.responseType = Resource.XHR_RESPONSE_TYPE.TEXT; + } else { + xhr.responseType = this.xhrType; + } + + xhr.addEventListener('error', this._boundXhrOnError, false); + xhr.addEventListener('timeout', this._boundXhrOnTimeout, false); + xhr.addEventListener('abort', this._boundXhrOnAbort, false); + xhr.addEventListener('progress', this._boundOnProgress, false); + xhr.addEventListener('load', this._boundXhrOnLoad, false); + + xhr.send(); + }; + + /** + * Loads this resources using an XDomainRequest. This is here because we need to support IE9 (gross). + * + * @private + */ + + + Resource.prototype._loadXdr = function _loadXdr() { + // if unset, determine the value + if (typeof this.xhrType !== 'string') { + this.xhrType = this._determineXhrType(); + } + + var xdr = this.xhr = new XDomainRequest(); // eslint-disable-line no-undef + + // XDomainRequest has a few quirks. Occasionally it will abort requests + // A way to avoid this is to make sure ALL callbacks are set even if not used + // More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9 + xdr.timeout = this.timeout || 5000; // XDR needs a timeout value or it breaks in IE9 + + xdr.onerror = this._boundXhrOnError; + xdr.ontimeout = this._boundXhrOnTimeout; + xdr.onprogress = this._boundOnProgress; + xdr.onload = this._boundXhrOnLoad; + + xdr.open('GET', this.url, true); + + // Note: The xdr.send() call is wrapped in a timeout to prevent an + // issue with the interface where some requests are lost if multiple + // XDomainRequests are being sent at the same time. + // Some info here: https://github.com/photonstorm/phaser/issues/1248 + setTimeout(function () { + return xdr.send(); + }, 1); + }; - var currentIndex = this.getChildIndex(child); + /** + * Creates a source used in loading via an element. + * + * @private + * @param {string} type - The element type (video or audio). + * @param {string} url - The source URL to load from. + * @param {string} [mime] - The mime type of the video + * @return {HTMLSourceElement} The source element. + */ - (0, _utils.removeItems)(this.children, currentIndex, 1); // remove from old position - this.children.splice(index, 0, child); // add at new position - this.onChildrenChange(index); - }; + Resource.prototype._createSource = function _createSource(type, url, mime) { + if (!mime) { + mime = type + '/' + this._getExtension(url); + } - /** - * Returns the child at the specified index - * - * @param {number} index - The index to get the child at - * @return {PIXI.DisplayObject} The child at the given index, if any. - */ + var source = document.createElement('source'); + source.src = url; + source.type = mime; - Container.prototype.getChildAt = function getChildAt(index) { - if (index < 0 || index >= this.children.length) { - throw new Error('getChildAt: Index (' + index + ') does not exist.'); - } + return source; + }; + + /** + * Called if a load errors out. + * + * @param {Event} event - The error event from the element that emits it. + * @private + */ - return this.children[index]; - }; - /** - * Removes one or more children from the container. - * - * @param {...PIXI.DisplayObject} child - The DisplayObject(s) to remove - * @return {PIXI.DisplayObject} The first child that was removed. - */ - - - Container.prototype.removeChild = function removeChild(child) { - var argumentsLength = arguments.length; - - // if there is only one argument we can bypass looping through the them - if (argumentsLength > 1) { - // loop through the arguments property and add all children - // use it the right way (.length and [i]) so that this function can still be optimised by JS runtimes - for (var i = 0; i < argumentsLength; i++) { - this.removeChild(arguments[i]); - } - } else { - var index = this.children.indexOf(child); - - if (index === -1) return null; - - child.parent = null; - // ensure child transform will be recalculated - child.transform._parentID = -1; - (0, _utils.removeItems)(this.children, index, 1); - - // ensure bounds will be recalculated - this._boundsID++; - - // TODO - lets either do all callbacks or all events.. not both! - this.onChildrenChange(index); - child.emit('removed', this); - } - - return child; - }; - - /** - * Removes a child from the specified index position. - * - * @param {number} index - The index to get the child from - * @return {PIXI.DisplayObject} The child that was removed. - */ - - - Container.prototype.removeChildAt = function removeChildAt(index) { - var child = this.getChildAt(index); - - // ensure child transform will be recalculated.. - child.parent = null; - child.transform._parentID = -1; - (0, _utils.removeItems)(this.children, index, 1); - - // ensure bounds will be recalculated - this._boundsID++; - - // TODO - lets either do all callbacks or all events.. not both! - this.onChildrenChange(index); - child.emit('removed', this); - - return child; - }; - - /** - * Removes all children from this container that are within the begin and end indexes. - * - * @param {number} [beginIndex=0] - The beginning position. - * @param {number} [endIndex=this.children.length] - The ending position. Default value is size of the container. - * @returns {DisplayObject[]} List of removed children - */ - - - Container.prototype.removeChildren = function removeChildren() { - var beginIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var endIndex = arguments[1]; - - var begin = beginIndex; - var end = typeof endIndex === 'number' ? endIndex : this.children.length; - var range = end - begin; - var removed = void 0; - - if (range > 0 && range <= end) { - removed = this.children.splice(begin, range); - - for (var i = 0; i < removed.length; ++i) { - removed[i].parent = null; - if (removed[i].transform) { - removed[i].transform._parentID = -1; - } - } - - this._boundsID++; - - this.onChildrenChange(beginIndex); - - for (var _i = 0; _i < removed.length; ++_i) { - removed[_i].emit('removed', this); - } - - return removed; - } else if (range === 0 && this.children.length === 0) { - return []; - } - - throw new RangeError('removeChildren: numeric values are outside the acceptable range.'); - }; - - /** - * Updates the transform on all children of this container for rendering - */ - - - Container.prototype.updateTransform = function updateTransform() { - this._boundsID++; - - this.transform.updateTransform(this.parent.transform); - - // TODO: check render flags, how to process stuff here - this.worldAlpha = this.alpha * this.parent.worldAlpha; - - for (var i = 0, j = this.children.length; i < j; ++i) { - var child = this.children[i]; - - if (child.visible) { - child.updateTransform(); - } - } - }; - - /** - * Recalculates the bounds of the container. - * - */ - - - Container.prototype.calculateBounds = function calculateBounds() { - this._bounds.clear(); - - this._calculateBounds(); - - for (var i = 0; i < this.children.length; i++) { - var child = this.children[i]; - - if (!child.visible || !child.renderable) { - continue; - } - - child.calculateBounds(); - - // TODO: filter+mask, need to mask both somehow - if (child._mask) { - child._mask.calculateBounds(); - this._bounds.addBoundsMask(child._bounds, child._mask._bounds); - } else if (child.filterArea) { - this._bounds.addBoundsArea(child._bounds, child.filterArea); - } else { - this._bounds.addBounds(child._bounds); - } - } - - this._lastBoundsID = this._boundsID; - }; - - /** - * Recalculates the bounds of the object. Override this to - * calculate the bounds of the specific object (not including children). - * - */ - - - Container.prototype._calculateBounds = function _calculateBounds() {} - // FILL IN// - - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.WebGLRenderer} renderer - The renderer - */ - ; - - Container.prototype.renderWebGL = function renderWebGL(renderer) { - // if the object is not visible or the alpha is 0 then no need to render this element - if (!this.visible || this.worldAlpha <= 0 || !this.renderable) { - return; - } - - // do a quick check to see if this element has a mask or a filter. - if (this._mask || this._filters) { - this.renderAdvancedWebGL(renderer); - } else { - this._renderWebGL(renderer); - - // simple render children! - for (var i = 0, j = this.children.length; i < j; ++i) { - this.children[i].renderWebGL(renderer); - } - } - }; - - /** - * Render the object using the WebGL renderer and advanced features. - * - * @private - * @param {PIXI.WebGLRenderer} renderer - The renderer - */ - - - Container.prototype.renderAdvancedWebGL = function renderAdvancedWebGL(renderer) { - renderer.flush(); - - var filters = this._filters; - var mask = this._mask; - - // push filter first as we need to ensure the stencil buffer is correct for any masking - if (filters) { - if (!this._enabledFilters) { - this._enabledFilters = []; - } - - this._enabledFilters.length = 0; - - for (var i = 0; i < filters.length; i++) { - if (filters[i].enabled) { - this._enabledFilters.push(filters[i]); - } - } - - if (this._enabledFilters.length) { - renderer.filterManager.pushFilter(this, this._enabledFilters); - } - } - - if (mask) { - renderer.maskManager.pushMask(this, this._mask); - } - - // add this object to the batch, only rendered if it has a texture. - this._renderWebGL(renderer); - - // now loop through the children and make sure they get rendered - for (var _i2 = 0, j = this.children.length; _i2 < j; _i2++) { - this.children[_i2].renderWebGL(renderer); - } - - renderer.flush(); - - if (mask) { - renderer.maskManager.popMask(this, this._mask); - } - - if (filters && this._enabledFilters && this._enabledFilters.length) { - renderer.filterManager.popFilter(); - } - }; - - /** - * To be overridden by the subclasses. - * - * @private - * @param {PIXI.WebGLRenderer} renderer - The renderer - */ - - - Container.prototype._renderWebGL = function _renderWebGL(renderer) // eslint-disable-line no-unused-vars - {} - // this is where content itself gets rendered... - - - /** - * To be overridden by the subclass - * - * @private - * @param {PIXI.CanvasRenderer} renderer - The renderer - */ - ; - - Container.prototype._renderCanvas = function _renderCanvas(renderer) // eslint-disable-line no-unused-vars - {} - // this is where content itself gets rendered... - - - /** - * Renders the object using the Canvas renderer - * - * @param {PIXI.CanvasRenderer} renderer - The renderer - */ - ; - - Container.prototype.renderCanvas = function renderCanvas(renderer) { - // if not visible or the alpha is 0 then no need to render this - if (!this.visible || this.worldAlpha <= 0 || !this.renderable) { - return; - } - - if (this._mask) { - renderer.maskManager.pushMask(this._mask); - } - - this._renderCanvas(renderer); - for (var i = 0, j = this.children.length; i < j; ++i) { - this.children[i].renderCanvas(renderer); - } - - if (this._mask) { - renderer.maskManager.popMask(renderer); - } - }; - - /** - * Removes all internal references and listeners as well as removes children from the display list. - * Do not use a Container after calling `destroy`. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options - * have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy - * method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - - - Container.prototype.destroy = function destroy(options) { - _DisplayObject.prototype.destroy.call(this); - - var destroyChildren = typeof options === 'boolean' ? options : options && options.children; - - var oldChildren = this.removeChildren(0, this.children.length); - - if (destroyChildren) { - for (var i = 0; i < oldChildren.length; ++i) { - oldChildren[i].destroy(options); - } - } - }; - - /** - * The width of the Container, setting this will actually modify the scale to achieve the value set - * - * @member {number} - */ - - - _createClass(Container, [{ - key: 'width', - get: function get() { - return this.scale.x * this.getLocalBounds().width; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - var width = this.getLocalBounds().width; - - if (width !== 0) { - this.scale.x = value / width; - } else { - this.scale.x = 1; - } - - this._width = value; - } - - /** - * The height of the Container, setting this will actually modify the scale to achieve the value set - * - * @member {number} - */ - - }, { - key: 'height', - get: function get() { - return this.scale.y * this.getLocalBounds().height; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - var height = this.getLocalBounds().height; - - if (height !== 0) { - this.scale.y = value / height; - } else { - this.scale.y = 1; - } - - this._height = value; - } - }]); - - return Container; -}(_DisplayObject3.default); - -// performance increase to avoid using call.. (10x faster) - - -exports.default = Container; -Container.prototype.containerUpdateTransform = Container.prototype.updateTransform; - -},{"../utils":125,"./DisplayObject":49}],49:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -var _const = require('../const'); - -var _settings = require('../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _TransformStatic = require('./TransformStatic'); - -var _TransformStatic2 = _interopRequireDefault(_TransformStatic); - -var _Transform = require('./Transform'); - -var _Transform2 = _interopRequireDefault(_Transform); - -var _Bounds = require('./Bounds'); - -var _Bounds2 = _interopRequireDefault(_Bounds); - -var _math = require('../math'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -// _tempDisplayObjectParent = new DisplayObject(); - -/** - * The base class for all objects that are rendered on the screen. - * This is an abstract class and should not be used on its own rather it should be extended. - * - * @class - * @extends EventEmitter - * @memberof PIXI - */ -var DisplayObject = function (_EventEmitter) { - _inherits(DisplayObject, _EventEmitter); - - /** - * - */ - function DisplayObject() { - _classCallCheck(this, DisplayObject); - - var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - - var TransformClass = _settings2.default.TRANSFORM_MODE === _const.TRANSFORM_MODE.STATIC ? _TransformStatic2.default : _Transform2.default; - - _this.tempDisplayObjectParent = null; - - // TODO: need to create Transform from factory - /** - * World transform and local transform of this object. - * This will become read-only later, please do not assign anything there unless you know what are you doing - * - * @member {PIXI.TransformBase} - */ - _this.transform = new TransformClass(); - - /** - * The opacity of the object. - * - * @member {number} - */ - _this.alpha = 1; - - /** - * The visibility of the object. If false the object will not be drawn, and - * the updateTransform function will not be called. - * - * Only affects recursive calls from parent. You can ask for bounds or call updateTransform manually - * - * @member {boolean} - */ - _this.visible = true; - - /** - * Can this object be rendered, if false the object will not be drawn but the updateTransform - * methods will still be called. - * - * Only affects recursive calls from parent. You can ask for bounds manually - * - * @member {boolean} - */ - _this.renderable = true; - - /** - * The display object container that contains this display object. - * - * @member {PIXI.Container} - * @readonly - */ - _this.parent = null; - - /** - * The multiplied alpha of the displayObject - * - * @member {number} - * @readonly - */ - _this.worldAlpha = 1; - - /** - * The area the filter is applied to. This is used as more of an optimisation - * rather than figuring out the dimensions of the displayObject each frame you can set this rectangle - * - * Also works as an interaction mask - * - * @member {PIXI.Rectangle} - */ - _this.filterArea = null; - - _this._filters = null; - _this._enabledFilters = null; - - /** - * The bounds object, this is used to calculate and store the bounds of the displayObject - * - * @member {PIXI.Rectangle} - * @private - */ - _this._bounds = new _Bounds2.default(); - _this._boundsID = 0; - _this._lastBoundsID = -1; - _this._boundsRect = null; - _this._localBoundsRect = null; - - /** - * The original, cached mask of the object - * - * @member {PIXI.Graphics|PIXI.Sprite} - * @private - */ - _this._mask = null; - - /** - * If the object has been destroyed via destroy(). If true, it should not be used. - * - * @member {boolean} - * @private - * @readonly - */ - _this._destroyed = false; - - /** - * Fired when this DisplayObject is added to a Container. - * - * @event PIXI.DisplayObject#added - * @param {PIXI.Container} container - The container added to. - */ - - /** - * Fired when this DisplayObject is removed from a Container. - * - * @event PIXI.DisplayObject#removed - * @param {PIXI.Container} container - The container removed from. - */ - return _this; - } - - /** - * @private - * @member {PIXI.DisplayObject} - */ - - - /** - * Updates the object transform for rendering - * - * TODO - Optimization pass! - */ - DisplayObject.prototype.updateTransform = function updateTransform() { - this.transform.updateTransform(this.parent.transform); - // multiply the alphas.. - this.worldAlpha = this.alpha * this.parent.worldAlpha; - - this._bounds.updateID++; - }; - - /** - * recursively updates transform of all objects from the root to this one - * internal function for toLocal() - */ - - - DisplayObject.prototype._recursivePostUpdateTransform = function _recursivePostUpdateTransform() { - if (this.parent) { - this.parent._recursivePostUpdateTransform(); - this.transform.updateTransform(this.parent.transform); - } else { - this.transform.updateTransform(this._tempDisplayObjectParent.transform); - } - }; - - /** - * Retrieves the bounds of the displayObject as a rectangle object. - * - * @param {boolean} skipUpdate - setting to true will stop the transforms of the scene graph from - * being updated. This means the calculation returned MAY be out of date BUT will give you a - * nice performance boost - * @param {PIXI.Rectangle} rect - Optional rectangle to store the result of the bounds calculation - * @return {PIXI.Rectangle} the rectangular bounding area - */ - - - DisplayObject.prototype.getBounds = function getBounds(skipUpdate, rect) { - if (!skipUpdate) { - if (!this.parent) { - this.parent = this._tempDisplayObjectParent; - this.updateTransform(); - this.parent = null; - } else { - this._recursivePostUpdateTransform(); - this.updateTransform(); - } - } - - if (this._boundsID !== this._lastBoundsID) { - this.calculateBounds(); - } - - if (!rect) { - if (!this._boundsRect) { - this._boundsRect = new _math.Rectangle(); - } - - rect = this._boundsRect; - } - - return this._bounds.getRectangle(rect); - }; - - /** - * Retrieves the local bounds of the displayObject as a rectangle object - * - * @param {PIXI.Rectangle} [rect] - Optional rectangle to store the result of the bounds calculation - * @return {PIXI.Rectangle} the rectangular bounding area - */ - - - DisplayObject.prototype.getLocalBounds = function getLocalBounds(rect) { - var transformRef = this.transform; - var parentRef = this.parent; - - this.parent = null; - this.transform = this._tempDisplayObjectParent.transform; - - if (!rect) { - if (!this._localBoundsRect) { - this._localBoundsRect = new _math.Rectangle(); - } - - rect = this._localBoundsRect; - } - - var bounds = this.getBounds(false, rect); - - this.parent = parentRef; - this.transform = transformRef; - - return bounds; - }; - - /** - * Calculates the global position of the display object - * - * @param {PIXI.Point} position - The world origin to calculate from - * @param {PIXI.Point} [point] - A Point object in which to store the value, optional - * (otherwise will create a new Point) - * @param {boolean} [skipUpdate=false] - Should we skip the update transform. - * @return {PIXI.Point} A point object representing the position of this object - */ - - - DisplayObject.prototype.toGlobal = function toGlobal(position, point) { - var skipUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - - if (!skipUpdate) { - this._recursivePostUpdateTransform(); - - // this parent check is for just in case the item is a root object. - // If it is we need to give it a temporary parent so that displayObjectUpdateTransform works correctly - // this is mainly to avoid a parent check in the main loop. Every little helps for performance :) - if (!this.parent) { - this.parent = this._tempDisplayObjectParent; - this.displayObjectUpdateTransform(); - this.parent = null; - } else { - this.displayObjectUpdateTransform(); - } - } - - // don't need to update the lot - return this.worldTransform.apply(position, point); - }; - - /** - * Calculates the local position of the display object relative to another point - * - * @param {PIXI.Point} position - The world origin to calculate from - * @param {PIXI.DisplayObject} [from] - The DisplayObject to calculate the global position from - * @param {PIXI.Point} [point] - A Point object in which to store the value, optional - * (otherwise will create a new Point) - * @param {boolean} [skipUpdate=false] - Should we skip the update transform - * @return {PIXI.Point} A point object representing the position of this object - */ - - - DisplayObject.prototype.toLocal = function toLocal(position, from, point, skipUpdate) { - if (from) { - position = from.toGlobal(position, point, skipUpdate); - } - - if (!skipUpdate) { - this._recursivePostUpdateTransform(); - - // this parent check is for just in case the item is a root object. - // If it is we need to give it a temporary parent so that displayObjectUpdateTransform works correctly - // this is mainly to avoid a parent check in the main loop. Every little helps for performance :) - if (!this.parent) { - this.parent = this._tempDisplayObjectParent; - this.displayObjectUpdateTransform(); - this.parent = null; - } else { - this.displayObjectUpdateTransform(); - } - } - - // simply apply the matrix.. - return this.worldTransform.applyInverse(position, point); - }; - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.WebGLRenderer} renderer - The renderer - */ - - - DisplayObject.prototype.renderWebGL = function renderWebGL(renderer) // eslint-disable-line no-unused-vars - {} - // OVERWRITE; - - - /** - * Renders the object using the Canvas renderer - * - * @param {PIXI.CanvasRenderer} renderer - The renderer - */ - ; - - DisplayObject.prototype.renderCanvas = function renderCanvas(renderer) // eslint-disable-line no-unused-vars - {} - // OVERWRITE; - - - /** - * Set the parent Container of this DisplayObject - * - * @param {PIXI.Container} container - The Container to add this DisplayObject to - * @return {PIXI.Container} The Container that this DisplayObject was added to - */ - ; - - DisplayObject.prototype.setParent = function setParent(container) { - if (!container || !container.addChild) { - throw new Error('setParent: Argument must be a Container'); - } - - container.addChild(this); - - return container; - }; - - /** - * Convenience function to set the position, scale, skew and pivot at once. - * - * @param {number} [x=0] - The X position - * @param {number} [y=0] - The Y position - * @param {number} [scaleX=1] - The X scale value - * @param {number} [scaleY=1] - The Y scale value - * @param {number} [rotation=0] - The rotation - * @param {number} [skewX=0] - The X skew value - * @param {number} [skewY=0] - The Y skew value - * @param {number} [pivotX=0] - The X pivot value - * @param {number} [pivotY=0] - The Y pivot value - * @return {PIXI.DisplayObject} The DisplayObject instance - */ - - - DisplayObject.prototype.setTransform = function setTransform() { - var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var scaleX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; - var scaleY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; - var rotation = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; - var skewX = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; - var skewY = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0; - var pivotX = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0; - var pivotY = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 0; - - this.position.x = x; - this.position.y = y; - this.scale.x = !scaleX ? 1 : scaleX; - this.scale.y = !scaleY ? 1 : scaleY; - this.rotation = rotation; - this.skew.x = skewX; - this.skew.y = skewY; - this.pivot.x = pivotX; - this.pivot.y = pivotY; - - return this; - }; - - /** - * Base destroy method for generic display objects. This will automatically - * remove the display object from its parent Container as well as remove - * all current event listeners and internal references. Do not use a DisplayObject - * after calling `destroy`. - * - */ - - - DisplayObject.prototype.destroy = function destroy() { - this.removeAllListeners(); - if (this.parent) { - this.parent.removeChild(this); - } - this.transform = null; - - this.parent = null; - - this._bounds = null; - this._currentBounds = null; - this._mask = null; - - this.filterArea = null; - - this.interactive = false; - this.interactiveChildren = false; - - this._destroyed = true; - }; - - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * An alias to position.x - * - * @member {number} - */ - - - _createClass(DisplayObject, [{ - key: '_tempDisplayObjectParent', - get: function get() { - if (this.tempDisplayObjectParent === null) { - this.tempDisplayObjectParent = new DisplayObject(); - } - - return this.tempDisplayObjectParent; - } - }, { - key: 'x', - get: function get() { - return this.position.x; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.transform.position.x = value; - } - - /** - * The position of the displayObject on the y axis relative to the local coordinates of the parent. - * An alias to position.y - * - * @member {number} - */ - - }, { - key: 'y', - get: function get() { - return this.position.y; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.transform.position.y = value; - } - - /** - * Current transform of the object based on world (parent) factors - * - * @member {PIXI.Matrix} - * @readonly - */ - - }, { - key: 'worldTransform', - get: function get() { - return this.transform.worldTransform; - } - - /** - * Current transform of the object based on local factors: position, scale, other stuff - * - * @member {PIXI.Matrix} - * @readonly - */ - - }, { - key: 'localTransform', - get: function get() { - return this.transform.localTransform; - } - - /** - * The coordinate of the object relative to the local coordinates of the parent. - * Assignment by value since pixi-v4. - * - * @member {PIXI.Point|PIXI.ObservablePoint} - */ - - }, { - key: 'position', - get: function get() { - return this.transform.position; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.transform.position.copy(value); - } - - /** - * The scale factor of the object. - * Assignment by value since pixi-v4. - * - * @member {PIXI.Point|PIXI.ObservablePoint} - */ - - }, { - key: 'scale', - get: function get() { - return this.transform.scale; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.transform.scale.copy(value); - } - - /** - * The pivot point of the displayObject that it rotates around. - * Assignment by value since pixi-v4. - * - * @member {PIXI.Point|PIXI.ObservablePoint} - */ - - }, { - key: 'pivot', - get: function get() { - return this.transform.pivot; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.transform.pivot.copy(value); - } - - /** - * The skew factor for the object in radians. - * Assignment by value since pixi-v4. - * - * @member {PIXI.ObservablePoint} - */ - - }, { - key: 'skew', - get: function get() { - return this.transform.skew; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.transform.skew.copy(value); - } - - /** - * The rotation of the object in radians. - * - * @member {number} - */ - - }, { - key: 'rotation', - get: function get() { - return this.transform.rotation; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.transform.rotation = value; - } - - /** - * Indicates if the object is globally visible. - * - * @member {boolean} - * @readonly - */ - - }, { - key: 'worldVisible', - get: function get() { - var item = this; - - do { - if (!item.visible) { - return false; - } - - item = item.parent; - } while (item); - - return true; - } - - /** - * Sets a mask for the displayObject. A mask is an object that limits the visibility of an - * object to the shape of the mask applied to it. In PIXI a regular mask must be a - * PIXI.Graphics or a PIXI.Sprite object. This allows for much faster masking in canvas as it - * utilises shape clipping. To remove a mask, set this property to null. - * - * @todo For the moment, PIXI.CanvasRenderer doesn't support PIXI.Sprite as mask. - * - * @member {PIXI.Graphics|PIXI.Sprite} - */ - - }, { - key: 'mask', - get: function get() { - return this._mask; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (this._mask) { - this._mask.renderable = true; - this._mask.isMask = false; - } - - this._mask = value; - - if (this._mask) { - this._mask.renderable = false; - this._mask.isMask = true; - } - } - - /** - * Sets the filters for the displayObject. - * * IMPORTANT: This is a webGL only feature and will be ignored by the canvas renderer. - * To remove filters simply set this property to 'null' - * - * @member {PIXI.Filter[]} - */ - - }, { - key: 'filters', - get: function get() { - return this._filters && this._filters.slice(); - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._filters = value && value.slice(); - } - }]); - - return DisplayObject; -}(_eventemitter2.default); - -// performance increase to avoid using call.. (10x faster) - - -exports.default = DisplayObject; -DisplayObject.prototype.displayObjectUpdateTransform = DisplayObject.prototype.updateTransform; - -},{"../const":46,"../math":70,"../settings":101,"./Bounds":47,"./Transform":50,"./TransformStatic":52,"eventemitter3":3}],50:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = require('../math'); - -var _TransformBase2 = require('./TransformBase'); - -var _TransformBase3 = _interopRequireDefault(_TransformBase2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Generic class to deal with traditional 2D matrix transforms - * local transformation is calculated from position,scale,skew and rotation - * - * @class - * @extends PIXI.TransformBase - * @memberof PIXI - */ -var Transform = function (_TransformBase) { - _inherits(Transform, _TransformBase); - - /** - * - */ - function Transform() { - _classCallCheck(this, Transform); - - /** - * The coordinate of the object relative to the local coordinates of the parent. - * - * @member {PIXI.Point} - */ - var _this = _possibleConstructorReturn(this, _TransformBase.call(this)); - - _this.position = new _math.Point(0, 0); - - /** - * The scale factor of the object. - * - * @member {PIXI.Point} - */ - _this.scale = new _math.Point(1, 1); - - /** - * The skew amount, on the x and y axis. - * - * @member {PIXI.ObservablePoint} - */ - _this.skew = new _math.ObservablePoint(_this.updateSkew, _this, 0, 0); - - /** - * The pivot point of the displayObject that it rotates around. - * - * @member {PIXI.Point} - */ - _this.pivot = new _math.Point(0, 0); - - /** - * The rotation value of the object, in radians - * - * @member {Number} - * @private - */ - _this._rotation = 0; - - _this._cx = 1; // cos rotation + skewY; - _this._sx = 0; // sin rotation + skewY; - _this._cy = 0; // cos rotation + Math.PI/2 - skewX; - _this._sy = 1; // sin rotation + Math.PI/2 - skewX; - return _this; - } - - /** - * Updates the skew values when the skew or rotation changes. - * - * @private - */ - - - Transform.prototype.updateSkew = function updateSkew() { - this._cx = Math.cos(this._rotation + this.skew._y); - this._sx = Math.sin(this._rotation + this.skew._y); - this._cy = -Math.sin(this._rotation - this.skew._x); // cos, added PI/2 - this._sy = Math.cos(this._rotation - this.skew._x); // sin, added PI/2 - }; - - /** - * Updates only local matrix - */ - - - Transform.prototype.updateLocalTransform = function updateLocalTransform() { - var lt = this.localTransform; - - lt.a = this._cx * this.scale.x; - lt.b = this._sx * this.scale.x; - lt.c = this._cy * this.scale.y; - lt.d = this._sy * this.scale.y; - - lt.tx = this.position.x - (this.pivot.x * lt.a + this.pivot.y * lt.c); - lt.ty = this.position.y - (this.pivot.x * lt.b + this.pivot.y * lt.d); - }; - - /** - * Updates the values of the object and applies the parent's transform. - * - * @param {PIXI.Transform} parentTransform - The transform of the parent of this object - */ - - - Transform.prototype.updateTransform = function updateTransform(parentTransform) { - var lt = this.localTransform; - - lt.a = this._cx * this.scale.x; - lt.b = this._sx * this.scale.x; - lt.c = this._cy * this.scale.y; - lt.d = this._sy * this.scale.y; - - lt.tx = this.position.x - (this.pivot.x * lt.a + this.pivot.y * lt.c); - lt.ty = this.position.y - (this.pivot.x * lt.b + this.pivot.y * lt.d); - - // concat the parent matrix with the objects transform. - var pt = parentTransform.worldTransform; - var wt = this.worldTransform; - - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - - this._worldID++; - }; - - /** - * Decomposes a matrix and sets the transforms properties based on it. - * - * @param {PIXI.Matrix} matrix - The matrix to decompose - */ - - - Transform.prototype.setFromMatrix = function setFromMatrix(matrix) { - matrix.decompose(this); - }; - - /** - * The rotation of the object in radians. - * - * @member {number} - */ - - - _createClass(Transform, [{ - key: 'rotation', - get: function get() { - return this._rotation; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._rotation = value; - this.updateSkew(); - } - }]); - - return Transform; -}(_TransformBase3.default); - -exports.default = Transform; - -},{"../math":70,"./TransformBase":51}],51:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _math = require('../math'); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Generic class to deal with traditional 2D matrix transforms - * - * @class - * @memberof PIXI - */ -var TransformBase = function () { - /** - * - */ - function TransformBase() { - _classCallCheck(this, TransformBase); - - /** - * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds() - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new _math.Matrix(); - - /** - * The local matrix transform - * - * @member {PIXI.Matrix} - */ - this.localTransform = new _math.Matrix(); - - this._worldID = 0; - this._parentID = 0; - } - - /** - * TransformBase does not have decomposition, so this function wont do anything - */ - - - TransformBase.prototype.updateLocalTransform = function updateLocalTransform() {} - // empty - - - /** - * Updates the values of the object and applies the parent's transform. - * - * @param {PIXI.TransformBase} parentTransform - The transform of the parent of this object - */ - ; - - TransformBase.prototype.updateTransform = function updateTransform(parentTransform) { - var pt = parentTransform.worldTransform; - var wt = this.worldTransform; - var lt = this.localTransform; - - // concat the parent matrix with the objects transform. - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - - this._worldID++; - }; - - return TransformBase; -}(); - -/** - * Updates the values of the object and applies the parent's transform. - * @param parentTransform {PIXI.Transform} The transform of the parent of this object - * - */ - - -exports.default = TransformBase; -TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform; - -TransformBase.IDENTITY = new TransformBase(); - -},{"../math":70}],52:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = require('../math'); - -var _TransformBase2 = require('./TransformBase'); - -var _TransformBase3 = _interopRequireDefault(_TransformBase2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Transform that takes care about its versions - * - * @class - * @extends PIXI.TransformBase - * @memberof PIXI - */ -var TransformStatic = function (_TransformBase) { - _inherits(TransformStatic, _TransformBase); - - /** - * - */ - function TransformStatic() { - _classCallCheck(this, TransformStatic); - - /** - * The coordinate of the object relative to the local coordinates of the parent. - * - * @member {PIXI.ObservablePoint} - */ - var _this = _possibleConstructorReturn(this, _TransformBase.call(this)); - - _this.position = new _math.ObservablePoint(_this.onChange, _this, 0, 0); - - /** - * The scale factor of the object. - * - * @member {PIXI.ObservablePoint} - */ - _this.scale = new _math.ObservablePoint(_this.onChange, _this, 1, 1); - - /** - * The pivot point of the displayObject that it rotates around. - * - * @member {PIXI.ObservablePoint} - */ - _this.pivot = new _math.ObservablePoint(_this.onChange, _this, 0, 0); - - /** - * The skew amount, on the x and y axis. - * - * @member {PIXI.ObservablePoint} - */ - _this.skew = new _math.ObservablePoint(_this.updateSkew, _this, 0, 0); - - _this._rotation = 0; - - _this._cx = 1; // cos rotation + skewY; - _this._sx = 0; // sin rotation + skewY; - _this._cy = 0; // cos rotation + Math.PI/2 - skewX; - _this._sy = 1; // sin rotation + Math.PI/2 - skewX; - - _this._localID = 0; - _this._currentLocalID = 0; - return _this; - } - - /** - * Called when a value changes. - * - * @private - */ - - - TransformStatic.prototype.onChange = function onChange() { - this._localID++; - }; - - /** - * Called when skew or rotation changes - * - * @private - */ - - - TransformStatic.prototype.updateSkew = function updateSkew() { - this._cx = Math.cos(this._rotation + this.skew._y); - this._sx = Math.sin(this._rotation + this.skew._y); - this._cy = -Math.sin(this._rotation - this.skew._x); // cos, added PI/2 - this._sy = Math.cos(this._rotation - this.skew._x); // sin, added PI/2 - - this._localID++; - }; - - /** - * Updates only local matrix - */ - - - TransformStatic.prototype.updateLocalTransform = function updateLocalTransform() { - var lt = this.localTransform; - - if (this._localID !== this._currentLocalID) { - // get the matrix values of the displayobject based on its transform properties.. - lt.a = this._cx * this.scale._x; - lt.b = this._sx * this.scale._x; - lt.c = this._cy * this.scale._y; - lt.d = this._sy * this.scale._y; - - lt.tx = this.position._x - (this.pivot._x * lt.a + this.pivot._y * lt.c); - lt.ty = this.position._y - (this.pivot._x * lt.b + this.pivot._y * lt.d); - this._currentLocalID = this._localID; - - // force an update.. - this._parentID = -1; - } - }; - - /** - * Updates the values of the object and applies the parent's transform. - * - * @param {PIXI.Transform} parentTransform - The transform of the parent of this object - */ - - - TransformStatic.prototype.updateTransform = function updateTransform(parentTransform) { - var lt = this.localTransform; - - if (this._localID !== this._currentLocalID) { - // get the matrix values of the displayobject based on its transform properties.. - lt.a = this._cx * this.scale._x; - lt.b = this._sx * this.scale._x; - lt.c = this._cy * this.scale._y; - lt.d = this._sy * this.scale._y; - - lt.tx = this.position._x - (this.pivot._x * lt.a + this.pivot._y * lt.c); - lt.ty = this.position._y - (this.pivot._x * lt.b + this.pivot._y * lt.d); - this._currentLocalID = this._localID; - - // force an update.. - this._parentID = -1; - } - - if (this._parentID !== parentTransform._worldID) { - // concat the parent matrix with the objects transform. - var pt = parentTransform.worldTransform; - var wt = this.worldTransform; - - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - - this._parentID = parentTransform._worldID; - - // update the id of the transform.. - this._worldID++; - } - }; - - /** - * Decomposes a matrix and sets the transforms properties based on it. - * - * @param {PIXI.Matrix} matrix - The matrix to decompose - */ - - - TransformStatic.prototype.setFromMatrix = function setFromMatrix(matrix) { - matrix.decompose(this); - this._localID++; - }; - - /** - * The rotation of the object in radians. - * - * @member {number} - */ - - - _createClass(TransformStatic, [{ - key: 'rotation', - get: function get() { - return this._rotation; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (this._rotation !== value) { - this._rotation = value; - this.updateSkew(); - } - } - }]); - - return TransformStatic; -}(_TransformBase3.default); - -exports.default = TransformStatic; - -},{"../math":70,"./TransformBase":51}],53:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Container2 = require('../display/Container'); - -var _Container3 = _interopRequireDefault(_Container2); - -var _RenderTexture = require('../textures/RenderTexture'); - -var _RenderTexture2 = _interopRequireDefault(_RenderTexture); - -var _Texture = require('../textures/Texture'); - -var _Texture2 = _interopRequireDefault(_Texture); - -var _GraphicsData = require('./GraphicsData'); - -var _GraphicsData2 = _interopRequireDefault(_GraphicsData); - -var _Sprite = require('../sprites/Sprite'); - -var _Sprite2 = _interopRequireDefault(_Sprite); - -var _math = require('../math'); - -var _utils = require('../utils'); - -var _const = require('../const'); - -var _Bounds = require('../display/Bounds'); - -var _Bounds2 = _interopRequireDefault(_Bounds); - -var _bezierCurveTo2 = require('./utils/bezierCurveTo'); - -var _bezierCurveTo3 = _interopRequireDefault(_bezierCurveTo2); - -var _CanvasRenderer = require('../renderers/canvas/CanvasRenderer'); - -var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var canvasRenderer = void 0; -var tempMatrix = new _math.Matrix(); -var tempPoint = new _math.Point(); -var tempColor1 = new Float32Array(4); -var tempColor2 = new Float32Array(4); - -/** - * The Graphics class contains methods used to draw primitive shapes such as lines, circles and - * rectangles to the display, and to color and fill them. - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ - -var Graphics = function (_Container) { - _inherits(Graphics, _Container); - - /** - * - * @param {boolean} [nativeLines=false] - If true the lines will be draw using LINES instead of TRIANGLE_STRIP - */ - function Graphics() { - var nativeLines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - - _classCallCheck(this, Graphics); - - /** - * The alpha value used when filling the Graphics object. - * - * @member {number} - * @default 1 - */ - var _this = _possibleConstructorReturn(this, _Container.call(this)); - - _this.fillAlpha = 1; - - /** - * The width (thickness) of any lines drawn. - * - * @member {number} - * @default 0 - */ - _this.lineWidth = 0; - - /** - * If true the lines will be draw using LINES instead of TRIANGLE_STRIP - * - * @member {boolean} - */ - _this.nativeLines = nativeLines; - - /** - * The color of any lines drawn. - * - * @member {string} - * @default 0 - */ - _this.lineColor = 0; - - /** - * The alignment of any lines drawn (0.5 = middle, 1 = outter, 0 = inner). - * - * @member {number} - * @default 0.5 - */ - _this.lineAlignment = 0.5; - - /** - * Graphics data - * - * @member {PIXI.GraphicsData[]} - * @private - */ - _this.graphicsData = []; - - /** - * The tint applied to the graphic shape. This is a hex value. Apply a value of 0xFFFFFF to - * reset the tint. - * - * @member {number} - * @default 0xFFFFFF - */ - _this.tint = 0xFFFFFF; - - /** - * The previous tint applied to the graphic shape. Used to compare to the current tint and - * check if theres change. - * - * @member {number} - * @private - * @default 0xFFFFFF - */ - _this._prevTint = 0xFFFFFF; - - /** - * The blend mode to be applied to the graphic shape. Apply a value of - * `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL; - * @see PIXI.BLEND_MODES - */ - _this.blendMode = _const.BLEND_MODES.NORMAL; - - /** - * Current path - * - * @member {PIXI.GraphicsData} - * @private - */ - _this.currentPath = null; - - /** - * Array containing some WebGL-related properties used by the WebGL renderer. - * - * @member {object} - * @private - */ - // TODO - _webgl should use a prototype object, not a random undocumented object... - _this._webGL = {}; - - /** - * Whether this shape is being used as a mask. - * - * @member {boolean} - */ - _this.isMask = false; - - /** - * The bounds' padding used for bounds calculation. - * - * @member {number} - */ - _this.boundsPadding = 0; - - /** - * A cache of the local bounds to prevent recalculation. - * - * @member {PIXI.Rectangle} - * @private - */ - _this._localBounds = new _Bounds2.default(); - - /** - * Used to detect if the graphics object has changed. If this is set to true then the graphics - * object will be recalculated. - * - * @member {boolean} - * @private - */ - _this.dirty = 0; - - /** - * Used to detect if we need to do a fast rect check using the id compare method - * @type {Number} - */ - _this.fastRectDirty = -1; - - /** - * Used to detect if we clear the graphics webGL data - * @type {Number} - */ - _this.clearDirty = 0; - - /** - * Used to detect if we we need to recalculate local bounds - * @type {Number} - */ - _this.boundsDirty = -1; - - /** - * Used to detect if the cached sprite object needs to be updated. - * - * @member {boolean} - * @private - */ - _this.cachedSpriteDirty = false; - - _this._spriteRect = null; - _this._fastRect = false; - - _this._prevRectTint = null; - _this._prevRectFillColor = null; - - /** - * When cacheAsBitmap is set to true the graphics object will be rendered as if it was a sprite. - * This is useful if your graphics element does not change often, as it will speed up the rendering - * of the object in exchange for taking up texture memory. It is also useful if you need the graphics - * object to be anti-aliased, because it will be rendered using canvas. This is not recommended if - * you are constantly redrawing the graphics element. - * - * @name cacheAsBitmap - * @member {boolean} - * @memberof PIXI.Graphics# - * @default false - */ - return _this; - } - - /** - * Creates a new Graphics object with the same values as this one. - * Note that the only the properties of the object are cloned, not its transform (position,scale,etc) - * - * @return {PIXI.Graphics} A clone of the graphics object - */ - - - Graphics.prototype.clone = function clone() { - var clone = new Graphics(); - - clone.renderable = this.renderable; - clone.fillAlpha = this.fillAlpha; - clone.lineWidth = this.lineWidth; - clone.lineColor = this.lineColor; - clone.lineAlignment = this.lineAlignment; - clone.tint = this.tint; - clone.blendMode = this.blendMode; - clone.isMask = this.isMask; - clone.boundsPadding = this.boundsPadding; - clone.dirty = 0; - clone.cachedSpriteDirty = this.cachedSpriteDirty; - - // copy graphics data - for (var i = 0; i < this.graphicsData.length; ++i) { - clone.graphicsData.push(this.graphicsData[i].clone()); - } - - clone.currentPath = clone.graphicsData[clone.graphicsData.length - 1]; - - clone.updateLocalBounds(); - - return clone; - }; - - /** - * Calculate length of quadratic curve - * @see {@link http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/} - * for the detailed explanation of math behind this. - * - * @private - * @param {number} fromX - x-coordinate of curve start point - * @param {number} fromY - y-coordinate of curve start point - * @param {number} cpX - x-coordinate of curve control point - * @param {number} cpY - y-coordinate of curve control point - * @param {number} toX - x-coordinate of curve end point - * @param {number} toY - y-coordinate of curve end point - * @return {number} Length of quadratic curve - */ - - - Graphics.prototype._quadraticCurveLength = function _quadraticCurveLength(fromX, fromY, cpX, cpY, toX, toY) { - var ax = fromX - 2.0 * cpX + toX; - var ay = fromY - 2.0 * cpY + toY; - var bx = 2.0 * cpX - 2.0 * fromX; - var by = 2.0 * cpY - 2.0 * fromY; - var a = 4.0 * (ax * ax + ay * ay); - var b = 4.0 * (ax * bx + ay * by); - var c = bx * bx + by * by; - - var s = 2.0 * Math.sqrt(a + b + c); - var a2 = Math.sqrt(a); - var a32 = 2.0 * a * a2; - var c2 = 2.0 * Math.sqrt(c); - var ba = b / a2; - - return (a32 * s + a2 * b * (s - c2) + (4.0 * c * a - b * b) * Math.log((2.0 * a2 + ba + s) / (ba + c2))) / (4.0 * a32); - }; - - /** - * Calculate length of bezier curve. - * Analytical solution is impossible, since it involves an integral that does not integrate in general. - * Therefore numerical solution is used. - * - * @private - * @param {number} fromX - Starting point x - * @param {number} fromY - Starting point y - * @param {number} cpX - Control point x - * @param {number} cpY - Control point y - * @param {number} cpX2 - Second Control point x - * @param {number} cpY2 - Second Control point y - * @param {number} toX - Destination point x - * @param {number} toY - Destination point y - * @return {number} Length of bezier curve - */ - - - Graphics.prototype._bezierCurveLength = function _bezierCurveLength(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) { - var n = 10; - var result = 0.0; - var t = 0.0; - var t2 = 0.0; - var t3 = 0.0; - var nt = 0.0; - var nt2 = 0.0; - var nt3 = 0.0; - var x = 0.0; - var y = 0.0; - var dx = 0.0; - var dy = 0.0; - var prevX = fromX; - var prevY = fromY; - - for (var i = 1; i <= n; ++i) { - t = i / n; - t2 = t * t; - t3 = t2 * t; - nt = 1.0 - t; - nt2 = nt * nt; - nt3 = nt2 * nt; - - x = nt3 * fromX + 3.0 * nt2 * t * cpX + 3.0 * nt * t2 * cpX2 + t3 * toX; - y = nt3 * fromY + 3.0 * nt2 * t * cpY + 3 * nt * t2 * cpY2 + t3 * toY; - dx = prevX - x; - dy = prevY - y; - prevX = x; - prevY = y; - - result += Math.sqrt(dx * dx + dy * dy); - } - - return result; - }; - - /** - * Calculate number of segments for the curve based on its length to ensure its smoothness. - * - * @private - * @param {number} length - length of curve - * @return {number} Number of segments - */ - - - Graphics.prototype._segmentsCount = function _segmentsCount(length) { - var result = Math.ceil(length / Graphics.CURVES.maxLength); - - if (result < Graphics.CURVES.minSegments) { - result = Graphics.CURVES.minSegments; - } else if (result > Graphics.CURVES.maxSegments) { - result = Graphics.CURVES.maxSegments; - } - - return result; - }; - - /** - * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() - * method or the drawCircle() method. - * - * @param {number} [lineWidth=0] - width of the line to draw, will update the objects stored style - * @param {number} [color=0] - color of the line to draw, will update the objects stored style - * @param {number} [alpha=1] - alpha of the line to draw, will update the objects stored style - * @param {number} [alignment=0.5] - alignment of the line to draw, (0 = inner, 0.5 = middle, 1 = outter) - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.lineStyle = function lineStyle() { - var lineWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var alpha = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; - var alignment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5; - - this.lineWidth = lineWidth; - this.lineColor = color; - this.lineAlpha = alpha; - this.lineAlignment = alignment; - - if (this.currentPath) { - if (this.currentPath.shape.points.length) { - // halfway through a line? start a new one! - var shape = new _math.Polygon(this.currentPath.shape.points.slice(-2)); - - shape.closed = false; - - this.drawShape(shape); - } else { - // otherwise its empty so lets just set the line properties - this.currentPath.lineWidth = this.lineWidth; - this.currentPath.lineColor = this.lineColor; - this.currentPath.lineAlpha = this.lineAlpha; - this.currentPath.lineAlignment = this.lineAlignment; - } - } - - return this; - }; - - /** - * Moves the current drawing position to x, y. - * - * @param {number} x - the X coordinate to move to - * @param {number} y - the Y coordinate to move to - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.moveTo = function moveTo(x, y) { - var shape = new _math.Polygon([x, y]); - - shape.closed = false; - this.drawShape(shape); - - return this; - }; - - /** - * Draws a line using the current line style from the current drawing position to (x, y); - * The current drawing position is then set to (x, y). - * - * @param {number} x - the X coordinate to draw to - * @param {number} y - the Y coordinate to draw to - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.lineTo = function lineTo(x, y) { - var points = this.currentPath.shape.points; - - var fromX = points[points.length - 2]; - var fromY = points[points.length - 1]; - - if (fromX !== x || fromY !== y) { - points.push(x, y); - this.dirty++; - } - - return this; - }; - - /** - * Calculate the points for a quadratic bezier curve and then draws it. - * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c - * - * @param {number} cpX - Control point x - * @param {number} cpY - Control point y - * @param {number} toX - Destination point x - * @param {number} toY - Destination point y - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.quadraticCurveTo = function quadraticCurveTo(cpX, cpY, toX, toY) { - if (this.currentPath) { - if (this.currentPath.shape.points.length === 0) { - this.currentPath.shape.points = [0, 0]; - } - } else { - this.moveTo(0, 0); - } - - var points = this.currentPath.shape.points; - var xa = 0; - var ya = 0; - - if (points.length === 0) { - this.moveTo(0, 0); - } - - var fromX = points[points.length - 2]; - var fromY = points[points.length - 1]; - var n = Graphics.CURVES.adaptive ? this._segmentsCount(this._quadraticCurveLength(fromX, fromY, cpX, cpY, toX, toY)) : 20; - - for (var i = 1; i <= n; ++i) { - var j = i / n; - - xa = fromX + (cpX - fromX) * j; - ya = fromY + (cpY - fromY) * j; - - points.push(xa + (cpX + (toX - cpX) * j - xa) * j, ya + (cpY + (toY - cpY) * j - ya) * j); - } - - this.dirty++; - - return this; - }; - - /** - * Calculate the points for a bezier curve and then draws it. - * - * @param {number} cpX - Control point x - * @param {number} cpY - Control point y - * @param {number} cpX2 - Second Control point x - * @param {number} cpY2 - Second Control point y - * @param {number} toX - Destination point x - * @param {number} toY - Destination point y - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.bezierCurveTo = function bezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY) { - if (this.currentPath) { - if (this.currentPath.shape.points.length === 0) { - this.currentPath.shape.points = [0, 0]; - } - } else { - this.moveTo(0, 0); - } - - var points = this.currentPath.shape.points; - - var fromX = points[points.length - 2]; - var fromY = points[points.length - 1]; - - points.length -= 2; - - var n = Graphics.CURVES.adaptive ? this._segmentsCount(this._bezierCurveLength(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY)) : 20; - - (0, _bezierCurveTo3.default)(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY, n, points); - - this.dirty++; - - return this; - }; - - /** - * The arcTo() method creates an arc/curve between two tangents on the canvas. - * - * "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google! - * - * @param {number} x1 - The x-coordinate of the beginning of the arc - * @param {number} y1 - The y-coordinate of the beginning of the arc - * @param {number} x2 - The x-coordinate of the end of the arc - * @param {number} y2 - The y-coordinate of the end of the arc - * @param {number} radius - The radius of the arc - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.arcTo = function arcTo(x1, y1, x2, y2, radius) { - if (this.currentPath) { - if (this.currentPath.shape.points.length === 0) { - this.currentPath.shape.points.push(x1, y1); - } - } else { - this.moveTo(x1, y1); - } - - var points = this.currentPath.shape.points; - var fromX = points[points.length - 2]; - var fromY = points[points.length - 1]; - var a1 = fromY - y1; - var b1 = fromX - x1; - var a2 = y2 - y1; - var b2 = x2 - x1; - var mm = Math.abs(a1 * b2 - b1 * a2); - - if (mm < 1.0e-8 || radius === 0) { - if (points[points.length - 2] !== x1 || points[points.length - 1] !== y1) { - points.push(x1, y1); - } - } else { - var dd = a1 * a1 + b1 * b1; - var cc = a2 * a2 + b2 * b2; - var tt = a1 * a2 + b1 * b2; - var k1 = radius * Math.sqrt(dd) / mm; - var k2 = radius * Math.sqrt(cc) / mm; - var j1 = k1 * tt / dd; - var j2 = k2 * tt / cc; - var cx = k1 * b2 + k2 * b1; - var cy = k1 * a2 + k2 * a1; - var px = b1 * (k2 + j1); - var py = a1 * (k2 + j1); - var qx = b2 * (k1 + j2); - var qy = a2 * (k1 + j2); - var startAngle = Math.atan2(py - cy, px - cx); - var endAngle = Math.atan2(qy - cy, qx - cx); - - this.arc(cx + x1, cy + y1, radius, startAngle, endAngle, b1 * a2 > b2 * a1); - } - - this.dirty++; - - return this; - }; - - /** - * The arc method creates an arc/curve (used to create circles, or parts of circles). - * - * @param {number} cx - The x-coordinate of the center of the circle - * @param {number} cy - The y-coordinate of the center of the circle - * @param {number} radius - The radius of the circle - * @param {number} startAngle - The starting angle, in radians (0 is at the 3 o'clock position - * of the arc's circle) - * @param {number} endAngle - The ending angle, in radians - * @param {boolean} [anticlockwise=false] - Specifies whether the drawing should be - * counter-clockwise or clockwise. False is default, and indicates clockwise, while true - * indicates counter-clockwise. - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.arc = function arc(cx, cy, radius, startAngle, endAngle) { - var anticlockwise = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false; - - if (startAngle === endAngle) { - return this; - } - - if (!anticlockwise && endAngle <= startAngle) { - endAngle += _const.PI_2; - } else if (anticlockwise && startAngle <= endAngle) { - startAngle += _const.PI_2; - } - - var sweep = endAngle - startAngle; - var segs = Graphics.CURVES.adaptive ? this._segmentsCount(Math.abs(sweep) * radius) : Math.ceil(Math.abs(sweep) / _const.PI_2) * 40; - - if (sweep === 0) { - return this; - } - - var startX = cx + Math.cos(startAngle) * radius; - var startY = cy + Math.sin(startAngle) * radius; - - // If the currentPath exists, take its points. Otherwise call `moveTo` to start a path. - var points = this.currentPath ? this.currentPath.shape.points : null; - - if (points) { - // We check how far our start is from the last existing point - var xDiff = Math.abs(points[points.length - 2] - startX); - var yDiff = Math.abs(points[points.length - 1] - startY); - - if (xDiff < 0.001 && yDiff < 0.001) { - // If the point is very close, we don't add it, since this would lead to artifacts - // during tesselation due to floating point imprecision. - } else { - points.push(startX, startY); - } - } else { - this.moveTo(startX, startY); - points = this.currentPath.shape.points; - } - - var theta = sweep / (segs * 2); - var theta2 = theta * 2; - - var cTheta = Math.cos(theta); - var sTheta = Math.sin(theta); - - var segMinus = segs - 1; - - var remainder = segMinus % 1 / segMinus; - - for (var i = 0; i <= segMinus; ++i) { - var real = i + remainder * i; - - var angle = theta + startAngle + theta2 * real; - - var c = Math.cos(angle); - var s = -Math.sin(angle); - - points.push((cTheta * c + sTheta * s) * radius + cx, (cTheta * -s + sTheta * c) * radius + cy); - } - - this.dirty++; - - return this; - }; - - /** - * Specifies a simple one-color fill that subsequent calls to other Graphics methods - * (such as lineTo() or drawCircle()) use when drawing. - * - * @param {number} [color=0] - the color of the fill - * @param {number} [alpha=1] - the alpha of the fill - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.beginFill = function beginFill() { - var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - - this.filling = true; - this.fillColor = color; - this.fillAlpha = alpha; - - if (this.currentPath) { - if (this.currentPath.shape.points.length <= 2) { - this.currentPath.fill = this.filling; - this.currentPath.fillColor = this.fillColor; - this.currentPath.fillAlpha = this.fillAlpha; - } - } - - return this; - }; - - /** - * Applies a fill to the lines and shapes that were added since the last call to the beginFill() method. - * - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.endFill = function endFill() { - this.filling = false; - this.fillColor = null; - this.fillAlpha = 1; - - return this; - }; - - /** - * - * @param {number} x - The X coord of the top-left of the rectangle - * @param {number} y - The Y coord of the top-left of the rectangle - * @param {number} width - The width of the rectangle - * @param {number} height - The height of the rectangle - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.drawRect = function drawRect(x, y, width, height) { - this.drawShape(new _math.Rectangle(x, y, width, height)); - - return this; - }; - - /** - * - * @param {number} x - The X coord of the top-left of the rectangle - * @param {number} y - The Y coord of the top-left of the rectangle - * @param {number} width - The width of the rectangle - * @param {number} height - The height of the rectangle - * @param {number} radius - Radius of the rectangle corners - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.drawRoundedRect = function drawRoundedRect(x, y, width, height, radius) { - this.drawShape(new _math.RoundedRectangle(x, y, width, height, radius)); - - return this; - }; - - /** - * Draws a circle. - * - * @param {number} x - The X coordinate of the center of the circle - * @param {number} y - The Y coordinate of the center of the circle - * @param {number} radius - The radius of the circle - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.drawCircle = function drawCircle(x, y, radius) { - this.drawShape(new _math.Circle(x, y, radius)); - - return this; - }; - - /** - * Draws an ellipse. - * - * @param {number} x - The X coordinate of the center of the ellipse - * @param {number} y - The Y coordinate of the center of the ellipse - * @param {number} width - The half width of the ellipse - * @param {number} height - The half height of the ellipse - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.drawEllipse = function drawEllipse(x, y, width, height) { - this.drawShape(new _math.Ellipse(x, y, width, height)); - - return this; - }; - - /** - * Draws a polygon using the given path. - * - * @param {number[]|PIXI.Point[]|PIXI.Polygon} path - The path data used to construct the polygon. - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.drawPolygon = function drawPolygon(path) { - // prevents an argument assignment deopt - // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments - var points = path; - - var closed = true; - - if (points instanceof _math.Polygon) { - closed = points.closed; - points = points.points; - } - - if (!Array.isArray(points)) { - // prevents an argument leak deopt - // see section 3.2: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments - points = new Array(arguments.length); - - for (var i = 0; i < points.length; ++i) { - points[i] = arguments[i]; // eslint-disable-line prefer-rest-params - } - } - - var shape = new _math.Polygon(points); - - shape.closed = closed; - - this.drawShape(shape); - - return this; - }; - - /** - * Draw a star shape with an abitrary number of points. - * - * @param {number} x - Center X position of the star - * @param {number} y - Center Y position of the star - * @param {number} points - The number of points of the star, must be > 1 - * @param {number} radius - The outer radius of the star - * @param {number} [innerRadius] - The inner radius between points, default half `radius` - * @param {number} [rotation=0] - The rotation of the star in radians, where 0 is vertical - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.drawStar = function drawStar(x, y, points, radius, innerRadius) { - var rotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; - - innerRadius = innerRadius || radius / 2; - - var startAngle = -1 * Math.PI / 2 + rotation; - var len = points * 2; - var delta = _const.PI_2 / len; - var polygon = []; - - for (var i = 0; i < len; i++) { - var r = i % 2 ? innerRadius : radius; - var angle = i * delta + startAngle; - - polygon.push(x + r * Math.cos(angle), y + r * Math.sin(angle)); - } - - return this.drawPolygon(polygon); - }; - - /** - * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings. - * - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls - */ - - - Graphics.prototype.clear = function clear() { - if (this.lineWidth || this.filling || this.graphicsData.length > 0) { - this.lineWidth = 0; - this.lineAlignment = 0.5; - - this.filling = false; - - this.boundsDirty = -1; - this.canvasTintDirty = -1; - this.dirty++; - this.clearDirty++; - this.graphicsData.length = 0; - } - - this.currentPath = null; - this._spriteRect = null; - - return this; - }; - - /** - * True if graphics consists of one rectangle, and thus, can be drawn like a Sprite and - * masked with gl.scissor. - * - * @returns {boolean} True if only 1 rect. - */ - - - Graphics.prototype.isFastRect = function isFastRect() { - return this.graphicsData.length === 1 && this.graphicsData[0].shape.type === _const.SHAPES.RECT && !this.graphicsData[0].lineWidth; - }; - - /** - * Renders the object using the WebGL renderer - * - * @private - * @param {PIXI.WebGLRenderer} renderer - The renderer - */ - - - Graphics.prototype._renderWebGL = function _renderWebGL(renderer) { - // if the sprite is not visible or the alpha is 0 then no need to render this element - if (this.dirty !== this.fastRectDirty) { - this.fastRectDirty = this.dirty; - this._fastRect = this.isFastRect(); - } - - // TODO this check can be moved to dirty? - if (this._fastRect) { - this._renderSpriteRect(renderer); - } else { - renderer.setObjectRenderer(renderer.plugins.graphics); - renderer.plugins.graphics.render(this); - } - }; - - /** - * Renders a sprite rectangle. - * - * @private - * @param {PIXI.WebGLRenderer} renderer - The renderer - */ - - - Graphics.prototype._renderSpriteRect = function _renderSpriteRect(renderer) { - var rect = this.graphicsData[0].shape; - - if (!this._spriteRect) { - this._spriteRect = new _Sprite2.default(new _Texture2.default(_Texture2.default.WHITE)); - } - - var sprite = this._spriteRect; - var fillColor = this.graphicsData[0].fillColor; - - if (this.tint === 0xffffff) { - sprite.tint = fillColor; - } else if (this.tint !== this._prevRectTint || fillColor !== this._prevRectFillColor) { - var t1 = tempColor1; - var t2 = tempColor2; - - (0, _utils.hex2rgb)(fillColor, t1); - (0, _utils.hex2rgb)(this.tint, t2); - - t1[0] *= t2[0]; - t1[1] *= t2[1]; - t1[2] *= t2[2]; - - sprite.tint = (0, _utils.rgb2hex)(t1); - - this._prevRectTint = this.tint; - this._prevRectFillColor = fillColor; - } - - sprite.alpha = this.graphicsData[0].fillAlpha; - sprite.worldAlpha = this.worldAlpha * sprite.alpha; - sprite.blendMode = this.blendMode; - - sprite._texture._frame.width = rect.width; - sprite._texture._frame.height = rect.height; - - sprite.transform.worldTransform = this.transform.worldTransform; - - sprite.anchor.set(-rect.x / rect.width, -rect.y / rect.height); - sprite._onAnchorUpdate(); - - sprite._renderWebGL(renderer); - }; - - /** - * Renders the object using the Canvas renderer - * - * @private - * @param {PIXI.CanvasRenderer} renderer - The renderer - */ - - - Graphics.prototype._renderCanvas = function _renderCanvas(renderer) { - if (this.isMask === true) { - return; - } - - renderer.plugins.graphics.render(this); - }; - - /** - * Retrieves the bounds of the graphic shape as a rectangle object - * - * @private - */ - - - Graphics.prototype._calculateBounds = function _calculateBounds() { - if (this.boundsDirty !== this.dirty) { - this.boundsDirty = this.dirty; - this.updateLocalBounds(); - - this.cachedSpriteDirty = true; - } - - var lb = this._localBounds; - - this._bounds.addFrame(this.transform, lb.minX, lb.minY, lb.maxX, lb.maxY); - }; - - /** - * Tests if a point is inside this graphics object - * - * @param {PIXI.Point} point - the point to test - * @return {boolean} the result of the test - */ - - - Graphics.prototype.containsPoint = function containsPoint(point) { - this.worldTransform.applyInverse(point, tempPoint); - - var graphicsData = this.graphicsData; - - for (var i = 0; i < graphicsData.length; ++i) { - var data = graphicsData[i]; - - if (!data.fill) { - continue; - } - - // only deal with fills.. - if (data.shape) { - if (data.shape.contains(tempPoint.x, tempPoint.y)) { - if (data.holes) { - for (var _i = 0; _i < data.holes.length; _i++) { - var hole = data.holes[_i]; - - if (hole.contains(tempPoint.x, tempPoint.y)) { - return false; - } - } - } - - return true; - } - } - } - - return false; - }; - - /** - * Update the bounds of the object - * - */ - - - Graphics.prototype.updateLocalBounds = function updateLocalBounds() { - var minX = Infinity; - var maxX = -Infinity; - - var minY = Infinity; - var maxY = -Infinity; - - if (this.graphicsData.length) { - var shape = 0; - var x = 0; - var y = 0; - var w = 0; - var h = 0; - - for (var i = 0; i < this.graphicsData.length; i++) { - var data = this.graphicsData[i]; - var type = data.type; - var lineWidth = data.lineWidth; - var lineAlignment = data.lineAlignment; - - var lineOffset = lineWidth * lineAlignment; - - shape = data.shape; - - if (type === _const.SHAPES.RECT || type === _const.SHAPES.RREC) { - x = shape.x - lineOffset; - y = shape.y - lineOffset; - w = shape.width + lineOffset * 2; - h = shape.height + lineOffset * 2; - - minX = x < minX ? x : minX; - maxX = x + w > maxX ? x + w : maxX; - - minY = y < minY ? y : minY; - maxY = y + h > maxY ? y + h : maxY; - } else if (type === _const.SHAPES.CIRC) { - x = shape.x; - y = shape.y; - w = shape.radius + lineOffset; - h = shape.radius + lineOffset; - - minX = x - w < minX ? x - w : minX; - maxX = x + w > maxX ? x + w : maxX; - - minY = y - h < minY ? y - h : minY; - maxY = y + h > maxY ? y + h : maxY; - } else if (type === _const.SHAPES.ELIP) { - x = shape.x; - y = shape.y; - w = shape.width + lineOffset; - h = shape.height + lineOffset; - - minX = x - w < minX ? x - w : minX; - maxX = x + w > maxX ? x + w : maxX; - - minY = y - h < minY ? y - h : minY; - maxY = y + h > maxY ? y + h : maxY; - } else { - // POLY - var points = shape.points; - var x2 = 0; - var y2 = 0; - var dx = 0; - var dy = 0; - var rw = 0; - var rh = 0; - var cx = 0; - var cy = 0; - - for (var j = 0; j + 2 < points.length; j += 2) { - x = points[j]; - y = points[j + 1]; - x2 = points[j + 2]; - y2 = points[j + 3]; - dx = Math.abs(x2 - x); - dy = Math.abs(y2 - y); - h = lineOffset * 2; - w = Math.sqrt(dx * dx + dy * dy); - - if (w < 1e-9) { - continue; - } - - rw = (h / w * dy + dx) / 2; - rh = (h / w * dx + dy) / 2; - cx = (x2 + x) / 2; - cy = (y2 + y) / 2; - - minX = cx - rw < minX ? cx - rw : minX; - maxX = cx + rw > maxX ? cx + rw : maxX; - - minY = cy - rh < minY ? cy - rh : minY; - maxY = cy + rh > maxY ? cy + rh : maxY; - } - } - } - } else { - minX = 0; - maxX = 0; - minY = 0; - maxY = 0; - } - - var padding = this.boundsPadding; - - this._localBounds.minX = minX - padding; - this._localBounds.maxX = maxX + padding; - - this._localBounds.minY = minY - padding; - this._localBounds.maxY = maxY + padding; - }; - - /** - * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. - * - * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw. - * @return {PIXI.GraphicsData} The generated GraphicsData object. - */ - - - Graphics.prototype.drawShape = function drawShape(shape) { - if (this.currentPath) { - // check current path! - if (this.currentPath.shape.points.length <= 2) { - this.graphicsData.pop(); - } - } - - this.currentPath = null; - - var data = new _GraphicsData2.default(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, this.nativeLines, shape, this.lineAlignment); - - this.graphicsData.push(data); - - if (data.type === _const.SHAPES.POLY) { - data.shape.closed = data.shape.closed; - this.currentPath = data; - } - - this.dirty++; - - return data; - }; - - /** - * Generates a canvas texture. - * - * @param {number} scaleMode - The scale mode of the texture. - * @param {number} resolution - The resolution of the texture. - * @return {PIXI.Texture} The new texture. - */ - - - Graphics.prototype.generateCanvasTexture = function generateCanvasTexture(scaleMode) { - var resolution = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - - var bounds = this.getLocalBounds(); - - var canvasBuffer = _RenderTexture2.default.create(bounds.width, bounds.height, scaleMode, resolution); - - if (!canvasRenderer) { - canvasRenderer = new _CanvasRenderer2.default(); - } - - this.transform.updateLocalTransform(); - this.transform.localTransform.copy(tempMatrix); - - tempMatrix.invert(); - - tempMatrix.tx -= bounds.x; - tempMatrix.ty -= bounds.y; - - canvasRenderer.render(this, canvasBuffer, true, tempMatrix); - - var texture = _Texture2.default.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode, 'graphics'); - - texture.baseTexture.resolution = resolution; - texture.baseTexture.update(); - - return texture; - }; - - /** - * Closes the current path. - * - * @return {PIXI.Graphics} Returns itself. - */ - - - Graphics.prototype.closePath = function closePath() { - // ok so close path assumes next one is a hole! - var currentPath = this.currentPath; - - if (currentPath && currentPath.shape) { - currentPath.shape.close(); - } - - return this; - }; - - /** - * Adds a hole in the current path. - * - * @return {PIXI.Graphics} Returns itself. - */ - - - Graphics.prototype.addHole = function addHole() { - // this is a hole! - var hole = this.graphicsData.pop(); - - this.currentPath = this.graphicsData[this.graphicsData.length - 1]; - - this.currentPath.addHole(hole.shape); - this.currentPath = null; - - return this; - }; - - /** - * Destroys the Graphics object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - - - Graphics.prototype.destroy = function destroy(options) { - _Container.prototype.destroy.call(this, options); - - // destroy each of the GraphicsData objects - for (var i = 0; i < this.graphicsData.length; ++i) { - this.graphicsData[i].destroy(); - } - - // for each webgl data entry, destroy the WebGLGraphicsData - for (var id in this._webGL) { - for (var j = 0; j < this._webGL[id].data.length; ++j) { - this._webGL[id].data[j].destroy(); - } - } - - if (this._spriteRect) { - this._spriteRect.destroy(); - } - - this.graphicsData = null; - - this.currentPath = null; - this._webGL = null; - this._localBounds = null; - }; - - return Graphics; -}(_Container3.default); - -exports.default = Graphics; - - -Graphics._SPRITE_TEXTURE = null; - -/** - * Graphics curves resolution settings. If `adaptive` flag is set to `true`, - * the resolution is calculated based on the curve's length to ensure better visual quality. - * Adaptive draw works with `bezierCurveTo` and `quadraticCurveTo`. - * - * @static - * @constant - * @memberof PIXI.Graphics - * @name CURVES - * @type {object} - * @property {boolean} adaptive=false - flag indicating if the resolution should be adaptive - * @property {number} maxLength=10 - maximal length of a single segment of the curve (if adaptive = false, ignored) - * @property {number} minSegments=8 - minimal number of segments in the curve (if adaptive = false, ignored) - * @property {number} maxSegments=2048 - maximal number of segments in the curve (if adaptive = false, ignored) - */ -Graphics.CURVES = { - adaptive: false, - maxLength: 10, - minSegments: 8, - maxSegments: 2048 -}; - -},{"../const":46,"../display/Bounds":47,"../display/Container":48,"../math":70,"../renderers/canvas/CanvasRenderer":77,"../sprites/Sprite":102,"../textures/RenderTexture":113,"../textures/Texture":115,"../utils":125,"./GraphicsData":54,"./utils/bezierCurveTo":56}],54:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * A GraphicsData object. - * - * @class - * @memberof PIXI - */ -var GraphicsData = function () { - /** - * - * @param {number} lineWidth - the width of the line to draw - * @param {number} lineColor - the color of the line to draw - * @param {number} lineAlpha - the alpha of the line to draw - * @param {number} fillColor - the color of the fill - * @param {number} fillAlpha - the alpha of the fill - * @param {boolean} fill - whether or not the shape is filled with a colour - * @param {boolean} nativeLines - the method for drawing lines - * @param {PIXI.Circle|PIXI.Rectangle|PIXI.Ellipse|PIXI.Polygon} shape - The shape object to draw. - * @param {number} lineAlignment - the alignment of the line. - */ - function GraphicsData(lineWidth, lineColor, lineAlpha, fillColor, fillAlpha, fill, nativeLines, shape, lineAlignment) { - _classCallCheck(this, GraphicsData); - - /** - * the width of the line to draw - * @member {number} - */ - this.lineWidth = lineWidth; - - /** - * The alignment of any lines drawn (0.5 = middle, 1 = outter, 0 = inner). - * - * @member {number} - * @default 0 - */ - this.lineAlignment = lineAlignment; - - /** - * if true the liens will be draw using LINES instead of TRIANGLE_STRIP - * @member {boolean} - */ - this.nativeLines = nativeLines; - - /** - * the color of the line to draw - * @member {number} - */ - this.lineColor = lineColor; - - /** - * the alpha of the line to draw - * @member {number} - */ - this.lineAlpha = lineAlpha; - - /** - * cached tint of the line to draw - * @member {number} - * @private - */ - this._lineTint = lineColor; - - /** - * the color of the fill - * @member {number} - */ - this.fillColor = fillColor; - - /** - * the alpha of the fill - * @member {number} - */ - this.fillAlpha = fillAlpha; - - /** - * cached tint of the fill - * @member {number} - * @private - */ - this._fillTint = fillColor; - - /** - * whether or not the shape is filled with a colour - * @member {boolean} - */ - this.fill = fill; - - this.holes = []; - - /** - * The shape object to draw. - * @member {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} - */ - this.shape = shape; - - /** - * The type of the shape, see the Const.Shapes file for all the existing types, - * @member {number} - */ - this.type = shape.type; - } - - /** - * Creates a new GraphicsData object with the same values as this one. - * - * @return {PIXI.GraphicsData} Cloned GraphicsData object - */ - - - GraphicsData.prototype.clone = function clone() { - return new GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.fill, this.nativeLines, this.shape, this.lineAlignment); - }; - - /** - * Adds a hole to the shape. - * - * @param {PIXI.Rectangle|PIXI.Circle} shape - The shape of the hole. - */ - - - GraphicsData.prototype.addHole = function addHole(shape) { - this.holes.push(shape); - }; - - /** - * Destroys the Graphics data. - */ - - - GraphicsData.prototype.destroy = function destroy() { - this.shape = null; - this.holes = null; - }; - - return GraphicsData; -}(); - -exports.default = GraphicsData; - -},{}],55:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _CanvasRenderer = require('../../renderers/canvas/CanvasRenderer'); - -var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer); - -var _const = require('../../const'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * @author Mat Groves - * - * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/ - * for creating the original PixiJS version! - * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they - * now share 4 bytes on the vertex buffer - * - * Heavily inspired by LibGDX's CanvasGraphicsRenderer: - * https://github.com/libgdx/libgdx/blob/1.0.0/gdx/src/com/badlogic/gdx/graphics/glutils/ShapeRenderer.java - */ - -/** - * Renderer dedicated to drawing and batching graphics objects. - * - * @class - * @private - * @memberof PIXI - */ -var CanvasGraphicsRenderer = function () { - /** - * @param {PIXI.CanvasRenderer} renderer - The current PIXI renderer. - */ - function CanvasGraphicsRenderer(renderer) { - _classCallCheck(this, CanvasGraphicsRenderer); - - this.renderer = renderer; - } - - /** - * Renders a Graphics object to a canvas. - * - * @param {PIXI.Graphics} graphics - the actual graphics object to render - */ - - - CanvasGraphicsRenderer.prototype.render = function render(graphics) { - var renderer = this.renderer; - var context = renderer.context; - var worldAlpha = graphics.worldAlpha; - var transform = graphics.transform.worldTransform; - var resolution = renderer.resolution; - - context.setTransform(transform.a * resolution, transform.b * resolution, transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution); - - // update tint if graphics was dirty - if (graphics.canvasTintDirty !== graphics.dirty || graphics._prevTint !== graphics.tint) { - this.updateGraphicsTint(graphics); - } - - renderer.setBlendMode(graphics.blendMode); - - for (var i = 0; i < graphics.graphicsData.length; i++) { - var data = graphics.graphicsData[i]; - var shape = data.shape; - - var fillColor = data._fillTint; - var lineColor = data._lineTint; - - context.lineWidth = data.lineWidth; - - if (data.type === _const.SHAPES.POLY) { - context.beginPath(); - - var points = shape.points; - var holes = data.holes; - var outerArea = void 0; - var innerArea = void 0; - - context.moveTo(points[0], points[1]); - - for (var j = 2; j < points.length; j += 2) { - context.lineTo(points[j], points[j + 1]); - } - - // if the first and last point are the same close the path - much neater :) - if (shape.closed) { - context.closePath(); - } - - if (holes.length > 0) { - outerArea = 0; - for (var _j = 0; _j < points.length; _j += 2) { - outerArea += points[_j] * points[_j + 3] - points[_j + 1] * points[_j + 2]; - } - - for (var k = 0; k < holes.length; k++) { - points = holes[k].points; - - innerArea = 0; - for (var _j2 = 0; _j2 < points.length; _j2 += 2) { - innerArea += points[_j2] * points[_j2 + 3] - points[_j2 + 1] * points[_j2 + 2]; - } - - context.moveTo(points[0], points[1]); - - if (innerArea * outerArea < 0) { - for (var _j3 = 2; _j3 < points.length; _j3 += 2) { - context.lineTo(points[_j3], points[_j3 + 1]); - } - } else { - for (var _j4 = points.length - 2; _j4 >= 2; _j4 -= 2) { - context.lineTo(points[_j4], points[_j4 + 1]); - } - } - - if (holes[k].closed) { - context.closePath(); - } - } - } - - if (data.fill) { - context.globalAlpha = data.fillAlpha * worldAlpha; - context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6); - context.fill(); - } - if (data.lineWidth) { - context.globalAlpha = data.lineAlpha * worldAlpha; - context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6); - context.stroke(); - } - } else if (data.type === _const.SHAPES.RECT) { - if (data.fillColor || data.fillColor === 0) { - context.globalAlpha = data.fillAlpha * worldAlpha; - context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6); - context.fillRect(shape.x, shape.y, shape.width, shape.height); - } - if (data.lineWidth) { - context.globalAlpha = data.lineAlpha * worldAlpha; - context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6); - context.strokeRect(shape.x, shape.y, shape.width, shape.height); - } - } else if (data.type === _const.SHAPES.CIRC) { - // TODO - need to be Undefined! - context.beginPath(); - context.arc(shape.x, shape.y, shape.radius, 0, 2 * Math.PI); - context.closePath(); - - if (data.fill) { - context.globalAlpha = data.fillAlpha * worldAlpha; - context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6); - context.fill(); - } - if (data.lineWidth) { - context.globalAlpha = data.lineAlpha * worldAlpha; - context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6); - context.stroke(); - } - } else if (data.type === _const.SHAPES.ELIP) { - // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas - - var w = shape.width * 2; - var h = shape.height * 2; - - var x = shape.x - w / 2; - var y = shape.y - h / 2; - - context.beginPath(); - - var kappa = 0.5522848; - var ox = w / 2 * kappa; // control point offset horizontal - var oy = h / 2 * kappa; // control point offset vertical - var xe = x + w; // x-end - var ye = y + h; // y-end - var xm = x + w / 2; // x-middle - var ym = y + h / 2; // y-middle - - context.moveTo(x, ym); - context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); - context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); - context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); - context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); - - context.closePath(); - - if (data.fill) { - context.globalAlpha = data.fillAlpha * worldAlpha; - context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6); - context.fill(); - } - if (data.lineWidth) { - context.globalAlpha = data.lineAlpha * worldAlpha; - context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6); - context.stroke(); - } - } else if (data.type === _const.SHAPES.RREC) { - var rx = shape.x; - var ry = shape.y; - var width = shape.width; - var height = shape.height; - var radius = shape.radius; - - var maxRadius = Math.min(width, height) / 2 | 0; - - radius = radius > maxRadius ? maxRadius : radius; - - context.beginPath(); - context.moveTo(rx, ry + radius); - context.lineTo(rx, ry + height - radius); - context.quadraticCurveTo(rx, ry + height, rx + radius, ry + height); - context.lineTo(rx + width - radius, ry + height); - context.quadraticCurveTo(rx + width, ry + height, rx + width, ry + height - radius); - context.lineTo(rx + width, ry + radius); - context.quadraticCurveTo(rx + width, ry, rx + width - radius, ry); - context.lineTo(rx + radius, ry); - context.quadraticCurveTo(rx, ry, rx, ry + radius); - context.closePath(); - - if (data.fillColor || data.fillColor === 0) { - context.globalAlpha = data.fillAlpha * worldAlpha; - context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6); - context.fill(); - } - - if (data.lineWidth) { - context.globalAlpha = data.lineAlpha * worldAlpha; - context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6); - context.stroke(); - } - } - } - }; - - /** - * Updates the tint of a graphics object - * - * @private - * @param {PIXI.Graphics} graphics - the graphics that will have its tint updated - */ - - - CanvasGraphicsRenderer.prototype.updateGraphicsTint = function updateGraphicsTint(graphics) { - graphics._prevTint = graphics.tint; - graphics.canvasTintDirty = graphics.dirty; - - var tintR = (graphics.tint >> 16 & 0xFF) / 255; - var tintG = (graphics.tint >> 8 & 0xFF) / 255; - var tintB = (graphics.tint & 0xFF) / 255; - - for (var i = 0; i < graphics.graphicsData.length; ++i) { - var data = graphics.graphicsData[i]; - - var fillColor = data.fillColor | 0; - var lineColor = data.lineColor | 0; - - // super inline, cos optimization :) - data._fillTint = ((fillColor >> 16 & 0xFF) / 255 * tintR * 255 << 16) + ((fillColor >> 8 & 0xFF) / 255 * tintG * 255 << 8) + (fillColor & 0xFF) / 255 * tintB * 255; - - data._lineTint = ((lineColor >> 16 & 0xFF) / 255 * tintR * 255 << 16) + ((lineColor >> 8 & 0xFF) / 255 * tintG * 255 << 8) + (lineColor & 0xFF) / 255 * tintB * 255; - } - }; - - /** - * Renders a polygon. - * - * @param {PIXI.Point[]} points - The points to render - * @param {boolean} close - Should the polygon be closed - * @param {CanvasRenderingContext2D} context - The rendering context to use - */ - - - CanvasGraphicsRenderer.prototype.renderPolygon = function renderPolygon(points, close, context) { - context.moveTo(points[0], points[1]); - - for (var j = 1; j < points.length / 2; ++j) { - context.lineTo(points[j * 2], points[j * 2 + 1]); - } - - if (close) { - context.closePath(); - } - }; - - /** - * destroy graphics object - * - */ - - - CanvasGraphicsRenderer.prototype.destroy = function destroy() { - this.renderer = null; - }; - - return CanvasGraphicsRenderer; -}(); - -exports.default = CanvasGraphicsRenderer; - - -_CanvasRenderer2.default.registerPlugin('graphics', CanvasGraphicsRenderer); - -},{"../../const":46,"../../renderers/canvas/CanvasRenderer":77}],56:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; -exports.default = bezierCurveTo; -/** - * Calculate the points for a bezier curve and then draws it. - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @param {number} fromX - Starting point x - * @param {number} fromY - Starting point y - * @param {number} cpX - Control point x - * @param {number} cpY - Control point y - * @param {number} cpX2 - Second Control point x - * @param {number} cpY2 - Second Control point y - * @param {number} toX - Destination point x - * @param {number} toY - Destination point y - * @param {number} n - Number of segments approximating the bezier curve - * @param {number[]} [path=[]] - Path array to push points into - * @return {number[]} Array of points of the curve - */ -function bezierCurveTo(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY, n) { - var path = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : []; - - var dt = 0; - var dt2 = 0; - var dt3 = 0; - var t2 = 0; - var t3 = 0; - - path.push(fromX, fromY); - - for (var i = 1, j = 0; i <= n; ++i) { - j = i / n; - - dt = 1 - j; - dt2 = dt * dt; - dt3 = dt2 * dt; - - t2 = j * j; - t3 = t2 * j; - - path.push(dt3 * fromX + 3 * dt2 * j * cpX + 3 * dt * t2 * cpX2 + t3 * toX, dt3 * fromY + 3 * dt2 * j * cpY + 3 * dt * t2 * cpY2 + t3 * toY); - } - - return path; -} - -},{}],57:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _utils = require('../../utils'); - -var _const = require('../../const'); - -var _ObjectRenderer2 = require('../../renderers/webgl/utils/ObjectRenderer'); - -var _ObjectRenderer3 = _interopRequireDefault(_ObjectRenderer2); - -var _WebGLRenderer = require('../../renderers/webgl/WebGLRenderer'); - -var _WebGLRenderer2 = _interopRequireDefault(_WebGLRenderer); - -var _WebGLGraphicsData = require('./WebGLGraphicsData'); - -var _WebGLGraphicsData2 = _interopRequireDefault(_WebGLGraphicsData); - -var _PrimitiveShader = require('./shaders/PrimitiveShader'); - -var _PrimitiveShader2 = _interopRequireDefault(_PrimitiveShader); - -var _buildPoly = require('./utils/buildPoly'); - -var _buildPoly2 = _interopRequireDefault(_buildPoly); - -var _buildRectangle = require('./utils/buildRectangle'); - -var _buildRectangle2 = _interopRequireDefault(_buildRectangle); - -var _buildRoundedRectangle = require('./utils/buildRoundedRectangle'); - -var _buildRoundedRectangle2 = _interopRequireDefault(_buildRoundedRectangle); - -var _buildCircle = require('./utils/buildCircle'); - -var _buildCircle2 = _interopRequireDefault(_buildCircle); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Renders the graphics object. - * - * @class - * @memberof PIXI - * @extends PIXI.ObjectRenderer - */ -var GraphicsRenderer = function (_ObjectRenderer) { - _inherits(GraphicsRenderer, _ObjectRenderer); - - /** - * @param {PIXI.WebGLRenderer} renderer - The renderer this object renderer works for. - */ - function GraphicsRenderer(renderer) { - _classCallCheck(this, GraphicsRenderer); - - var _this = _possibleConstructorReturn(this, _ObjectRenderer.call(this, renderer)); - - _this.graphicsDataPool = []; - - _this.primitiveShader = null; - - _this.gl = renderer.gl; - - // easy access! - _this.CONTEXT_UID = 0; - return _this; - } - - /** - * Called when there is a WebGL context change - * - * @private - * - */ - - - GraphicsRenderer.prototype.onContextChange = function onContextChange() { - this.gl = this.renderer.gl; - this.CONTEXT_UID = this.renderer.CONTEXT_UID; - this.primitiveShader = new _PrimitiveShader2.default(this.gl); - }; - - /** - * Destroys this renderer. - * - */ - - - GraphicsRenderer.prototype.destroy = function destroy() { - _ObjectRenderer3.default.prototype.destroy.call(this); - - for (var i = 0; i < this.graphicsDataPool.length; ++i) { - this.graphicsDataPool[i].destroy(); - } - - this.graphicsDataPool = null; - }; - - /** - * Renders a graphics object. - * - * @param {PIXI.Graphics} graphics - The graphics object to render. - */ - - - GraphicsRenderer.prototype.render = function render(graphics) { - var renderer = this.renderer; - var gl = renderer.gl; - - var webGLData = void 0; - var webGL = graphics._webGL[this.CONTEXT_UID]; - - if (!webGL || graphics.dirty !== webGL.dirty) { - this.updateGraphics(graphics); - - webGL = graphics._webGL[this.CONTEXT_UID]; - } - - // This could be speeded up for sure! - var shader = this.primitiveShader; - - renderer.bindShader(shader); - renderer.state.setBlendMode(graphics.blendMode); - - for (var i = 0, n = webGL.data.length; i < n; i++) { - webGLData = webGL.data[i]; - var shaderTemp = webGLData.shader; - - renderer.bindShader(shaderTemp); - shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true); - shaderTemp.uniforms.tint = (0, _utils.hex2rgb)(graphics.tint); - shaderTemp.uniforms.alpha = graphics.worldAlpha; - - renderer.bindVao(webGLData.vao); - - if (webGLData.nativeLines) { - gl.drawArrays(gl.LINES, 0, webGLData.points.length / 6); - } else { - webGLData.vao.draw(gl.TRIANGLE_STRIP, webGLData.indices.length); - } - } - }; - - /** - * Updates the graphics object - * - * @private - * @param {PIXI.Graphics} graphics - The graphics object to update - */ - - - GraphicsRenderer.prototype.updateGraphics = function updateGraphics(graphics) { - var gl = this.renderer.gl; - - // get the contexts graphics object - var webGL = graphics._webGL[this.CONTEXT_UID]; - - // if the graphics object does not exist in the webGL context time to create it! - if (!webGL) { - webGL = graphics._webGL[this.CONTEXT_UID] = { lastIndex: 0, data: [], gl: gl, clearDirty: -1, dirty: -1 }; - } - - // flag the graphics as not dirty as we are about to update it... - webGL.dirty = graphics.dirty; - - // if the user cleared the graphics object we will need to clear every object - if (graphics.clearDirty !== webGL.clearDirty) { - webGL.clearDirty = graphics.clearDirty; - - // loop through and return all the webGLDatas to the object pool so than can be reused later on - for (var i = 0; i < webGL.data.length; i++) { - this.graphicsDataPool.push(webGL.data[i]); - } - - // clear the array and reset the index.. - webGL.data.length = 0; - webGL.lastIndex = 0; - } - - var webGLData = void 0; - var webGLDataNativeLines = void 0; - - // loop through the graphics datas and construct each one.. - // if the object is a complex fill then the new stencil buffer technique will be used - // other wise graphics objects will be pushed into a batch.. - for (var _i = webGL.lastIndex; _i < graphics.graphicsData.length; _i++) { - var data = graphics.graphicsData[_i]; - - // TODO - this can be simplified - webGLData = this.getWebGLData(webGL, 0); - - if (data.nativeLines && data.lineWidth) { - webGLDataNativeLines = this.getWebGLData(webGL, 0, true); - webGL.lastIndex++; - } - - if (data.type === _const.SHAPES.POLY) { - (0, _buildPoly2.default)(data, webGLData, webGLDataNativeLines); - } - if (data.type === _const.SHAPES.RECT) { - (0, _buildRectangle2.default)(data, webGLData, webGLDataNativeLines); - } else if (data.type === _const.SHAPES.CIRC || data.type === _const.SHAPES.ELIP) { - (0, _buildCircle2.default)(data, webGLData, webGLDataNativeLines); - } else if (data.type === _const.SHAPES.RREC) { - (0, _buildRoundedRectangle2.default)(data, webGLData, webGLDataNativeLines); - } - - webGL.lastIndex++; - } - - this.renderer.bindVao(null); - - // upload all the dirty data... - for (var _i2 = 0; _i2 < webGL.data.length; _i2++) { - webGLData = webGL.data[_i2]; - - if (webGLData.dirty) { - webGLData.upload(); - } - } - }; - - /** - * - * @private - * @param {WebGLRenderingContext} gl - the current WebGL drawing context - * @param {number} type - TODO @Alvin - * @param {number} nativeLines - indicate whether the webGLData use for nativeLines. - * @return {*} TODO - */ - - - GraphicsRenderer.prototype.getWebGLData = function getWebGLData(gl, type, nativeLines) { - var webGLData = gl.data[gl.data.length - 1]; - - if (!webGLData || webGLData.nativeLines !== nativeLines || webGLData.points.length > 320000) { - webGLData = this.graphicsDataPool.pop() || new _WebGLGraphicsData2.default(this.renderer.gl, this.primitiveShader, this.renderer.state.attribsState); - webGLData.nativeLines = nativeLines; - webGLData.reset(type); - gl.data.push(webGLData); - } - - webGLData.dirty = true; - - return webGLData; - }; - - return GraphicsRenderer; -}(_ObjectRenderer3.default); - -exports.default = GraphicsRenderer; - - -_WebGLRenderer2.default.registerPlugin('graphics', GraphicsRenderer); - -},{"../../const":46,"../../renderers/webgl/WebGLRenderer":84,"../../renderers/webgl/utils/ObjectRenderer":94,"../../utils":125,"./WebGLGraphicsData":58,"./shaders/PrimitiveShader":59,"./utils/buildCircle":60,"./utils/buildPoly":62,"./utils/buildRectangle":63,"./utils/buildRoundedRectangle":64}],58:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _pixiGlCore = require('pixi-gl-core'); - -var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * An object containing WebGL specific properties to be used by the WebGL renderer - * - * @class - * @private - * @memberof PIXI - */ -var WebGLGraphicsData = function () { - /** - * @param {WebGLRenderingContext} gl - The current WebGL drawing context - * @param {PIXI.Shader} shader - The shader - * @param {object} attribsState - The state for the VAO - */ - function WebGLGraphicsData(gl, shader, attribsState) { - _classCallCheck(this, WebGLGraphicsData); - - /** - * The current WebGL drawing context - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - // TODO does this need to be split before uploading?? - /** - * An array of color components (r,g,b) - * @member {number[]} - */ - this.color = [0, 0, 0]; // color split! - - /** - * An array of points to draw - * @member {PIXI.Point[]} - */ - this.points = []; - - /** - * The indices of the vertices - * @member {number[]} - */ - this.indices = []; - /** - * The main buffer - * @member {WebGLBuffer} - */ - this.buffer = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl); - - /** - * The index buffer - * @member {WebGLBuffer} - */ - this.indexBuffer = _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl); - - /** - * Whether this graphics is dirty or not - * @member {boolean} - */ - this.dirty = true; - - /** - * Whether this graphics is nativeLines or not - * @member {boolean} - */ - this.nativeLines = false; - - this.glPoints = null; - this.glIndices = null; - - /** - * - * @member {PIXI.Shader} - */ - this.shader = shader; - - this.vao = new _pixiGlCore2.default.VertexArrayObject(gl, attribsState).addIndex(this.indexBuffer).addAttribute(this.buffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 6, 0).addAttribute(this.buffer, shader.attributes.aColor, gl.FLOAT, false, 4 * 6, 2 * 4); - } - - /** - * Resets the vertices and the indices - */ - - - WebGLGraphicsData.prototype.reset = function reset() { - this.points.length = 0; - this.indices.length = 0; - }; - - /** - * Binds the buffers and uploads the data - */ - - - WebGLGraphicsData.prototype.upload = function upload() { - this.glPoints = new Float32Array(this.points); - this.buffer.upload(this.glPoints); - - this.glIndices = new Uint16Array(this.indices); - this.indexBuffer.upload(this.glIndices); - - this.dirty = false; - }; - - /** - * Empties all the data - */ - - - WebGLGraphicsData.prototype.destroy = function destroy() { - this.color = null; - this.points = null; - this.indices = null; - - this.vao.destroy(); - this.buffer.destroy(); - this.indexBuffer.destroy(); - - this.gl = null; - - this.buffer = null; - this.indexBuffer = null; - - this.glPoints = null; - this.glIndices = null; - }; - - return WebGLGraphicsData; -}(); - -exports.default = WebGLGraphicsData; - -},{"pixi-gl-core":15}],59:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Shader2 = require('../../../Shader'); - -var _Shader3 = _interopRequireDefault(_Shader2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * This shader is used to draw simple primitive shapes for {@link PIXI.Graphics}. - * - * @class - * @memberof PIXI - * @extends PIXI.Shader - */ -var PrimitiveShader = function (_Shader) { - _inherits(PrimitiveShader, _Shader); - - /** - * @param {WebGLRenderingContext} gl - The webgl shader manager this shader works for. - */ - function PrimitiveShader(gl) { - _classCallCheck(this, PrimitiveShader); - - return _possibleConstructorReturn(this, _Shader.call(this, gl, - // vertex shader - ['attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', 'uniform mat3 translationMatrix;', 'uniform mat3 projectionMatrix;', 'uniform float alpha;', 'uniform vec3 tint;', 'varying vec4 vColor;', 'void main(void){', ' gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);', ' vColor = aColor * vec4(tint * alpha, alpha);', '}'].join('\n'), - // fragment shader - ['varying vec4 vColor;', 'void main(void){', ' gl_FragColor = vColor;', '}'].join('\n'))); - } - - return PrimitiveShader; -}(_Shader3.default); - -exports.default = PrimitiveShader; - -},{"../../../Shader":44}],60:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = buildCircle; - -var _buildLine = require('./buildLine'); - -var _buildLine2 = _interopRequireDefault(_buildLine); - -var _const = require('../../../const'); - -var _utils = require('../../../utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Builds a circle to draw - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object to draw - * @param {object} webGLData - an object containing all the webGL-specific information to create this shape - * @param {object} webGLDataNativeLines - an object containing all the webGL-specific information to create nativeLines - */ -function buildCircle(graphicsData, webGLData, webGLDataNativeLines) { - // need to convert points to a nice regular data - var circleData = graphicsData.shape; - var x = circleData.x; - var y = circleData.y; - var width = void 0; - var height = void 0; - - // TODO - bit hacky?? - if (graphicsData.type === _const.SHAPES.CIRC) { - width = circleData.radius; - height = circleData.radius; - } else { - width = circleData.width; - height = circleData.height; - } - - if (width === 0 || height === 0) { - return; - } - - var totalSegs = Math.floor(30 * Math.sqrt(circleData.radius)) || Math.floor(15 * Math.sqrt(circleData.width + circleData.height)); - - var seg = Math.PI * 2 / totalSegs; - - if (graphicsData.fill) { - var color = (0, _utils.hex2rgb)(graphicsData.fillColor); - var alpha = graphicsData.fillAlpha; - - var r = color[0] * alpha; - var g = color[1] * alpha; - var b = color[2] * alpha; - - var verts = webGLData.points; - var indices = webGLData.indices; - - var vecPos = verts.length / 6; - - indices.push(vecPos); - - for (var i = 0; i < totalSegs + 1; i++) { - verts.push(x, y, r, g, b, alpha); - - verts.push(x + Math.sin(seg * i) * width, y + Math.cos(seg * i) * height, r, g, b, alpha); - - indices.push(vecPos++, vecPos++); - } - - indices.push(vecPos - 1); - } - - if (graphicsData.lineWidth) { - var tempPoints = graphicsData.points; - - graphicsData.points = []; - - for (var _i = 0; _i < totalSegs; _i++) { - graphicsData.points.push(x + Math.sin(seg * -_i) * width, y + Math.cos(seg * -_i) * height); - } - - graphicsData.points.push(graphicsData.points[0], graphicsData.points[1]); - - (0, _buildLine2.default)(graphicsData, webGLData, webGLDataNativeLines); - - graphicsData.points = tempPoints; - } -} - -},{"../../../const":46,"../../../utils":125,"./buildLine":61}],61:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -exports.default = function (graphicsData, webGLData, webGLDataNativeLines) { - if (graphicsData.nativeLines) { - buildNativeLine(graphicsData, webGLDataNativeLines); - } else { - buildLine(graphicsData, webGLData); - } -}; - -var _math = require('../../../math'); - -var _utils = require('../../../utils'); - -/** - * Builds a line to draw using the poligon method. - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties - * @param {object} webGLData - an object containing all the webGL-specific information to create this shape - */ -function buildLine(graphicsData, webGLData) { - // TODO OPTIMISE! - var points = graphicsData.points; - - if (points.length === 0) { - return; - } - // if the line width is an odd number add 0.5 to align to a whole pixel - // commenting this out fixes #711 and #1620 - // if (graphicsData.lineWidth%2) - // { - // for (i = 0; i < points.length; i++) - // { - // points[i] += 0.5; - // } - // } - - // get first and last point.. figure out the middle! - var firstPoint = new _math.Point(points[0], points[1]); - var lastPoint = new _math.Point(points[points.length - 2], points[points.length - 1]); - - // if the first point is the last point - gonna have issues :) - if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) { - // need to clone as we are going to slightly modify the shape.. - points = points.slice(); - - points.pop(); - points.pop(); - - lastPoint = new _math.Point(points[points.length - 2], points[points.length - 1]); - - var midPointX = lastPoint.x + (firstPoint.x - lastPoint.x) * 0.5; - var midPointY = lastPoint.y + (firstPoint.y - lastPoint.y) * 0.5; - - points.unshift(midPointX, midPointY); - points.push(midPointX, midPointY); - } - - var verts = webGLData.points; - var indices = webGLData.indices; - var length = points.length / 2; - var indexCount = points.length; - var indexStart = verts.length / 6; - - // DRAW the Line - var width = graphicsData.lineWidth / 2; - - // sort color - var color = (0, _utils.hex2rgb)(graphicsData.lineColor); - var alpha = graphicsData.lineAlpha; - var r = color[0] * alpha; - var g = color[1] * alpha; - var b = color[2] * alpha; - - var p1x = points[0]; - var p1y = points[1]; - var p2x = points[2]; - var p2y = points[3]; - var p3x = 0; - var p3y = 0; - - var perpx = -(p1y - p2y); - var perpy = p1x - p2x; - var perp2x = 0; - var perp2y = 0; - var perp3x = 0; - var perp3y = 0; - - var dist = Math.sqrt(perpx * perpx + perpy * perpy); - - perpx /= dist; - perpy /= dist; - perpx *= width; - perpy *= width; - - var ratio = graphicsData.lineAlignment; // 0.5; - var r1 = (1 - ratio) * 2; - var r2 = ratio * 2; - - // start - verts.push(p1x - perpx * r1, p1y - perpy * r1, r, g, b, alpha); - - verts.push(p1x + perpx * r2, p1y + perpy * r2, r, g, b, alpha); - - for (var i = 1; i < length - 1; ++i) { - p1x = points[(i - 1) * 2]; - p1y = points[(i - 1) * 2 + 1]; - - p2x = points[i * 2]; - p2y = points[i * 2 + 1]; - - p3x = points[(i + 1) * 2]; - p3y = points[(i + 1) * 2 + 1]; - - perpx = -(p1y - p2y); - perpy = p1x - p2x; - - dist = Math.sqrt(perpx * perpx + perpy * perpy); - perpx /= dist; - perpy /= dist; - perpx *= width; - perpy *= width; - - perp2x = -(p2y - p3y); - perp2y = p2x - p3x; - - dist = Math.sqrt(perp2x * perp2x + perp2y * perp2y); - perp2x /= dist; - perp2y /= dist; - perp2x *= width; - perp2y *= width; - - var a1 = -perpy + p1y - (-perpy + p2y); - var b1 = -perpx + p2x - (-perpx + p1x); - var c1 = (-perpx + p1x) * (-perpy + p2y) - (-perpx + p2x) * (-perpy + p1y); - var a2 = -perp2y + p3y - (-perp2y + p2y); - var b2 = -perp2x + p2x - (-perp2x + p3x); - var c2 = (-perp2x + p3x) * (-perp2y + p2y) - (-perp2x + p2x) * (-perp2y + p3y); - - var denom = a1 * b2 - a2 * b1; - - if (Math.abs(denom) < 0.1) { - denom += 10.1; - verts.push(p2x - perpx * r1, p2y - perpy * r1, r, g, b, alpha); - - verts.push(p2x + perpx * r2, p2y + perpy * r2, r, g, b, alpha); - - continue; - } - - var px = (b1 * c2 - b2 * c1) / denom; - var py = (a2 * c1 - a1 * c2) / denom; - var pdist = (px - p2x) * (px - p2x) + (py - p2y) * (py - p2y); - - if (pdist > 196 * width * width) { - perp3x = perpx - perp2x; - perp3y = perpy - perp2y; - - dist = Math.sqrt(perp3x * perp3x + perp3y * perp3y); - perp3x /= dist; - perp3y /= dist; - perp3x *= width; - perp3y *= width; - - verts.push(p2x - perp3x * r1, p2y - perp3y * r1); - verts.push(r, g, b, alpha); - - verts.push(p2x + perp3x * r2, p2y + perp3y * r2); - verts.push(r, g, b, alpha); - - verts.push(p2x - perp3x * r2 * r1, p2y - perp3y * r1); - verts.push(r, g, b, alpha); - - indexCount++; - } else { - verts.push(p2x + (px - p2x) * r1, p2y + (py - p2y) * r1); - verts.push(r, g, b, alpha); - - verts.push(p2x - (px - p2x) * r2, p2y - (py - p2y) * r2); - verts.push(r, g, b, alpha); - } - } - - p1x = points[(length - 2) * 2]; - p1y = points[(length - 2) * 2 + 1]; - - p2x = points[(length - 1) * 2]; - p2y = points[(length - 1) * 2 + 1]; - - perpx = -(p1y - p2y); - perpy = p1x - p2x; - - dist = Math.sqrt(perpx * perpx + perpy * perpy); - perpx /= dist; - perpy /= dist; - perpx *= width; - perpy *= width; - - verts.push(p2x - perpx * r1, p2y - perpy * r1); - verts.push(r, g, b, alpha); - - verts.push(p2x + perpx * r2, p2y + perpy * r2); - verts.push(r, g, b, alpha); - - indices.push(indexStart); - - for (var _i = 0; _i < indexCount; ++_i) { - indices.push(indexStart++); - } - - indices.push(indexStart - 1); -} - -/** - * Builds a line to draw using the gl.drawArrays(gl.LINES) method - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties - * @param {object} webGLData - an object containing all the webGL-specific information to create this shape - */ - - -/** - * Builds a line to draw - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties - * @param {object} webGLData - an object containing all the webGL-specific information to create this shape - * @param {object} webGLDataNativeLines - an object containing all the webGL-specific information to create nativeLines - */ -function buildNativeLine(graphicsData, webGLData) { - var i = 0; - var points = graphicsData.points; - - if (points.length === 0) return; - - var verts = webGLData.points; - var length = points.length / 2; - - // sort color - var color = (0, _utils.hex2rgb)(graphicsData.lineColor); - var alpha = graphicsData.lineAlpha; - var r = color[0] * alpha; - var g = color[1] * alpha; - var b = color[2] * alpha; - - for (i = 1; i < length; i++) { - var p1x = points[(i - 1) * 2]; - var p1y = points[(i - 1) * 2 + 1]; - - var p2x = points[i * 2]; - var p2y = points[i * 2 + 1]; - - verts.push(p1x, p1y); - verts.push(r, g, b, alpha); - - verts.push(p2x, p2y); - verts.push(r, g, b, alpha); - } -} - -},{"../../../math":70,"../../../utils":125}],62:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = buildPoly; - -var _buildLine = require('./buildLine'); - -var _buildLine2 = _interopRequireDefault(_buildLine); - -var _utils = require('../../../utils'); - -var _earcut = require('earcut'); - -var _earcut2 = _interopRequireDefault(_earcut); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Builds a polygon to draw - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties - * @param {object} webGLData - an object containing all the webGL-specific information to create this shape - * @param {object} webGLDataNativeLines - an object containing all the webGL-specific information to create nativeLines - */ -function buildPoly(graphicsData, webGLData, webGLDataNativeLines) { - graphicsData.points = graphicsData.shape.points.slice(); - - var points = graphicsData.points; - - if (graphicsData.fill && points.length >= 6) { - var holeArray = []; - // Process holes.. - var holes = graphicsData.holes; - - for (var i = 0; i < holes.length; i++) { - var hole = holes[i]; - - holeArray.push(points.length / 2); - - points = points.concat(hole.points); - } - - // get first and last point.. figure out the middle! - var verts = webGLData.points; - var indices = webGLData.indices; - - var length = points.length / 2; - - // sort color - var color = (0, _utils.hex2rgb)(graphicsData.fillColor); - var alpha = graphicsData.fillAlpha; - var r = color[0] * alpha; - var g = color[1] * alpha; - var b = color[2] * alpha; - - var triangles = (0, _earcut2.default)(points, holeArray, 2); - - if (!triangles) { - return; - } - - var vertPos = verts.length / 6; - - for (var _i = 0; _i < triangles.length; _i += 3) { - indices.push(triangles[_i] + vertPos); - indices.push(triangles[_i] + vertPos); - indices.push(triangles[_i + 1] + vertPos); - indices.push(triangles[_i + 2] + vertPos); - indices.push(triangles[_i + 2] + vertPos); - } - - for (var _i2 = 0; _i2 < length; _i2++) { - verts.push(points[_i2 * 2], points[_i2 * 2 + 1], r, g, b, alpha); - } - } - - if (graphicsData.lineWidth > 0) { - (0, _buildLine2.default)(graphicsData, webGLData, webGLDataNativeLines); - } -} - -},{"../../../utils":125,"./buildLine":61,"earcut":2}],63:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = buildRectangle; - -var _buildLine = require('./buildLine'); - -var _buildLine2 = _interopRequireDefault(_buildLine); - -var _utils = require('../../../utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Builds a rectangle to draw - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties - * @param {object} webGLData - an object containing all the webGL-specific information to create this shape - * @param {object} webGLDataNativeLines - an object containing all the webGL-specific information to create nativeLines - */ -function buildRectangle(graphicsData, webGLData, webGLDataNativeLines) { - // --- // - // need to convert points to a nice regular data - // - var rectData = graphicsData.shape; - var x = rectData.x; - var y = rectData.y; - var width = rectData.width; - var height = rectData.height; - - if (graphicsData.fill) { - var color = (0, _utils.hex2rgb)(graphicsData.fillColor); - var alpha = graphicsData.fillAlpha; - - var r = color[0] * alpha; - var g = color[1] * alpha; - var b = color[2] * alpha; - - var verts = webGLData.points; - var indices = webGLData.indices; - - var vertPos = verts.length / 6; - - // start - verts.push(x, y); - verts.push(r, g, b, alpha); - - verts.push(x + width, y); - verts.push(r, g, b, alpha); - - verts.push(x, y + height); - verts.push(r, g, b, alpha); - - verts.push(x + width, y + height); - verts.push(r, g, b, alpha); - - // insert 2 dead triangles.. - indices.push(vertPos, vertPos, vertPos + 1, vertPos + 2, vertPos + 3, vertPos + 3); - } - - if (graphicsData.lineWidth) { - var tempPoints = graphicsData.points; - - graphicsData.points = [x, y, x + width, y, x + width, y + height, x, y + height, x, y]; - - (0, _buildLine2.default)(graphicsData, webGLData, webGLDataNativeLines); - - graphicsData.points = tempPoints; - } -} - -},{"../../../utils":125,"./buildLine":61}],64:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = buildRoundedRectangle; - -var _earcut = require('earcut'); - -var _earcut2 = _interopRequireDefault(_earcut); - -var _buildLine = require('./buildLine'); - -var _buildLine2 = _interopRequireDefault(_buildLine); - -var _utils = require('../../../utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Builds a rounded rectangle to draw - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties - * @param {object} webGLData - an object containing all the webGL-specific information to create this shape - * @param {object} webGLDataNativeLines - an object containing all the webGL-specific information to create nativeLines - */ -function buildRoundedRectangle(graphicsData, webGLData, webGLDataNativeLines) { - var rrectData = graphicsData.shape; - var x = rrectData.x; - var y = rrectData.y; - var width = rrectData.width; - var height = rrectData.height; - - var radius = rrectData.radius; - - var recPoints = []; - - recPoints.push(x + radius, y); - quadraticBezierCurve(x + width - radius, y, x + width, y, x + width, y + radius, recPoints); - quadraticBezierCurve(x + width, y + height - radius, x + width, y + height, x + width - radius, y + height, recPoints); - quadraticBezierCurve(x + radius, y + height, x, y + height, x, y + height - radius, recPoints); - quadraticBezierCurve(x, y + radius, x, y, x + radius + 0.0000000001, y, recPoints); - - // this tiny number deals with the issue that occurs when points overlap and earcut fails to triangulate the item. - // TODO - fix this properly, this is not very elegant.. but it works for now. - - if (graphicsData.fill) { - var color = (0, _utils.hex2rgb)(graphicsData.fillColor); - var alpha = graphicsData.fillAlpha; - - var r = color[0] * alpha; - var g = color[1] * alpha; - var b = color[2] * alpha; - - var verts = webGLData.points; - var indices = webGLData.indices; - - var vecPos = verts.length / 6; - - var triangles = (0, _earcut2.default)(recPoints, null, 2); - - for (var i = 0, j = triangles.length; i < j; i += 3) { - indices.push(triangles[i] + vecPos); - indices.push(triangles[i] + vecPos); - indices.push(triangles[i + 1] + vecPos); - indices.push(triangles[i + 2] + vecPos); - indices.push(triangles[i + 2] + vecPos); - } - - for (var _i = 0, _j = recPoints.length; _i < _j; _i++) { - verts.push(recPoints[_i], recPoints[++_i], r, g, b, alpha); - } - } - - if (graphicsData.lineWidth) { - var tempPoints = graphicsData.points; - - graphicsData.points = recPoints; - - (0, _buildLine2.default)(graphicsData, webGLData, webGLDataNativeLines); - - graphicsData.points = tempPoints; - } -} - -/** - * Calculate a single point for a quadratic bezier curve. - * Utility function used by quadraticBezierCurve. - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {number} n1 - first number - * @param {number} n2 - second number - * @param {number} perc - percentage - * @return {number} the result - * - */ -function getPt(n1, n2, perc) { - var diff = n2 - n1; - - return n1 + diff * perc; -} - -/** - * Calculate the points for a quadratic bezier curve. (helper function..) - * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c - * - * Ignored from docs since it is not directly exposed. - * - * @ignore - * @private - * @param {number} fromX - Origin point x - * @param {number} fromY - Origin point x - * @param {number} cpX - Control point x - * @param {number} cpY - Control point y - * @param {number} toX - Destination point x - * @param {number} toY - Destination point y - * @param {number[]} [out=[]] - The output array to add points into. If not passed, a new array is created. - * @return {number[]} an array of points - */ -function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) { - var out = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : []; - - var n = 20; - var points = out; - - var xa = 0; - var ya = 0; - var xb = 0; - var yb = 0; - var x = 0; - var y = 0; - - for (var i = 0, j = 0; i <= n; ++i) { - j = i / n; - - // The Green Line - xa = getPt(fromX, cpX, j); - ya = getPt(fromY, cpY, j); - xb = getPt(cpX, toX, j); - yb = getPt(cpY, toY, j); - - // The Black Dot - x = getPt(xa, xb, j); - y = getPt(ya, yb, j); - - points.push(x, y); - } - - return points; -} - -},{"../../../utils":125,"./buildLine":61,"earcut":2}],65:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.autoDetectRenderer = exports.Application = exports.Filter = exports.SpriteMaskFilter = exports.Quad = exports.RenderTarget = exports.ObjectRenderer = exports.WebGLManager = exports.Shader = exports.CanvasRenderTarget = exports.TextureUvs = exports.VideoBaseTexture = exports.BaseRenderTexture = exports.RenderTexture = exports.BaseTexture = exports.TextureMatrix = exports.Texture = exports.Spritesheet = exports.CanvasGraphicsRenderer = exports.GraphicsRenderer = exports.GraphicsData = exports.Graphics = exports.TextMetrics = exports.TextStyle = exports.Text = exports.SpriteRenderer = exports.CanvasTinter = exports.CanvasSpriteRenderer = exports.Sprite = exports.TransformBase = exports.TransformStatic = exports.Transform = exports.Container = exports.DisplayObject = exports.Bounds = exports.glCore = exports.WebGLRenderer = exports.CanvasRenderer = exports.ticker = exports.utils = exports.settings = undefined; - -var _const = require('./const'); - -Object.keys(_const).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _const[key]; - } - }); -}); - -var _math = require('./math'); - -Object.keys(_math).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _math[key]; - } - }); -}); - -var _pixiGlCore = require('pixi-gl-core'); - -Object.defineProperty(exports, 'glCore', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_pixiGlCore).default; - } -}); - -var _Bounds = require('./display/Bounds'); - -Object.defineProperty(exports, 'Bounds', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Bounds).default; - } -}); - -var _DisplayObject = require('./display/DisplayObject'); - -Object.defineProperty(exports, 'DisplayObject', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_DisplayObject).default; - } -}); - -var _Container = require('./display/Container'); - -Object.defineProperty(exports, 'Container', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Container).default; - } -}); - -var _Transform = require('./display/Transform'); - -Object.defineProperty(exports, 'Transform', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Transform).default; - } -}); - -var _TransformStatic = require('./display/TransformStatic'); - -Object.defineProperty(exports, 'TransformStatic', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TransformStatic).default; - } -}); - -var _TransformBase = require('./display/TransformBase'); - -Object.defineProperty(exports, 'TransformBase', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TransformBase).default; - } -}); - -var _Sprite = require('./sprites/Sprite'); - -Object.defineProperty(exports, 'Sprite', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Sprite).default; - } -}); - -var _CanvasSpriteRenderer = require('./sprites/canvas/CanvasSpriteRenderer'); - -Object.defineProperty(exports, 'CanvasSpriteRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_CanvasSpriteRenderer).default; - } -}); - -var _CanvasTinter = require('./sprites/canvas/CanvasTinter'); - -Object.defineProperty(exports, 'CanvasTinter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_CanvasTinter).default; - } -}); - -var _SpriteRenderer = require('./sprites/webgl/SpriteRenderer'); - -Object.defineProperty(exports, 'SpriteRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_SpriteRenderer).default; - } -}); - -var _Text = require('./text/Text'); - -Object.defineProperty(exports, 'Text', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Text).default; - } -}); - -var _TextStyle = require('./text/TextStyle'); - -Object.defineProperty(exports, 'TextStyle', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TextStyle).default; - } -}); - -var _TextMetrics = require('./text/TextMetrics'); - -Object.defineProperty(exports, 'TextMetrics', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TextMetrics).default; - } -}); - -var _Graphics = require('./graphics/Graphics'); - -Object.defineProperty(exports, 'Graphics', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Graphics).default; - } -}); - -var _GraphicsData = require('./graphics/GraphicsData'); - -Object.defineProperty(exports, 'GraphicsData', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_GraphicsData).default; - } -}); - -var _GraphicsRenderer = require('./graphics/webgl/GraphicsRenderer'); - -Object.defineProperty(exports, 'GraphicsRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_GraphicsRenderer).default; - } -}); - -var _CanvasGraphicsRenderer = require('./graphics/canvas/CanvasGraphicsRenderer'); - -Object.defineProperty(exports, 'CanvasGraphicsRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_CanvasGraphicsRenderer).default; - } -}); - -var _Spritesheet = require('./textures/Spritesheet'); - -Object.defineProperty(exports, 'Spritesheet', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Spritesheet).default; - } -}); - -var _Texture = require('./textures/Texture'); - -Object.defineProperty(exports, 'Texture', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Texture).default; - } -}); - -var _TextureMatrix = require('./textures/TextureMatrix'); - -Object.defineProperty(exports, 'TextureMatrix', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TextureMatrix).default; - } -}); - -var _BaseTexture = require('./textures/BaseTexture'); - -Object.defineProperty(exports, 'BaseTexture', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_BaseTexture).default; - } -}); - -var _RenderTexture = require('./textures/RenderTexture'); - -Object.defineProperty(exports, 'RenderTexture', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_RenderTexture).default; - } -}); - -var _BaseRenderTexture = require('./textures/BaseRenderTexture'); - -Object.defineProperty(exports, 'BaseRenderTexture', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_BaseRenderTexture).default; - } -}); - -var _VideoBaseTexture = require('./textures/VideoBaseTexture'); - -Object.defineProperty(exports, 'VideoBaseTexture', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_VideoBaseTexture).default; - } -}); - -var _TextureUvs = require('./textures/TextureUvs'); - -Object.defineProperty(exports, 'TextureUvs', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TextureUvs).default; - } -}); - -var _CanvasRenderTarget = require('./renderers/canvas/utils/CanvasRenderTarget'); - -Object.defineProperty(exports, 'CanvasRenderTarget', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_CanvasRenderTarget).default; - } -}); - -var _Shader = require('./Shader'); - -Object.defineProperty(exports, 'Shader', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Shader).default; - } -}); - -var _WebGLManager = require('./renderers/webgl/managers/WebGLManager'); - -Object.defineProperty(exports, 'WebGLManager', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_WebGLManager).default; - } -}); - -var _ObjectRenderer = require('./renderers/webgl/utils/ObjectRenderer'); - -Object.defineProperty(exports, 'ObjectRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_ObjectRenderer).default; - } -}); - -var _RenderTarget = require('./renderers/webgl/utils/RenderTarget'); - -Object.defineProperty(exports, 'RenderTarget', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_RenderTarget).default; - } -}); - -var _Quad = require('./renderers/webgl/utils/Quad'); - -Object.defineProperty(exports, 'Quad', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Quad).default; - } -}); - -var _SpriteMaskFilter = require('./renderers/webgl/filters/spriteMask/SpriteMaskFilter'); - -Object.defineProperty(exports, 'SpriteMaskFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_SpriteMaskFilter).default; - } -}); - -var _Filter = require('./renderers/webgl/filters/Filter'); - -Object.defineProperty(exports, 'Filter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Filter).default; - } -}); - -var _Application = require('./Application'); - -Object.defineProperty(exports, 'Application', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Application).default; - } -}); - -var _autoDetectRenderer = require('./autoDetectRenderer'); - -Object.defineProperty(exports, 'autoDetectRenderer', { - enumerable: true, - get: function get() { - return _autoDetectRenderer.autoDetectRenderer; - } -}); - -var _utils = require('./utils'); - -var utils = _interopRequireWildcard(_utils); - -var _ticker = require('./ticker'); - -var ticker = _interopRequireWildcard(_ticker); - -var _settings = require('./settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _CanvasRenderer = require('./renderers/canvas/CanvasRenderer'); - -var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer); - -var _WebGLRenderer = require('./renderers/webgl/WebGLRenderer'); - -var _WebGLRenderer2 = _interopRequireDefault(_WebGLRenderer); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -exports.settings = _settings2.default; -exports.utils = utils; -exports.ticker = ticker; -exports.CanvasRenderer = _CanvasRenderer2.default; -exports.WebGLRenderer = _WebGLRenderer2.default; /** - * @namespace PIXI - */ - -},{"./Application":43,"./Shader":44,"./autoDetectRenderer":45,"./const":46,"./display/Bounds":47,"./display/Container":48,"./display/DisplayObject":49,"./display/Transform":50,"./display/TransformBase":51,"./display/TransformStatic":52,"./graphics/Graphics":53,"./graphics/GraphicsData":54,"./graphics/canvas/CanvasGraphicsRenderer":55,"./graphics/webgl/GraphicsRenderer":57,"./math":70,"./renderers/canvas/CanvasRenderer":77,"./renderers/canvas/utils/CanvasRenderTarget":79,"./renderers/webgl/WebGLRenderer":84,"./renderers/webgl/filters/Filter":86,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":89,"./renderers/webgl/managers/WebGLManager":93,"./renderers/webgl/utils/ObjectRenderer":94,"./renderers/webgl/utils/Quad":95,"./renderers/webgl/utils/RenderTarget":96,"./settings":101,"./sprites/Sprite":102,"./sprites/canvas/CanvasSpriteRenderer":103,"./sprites/canvas/CanvasTinter":104,"./sprites/webgl/SpriteRenderer":106,"./text/Text":108,"./text/TextMetrics":109,"./text/TextStyle":110,"./textures/BaseRenderTexture":111,"./textures/BaseTexture":112,"./textures/RenderTexture":113,"./textures/Spritesheet":114,"./textures/Texture":115,"./textures/TextureMatrix":116,"./textures/TextureUvs":117,"./textures/VideoBaseTexture":118,"./ticker":121,"./utils":125,"pixi-gl-core":15}],66:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Matrix = require('./Matrix'); - -var _Matrix2 = _interopRequireDefault(_Matrix); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; // Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16 - -var uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1]; -var vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1]; -var vy = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1]; -var tempMatrices = []; - -var mul = []; - -function signum(x) { - if (x < 0) { - return -1; - } - if (x > 0) { - return 1; - } - - return 0; -} - -function init() { - for (var i = 0; i < 16; i++) { - var row = []; - - mul.push(row); - - for (var j = 0; j < 16; j++) { - var _ux = signum(ux[i] * ux[j] + vx[i] * uy[j]); - var _uy = signum(uy[i] * ux[j] + vy[i] * uy[j]); - var _vx = signum(ux[i] * vx[j] + vx[i] * vy[j]); - var _vy = signum(uy[i] * vx[j] + vy[i] * vy[j]); - - for (var k = 0; k < 16; k++) { - if (ux[k] === _ux && uy[k] === _uy && vx[k] === _vx && vy[k] === _vy) { - row.push(k); - break; - } - } - } - } - - for (var _i = 0; _i < 16; _i++) { - var mat = new _Matrix2.default(); - - mat.set(ux[_i], uy[_i], vx[_i], vy[_i], 0, 0); - tempMatrices.push(mat); - } -} - -init(); - -/** - * Implements Dihedral Group D_8, see [group D4]{@link http://mathworld.wolfram.com/DihedralGroupD4.html}, - * D8 is the same but with diagonals. Used for texture rotations. - * - * Vector xX(i), xY(i) is U-axis of sprite with rotation i - * Vector yY(i), yY(i) is V-axis of sprite with rotation i - * Rotations: 0 grad (0), 90 grad (2), 180 grad (4), 270 grad (6) - * Mirrors: vertical (8), main diagonal (10), horizontal (12), reverse diagonal (14) - * This is the small part of gameofbombs.com portal system. It works. - * - * @author Ivan @ivanpopelyshev - * @class - * @memberof PIXI - */ -var GroupD8 = { - E: 0, - SE: 1, - S: 2, - SW: 3, - W: 4, - NW: 5, - N: 6, - NE: 7, - MIRROR_VERTICAL: 8, - MIRROR_HORIZONTAL: 12, - uX: function uX(ind) { - return ux[ind]; - }, - uY: function uY(ind) { - return uy[ind]; - }, - vX: function vX(ind) { - return vx[ind]; - }, - vY: function vY(ind) { - return vy[ind]; - }, - inv: function inv(rotation) { - if (rotation & 8) { - return rotation & 15; - } - - return -rotation & 7; - }, - add: function add(rotationSecond, rotationFirst) { - return mul[rotationSecond][rotationFirst]; - }, - sub: function sub(rotationSecond, rotationFirst) { - return mul[rotationSecond][GroupD8.inv(rotationFirst)]; - }, - - /** - * Adds 180 degrees to rotation. Commutative operation. - * - * @memberof PIXI.GroupD8 - * @param {number} rotation - The number to rotate. - * @returns {number} rotated number - */ - rotate180: function rotate180(rotation) { - return rotation ^ 4; - }, - - /** - * Direction of main vector can be horizontal, vertical or diagonal. - * Some objects work with vertical directions different. - * - * @memberof PIXI.GroupD8 - * @param {number} rotation - The number to check. - * @returns {boolean} Whether or not the direction is vertical - */ - isVertical: function isVertical(rotation) { - return (rotation & 3) === 2; - }, - - /** - * @memberof PIXI.GroupD8 - * @param {number} dx - TODO - * @param {number} dy - TODO - * - * @return {number} TODO - */ - byDirection: function byDirection(dx, dy) { - if (Math.abs(dx) * 2 <= Math.abs(dy)) { - if (dy >= 0) { - return GroupD8.S; - } - - return GroupD8.N; - } else if (Math.abs(dy) * 2 <= Math.abs(dx)) { - if (dx > 0) { - return GroupD8.E; - } - - return GroupD8.W; - } else if (dy > 0) { - if (dx > 0) { - return GroupD8.SE; - } - - return GroupD8.SW; - } else if (dx > 0) { - return GroupD8.NE; - } - - return GroupD8.NW; - }, - - /** - * Helps sprite to compensate texture packer rotation. - * - * @memberof PIXI.GroupD8 - * @param {PIXI.Matrix} matrix - sprite world matrix - * @param {number} rotation - The rotation factor to use. - * @param {number} tx - sprite anchoring - * @param {number} ty - sprite anchoring - */ - matrixAppendRotationInv: function matrixAppendRotationInv(matrix, rotation) { - var tx = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var ty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; - - // Packer used "rotation", we use "inv(rotation)" - var mat = tempMatrices[GroupD8.inv(rotation)]; - - mat.tx = tx; - mat.ty = ty; - matrix.append(mat); - } -}; - -exports.default = GroupD8; - -},{"./Matrix":67}],67:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _Point = require('./Point'); - -var _Point2 = _interopRequireDefault(_Point); - -var _const = require('../const'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * The PixiJS Matrix class as an object, which makes it a lot faster, - * here is a representation of it : - * | a | c | tx| - * | b | d | ty| - * | 0 | 0 | 1 | - * - * @class - * @memberof PIXI - */ -var Matrix = function () { - /** - * @param {number} [a=1] - x scale - * @param {number} [b=0] - x skew - * @param {number} [c=0] - y skew - * @param {number} [d=1] - y scale - * @param {number} [tx=0] - x translation - * @param {number} [ty=0] - y translation - */ - function Matrix() { - var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var c = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var d = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; - var tx = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; - var ty = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; - - _classCallCheck(this, Matrix); - - /** - * @member {number} - * @default 1 - */ - this.a = a; - - /** - * @member {number} - * @default 0 - */ - this.b = b; - - /** - * @member {number} - * @default 0 - */ - this.c = c; - - /** - * @member {number} - * @default 1 - */ - this.d = d; - - /** - * @member {number} - * @default 0 - */ - this.tx = tx; - - /** - * @member {number} - * @default 0 - */ - this.ty = ty; - - this.array = null; - } - - /** - * Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows: - * - * a = array[0] - * b = array[1] - * c = array[3] - * d = array[4] - * tx = array[2] - * ty = array[5] - * - * @param {number[]} array - The array that the matrix will be populated from. - */ - - - Matrix.prototype.fromArray = function fromArray(array) { - this.a = array[0]; - this.b = array[1]; - this.c = array[3]; - this.d = array[4]; - this.tx = array[2]; - this.ty = array[5]; - }; - - /** - * sets the matrix properties - * - * @param {number} a - Matrix component - * @param {number} b - Matrix component - * @param {number} c - Matrix component - * @param {number} d - Matrix component - * @param {number} tx - Matrix component - * @param {number} ty - Matrix component - * - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.set = function set(a, b, c, d, tx, ty) { - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - - return this; - }; - - /** - * Creates an array from the current Matrix object. - * - * @param {boolean} transpose - Whether we need to transpose the matrix or not - * @param {Float32Array} [out=new Float32Array(9)] - If provided the array will be assigned to out - * @return {number[]} the newly created array which contains the matrix - */ - - - Matrix.prototype.toArray = function toArray(transpose, out) { - if (!this.array) { - this.array = new Float32Array(9); - } - - var array = out || this.array; - - if (transpose) { - array[0] = this.a; - array[1] = this.b; - array[2] = 0; - array[3] = this.c; - array[4] = this.d; - array[5] = 0; - array[6] = this.tx; - array[7] = this.ty; - array[8] = 1; - } else { - array[0] = this.a; - array[1] = this.c; - array[2] = this.tx; - array[3] = this.b; - array[4] = this.d; - array[5] = this.ty; - array[6] = 0; - array[7] = 0; - array[8] = 1; - } - - return array; - }; - - /** - * Get a new position with the current transformation applied. - * Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering) - * - * @param {PIXI.Point} pos - The origin - * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input) - * @return {PIXI.Point} The new point, transformed through this matrix - */ - - - Matrix.prototype.apply = function apply(pos, newPos) { - newPos = newPos || new _Point2.default(); - - var x = pos.x; - var y = pos.y; - - newPos.x = this.a * x + this.c * y + this.tx; - newPos.y = this.b * x + this.d * y + this.ty; - - return newPos; - }; - - /** - * Get a new position with the inverse of the current transformation applied. - * Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input) - * - * @param {PIXI.Point} pos - The origin - * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input) - * @return {PIXI.Point} The new point, inverse-transformed through this matrix - */ - - - Matrix.prototype.applyInverse = function applyInverse(pos, newPos) { - newPos = newPos || new _Point2.default(); - - var id = 1 / (this.a * this.d + this.c * -this.b); - - var x = pos.x; - var y = pos.y; - - newPos.x = this.d * id * x + -this.c * id * y + (this.ty * this.c - this.tx * this.d) * id; - newPos.y = this.a * id * y + -this.b * id * x + (-this.ty * this.a + this.tx * this.b) * id; - - return newPos; - }; - - /** - * Translates the matrix on the x and y. - * - * @param {number} x How much to translate x by - * @param {number} y How much to translate y by - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.translate = function translate(x, y) { - this.tx += x; - this.ty += y; - - return this; - }; - - /** - * Applies a scale transformation to the matrix. - * - * @param {number} x The amount to scale horizontally - * @param {number} y The amount to scale vertically - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.scale = function scale(x, y) { - this.a *= x; - this.d *= y; - this.c *= x; - this.b *= y; - this.tx *= x; - this.ty *= y; - - return this; - }; - - /** - * Applies a rotation transformation to the matrix. - * - * @param {number} angle - The angle in radians. - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.rotate = function rotate(angle) { - var cos = Math.cos(angle); - var sin = Math.sin(angle); - - var a1 = this.a; - var c1 = this.c; - var tx1 = this.tx; - - this.a = a1 * cos - this.b * sin; - this.b = a1 * sin + this.b * cos; - this.c = c1 * cos - this.d * sin; - this.d = c1 * sin + this.d * cos; - this.tx = tx1 * cos - this.ty * sin; - this.ty = tx1 * sin + this.ty * cos; - - return this; - }; - - /** - * Appends the given Matrix to this Matrix. - * - * @param {PIXI.Matrix} matrix - The matrix to append. - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.append = function append(matrix) { - var a1 = this.a; - var b1 = this.b; - var c1 = this.c; - var d1 = this.d; - - this.a = matrix.a * a1 + matrix.b * c1; - this.b = matrix.a * b1 + matrix.b * d1; - this.c = matrix.c * a1 + matrix.d * c1; - this.d = matrix.c * b1 + matrix.d * d1; - - this.tx = matrix.tx * a1 + matrix.ty * c1 + this.tx; - this.ty = matrix.tx * b1 + matrix.ty * d1 + this.ty; - - return this; - }; - - /** - * Sets the matrix based on all the available properties - * - * @param {number} x - Position on the x axis - * @param {number} y - Position on the y axis - * @param {number} pivotX - Pivot on the x axis - * @param {number} pivotY - Pivot on the y axis - * @param {number} scaleX - Scale on the x axis - * @param {number} scaleY - Scale on the y axis - * @param {number} rotation - Rotation in radians - * @param {number} skewX - Skew on the x axis - * @param {number} skewY - Skew on the y axis - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.setTransform = function setTransform(x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) { - this.a = Math.cos(rotation + skewY) * scaleX; - this.b = Math.sin(rotation + skewY) * scaleX; - this.c = -Math.sin(rotation - skewX) * scaleY; - this.d = Math.cos(rotation - skewX) * scaleY; - - this.tx = x - (pivotX * this.a + pivotY * this.c); - this.ty = y - (pivotX * this.b + pivotY * this.d); - - return this; - }; - - /** - * Prepends the given Matrix to this Matrix. - * - * @param {PIXI.Matrix} matrix - The matrix to prepend - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.prepend = function prepend(matrix) { - var tx1 = this.tx; - - if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) { - var a1 = this.a; - var c1 = this.c; - - this.a = a1 * matrix.a + this.b * matrix.c; - this.b = a1 * matrix.b + this.b * matrix.d; - this.c = c1 * matrix.a + this.d * matrix.c; - this.d = c1 * matrix.b + this.d * matrix.d; - } - - this.tx = tx1 * matrix.a + this.ty * matrix.c + matrix.tx; - this.ty = tx1 * matrix.b + this.ty * matrix.d + matrix.ty; - - return this; - }; - - /** - * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform. - * - * @param {PIXI.Transform|PIXI.TransformStatic} transform - The transform to apply the properties to. - * @return {PIXI.Transform|PIXI.TransformStatic} The transform with the newly applied properties - */ - - - Matrix.prototype.decompose = function decompose(transform) { - // sort out rotation / skew.. - var a = this.a; - var b = this.b; - var c = this.c; - var d = this.d; - - var skewX = -Math.atan2(-c, d); - var skewY = Math.atan2(b, a); - - var delta = Math.abs(skewX + skewY); - - if (delta < 0.00001 || Math.abs(_const.PI_2 - delta) < 0.00001) { - transform.rotation = skewY; - transform.skew.x = transform.skew.y = 0; - } else { - transform.rotation = 0; - transform.skew.x = skewX; - transform.skew.y = skewY; - } - - // next set scale - transform.scale.x = Math.sqrt(a * a + b * b); - transform.scale.y = Math.sqrt(c * c + d * d); - - // next set position - transform.position.x = this.tx; - transform.position.y = this.ty; - - return transform; - }; - - /** - * Inverts this matrix - * - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.invert = function invert() { - var a1 = this.a; - var b1 = this.b; - var c1 = this.c; - var d1 = this.d; - var tx1 = this.tx; - var n = a1 * d1 - b1 * c1; - - this.a = d1 / n; - this.b = -b1 / n; - this.c = -c1 / n; - this.d = a1 / n; - this.tx = (c1 * this.ty - d1 * tx1) / n; - this.ty = -(a1 * this.ty - b1 * tx1) / n; - - return this; - }; - - /** - * Resets this Matix to an identity (default) matrix. - * - * @return {PIXI.Matrix} This matrix. Good for chaining method calls. - */ - - - Matrix.prototype.identity = function identity() { - this.a = 1; - this.b = 0; - this.c = 0; - this.d = 1; - this.tx = 0; - this.ty = 0; - - return this; - }; - - /** - * Creates a new Matrix object with the same values as this one. - * - * @return {PIXI.Matrix} A copy of this matrix. Good for chaining method calls. - */ - - - Matrix.prototype.clone = function clone() { - var matrix = new Matrix(); - - matrix.a = this.a; - matrix.b = this.b; - matrix.c = this.c; - matrix.d = this.d; - matrix.tx = this.tx; - matrix.ty = this.ty; - - return matrix; - }; - - /** - * Changes the values of the given matrix to be the same as the ones in this matrix - * - * @param {PIXI.Matrix} matrix - The matrix to copy from. - * @return {PIXI.Matrix} The matrix given in parameter with its values updated. - */ - - - Matrix.prototype.copy = function copy(matrix) { - matrix.a = this.a; - matrix.b = this.b; - matrix.c = this.c; - matrix.d = this.d; - matrix.tx = this.tx; - matrix.ty = this.ty; - - return matrix; - }; - - /** - * A default (identity) matrix - * - * @static - * @const - */ - - - _createClass(Matrix, null, [{ - key: 'IDENTITY', - get: function get() { - return new Matrix(); - } - - /** - * A temp matrix - * - * @static - * @const - */ - - }, { - key: 'TEMP_MATRIX', - get: function get() { - return new Matrix(); - } - }]); - - return Matrix; -}(); - -exports.default = Matrix; - -},{"../const":46,"./Point":69}],68:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. - * An observable point is a point that triggers a callback when the point's position is changed. - * - * @class - * @memberof PIXI - */ -var ObservablePoint = function () { - /** - * @param {Function} cb - callback when changed - * @param {object} scope - owner of callback - * @param {number} [x=0] - position of the point on the x axis - * @param {number} [y=0] - position of the point on the y axis - */ - function ObservablePoint(cb, scope) { - var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; - - _classCallCheck(this, ObservablePoint); - - this._x = x; - this._y = y; - - this.cb = cb; - this.scope = scope; - } - - /** - * Creates a clone of this point. - * The callback and scope params can be overidden otherwise they will default - * to the clone object's values. - * - * @override - * @param {Function} [cb=null] - callback when changed - * @param {object} [scope=null] - owner of callback - * @return {PIXI.ObservablePoint} a copy of the point - */ - - - ObservablePoint.prototype.clone = function clone() { - var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - - var _cb = cb || this.cb; - var _scope = scope || this.scope; - - return new ObservablePoint(_cb, _scope, this._x, this._y); - }; - - /** - * Sets the point to a new x and y position. - * If y is omitted, both x and y will be set to x. - * - * @param {number} [x=0] - position of the point on the x axis - * @param {number} [y=0] - position of the point on the y axis - */ - - - ObservablePoint.prototype.set = function set(x, y) { - var _x = x || 0; - var _y = y || (y !== 0 ? _x : 0); - - if (this._x !== _x || this._y !== _y) { - this._x = _x; - this._y = _y; - this.cb.call(this.scope); - } - }; - - /** - * Copies the data from another point - * - * @param {PIXI.Point|PIXI.ObservablePoint} point - point to copy from - */ - - - ObservablePoint.prototype.copy = function copy(point) { - if (this._x !== point.x || this._y !== point.y) { - this._x = point.x; - this._y = point.y; - this.cb.call(this.scope); - } - }; - - /** - * Returns true if the given point is equal to this point - * - * @param {PIXI.Point|PIXI.ObservablePoint} p - The point to check - * @returns {boolean} Whether the given point equal to this point - */ - - - ObservablePoint.prototype.equals = function equals(p) { - return p.x === this._x && p.y === this._y; - }; - - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - */ - - - _createClass(ObservablePoint, [{ - key: "x", - get: function get() { - return this._x; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (this._x !== value) { - this._x = value; - this.cb.call(this.scope); - } - } - - /** - * The position of the displayObject on the x axis relative to the local coordinates of the parent. - * - * @member {number} - */ - - }, { - key: "y", - get: function get() { - return this._y; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (this._y !== value) { - this._y = value; - this.cb.call(this.scope); - } - } - }]); - - return ObservablePoint; -}(); - -exports.default = ObservablePoint; - -},{}],69:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. - * - * @class - * @memberof PIXI - */ -var Point = function () { - /** - * @param {number} [x=0] - position of the point on the x axis - * @param {number} [y=0] - position of the point on the y axis - */ - function Point() { - var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - - _classCallCheck(this, Point); - - /** - * @member {number} - * @default 0 - */ - this.x = x; - - /** - * @member {number} - * @default 0 - */ - this.y = y; - } - - /** - * Creates a clone of this point - * - * @return {PIXI.Point} a copy of the point - */ - - - Point.prototype.clone = function clone() { - return new Point(this.x, this.y); - }; - - /** - * Copies x and y from the given point - * - * @param {PIXI.Point} p - The point to copy. - */ - - - Point.prototype.copy = function copy(p) { - this.set(p.x, p.y); - }; - - /** - * Returns true if the given point is equal to this point - * - * @param {PIXI.Point} p - The point to check - * @returns {boolean} Whether the given point equal to this point - */ - - - Point.prototype.equals = function equals(p) { - return p.x === this.x && p.y === this.y; - }; - - /** - * Sets the point to a new x and y position. - * If y is omitted, both x and y will be set to x. - * - * @param {number} [x=0] - position of the point on the x axis - * @param {number} [y=0] - position of the point on the y axis - */ - - - Point.prototype.set = function set(x, y) { - this.x = x || 0; - this.y = y || (y !== 0 ? this.x : 0); - }; - - return Point; -}(); - -exports.default = Point; - -},{}],70:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Point = require('./Point'); - -Object.defineProperty(exports, 'Point', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Point).default; - } -}); - -var _ObservablePoint = require('./ObservablePoint'); - -Object.defineProperty(exports, 'ObservablePoint', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_ObservablePoint).default; - } -}); - -var _Matrix = require('./Matrix'); - -Object.defineProperty(exports, 'Matrix', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Matrix).default; - } -}); - -var _GroupD = require('./GroupD8'); - -Object.defineProperty(exports, 'GroupD8', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_GroupD).default; - } -}); - -var _Circle = require('./shapes/Circle'); - -Object.defineProperty(exports, 'Circle', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Circle).default; - } -}); - -var _Ellipse = require('./shapes/Ellipse'); - -Object.defineProperty(exports, 'Ellipse', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Ellipse).default; - } -}); - -var _Polygon = require('./shapes/Polygon'); - -Object.defineProperty(exports, 'Polygon', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Polygon).default; - } -}); - -var _Rectangle = require('./shapes/Rectangle'); - -Object.defineProperty(exports, 'Rectangle', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Rectangle).default; - } -}); - -var _RoundedRectangle = require('./shapes/RoundedRectangle'); - -Object.defineProperty(exports, 'RoundedRectangle', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_RoundedRectangle).default; - } -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"./GroupD8":66,"./Matrix":67,"./ObservablePoint":68,"./Point":69,"./shapes/Circle":71,"./shapes/Ellipse":72,"./shapes/Polygon":73,"./shapes/Rectangle":74,"./shapes/RoundedRectangle":75}],71:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Rectangle = require('./Rectangle'); - -var _Rectangle2 = _interopRequireDefault(_Rectangle); - -var _const = require('../../const'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * The Circle object can be used to specify a hit area for displayObjects - * - * @class - * @memberof PIXI - */ -var Circle = function () { - /** - * @param {number} [x=0] - The X coordinate of the center of this circle - * @param {number} [y=0] - The Y coordinate of the center of this circle - * @param {number} [radius=0] - The radius of the circle - */ - function Circle() { - var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var radius = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - - _classCallCheck(this, Circle); - - /** - * @member {number} - * @default 0 - */ - this.x = x; - - /** - * @member {number} - * @default 0 - */ - this.y = y; - - /** - * @member {number} - * @default 0 - */ - this.radius = radius; - - /** - * The type of the object, mainly used to avoid `instanceof` checks - * - * @member {number} - * @readOnly - * @default PIXI.SHAPES.CIRC - * @see PIXI.SHAPES - */ - this.type = _const.SHAPES.CIRC; - } - - /** - * Creates a clone of this Circle instance - * - * @return {PIXI.Circle} a copy of the Circle - */ - - - Circle.prototype.clone = function clone() { - return new Circle(this.x, this.y, this.radius); - }; - - /** - * Checks whether the x and y coordinates given are contained within this circle - * - * @param {number} x - The X coordinate of the point to test - * @param {number} y - The Y coordinate of the point to test - * @return {boolean} Whether the x/y coordinates are within this Circle - */ - - - Circle.prototype.contains = function contains(x, y) { - if (this.radius <= 0) { - return false; - } - - var r2 = this.radius * this.radius; - var dx = this.x - x; - var dy = this.y - y; - - dx *= dx; - dy *= dy; - - return dx + dy <= r2; - }; - - /** - * Returns the framing rectangle of the circle as a Rectangle object - * - * @return {PIXI.Rectangle} the framing rectangle - */ - - - Circle.prototype.getBounds = function getBounds() { - return new _Rectangle2.default(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); - }; - - return Circle; -}(); - -exports.default = Circle; - -},{"../../const":46,"./Rectangle":74}],72:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Rectangle = require('./Rectangle'); - -var _Rectangle2 = _interopRequireDefault(_Rectangle); - -var _const = require('../../const'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * The Ellipse object can be used to specify a hit area for displayObjects - * - * @class - * @memberof PIXI - */ -var Ellipse = function () { - /** - * @param {number} [x=0] - The X coordinate of the center of this ellipse - * @param {number} [y=0] - The Y coordinate of the center of this ellipse - * @param {number} [halfWidth=0] - The half width of this ellipse - * @param {number} [halfHeight=0] - The half height of this ellipse - */ - function Ellipse() { - var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var halfWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var halfHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; - - _classCallCheck(this, Ellipse); - - /** - * @member {number} - * @default 0 - */ - this.x = x; - - /** - * @member {number} - * @default 0 - */ - this.y = y; - - /** - * @member {number} - * @default 0 - */ - this.width = halfWidth; - - /** - * @member {number} - * @default 0 - */ - this.height = halfHeight; - - /** - * The type of the object, mainly used to avoid `instanceof` checks - * - * @member {number} - * @readOnly - * @default PIXI.SHAPES.ELIP - * @see PIXI.SHAPES - */ - this.type = _const.SHAPES.ELIP; - } - - /** - * Creates a clone of this Ellipse instance - * - * @return {PIXI.Ellipse} a copy of the ellipse - */ - - - Ellipse.prototype.clone = function clone() { - return new Ellipse(this.x, this.y, this.width, this.height); - }; - - /** - * Checks whether the x and y coordinates given are contained within this ellipse - * - * @param {number} x - The X coordinate of the point to test - * @param {number} y - The Y coordinate of the point to test - * @return {boolean} Whether the x/y coords are within this ellipse - */ - - - Ellipse.prototype.contains = function contains(x, y) { - if (this.width <= 0 || this.height <= 0) { - return false; - } - - // normalize the coords to an ellipse with center 0,0 - var normx = (x - this.x) / this.width; - var normy = (y - this.y) / this.height; - - normx *= normx; - normy *= normy; - - return normx + normy <= 1; - }; - - /** - * Returns the framing rectangle of the ellipse as a Rectangle object - * - * @return {PIXI.Rectangle} the framing rectangle - */ - - - Ellipse.prototype.getBounds = function getBounds() { - return new _Rectangle2.default(this.x - this.width, this.y - this.height, this.width, this.height); - }; - - return Ellipse; -}(); - -exports.default = Ellipse; - -},{"../../const":46,"./Rectangle":74}],73:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Point = require('../Point'); - -var _Point2 = _interopRequireDefault(_Point); - -var _const = require('../../const'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * @class - * @memberof PIXI - */ -var Polygon = function () { - /** - * @param {PIXI.Point[]|number[]} points - This can be an array of Points - * that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or - * the arguments passed can be all the points of the polygon e.g. - * `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the arguments passed can be flat - * x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers. - */ - function Polygon() { - for (var _len = arguments.length, points = Array(_len), _key = 0; _key < _len; _key++) { - points[_key] = arguments[_key]; - } - - _classCallCheck(this, Polygon); - - if (Array.isArray(points[0])) { - points = points[0]; - } - - // if this is an array of points, convert it to a flat array of numbers - if (points[0] instanceof _Point2.default) { - var p = []; - - for (var i = 0, il = points.length; i < il; i++) { - p.push(points[i].x, points[i].y); - } - - points = p; - } - - this.closed = true; - - /** - * An array of the points of this polygon - * - * @member {number[]} - */ - this.points = points; - - /** - * The type of the object, mainly used to avoid `instanceof` checks - * - * @member {number} - * @readOnly - * @default PIXI.SHAPES.POLY - * @see PIXI.SHAPES - */ - this.type = _const.SHAPES.POLY; - } - - /** - * Creates a clone of this polygon - * - * @return {PIXI.Polygon} a copy of the polygon - */ - - - Polygon.prototype.clone = function clone() { - return new Polygon(this.points.slice()); - }; - - /** - * Closes the polygon, adding points if necessary. - * - */ - - - Polygon.prototype.close = function close() { - var points = this.points; - - // close the poly if the value is true! - if (points[0] !== points[points.length - 2] || points[1] !== points[points.length - 1]) { - points.push(points[0], points[1]); - } - }; - - /** - * Checks whether the x and y coordinates passed to this function are contained within this polygon - * - * @param {number} x - The X coordinate of the point to test - * @param {number} y - The Y coordinate of the point to test - * @return {boolean} Whether the x/y coordinates are within this polygon - */ - - - Polygon.prototype.contains = function contains(x, y) { - var inside = false; - - // use some raycasting to test hits - // https://github.com/substack/point-in-polygon/blob/master/index.js - var length = this.points.length / 2; - - for (var i = 0, j = length - 1; i < length; j = i++) { - var xi = this.points[i * 2]; - var yi = this.points[i * 2 + 1]; - var xj = this.points[j * 2]; - var yj = this.points[j * 2 + 1]; - var intersect = yi > y !== yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi; - - if (intersect) { - inside = !inside; - } - } - - return inside; - }; - - return Polygon; -}(); - -exports.default = Polygon; - -},{"../../const":46,"../Point":69}],74:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _const = require('../../const'); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Rectangle object is an area defined by its position, as indicated by its top-left corner - * point (x, y) and by its width and its height. - * - * @class - * @memberof PIXI - */ -var Rectangle = function () { - /** - * @param {number} [x=0] - The X coordinate of the upper-left corner of the rectangle - * @param {number} [y=0] - The Y coordinate of the upper-left corner of the rectangle - * @param {number} [width=0] - The overall width of this rectangle - * @param {number} [height=0] - The overall height of this rectangle - */ - function Rectangle() { - var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var height = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; - - _classCallCheck(this, Rectangle); - - /** - * @member {number} - * @default 0 - */ - this.x = Number(x); - - /** - * @member {number} - * @default 0 - */ - this.y = Number(y); - - /** - * @member {number} - * @default 0 - */ - this.width = Number(width); - - /** - * @member {number} - * @default 0 - */ - this.height = Number(height); - - /** - * The type of the object, mainly used to avoid `instanceof` checks - * - * @member {number} - * @readOnly - * @default PIXI.SHAPES.RECT - * @see PIXI.SHAPES - */ - this.type = _const.SHAPES.RECT; - } - - /** - * returns the left edge of the rectangle - * - * @member {number} - */ - - - /** - * Creates a clone of this Rectangle - * - * @return {PIXI.Rectangle} a copy of the rectangle - */ - Rectangle.prototype.clone = function clone() { - return new Rectangle(this.x, this.y, this.width, this.height); - }; - - /** - * Copies another rectangle to this one. - * - * @param {PIXI.Rectangle} rectangle - The rectangle to copy. - * @return {PIXI.Rectangle} Returns itself. - */ - - - Rectangle.prototype.copy = function copy(rectangle) { - this.x = rectangle.x; - this.y = rectangle.y; - this.width = rectangle.width; - this.height = rectangle.height; - - return this; - }; - - /** - * Checks whether the x and y coordinates given are contained within this Rectangle - * - * @param {number} x - The X coordinate of the point to test - * @param {number} y - The Y coordinate of the point to test - * @return {boolean} Whether the x/y coordinates are within this Rectangle - */ - - - Rectangle.prototype.contains = function contains(x, y) { - if (this.width <= 0 || this.height <= 0) { - return false; - } - - if (x >= this.x && x < this.x + this.width) { - if (y >= this.y && y < this.y + this.height) { - return true; - } - } - - return false; - }; - - /** - * Pads the rectangle making it grow in all directions. - * - * @param {number} paddingX - The horizontal padding amount. - * @param {number} [paddingY] - The vertical padding amount. - */ - - - Rectangle.prototype.pad = function pad(paddingX, paddingY) { - paddingX = paddingX || 0; - paddingY = paddingY || (paddingY !== 0 ? paddingX : 0); - - this.x -= paddingX; - this.y -= paddingY; - - this.width += paddingX * 2; - this.height += paddingY * 2; - }; - - /** - * Fits this rectangle around the passed one. - * - * @param {PIXI.Rectangle} rectangle - The rectangle to fit. - */ - - - Rectangle.prototype.fit = function fit(rectangle) { - var x1 = Math.max(this.x, rectangle.x); - var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width); - var y1 = Math.max(this.y, rectangle.y); - var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height); - - this.x = x1; - this.width = Math.max(x2 - x1, 0); - this.y = y1; - this.height = Math.max(y2 - y1, 0); - }; - - /** - * Enlarges this rectangle to include the passed rectangle. - * - * @param {PIXI.Rectangle} rectangle - The rectangle to include. - */ - - - Rectangle.prototype.enlarge = function enlarge(rectangle) { - var x1 = Math.min(this.x, rectangle.x); - var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width); - var y1 = Math.min(this.y, rectangle.y); - var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height); - - this.x = x1; - this.width = x2 - x1; - this.y = y1; - this.height = y2 - y1; - }; - - /** - * Enlarges rectangle that way its corners lie on grid - * - * @param {number} [resolution=1] resolution - * @param {number} [eps=0.001] precision - */ - - - Rectangle.prototype.ceil = function ceil() { - var resolution = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - var eps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.001; - - var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution; - var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution; - - this.x = Math.floor((this.x + eps) * resolution) / resolution; - this.y = Math.floor((this.y + eps) * resolution) / resolution; - - this.width = x2 - this.x; - this.height = y2 - this.y; - }; - - _createClass(Rectangle, [{ - key: 'left', - get: function get() { - return this.x; - } - - /** - * returns the right edge of the rectangle - * - * @member {number} - */ - - }, { - key: 'right', - get: function get() { - return this.x + this.width; - } - - /** - * returns the top edge of the rectangle - * - * @member {number} - */ - - }, { - key: 'top', - get: function get() { - return this.y; - } - - /** - * returns the bottom edge of the rectangle - * - * @member {number} - */ - - }, { - key: 'bottom', - get: function get() { - return this.y + this.height; - } - - /** - * A constant empty rectangle. - * - * @static - * @constant - */ - - }], [{ - key: 'EMPTY', - get: function get() { - return new Rectangle(0, 0, 0, 0); - } - }]); - - return Rectangle; -}(); - -exports.default = Rectangle; - -},{"../../const":46}],75:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _const = require('../../const'); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * The Rounded Rectangle object is an area that has nice rounded corners, as indicated by its - * top-left corner point (x, y) and by its width and its height and its radius. - * - * @class - * @memberof PIXI - */ -var RoundedRectangle = function () { - /** - * @param {number} [x=0] - The X coordinate of the upper-left corner of the rounded rectangle - * @param {number} [y=0] - The Y coordinate of the upper-left corner of the rounded rectangle - * @param {number} [width=0] - The overall width of this rounded rectangle - * @param {number} [height=0] - The overall height of this rounded rectangle - * @param {number} [radius=20] - Controls the radius of the rounded corners - */ - function RoundedRectangle() { - var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var height = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; - var radius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 20; - - _classCallCheck(this, RoundedRectangle); - - /** - * @member {number} - * @default 0 - */ - this.x = x; - - /** - * @member {number} - * @default 0 - */ - this.y = y; - - /** - * @member {number} - * @default 0 - */ - this.width = width; - - /** - * @member {number} - * @default 0 - */ - this.height = height; - - /** - * @member {number} - * @default 20 - */ - this.radius = radius; - - /** - * The type of the object, mainly used to avoid `instanceof` checks - * - * @member {number} - * @readonly - * @default PIXI.SHAPES.RREC - * @see PIXI.SHAPES - */ - this.type = _const.SHAPES.RREC; - } - - /** - * Creates a clone of this Rounded Rectangle - * - * @return {PIXI.RoundedRectangle} a copy of the rounded rectangle - */ - - - RoundedRectangle.prototype.clone = function clone() { - return new RoundedRectangle(this.x, this.y, this.width, this.height, this.radius); - }; - - /** - * Checks whether the x and y coordinates given are contained within this Rounded Rectangle - * - * @param {number} x - The X coordinate of the point to test - * @param {number} y - The Y coordinate of the point to test - * @return {boolean} Whether the x/y coordinates are within this Rounded Rectangle - */ - - - RoundedRectangle.prototype.contains = function contains(x, y) { - if (this.width <= 0 || this.height <= 0) { - return false; - } - if (x >= this.x && x <= this.x + this.width) { - if (y >= this.y && y <= this.y + this.height) { - if (y >= this.y + this.radius && y <= this.y + this.height - this.radius || x >= this.x + this.radius && x <= this.x + this.width - this.radius) { - return true; - } - var dx = x - (this.x + this.radius); - var dy = y - (this.y + this.radius); - var radius2 = this.radius * this.radius; - - if (dx * dx + dy * dy <= radius2) { - return true; - } - dx = x - (this.x + this.width - this.radius); - if (dx * dx + dy * dy <= radius2) { - return true; - } - dy = y - (this.y + this.height - this.radius); - if (dx * dx + dy * dy <= radius2) { - return true; - } - dx = x - (this.x + this.radius); - if (dx * dx + dy * dy <= radius2) { - return true; - } - } - } - - return false; - }; - - return RoundedRectangle; -}(); - -exports.default = RoundedRectangle; - -},{"../../const":46}],76:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _utils = require('../utils'); - -var _math = require('../math'); - -var _const = require('../const'); - -var _settings = require('../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _Container = require('../display/Container'); - -var _Container2 = _interopRequireDefault(_Container); - -var _RenderTexture = require('../textures/RenderTexture'); - -var _RenderTexture2 = _interopRequireDefault(_RenderTexture); - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var tempMatrix = new _math.Matrix(); - -/** - * The SystemRenderer is the base for a PixiJS Renderer. It is extended by the {@link PIXI.CanvasRenderer} - * and {@link PIXI.WebGLRenderer} which can be used for rendering a PixiJS scene. - * - * @abstract - * @class - * @extends EventEmitter - * @memberof PIXI - */ - -var SystemRenderer = function (_EventEmitter) { - _inherits(SystemRenderer, _EventEmitter); - - // eslint-disable-next-line valid-jsdoc - /** - * @param {string} system - The name of the system this renderer is for. - * @param {object} [options] - The optional renderer parameters - * @param {number} [options.width=800] - the width of the screen - * @param {number} [options.height=600] - the height of the screen - * @param {HTMLCanvasElement} [options.view] - the canvas to use as a view, optional - * @param {boolean} [options.transparent=false] - If the render view is transparent, default false - * @param {boolean} [options.autoResize=false] - If the render view is automatically resized, default false - * @param {boolean} [options.antialias=false] - sets antialias (only applicable in chrome at the moment) - * @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer. The - * resolution of the renderer retina would be 2. - * @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, - * enable this if you need to call toDataUrl on the webgl context. - * @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or - * not before the new render pass. - * @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area - * (shown if not transparent). - * @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when rendering, - * stopping pixel interpolation. - */ - function SystemRenderer(system, options, arg2, arg3) { - _classCallCheck(this, SystemRenderer); - - var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - - (0, _utils.sayHello)(system); - - // Support for constructor(system, screenWidth, screenHeight, options) - if (typeof options === 'number') { - options = Object.assign({ - width: options, - height: arg2 || _settings2.default.RENDER_OPTIONS.height - }, arg3); - } - - // Add the default render options - options = Object.assign({}, _settings2.default.RENDER_OPTIONS, options); - - /** - * The supplied constructor options. - * - * @member {Object} - * @readOnly - */ - _this.options = options; - - /** - * The type of the renderer. - * - * @member {number} - * @default PIXI.RENDERER_TYPE.UNKNOWN - * @see PIXI.RENDERER_TYPE - */ - _this.type = _const.RENDERER_TYPE.UNKNOWN; - - /** - * Measurements of the screen. (0, 0, screenWidth, screenHeight) - * - * Its safe to use as filterArea or hitArea for whole stage - * - * @member {PIXI.Rectangle} - */ - _this.screen = new _math.Rectangle(0, 0, options.width, options.height); - - /** - * The canvas element that everything is drawn to - * - * @member {HTMLCanvasElement} - */ - _this.view = options.view || document.createElement('canvas'); - - /** - * The resolution / device pixel ratio of the renderer - * - * @member {number} - * @default 1 - */ - _this.resolution = options.resolution || _settings2.default.RESOLUTION; - - /** - * Whether the render view is transparent - * - * @member {boolean} - */ - _this.transparent = options.transparent; - - /** - * Whether css dimensions of canvas view should be resized to screen dimensions automatically - * - * @member {boolean} - */ - _this.autoResize = options.autoResize || false; - - /** - * Tracks the blend modes useful for this renderer. - * - * @member {object} - */ - _this.blendModes = null; - - /** - * The value of the preserveDrawingBuffer flag affects whether or not the contents of - * the stencil buffer is retained after rendering. - * - * @member {boolean} - */ - _this.preserveDrawingBuffer = options.preserveDrawingBuffer; - - /** - * This sets if the CanvasRenderer will clear the canvas or not before the new render pass. - * If the scene is NOT transparent PixiJS will use a canvas sized fillRect operation every - * frame to set the canvas background color. If the scene is transparent PixiJS will use clearRect - * to clear the canvas every frame. Disable this by setting this to false. For example if - * your game has a canvas filling background image you often don't need this set. - * - * @member {boolean} - * @default - */ - _this.clearBeforeRender = options.clearBeforeRender; - - /** - * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. - * Handy for crisp pixel art and speed on legacy devices. - * - * @member {boolean} - */ - _this.roundPixels = options.roundPixels; - - /** - * The background color as a number. - * - * @member {number} - * @private - */ - _this._backgroundColor = 0x000000; - - /** - * The background color as an [R, G, B] array. - * - * @member {number[]} - * @private - */ - _this._backgroundColorRgba = [0, 0, 0, 0]; - - /** - * The background color as a string. - * - * @member {string} - * @private - */ - _this._backgroundColorString = '#000000'; - - _this.backgroundColor = options.backgroundColor || _this._backgroundColor; // run bg color setter - - /** - * This temporary display object used as the parent of the currently being rendered item - * - * @member {PIXI.DisplayObject} - * @private - */ - _this._tempDisplayObjectParent = new _Container2.default(); - - /** - * The last root object that the renderer tried to render. - * - * @member {PIXI.DisplayObject} - * @private - */ - _this._lastObjectRendered = _this._tempDisplayObjectParent; - return _this; - } - - /** - * Same as view.width, actual number of pixels in the canvas by horizontal - * - * @member {number} - * @readonly - * @default 800 - */ - - - /** - * Resizes the screen and canvas to the specified width and height - * Canvas dimensions are multiplied by resolution - * - * @param {number} screenWidth - the new width of the screen - * @param {number} screenHeight - the new height of the screen - */ - SystemRenderer.prototype.resize = function resize(screenWidth, screenHeight) { - this.screen.width = screenWidth; - this.screen.height = screenHeight; - - this.view.width = screenWidth * this.resolution; - this.view.height = screenHeight * this.resolution; - - if (this.autoResize) { - this.view.style.width = screenWidth + 'px'; - this.view.style.height = screenHeight + 'px'; - } - }; - - /** - * Useful function that returns a texture of the display object that can then be used to create sprites - * This can be quite useful if your displayObject is complicated and needs to be reused multiple times. - * - * @param {PIXI.DisplayObject} displayObject - The displayObject the object will be generated from - * @param {number} scaleMode - Should be one of the scaleMode consts - * @param {number} resolution - The resolution / device pixel ratio of the texture being generated - * @param {PIXI.Rectangle} [region] - The region of the displayObject, that shall be rendered, - * if no region is specified, defaults to the local bounds of the displayObject. - * @return {PIXI.Texture} a texture of the graphics object - */ - - - SystemRenderer.prototype.generateTexture = function generateTexture(displayObject, scaleMode, resolution, region) { - region = region || displayObject.getLocalBounds(); - - var renderTexture = _RenderTexture2.default.create(region.width | 0, region.height | 0, scaleMode, resolution); - - tempMatrix.tx = -region.x; - tempMatrix.ty = -region.y; - - this.render(displayObject, renderTexture, false, tempMatrix, !!displayObject.parent); - - return renderTexture; - }; - - /** - * Removes everything from the renderer and optionally removes the Canvas DOM element. - * - * @param {boolean} [removeView=false] - Removes the Canvas element from the DOM. - */ - - - SystemRenderer.prototype.destroy = function destroy(removeView) { - if (removeView && this.view.parentNode) { - this.view.parentNode.removeChild(this.view); - } - - this.type = _const.RENDERER_TYPE.UNKNOWN; - - this.view = null; - - this.screen = null; - - this.resolution = 0; - - this.transparent = false; - - this.autoResize = false; - - this.blendModes = null; - - this.options = null; - - this.preserveDrawingBuffer = false; - this.clearBeforeRender = false; - - this.roundPixels = false; - - this._backgroundColor = 0; - this._backgroundColorRgba = null; - this._backgroundColorString = null; - - this._tempDisplayObjectParent = null; - this._lastObjectRendered = null; - }; - - /** - * The background color to fill if not transparent - * - * @member {number} - */ - - - _createClass(SystemRenderer, [{ - key: 'width', - get: function get() { - return this.view.width; - } - - /** - * Same as view.height, actual number of pixels in the canvas by vertical - * - * @member {number} - * @readonly - * @default 600 - */ - - }, { - key: 'height', - get: function get() { - return this.view.height; - } - }, { - key: 'backgroundColor', - get: function get() { - return this._backgroundColor; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._backgroundColor = value; - this._backgroundColorString = (0, _utils.hex2string)(value); - (0, _utils.hex2rgb)(value, this._backgroundColorRgba); - } - }]); - - return SystemRenderer; -}(_eventemitter2.default); - -exports.default = SystemRenderer; - -},{"../const":46,"../display/Container":48,"../math":70,"../settings":101,"../textures/RenderTexture":113,"../utils":125,"eventemitter3":3}],77:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _SystemRenderer2 = require('../SystemRenderer'); - -var _SystemRenderer3 = _interopRequireDefault(_SystemRenderer2); - -var _CanvasMaskManager = require('./utils/CanvasMaskManager'); - -var _CanvasMaskManager2 = _interopRequireDefault(_CanvasMaskManager); - -var _CanvasRenderTarget = require('./utils/CanvasRenderTarget'); - -var _CanvasRenderTarget2 = _interopRequireDefault(_CanvasRenderTarget); - -var _mapCanvasBlendModesToPixi = require('./utils/mapCanvasBlendModesToPixi'); - -var _mapCanvasBlendModesToPixi2 = _interopRequireDefault(_mapCanvasBlendModesToPixi); - -var _utils = require('../../utils'); - -var _const = require('../../const'); - -var _settings = require('../../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The CanvasRenderer draws the scene and all its content onto a 2d canvas. This renderer should - * be used for browsers that do not support WebGL. Don't forget to add the CanvasRenderer.view to - * your DOM or you will not see anything :) - * - * @class - * @memberof PIXI - * @extends PIXI.SystemRenderer - */ -var CanvasRenderer = function (_SystemRenderer) { - _inherits(CanvasRenderer, _SystemRenderer); - - // eslint-disable-next-line valid-jsdoc - /** - * @param {object} [options] - The optional renderer parameters - * @param {number} [options.width=800] - the width of the screen - * @param {number} [options.height=600] - the height of the screen - * @param {HTMLCanvasElement} [options.view] - the canvas to use as a view, optional - * @param {boolean} [options.transparent=false] - If the render view is transparent, default false - * @param {boolean} [options.autoResize=false] - If the render view is automatically resized, default false - * @param {boolean} [options.antialias=false] - sets antialias (only applicable in chrome at the moment) - * @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer. The - * resolution of the renderer retina would be 2. - * @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, - * enable this if you need to call toDataUrl on the webgl context. - * @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or - * not before the new render pass. - * @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area - * (shown if not transparent). - * @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when rendering, - * stopping pixel interpolation. - */ - function CanvasRenderer(options, arg2, arg3) { - _classCallCheck(this, CanvasRenderer); - - var _this = _possibleConstructorReturn(this, _SystemRenderer.call(this, 'Canvas', options, arg2, arg3)); - - _this.type = _const.RENDERER_TYPE.CANVAS; - - /** - * The root canvas 2d context that everything is drawn with. - * - * @member {CanvasRenderingContext2D} - */ - _this.rootContext = _this.view.getContext('2d', { alpha: _this.transparent }); - - /** - * The currently active canvas 2d context (could change with renderTextures) - * - * @member {CanvasRenderingContext2D} - */ - _this.context = _this.rootContext; - - /** - * Boolean flag controlling canvas refresh. - * - * @member {boolean} - */ - _this.refresh = true; - - /** - * Instance of a CanvasMaskManager, handles masking when using the canvas renderer. - * - * @member {PIXI.CanvasMaskManager} - */ - _this.maskManager = new _CanvasMaskManager2.default(_this); - - /** - * The canvas property used to set the canvas smoothing property. - * - * @member {string} - */ - _this.smoothProperty = 'imageSmoothingEnabled'; - - if (!_this.rootContext.imageSmoothingEnabled) { - if (_this.rootContext.webkitImageSmoothingEnabled) { - _this.smoothProperty = 'webkitImageSmoothingEnabled'; - } else if (_this.rootContext.mozImageSmoothingEnabled) { - _this.smoothProperty = 'mozImageSmoothingEnabled'; - } else if (_this.rootContext.oImageSmoothingEnabled) { - _this.smoothProperty = 'oImageSmoothingEnabled'; - } else if (_this.rootContext.msImageSmoothingEnabled) { - _this.smoothProperty = 'msImageSmoothingEnabled'; - } - } - - _this.initPlugins(); - - _this.blendModes = (0, _mapCanvasBlendModesToPixi2.default)(); - _this._activeBlendMode = null; - - _this.renderingToScreen = false; - - _this.resize(_this.options.width, _this.options.height); - - /** - * Fired after rendering finishes. - * - * @event PIXI.CanvasRenderer#postrender - */ - - /** - * Fired before rendering starts. - * - * @event PIXI.CanvasRenderer#prerender - */ - return _this; - } - - /** - * Renders the object to this canvas view - * - * @param {PIXI.DisplayObject} displayObject - The object to be rendered - * @param {PIXI.RenderTexture} [renderTexture] - A render texture to be rendered to. - * If unset, it will render to the root context. - * @param {boolean} [clear=false] - Whether to clear the canvas before drawing - * @param {PIXI.Matrix} [transform] - A transformation to be applied - * @param {boolean} [skipUpdateTransform=false] - Whether to skip the update transform - */ - - - CanvasRenderer.prototype.render = function render(displayObject, renderTexture, clear, transform, skipUpdateTransform) { - if (!this.view) { - return; - } - - // can be handy to know! - this.renderingToScreen = !renderTexture; - - this.emit('prerender'); - - var rootResolution = this.resolution; - - if (renderTexture) { - renderTexture = renderTexture.baseTexture || renderTexture; - - if (!renderTexture._canvasRenderTarget) { - renderTexture._canvasRenderTarget = new _CanvasRenderTarget2.default(renderTexture.width, renderTexture.height, renderTexture.resolution); - renderTexture.source = renderTexture._canvasRenderTarget.canvas; - renderTexture.valid = true; - } - - this.context = renderTexture._canvasRenderTarget.context; - this.resolution = renderTexture._canvasRenderTarget.resolution; - } else { - this.context = this.rootContext; - } - - var context = this.context; - - if (!renderTexture) { - this._lastObjectRendered = displayObject; - } - - if (!skipUpdateTransform) { - // update the scene graph - var cacheParent = displayObject.parent; - var tempWt = this._tempDisplayObjectParent.transform.worldTransform; - - if (transform) { - transform.copy(tempWt); - - // lets not forget to flag the parent transform as dirty... - this._tempDisplayObjectParent.transform._worldID = -1; - } else { - tempWt.identity(); - } - - displayObject.parent = this._tempDisplayObjectParent; - - displayObject.updateTransform(); - displayObject.parent = cacheParent; - // displayObject.hitArea = //TODO add a temp hit area - } - - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.globalAlpha = 1; - this._activeBlendMode = _const.BLEND_MODES.NORMAL; - context.globalCompositeOperation = this.blendModes[_const.BLEND_MODES.NORMAL]; - - if (navigator.isCocoonJS && this.view.screencanvas) { - context.fillStyle = 'black'; - context.clear(); - } - - if (clear !== undefined ? clear : this.clearBeforeRender) { - if (this.renderingToScreen) { - if (this.transparent) { - context.clearRect(0, 0, this.width, this.height); - } else { - context.fillStyle = this._backgroundColorString; - context.fillRect(0, 0, this.width, this.height); - } - } // else { - // TODO: implement background for CanvasRenderTarget or RenderTexture? - // } - } - - // TODO RENDER TARGET STUFF HERE.. - var tempContext = this.context; - - this.context = context; - displayObject.renderCanvas(this); - this.context = tempContext; - - context.restore(); - - this.resolution = rootResolution; - - this.emit('postrender'); - }; - - /** - * Clear the canvas of renderer. - * - * @param {string} [clearColor] - Clear the canvas with this color, except the canvas is transparent. - */ - - - CanvasRenderer.prototype.clear = function clear(clearColor) { - var context = this.context; - - clearColor = clearColor || this._backgroundColorString; - - if (!this.transparent && clearColor) { - context.fillStyle = clearColor; - context.fillRect(0, 0, this.width, this.height); - } else { - context.clearRect(0, 0, this.width, this.height); - } - }; - - /** - * Sets the blend mode of the renderer. - * - * @param {number} blendMode - See {@link PIXI.BLEND_MODES} for valid values. - */ - - - CanvasRenderer.prototype.setBlendMode = function setBlendMode(blendMode) { - if (this._activeBlendMode === blendMode) { - return; - } - - this._activeBlendMode = blendMode; - this.context.globalCompositeOperation = this.blendModes[blendMode]; - }; - - /** - * Removes everything from the renderer and optionally removes the Canvas DOM element. - * - * @param {boolean} [removeView=false] - Removes the Canvas element from the DOM. - */ - - - CanvasRenderer.prototype.destroy = function destroy(removeView) { - this.destroyPlugins(); - - // call the base destroy - _SystemRenderer.prototype.destroy.call(this, removeView); - - this.context = null; - - this.refresh = true; - - this.maskManager.destroy(); - this.maskManager = null; - - this.smoothProperty = null; - }; - - /** - * Resizes the canvas view to the specified width and height. - * - * @extends PIXI.SystemRenderer#resize - * - * @param {number} screenWidth - the new width of the screen - * @param {number} screenHeight - the new height of the screen - */ - - - CanvasRenderer.prototype.resize = function resize(screenWidth, screenHeight) { - _SystemRenderer.prototype.resize.call(this, screenWidth, screenHeight); - - // reset the scale mode.. oddly this seems to be reset when the canvas is resized. - // surely a browser bug?? Let PixiJS fix that for you.. - if (this.smoothProperty) { - this.rootContext[this.smoothProperty] = _settings2.default.SCALE_MODE === _const.SCALE_MODES.LINEAR; - } - }; - - /** - * Checks if blend mode has changed. - */ - - - CanvasRenderer.prototype.invalidateBlendMode = function invalidateBlendMode() { - this._activeBlendMode = this.blendModes.indexOf(this.context.globalCompositeOperation); - }; - - return CanvasRenderer; -}(_SystemRenderer3.default); - -/** - * Collection of installed plugins. These are included by default in PIXI, but can be excluded - * by creating a custom build. Consult the README for more information about creating custom - * builds and excluding plugins. - * @name PIXI.CanvasRenderer#plugins - * @type {object} - * @readonly - * @property {PIXI.accessibility.AccessibilityManager} accessibility Support tabbing interactive elements. - * @property {PIXI.extract.CanvasExtract} extract Extract image data from renderer. - * @property {PIXI.interaction.InteractionManager} interaction Handles mouse, touch and pointer events. - * @property {PIXI.prepare.CanvasPrepare} prepare Pre-render display objects. - */ - -/** - * Adds a plugin to the renderer. - * - * @method PIXI.CanvasRenderer#registerPlugin - * @param {string} pluginName - The name of the plugin. - * @param {Function} ctor - The constructor function or class for the plugin. - */ - -exports.default = CanvasRenderer; -_utils.pluginTarget.mixin(CanvasRenderer); - -},{"../../const":46,"../../settings":101,"../../utils":125,"../SystemRenderer":76,"./utils/CanvasMaskManager":78,"./utils/CanvasRenderTarget":79,"./utils/mapCanvasBlendModesToPixi":81}],78:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _const = require('../../../const'); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * A set of functions used to handle masking. - * - * @class - * @memberof PIXI - */ -var CanvasMaskManager = function () { - /** - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ - function CanvasMaskManager(renderer) { - _classCallCheck(this, CanvasMaskManager); - - this.renderer = renderer; - } - - /** - * This method adds it to the current stack of masks. - * - * @param {object} maskData - the maskData that will be pushed - */ - - - CanvasMaskManager.prototype.pushMask = function pushMask(maskData) { - var renderer = this.renderer; - - renderer.context.save(); - - var cacheAlpha = maskData.alpha; - var transform = maskData.transform.worldTransform; - var resolution = renderer.resolution; - - renderer.context.setTransform(transform.a * resolution, transform.b * resolution, transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution); - - // TODO suport sprite alpha masks?? - // lots of effort required. If demand is great enough.. - if (!maskData._texture) { - this.renderGraphicsShape(maskData); - renderer.context.clip(); - } - - maskData.worldAlpha = cacheAlpha; - }; - - /** - * Renders a PIXI.Graphics shape. - * - * @param {PIXI.Graphics} graphics - The object to render. - */ - - - CanvasMaskManager.prototype.renderGraphicsShape = function renderGraphicsShape(graphics) { - var context = this.renderer.context; - var len = graphics.graphicsData.length; - - if (len === 0) { - return; - } - - context.beginPath(); - - for (var i = 0; i < len; i++) { - var data = graphics.graphicsData[i]; - var shape = data.shape; - - if (data.type === _const.SHAPES.POLY) { - var points = shape.points; - var holes = data.holes; - var outerArea = void 0; - var innerArea = void 0; - - context.moveTo(points[0], points[1]); - - for (var j = 2; j < points.length; j += 2) { - context.lineTo(points[j], points[j + 1]); - } - - // if the first and last point are the same close the path - much neater :) - if (points[0] === points[points.length - 2] && points[1] === points[points.length - 1]) { - context.closePath(); - } - - if (holes.length > 0) { - outerArea = 0; - for (var _j = 0; _j < points.length; _j += 2) { - outerArea += points[_j] * points[_j + 3] - points[_j + 1] * points[_j + 2]; - } - - for (var k = 0; k < holes.length; k++) { - points = holes[k].points; - - innerArea = 0; - for (var _j2 = 0; _j2 < points.length; _j2 += 2) { - innerArea += points[_j2] * points[_j2 + 3] - points[_j2 + 1] * points[_j2 + 2]; - } - - context.moveTo(points[0], points[1]); - - if (innerArea * outerArea < 0) { - for (var _j3 = 2; _j3 < points.length; _j3 += 2) { - context.lineTo(points[_j3], points[_j3 + 1]); - } - } else { - for (var _j4 = points.length - 2; _j4 >= 2; _j4 -= 2) { - context.lineTo(points[_j4], points[_j4 + 1]); - } - } - } - } - } else if (data.type === _const.SHAPES.RECT) { - context.rect(shape.x, shape.y, shape.width, shape.height); - context.closePath(); - } else if (data.type === _const.SHAPES.CIRC) { - // TODO - need to be Undefined! - context.arc(shape.x, shape.y, shape.radius, 0, 2 * Math.PI); - context.closePath(); - } else if (data.type === _const.SHAPES.ELIP) { - // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas - - var w = shape.width * 2; - var h = shape.height * 2; - - var x = shape.x - w / 2; - var y = shape.y - h / 2; - - var kappa = 0.5522848; - var ox = w / 2 * kappa; // control point offset horizontal - var oy = h / 2 * kappa; // control point offset vertical - var xe = x + w; // x-end - var ye = y + h; // y-end - var xm = x + w / 2; // x-middle - var ym = y + h / 2; // y-middle - - context.moveTo(x, ym); - context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); - context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); - context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); - context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); - context.closePath(); - } else if (data.type === _const.SHAPES.RREC) { - var rx = shape.x; - var ry = shape.y; - var width = shape.width; - var height = shape.height; - var radius = shape.radius; - - var maxRadius = Math.min(width, height) / 2 | 0; - - radius = radius > maxRadius ? maxRadius : radius; - - context.moveTo(rx, ry + radius); - context.lineTo(rx, ry + height - radius); - context.quadraticCurveTo(rx, ry + height, rx + radius, ry + height); - context.lineTo(rx + width - radius, ry + height); - context.quadraticCurveTo(rx + width, ry + height, rx + width, ry + height - radius); - context.lineTo(rx + width, ry + radius); - context.quadraticCurveTo(rx + width, ry, rx + width - radius, ry); - context.lineTo(rx + radius, ry); - context.quadraticCurveTo(rx, ry, rx, ry + radius); - context.closePath(); - } - } - }; - - /** - * Restores the current drawing context to the state it was before the mask was applied. - * - * @param {PIXI.CanvasRenderer} renderer - The renderer context to use. - */ - - - CanvasMaskManager.prototype.popMask = function popMask(renderer) { - renderer.context.restore(); - renderer.invalidateBlendMode(); - }; - - /** - * Destroys this canvas mask manager. - * - */ - - - CanvasMaskManager.prototype.destroy = function destroy() { - /* empty */ - }; - - return CanvasMaskManager; -}(); - -exports.default = CanvasMaskManager; - -},{"../../../const":46}],79:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _settings = require('../../../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Creates a Canvas element of the given size. - * - * @class - * @memberof PIXI - */ -var CanvasRenderTarget = function () { - /** - * @param {number} width - the width for the newly created canvas - * @param {number} height - the height for the newly created canvas - * @param {number} [resolution=1] - The resolution / device pixel ratio of the canvas - */ - function CanvasRenderTarget(width, height, resolution) { - _classCallCheck(this, CanvasRenderTarget); - - /** - * The Canvas object that belongs to this CanvasRenderTarget. - * - * @member {HTMLCanvasElement} - */ - this.canvas = document.createElement('canvas'); - - /** - * A CanvasRenderingContext2D object representing a two-dimensional rendering context. - * - * @member {CanvasRenderingContext2D} - */ - this.context = this.canvas.getContext('2d'); - - this.resolution = resolution || _settings2.default.RESOLUTION; - - this.resize(width, height); - } - - /** - * Clears the canvas that was created by the CanvasRenderTarget class. - * - * @private - */ - - - CanvasRenderTarget.prototype.clear = function clear() { - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); - }; - - /** - * Resizes the canvas to the specified width and height. - * - * @param {number} width - the new width of the canvas - * @param {number} height - the new height of the canvas - */ - - - CanvasRenderTarget.prototype.resize = function resize(width, height) { - this.canvas.width = width * this.resolution; - this.canvas.height = height * this.resolution; - }; - - /** - * Destroys this canvas. - * - */ - - - CanvasRenderTarget.prototype.destroy = function destroy() { - this.context = null; - this.canvas = null; - }; - - /** - * The width of the canvas buffer in pixels. - * - * @member {number} - */ - - - _createClass(CanvasRenderTarget, [{ - key: 'width', - get: function get() { - return this.canvas.width; - }, - set: function set(val) // eslint-disable-line require-jsdoc - { - this.canvas.width = val; - } - - /** - * The height of the canvas buffer in pixels. - * - * @member {number} - */ - - }, { - key: 'height', - get: function get() { - return this.canvas.height; - }, - set: function set(val) // eslint-disable-line require-jsdoc - { - this.canvas.height = val; - } - }]); - - return CanvasRenderTarget; -}(); - -exports.default = CanvasRenderTarget; - -},{"../../../settings":101}],80:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = canUseNewCanvasBlendModes; -/** - * Creates a little colored canvas - * - * @ignore - * @param {string} color - The color to make the canvas - * @return {canvas} a small canvas element - */ -function createColoredCanvas(color) { - var canvas = document.createElement('canvas'); - - canvas.width = 6; - canvas.height = 1; - - var context = canvas.getContext('2d'); - - context.fillStyle = color; - context.fillRect(0, 0, 6, 1); - - return canvas; -} - -/** - * Checks whether the Canvas BlendModes are supported by the current browser - * - * @return {boolean} whether they are supported - */ -function canUseNewCanvasBlendModes() { - if (typeof document === 'undefined') { - return false; - } - - var magenta = createColoredCanvas('#ff00ff'); - var yellow = createColoredCanvas('#ffff00'); - - var canvas = document.createElement('canvas'); - - canvas.width = 6; - canvas.height = 1; - - var context = canvas.getContext('2d'); - - context.globalCompositeOperation = 'multiply'; - context.drawImage(magenta, 0, 0); - context.drawImage(yellow, 2, 0); - - var imageData = context.getImageData(2, 0, 1, 1); - - if (!imageData) { - return false; - } - - var data = imageData.data; - - return data[0] === 255 && data[1] === 0 && data[2] === 0; -} - -},{}],81:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = mapCanvasBlendModesToPixi; - -var _const = require('../../../const'); - -var _canUseNewCanvasBlendModes = require('./canUseNewCanvasBlendModes'); - -var _canUseNewCanvasBlendModes2 = _interopRequireDefault(_canUseNewCanvasBlendModes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Maps blend combinations to Canvas. - * - * @memberof PIXI - * @function mapCanvasBlendModesToPixi - * @private - * @param {string[]} [array=[]] - The array to output into. - * @return {string[]} Mapped modes. - */ -function mapCanvasBlendModesToPixi() { - var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - if ((0, _canUseNewCanvasBlendModes2.default)()) { - array[_const.BLEND_MODES.NORMAL] = 'source-over'; - array[_const.BLEND_MODES.ADD] = 'lighter'; // IS THIS OK??? - array[_const.BLEND_MODES.MULTIPLY] = 'multiply'; - array[_const.BLEND_MODES.SCREEN] = 'screen'; - array[_const.BLEND_MODES.OVERLAY] = 'overlay'; - array[_const.BLEND_MODES.DARKEN] = 'darken'; - array[_const.BLEND_MODES.LIGHTEN] = 'lighten'; - array[_const.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; - array[_const.BLEND_MODES.COLOR_BURN] = 'color-burn'; - array[_const.BLEND_MODES.HARD_LIGHT] = 'hard-light'; - array[_const.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; - array[_const.BLEND_MODES.DIFFERENCE] = 'difference'; - array[_const.BLEND_MODES.EXCLUSION] = 'exclusion'; - array[_const.BLEND_MODES.HUE] = 'hue'; - array[_const.BLEND_MODES.SATURATION] = 'saturate'; - array[_const.BLEND_MODES.COLOR] = 'color'; - array[_const.BLEND_MODES.LUMINOSITY] = 'luminosity'; - } else { - // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - array[_const.BLEND_MODES.NORMAL] = 'source-over'; - array[_const.BLEND_MODES.ADD] = 'lighter'; // IS THIS OK??? - array[_const.BLEND_MODES.MULTIPLY] = 'source-over'; - array[_const.BLEND_MODES.SCREEN] = 'source-over'; - array[_const.BLEND_MODES.OVERLAY] = 'source-over'; - array[_const.BLEND_MODES.DARKEN] = 'source-over'; - array[_const.BLEND_MODES.LIGHTEN] = 'source-over'; - array[_const.BLEND_MODES.COLOR_DODGE] = 'source-over'; - array[_const.BLEND_MODES.COLOR_BURN] = 'source-over'; - array[_const.BLEND_MODES.HARD_LIGHT] = 'source-over'; - array[_const.BLEND_MODES.SOFT_LIGHT] = 'source-over'; - array[_const.BLEND_MODES.DIFFERENCE] = 'source-over'; - array[_const.BLEND_MODES.EXCLUSION] = 'source-over'; - array[_const.BLEND_MODES.HUE] = 'source-over'; - array[_const.BLEND_MODES.SATURATION] = 'source-over'; - array[_const.BLEND_MODES.COLOR] = 'source-over'; - array[_const.BLEND_MODES.LUMINOSITY] = 'source-over'; - } - // not-premultiplied, only for webgl - array[_const.BLEND_MODES.NORMAL_NPM] = array[_const.BLEND_MODES.NORMAL]; - array[_const.BLEND_MODES.ADD_NPM] = array[_const.BLEND_MODES.ADD]; - array[_const.BLEND_MODES.SCREEN_NPM] = array[_const.BLEND_MODES.SCREEN]; - - return array; -} - -},{"../../../const":46,"./canUseNewCanvasBlendModes":80}],82:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _const = require('../../const'); - -var _settings = require('../../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * TextureGarbageCollector. This class manages the GPU and ensures that it does not get clogged - * up with textures that are no longer being used. - * - * @class - * @memberof PIXI - */ -var TextureGarbageCollector = function () { - /** - * @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for. - */ - function TextureGarbageCollector(renderer) { - _classCallCheck(this, TextureGarbageCollector); - - this.renderer = renderer; - - this.count = 0; - this.checkCount = 0; - this.maxIdle = _settings2.default.GC_MAX_IDLE; - this.checkCountMax = _settings2.default.GC_MAX_CHECK_COUNT; - this.mode = _settings2.default.GC_MODE; - } - - /** - * Checks to see when the last time a texture was used - * if the texture has not been used for a specified amount of time it will be removed from the GPU - */ - - - TextureGarbageCollector.prototype.update = function update() { - this.count++; - - if (this.mode === _const.GC_MODES.MANUAL) { - return; - } - - this.checkCount++; - - if (this.checkCount > this.checkCountMax) { - this.checkCount = 0; - - this.run(); - } - }; - - /** - * Checks to see when the last time a texture was used - * if the texture has not been used for a specified amount of time it will be removed from the GPU - */ - - - TextureGarbageCollector.prototype.run = function run() { - var tm = this.renderer.textureManager; - var managedTextures = tm._managedTextures; - var wasRemoved = false; - - for (var i = 0; i < managedTextures.length; i++) { - var texture = managedTextures[i]; - - // only supports non generated textures at the moment! - if (!texture._glRenderTargets && this.count - texture.touched > this.maxIdle) { - tm.destroyTexture(texture, true); - managedTextures[i] = null; - wasRemoved = true; - } - } - - if (wasRemoved) { - var j = 0; - - for (var _i = 0; _i < managedTextures.length; _i++) { - if (managedTextures[_i] !== null) { - managedTextures[j++] = managedTextures[_i]; - } - } - - managedTextures.length = j; - } - }; - - /** - * Removes all the textures within the specified displayObject and its children from the GPU - * - * @param {PIXI.DisplayObject} displayObject - the displayObject to remove the textures from. - */ - - - TextureGarbageCollector.prototype.unload = function unload(displayObject) { - var tm = this.renderer.textureManager; - - // only destroy non generated textures - if (displayObject._texture && displayObject._texture._glRenderTargets) { - tm.destroyTexture(displayObject._texture, true); - } - - for (var i = displayObject.children.length - 1; i >= 0; i--) { - this.unload(displayObject.children[i]); - } - }; - - return TextureGarbageCollector; -}(); - -exports.default = TextureGarbageCollector; - -},{"../../const":46,"../../settings":101}],83:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _pixiGlCore = require('pixi-gl-core'); - -var _const = require('../../const'); - -var _RenderTarget = require('./utils/RenderTarget'); - -var _RenderTarget2 = _interopRequireDefault(_RenderTarget); - -var _utils = require('../../utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Helper class to create a webGL Texture - * - * @class - * @memberof PIXI - */ -var TextureManager = function () { - /** - * @param {PIXI.WebGLRenderer} renderer - A reference to the current renderer - */ - function TextureManager(renderer) { - _classCallCheck(this, TextureManager); - - /** - * A reference to the current renderer - * - * @member {PIXI.WebGLRenderer} - */ - this.renderer = renderer; - - /** - * The current WebGL rendering context - * - * @member {WebGLRenderingContext} - */ - this.gl = renderer.gl; - - /** - * Track textures in the renderer so we can no longer listen to them on destruction. - * - * @member {Array<*>} - * @private - */ - this._managedTextures = []; - } - - /** - * Binds a texture. - * - */ - - - TextureManager.prototype.bindTexture = function bindTexture() {} - // empty - - - /** - * Gets a texture. - * - */ - ; - - TextureManager.prototype.getTexture = function getTexture() {} - // empty - - - /** - * Updates and/or Creates a WebGL texture for the renderer's context. - * - * @param {PIXI.BaseTexture|PIXI.Texture} texture - the texture to update - * @param {number} location - the location the texture will be bound to. - * @return {GLTexture} The gl texture. - */ - ; - - TextureManager.prototype.updateTexture = function updateTexture(texture, location) { - // assume it good! - // texture = texture.baseTexture || texture; - - var gl = this.gl; - - var isRenderTexture = !!texture._glRenderTargets; - - if (!texture.hasLoaded) { - return null; - } - - var boundTextures = this.renderer.boundTextures; - - // if the location is undefined then this may have been called by n event. - // this being the case the texture may already be bound to a slot. As a texture can only be bound once - // we need to find its current location if it exists. - if (location === undefined) { - location = 0; - - // TODO maybe we can use texture bound ids later on... - // check if texture is already bound.. - for (var i = 0; i < boundTextures.length; ++i) { - if (boundTextures[i] === texture) { - location = i; - break; - } - } - } - - boundTextures[location] = texture; - - gl.activeTexture(gl.TEXTURE0 + location); - - var glTexture = texture._glTextures[this.renderer.CONTEXT_UID]; - - if (!glTexture) { - if (isRenderTexture) { - var renderTarget = new _RenderTarget2.default(this.gl, texture.width, texture.height, texture.scaleMode, texture.resolution); - - renderTarget.resize(texture.width, texture.height); - texture._glRenderTargets[this.renderer.CONTEXT_UID] = renderTarget; - glTexture = renderTarget.texture; - - // framebuffer constructor disactivates current framebuffer - if (!this.renderer._activeRenderTarget.root) { - this.renderer._activeRenderTarget.frameBuffer.bind(); - } - } else { - glTexture = new _pixiGlCore.GLTexture(this.gl, null, null, null, null); - glTexture.bind(location); - glTexture.premultiplyAlpha = true; - glTexture.upload(texture.source); - } - - texture._glTextures[this.renderer.CONTEXT_UID] = glTexture; - - texture.on('update', this.updateTexture, this); - texture.on('dispose', this.destroyTexture, this); - - this._managedTextures.push(texture); - - if (texture.isPowerOfTwo) { - if (texture.mipmap) { - glTexture.enableMipmap(); - } - - if (texture.wrapMode === _const.WRAP_MODES.CLAMP) { - glTexture.enableWrapClamp(); - } else if (texture.wrapMode === _const.WRAP_MODES.REPEAT) { - glTexture.enableWrapRepeat(); - } else { - glTexture.enableWrapMirrorRepeat(); - } - } else { - glTexture.enableWrapClamp(); - } - - if (texture.scaleMode === _const.SCALE_MODES.NEAREST) { - glTexture.enableNearestScaling(); - } else { - glTexture.enableLinearScaling(); - } - } - // the texture already exists so we only need to update it.. - else if (isRenderTexture) { - texture._glRenderTargets[this.renderer.CONTEXT_UID].resize(texture.width, texture.height); - } else { - glTexture.upload(texture.source); - } - - return glTexture; - }; - - /** - * Deletes the texture from WebGL - * - * @param {PIXI.BaseTexture|PIXI.Texture} texture - the texture to destroy - * @param {boolean} [skipRemove=false] - Whether to skip removing the texture from the TextureManager. - */ - - - TextureManager.prototype.destroyTexture = function destroyTexture(texture, skipRemove) { - texture = texture.baseTexture || texture; - - if (!texture.hasLoaded) { - return; - } - - var renderer = this.renderer; - var uid = renderer.CONTEXT_UID; - var glTextures = texture._glTextures; - var glRenderTargets = texture._glRenderTargets; - - if (glTextures[uid]) { - renderer.unbindTexture(texture); - - glTextures[uid].destroy(); - texture.off('update', this.updateTexture, this); - texture.off('dispose', this.destroyTexture, this); - - delete glTextures[uid]; - - if (!skipRemove) { - var i = this._managedTextures.indexOf(texture); - - if (i !== -1) { - (0, _utils.removeItems)(this._managedTextures, i, 1); - } - } - } - - if (glRenderTargets && glRenderTargets[uid]) { - if (renderer._activeRenderTarget === glRenderTargets[uid]) { - renderer.bindRenderTarget(renderer.rootRenderTarget); - } - - glRenderTargets[uid].destroy(); - delete glRenderTargets[uid]; - } - }; - - /** - * Deletes all the textures from WebGL - */ - - - TextureManager.prototype.removeAll = function removeAll() { - // empty all the old gl textures as they are useless now - for (var i = 0; i < this._managedTextures.length; ++i) { - var texture = this._managedTextures[i]; - - if (texture._glTextures[this.renderer.CONTEXT_UID]) { - delete texture._glTextures[this.renderer.CONTEXT_UID]; - } - } - }; - - /** - * Destroys this manager and removes all its textures - */ - - - TextureManager.prototype.destroy = function destroy() { - // destroy managed textures - for (var i = 0; i < this._managedTextures.length; ++i) { - var texture = this._managedTextures[i]; - - this.destroyTexture(texture, true); - - texture.off('update', this.updateTexture, this); - texture.off('dispose', this.destroyTexture, this); - } - - this._managedTextures = null; - }; - - return TextureManager; -}(); - -exports.default = TextureManager; - -},{"../../const":46,"../../utils":125,"./utils/RenderTarget":96,"pixi-gl-core":15}],84:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _SystemRenderer2 = require('../SystemRenderer'); - -var _SystemRenderer3 = _interopRequireDefault(_SystemRenderer2); - -var _MaskManager = require('./managers/MaskManager'); - -var _MaskManager2 = _interopRequireDefault(_MaskManager); - -var _StencilManager = require('./managers/StencilManager'); - -var _StencilManager2 = _interopRequireDefault(_StencilManager); - -var _FilterManager = require('./managers/FilterManager'); - -var _FilterManager2 = _interopRequireDefault(_FilterManager); - -var _RenderTarget = require('./utils/RenderTarget'); - -var _RenderTarget2 = _interopRequireDefault(_RenderTarget); - -var _ObjectRenderer = require('./utils/ObjectRenderer'); - -var _ObjectRenderer2 = _interopRequireDefault(_ObjectRenderer); - -var _TextureManager = require('./TextureManager'); - -var _TextureManager2 = _interopRequireDefault(_TextureManager); - -var _BaseTexture = require('../../textures/BaseTexture'); - -var _BaseTexture2 = _interopRequireDefault(_BaseTexture); - -var _TextureGarbageCollector = require('./TextureGarbageCollector'); - -var _TextureGarbageCollector2 = _interopRequireDefault(_TextureGarbageCollector); - -var _WebGLState = require('./WebGLState'); - -var _WebGLState2 = _interopRequireDefault(_WebGLState); - -var _mapWebGLDrawModesToPixi = require('./utils/mapWebGLDrawModesToPixi'); - -var _mapWebGLDrawModesToPixi2 = _interopRequireDefault(_mapWebGLDrawModesToPixi); - -var _validateContext = require('./utils/validateContext'); - -var _validateContext2 = _interopRequireDefault(_validateContext); - -var _utils = require('../../utils'); - -var _pixiGlCore = require('pixi-gl-core'); - -var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore); - -var _const = require('../../const'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var CONTEXT_UID = 0; - -/** - * The WebGLRenderer draws the scene and all its content onto a webGL enabled canvas. This renderer - * should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs. - * So no need for Sprite Batches or Sprite Clouds. - * Don't forget to add the view to your DOM or you will not see anything :) - * - * @class - * @memberof PIXI - * @extends PIXI.SystemRenderer - */ - -var WebGLRenderer = function (_SystemRenderer) { - _inherits(WebGLRenderer, _SystemRenderer); - - // eslint-disable-next-line valid-jsdoc - /** - * - * @param {object} [options] - The optional renderer parameters - * @param {number} [options.width=800] - the width of the screen - * @param {number} [options.height=600] - the height of the screen - * @param {HTMLCanvasElement} [options.view] - the canvas to use as a view, optional - * @param {boolean} [options.transparent=false] - If the render view is transparent, default false - * @param {boolean} [options.autoResize=false] - If the render view is automatically resized, default false - * @param {boolean} [options.antialias=false] - sets antialias. If not available natively then FXAA - * antialiasing is used - * @param {boolean} [options.forceFXAA=false] - forces FXAA antialiasing to be used over native. - * FXAA is faster, but may not always look as great - * @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer. - * The resolution of the renderer retina would be 2. - * @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear - * the canvas or not before the new render pass. If you wish to set this to false, you *must* set - * preserveDrawingBuffer to `true`. - * @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, - * enable this if you need to call toDataUrl on the webgl context. - * @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when - * rendering, stopping pixel interpolation. - * @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area - * (shown if not transparent). - * @param {boolean} [options.legacy=false] - If true PixiJS will aim to ensure compatibility - * with older / less advanced devices. If you experience unexplained flickering try setting this to true. - * @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance" - * for devices with dual graphics card - */ - function WebGLRenderer(options, arg2, arg3) { - _classCallCheck(this, WebGLRenderer); - - var _this = _possibleConstructorReturn(this, _SystemRenderer.call(this, 'WebGL', options, arg2, arg3)); - - _this.legacy = _this.options.legacy; - - if (_this.legacy) { - _pixiGlCore2.default.VertexArrayObject.FORCE_NATIVE = true; - } - - /** - * The type of this renderer as a standardised const - * - * @member {number} - * @see PIXI.RENDERER_TYPE - */ - _this.type = _const.RENDERER_TYPE.WEBGL; - - _this.handleContextLost = _this.handleContextLost.bind(_this); - _this.handleContextRestored = _this.handleContextRestored.bind(_this); - - _this.view.addEventListener('webglcontextlost', _this.handleContextLost, false); - _this.view.addEventListener('webglcontextrestored', _this.handleContextRestored, false); - - /** - * The options passed in to create a new webgl context. - * - * @member {object} - * @private - */ - _this._contextOptions = { - alpha: _this.transparent, - antialias: _this.options.antialias, - premultipliedAlpha: _this.transparent && _this.transparent !== 'notMultiplied', - stencil: true, - preserveDrawingBuffer: _this.options.preserveDrawingBuffer, - powerPreference: _this.options.powerPreference - }; - - _this._backgroundColorRgba[3] = _this.transparent ? 0 : 1; - - /** - * Manages the masks using the stencil buffer. - * - * @member {PIXI.MaskManager} - */ - _this.maskManager = new _MaskManager2.default(_this); - - /** - * Manages the stencil buffer. - * - * @member {PIXI.StencilManager} - */ - _this.stencilManager = new _StencilManager2.default(_this); - - /** - * An empty renderer. - * - * @member {PIXI.ObjectRenderer} - */ - _this.emptyRenderer = new _ObjectRenderer2.default(_this); - - /** - * The currently active ObjectRenderer. - * - * @member {PIXI.ObjectRenderer} - */ - _this.currentRenderer = _this.emptyRenderer; - - /** - * Manages textures - * @member {PIXI.TextureManager} - */ - _this.textureManager = null; - - /** - * Manages the filters. - * - * @member {PIXI.FilterManager} - */ - _this.filterManager = null; - - _this.initPlugins(); - - /** - * The current WebGL rendering context, it is created here - * - * @member {WebGLRenderingContext} - */ - // initialize the context so it is ready for the managers. - if (_this.options.context) { - // checks to see if a context is valid.. - (0, _validateContext2.default)(_this.options.context); - } - - _this.gl = _this.options.context || _pixiGlCore2.default.createContext(_this.view, _this._contextOptions); - - _this.CONTEXT_UID = CONTEXT_UID++; - - /** - * The currently active ObjectRenderer. - * - * @member {PIXI.WebGLState} - */ - _this.state = new _WebGLState2.default(_this.gl); - - _this.renderingToScreen = true; - - /** - * Holds the current state of textures bound to the GPU. - * @type {Array} - */ - _this.boundTextures = null; - - /** - * Holds the current shader - * - * @member {PIXI.Shader} - */ - _this._activeShader = null; - - _this._activeVao = null; - - /** - * Holds the current render target - * - * @member {PIXI.RenderTarget} - */ - _this._activeRenderTarget = null; - - _this._initContext(); - - // map some webGL blend and drawmodes.. - _this.drawModes = (0, _mapWebGLDrawModesToPixi2.default)(_this.gl); - - _this._nextTextureLocation = 0; - - _this.setBlendMode(0); - - /** - * Fired after rendering finishes. - * - * @event PIXI.WebGLRenderer#postrender - */ - - /** - * Fired before rendering starts. - * - * @event PIXI.WebGLRenderer#prerender - */ - - /** - * Fired when the WebGL context is set. - * - * @event PIXI.WebGLRenderer#context - * @param {WebGLRenderingContext} gl - WebGL context. - */ - return _this; - } - - /** - * Creates the WebGL context - * - * @private - */ - - - WebGLRenderer.prototype._initContext = function _initContext() { - var gl = this.gl; - - // restore a context if it was previously lost - if (gl.isContextLost() && gl.getExtension('WEBGL_lose_context')) { - gl.getExtension('WEBGL_lose_context').restoreContext(); - } - - var maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); - - this._activeShader = null; - this._activeVao = null; - - this.boundTextures = new Array(maxTextures); - this.emptyTextures = new Array(maxTextures); - - /** - * Did someone temper with textures state? We'll overwrite them when we need to unbind something. - * @member {boolean} - * @private - */ - this._unknownBoundTextures = false; - - // create a texture manager... - this.textureManager = new _TextureManager2.default(this); - this.filterManager = new _FilterManager2.default(this); - this.textureGC = new _TextureGarbageCollector2.default(this); - - this.state.resetToDefault(); - - this.rootRenderTarget = new _RenderTarget2.default(gl, this.width, this.height, null, this.resolution, true); - this.rootRenderTarget.clearColor = this._backgroundColorRgba; - - this.bindRenderTarget(this.rootRenderTarget); - - // now lets fill up the textures with empty ones! - var emptyGLTexture = new _pixiGlCore2.default.GLTexture.fromData(gl, null, 1, 1); - - var tempObj = { _glTextures: {} }; - - tempObj._glTextures[this.CONTEXT_UID] = {}; - - for (var i = 0; i < maxTextures; i++) { - var empty = new _BaseTexture2.default(); - - empty._glTextures[this.CONTEXT_UID] = emptyGLTexture; - - this.boundTextures[i] = tempObj; - this.emptyTextures[i] = empty; - this.bindTexture(null, i); - } - - this.emit('context', gl); - - // setup the width/height properties and gl viewport - this.resize(this.screen.width, this.screen.height); - }; - - /** - * Renders the object to its webGL view - * - * @param {PIXI.DisplayObject} displayObject - the object to be rendered - * @param {PIXI.RenderTexture} renderTexture - The render texture to render to. - * @param {boolean} [clear] - Should the canvas be cleared before the new render - * @param {PIXI.Matrix} [transform] - A transform to apply to the render texture before rendering. - * @param {boolean} [skipUpdateTransform] - Should we skip the update transform pass? - */ - - - WebGLRenderer.prototype.render = function render(displayObject, renderTexture, clear, transform, skipUpdateTransform) { - // can be handy to know! - this.renderingToScreen = !renderTexture; - - this.emit('prerender'); - - // no point rendering if our context has been blown up! - if (!this.gl || this.gl.isContextLost()) { - return; - } - - this._nextTextureLocation = 0; - - if (!renderTexture) { - this._lastObjectRendered = displayObject; - } - - if (!skipUpdateTransform) { - // update the scene graph - var cacheParent = displayObject.parent; - - displayObject.parent = this._tempDisplayObjectParent; - displayObject.updateTransform(); - displayObject.parent = cacheParent; - // displayObject.hitArea = //TODO add a temp hit area - } - - this.bindRenderTexture(renderTexture, transform); - - this.currentRenderer.start(); - - if (clear !== undefined ? clear : this.clearBeforeRender) { - this._activeRenderTarget.clear(); - } - - displayObject.renderWebGL(this); - - // apply transform.. - this.currentRenderer.flush(); - - // this.setObjectRenderer(this.emptyRenderer); - - this.textureGC.update(); - - this.emit('postrender'); - }; - - /** - * Changes the current renderer to the one given in parameter - * - * @param {PIXI.ObjectRenderer} objectRenderer - The object renderer to use. - */ - - - WebGLRenderer.prototype.setObjectRenderer = function setObjectRenderer(objectRenderer) { - if (this.currentRenderer === objectRenderer) { - return; - } - - this.currentRenderer.stop(); - this.currentRenderer = objectRenderer; - this.currentRenderer.start(); - }; - - /** - * This should be called if you wish to do some custom rendering - * It will basically render anything that may be batched up such as sprites - * - */ - - - WebGLRenderer.prototype.flush = function flush() { - this.setObjectRenderer(this.emptyRenderer); - }; - - /** - * Resizes the webGL view to the specified width and height. - * - * @param {number} screenWidth - the new width of the screen - * @param {number} screenHeight - the new height of the screen - */ - - - WebGLRenderer.prototype.resize = function resize(screenWidth, screenHeight) { - // if(width * this.resolution === this.width && height * this.resolution === this.height)return; - - _SystemRenderer3.default.prototype.resize.call(this, screenWidth, screenHeight); - - this.rootRenderTarget.resize(screenWidth, screenHeight); - - if (this._activeRenderTarget === this.rootRenderTarget) { - this.rootRenderTarget.activate(); - - if (this._activeShader) { - this._activeShader.uniforms.projectionMatrix = this.rootRenderTarget.projectionMatrix.toArray(true); - } - } - }; - - /** - * Resizes the webGL view to the specified width and height. - * - * @param {number} blendMode - the desired blend mode - */ - - - WebGLRenderer.prototype.setBlendMode = function setBlendMode(blendMode) { - this.state.setBlendMode(blendMode); - }; - - /** - * Erases the active render target and fills the drawing area with a colour - * - * @param {number} [clearColor] - The colour - */ - - - WebGLRenderer.prototype.clear = function clear(clearColor) { - this._activeRenderTarget.clear(clearColor); - }; - - /** - * Sets the transform of the active render target to the given matrix - * - * @param {PIXI.Matrix} matrix - The transformation matrix - */ - - - WebGLRenderer.prototype.setTransform = function setTransform(matrix) { - this._activeRenderTarget.transform = matrix; - }; - - /** - * Erases the render texture and fills the drawing area with a colour - * - * @param {PIXI.RenderTexture} renderTexture - The render texture to clear - * @param {number} [clearColor] - The colour - * @return {PIXI.WebGLRenderer} Returns itself. - */ - - - WebGLRenderer.prototype.clearRenderTexture = function clearRenderTexture(renderTexture, clearColor) { - var baseTexture = renderTexture.baseTexture; - var renderTarget = baseTexture._glRenderTargets[this.CONTEXT_UID]; - - if (renderTarget) { - renderTarget.clear(clearColor); - } - - return this; - }; - - /** - * Binds a render texture for rendering - * - * @param {PIXI.RenderTexture} renderTexture - The render texture to render - * @param {PIXI.Matrix} transform - The transform to be applied to the render texture - * @return {PIXI.WebGLRenderer} Returns itself. - */ - - - WebGLRenderer.prototype.bindRenderTexture = function bindRenderTexture(renderTexture, transform) { - var renderTarget = void 0; - - if (renderTexture) { - var baseTexture = renderTexture.baseTexture; - - if (!baseTexture._glRenderTargets[this.CONTEXT_UID]) { - // bind the current texture - this.textureManager.updateTexture(baseTexture, 0); - } - - this.unbindTexture(baseTexture); - - renderTarget = baseTexture._glRenderTargets[this.CONTEXT_UID]; - renderTarget.setFrame(renderTexture.frame); - } else { - renderTarget = this.rootRenderTarget; - } - - renderTarget.transform = transform; - this.bindRenderTarget(renderTarget); - - return this; - }; - - /** - * Changes the current render target to the one given in parameter - * - * @param {PIXI.RenderTarget} renderTarget - the new render target - * @return {PIXI.WebGLRenderer} Returns itself. - */ - - - WebGLRenderer.prototype.bindRenderTarget = function bindRenderTarget(renderTarget) { - if (renderTarget !== this._activeRenderTarget) { - this._activeRenderTarget = renderTarget; - renderTarget.activate(); - - if (this._activeShader) { - this._activeShader.uniforms.projectionMatrix = renderTarget.projectionMatrix.toArray(true); - } - - this.stencilManager.setMaskStack(renderTarget.stencilMaskStack); - } - - return this; - }; - - /** - * Changes the current shader to the one given in parameter - * - * @param {PIXI.Shader} shader - the new shader - * @param {boolean} [autoProject=true] - Whether automatically set the projection matrix - * @return {PIXI.WebGLRenderer} Returns itself. - */ - - - WebGLRenderer.prototype.bindShader = function bindShader(shader, autoProject) { - // TODO cache - if (this._activeShader !== shader) { - this._activeShader = shader; - shader.bind(); - - // `autoProject` normally would be a default parameter set to true - // but because of how Babel transpiles default parameters - // it hinders the performance of this method. - if (autoProject !== false) { - // automatically set the projection matrix - shader.uniforms.projectionMatrix = this._activeRenderTarget.projectionMatrix.toArray(true); - } - } - - return this; - }; - - /** - * Binds the texture. This will return the location of the bound texture. - * It may not be the same as the one you pass in. This is due to optimisation that prevents - * needless binding of textures. For example if the texture is already bound it will return the - * current location of the texture instead of the one provided. To bypass this use force location - * - * @param {PIXI.Texture} texture - the new texture - * @param {number} location - the suggested texture location - * @param {boolean} forceLocation - force the location - * @return {number} bound texture location - */ - - - WebGLRenderer.prototype.bindTexture = function bindTexture(texture, location, forceLocation) { - texture = texture || this.emptyTextures[location]; - texture = texture.baseTexture || texture; - texture.touched = this.textureGC.count; - - if (!forceLocation) { - // TODO - maybe look into adding boundIds.. save us the loop? - for (var i = 0; i < this.boundTextures.length; i++) { - if (this.boundTextures[i] === texture) { - return i; - } - } - - if (location === undefined) { - this._nextTextureLocation++; - this._nextTextureLocation %= this.boundTextures.length; - location = this.boundTextures.length - this._nextTextureLocation - 1; - } - } else { - location = location || 0; - } - - var gl = this.gl; - var glTexture = texture._glTextures[this.CONTEXT_UID]; - - if (!glTexture) { - // this will also bind the texture.. - this.textureManager.updateTexture(texture, location); - } else { - // bind the current texture - this.boundTextures[location] = texture; - gl.activeTexture(gl.TEXTURE0 + location); - gl.bindTexture(gl.TEXTURE_2D, glTexture.texture); - } - - return location; - }; - - /** - * unbinds the texture ... - * - * @param {PIXI.Texture} texture - the texture to unbind - * @return {PIXI.WebGLRenderer} Returns itself. - */ - - - WebGLRenderer.prototype.unbindTexture = function unbindTexture(texture) { - var gl = this.gl; - - texture = texture.baseTexture || texture; - - if (this._unknownBoundTextures) { - this._unknownBoundTextures = false; - // someone changed webGL state, - // we have to be sure that our texture does not appear in multitexture renderer samplers - - for (var i = 0; i < this.boundTextures.length; i++) { - if (this.boundTextures[i] === this.emptyTextures[i]) { - gl.activeTexture(gl.TEXTURE0 + i); - gl.bindTexture(gl.TEXTURE_2D, this.emptyTextures[i]._glTextures[this.CONTEXT_UID].texture); - } - } - } - - for (var _i = 0; _i < this.boundTextures.length; _i++) { - if (this.boundTextures[_i] === texture) { - this.boundTextures[_i] = this.emptyTextures[_i]; - - gl.activeTexture(gl.TEXTURE0 + _i); - gl.bindTexture(gl.TEXTURE_2D, this.emptyTextures[_i]._glTextures[this.CONTEXT_UID].texture); - } - } - - return this; - }; - - /** - * Creates a new VAO from this renderer's context and state. - * - * @return {VertexArrayObject} The new VAO. - */ - - - WebGLRenderer.prototype.createVao = function createVao() { - return new _pixiGlCore2.default.VertexArrayObject(this.gl, this.state.attribState); - }; - - /** - * Changes the current Vao to the one given in parameter - * - * @param {PIXI.VertexArrayObject} vao - the new Vao - * @return {PIXI.WebGLRenderer} Returns itself. - */ - - - WebGLRenderer.prototype.bindVao = function bindVao(vao) { - if (this._activeVao === vao) { - return this; - } - - if (vao) { - vao.bind(); - } else if (this._activeVao) { - // TODO this should always be true i think? - this._activeVao.unbind(); - } - - this._activeVao = vao; - - return this; - }; - - /** - * Resets the WebGL state so you can render things however you fancy! - * - * @return {PIXI.WebGLRenderer} Returns itself. - */ - - - WebGLRenderer.prototype.reset = function reset() { - this.setObjectRenderer(this.emptyRenderer); - - this.bindVao(null); - this._activeShader = null; - this._activeRenderTarget = this.rootRenderTarget; - - this._unknownBoundTextures = true; - - for (var i = 0; i < this.boundTextures.length; i++) { - this.boundTextures[i] = this.emptyTextures[i]; - } - - // bind the main frame buffer (the screen); - this.rootRenderTarget.activate(); - - this.state.resetToDefault(); - - return this; - }; - - /** - * Handles a lost webgl context - * - * @private - * @param {WebGLContextEvent} event - The context lost event. - */ - - - WebGLRenderer.prototype.handleContextLost = function handleContextLost(event) { - event.preventDefault(); - }; - - /** - * Handles a restored webgl context - * - * @private - */ - - - WebGLRenderer.prototype.handleContextRestored = function handleContextRestored() { - this.textureManager.removeAll(); - this.filterManager.destroy(true); - this._initContext(); - }; - - /** - * Removes everything from the renderer (event listeners, spritebatch, etc...) - * - * @param {boolean} [removeView=false] - Removes the Canvas element from the DOM. - * See: https://github.com/pixijs/pixi.js/issues/2233 - */ - - - WebGLRenderer.prototype.destroy = function destroy(removeView) { - this.destroyPlugins(); - - // remove listeners - this.view.removeEventListener('webglcontextlost', this.handleContextLost); - this.view.removeEventListener('webglcontextrestored', this.handleContextRestored); - - this.textureManager.destroy(); - - // call base destroy - _SystemRenderer.prototype.destroy.call(this, removeView); - - this.uid = 0; - - // destroy the managers - this.maskManager.destroy(); - this.stencilManager.destroy(); - this.filterManager.destroy(); - - this.maskManager = null; - this.filterManager = null; - this.textureManager = null; - this.currentRenderer = null; - - this.handleContextLost = null; - this.handleContextRestored = null; - - this._contextOptions = null; - this.gl.useProgram(null); - - if (this.gl.getExtension('WEBGL_lose_context')) { - this.gl.getExtension('WEBGL_lose_context').loseContext(); - } - - this.gl = null; - - // this = null; - }; - - return WebGLRenderer; -}(_SystemRenderer3.default); - -/** - * Collection of installed plugins. These are included by default in PIXI, but can be excluded - * by creating a custom build. Consult the README for more information about creating custom - * builds and excluding plugins. - * @name PIXI.WebGLRenderer#plugins - * @type {object} - * @readonly - * @property {PIXI.accessibility.AccessibilityManager} accessibility Support tabbing interactive elements. - * @property {PIXI.extract.WebGLExtract} extract Extract image data from renderer. - * @property {PIXI.interaction.InteractionManager} interaction Handles mouse, touch and pointer events. - * @property {PIXI.prepare.WebGLPrepare} prepare Pre-render display objects. - */ - -/** - * Adds a plugin to the renderer. - * - * @method PIXI.WebGLRenderer#registerPlugin - * @param {string} pluginName - The name of the plugin. - * @param {Function} ctor - The constructor function or class for the plugin. - */ - -exports.default = WebGLRenderer; -_utils.pluginTarget.mixin(WebGLRenderer); - -},{"../../const":46,"../../textures/BaseTexture":112,"../../utils":125,"../SystemRenderer":76,"./TextureGarbageCollector":82,"./TextureManager":83,"./WebGLState":85,"./managers/FilterManager":90,"./managers/MaskManager":91,"./managers/StencilManager":92,"./utils/ObjectRenderer":94,"./utils/RenderTarget":96,"./utils/mapWebGLDrawModesToPixi":99,"./utils/validateContext":100,"pixi-gl-core":15}],85:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _mapWebGLBlendModesToPixi = require('./utils/mapWebGLBlendModesToPixi'); - -var _mapWebGLBlendModesToPixi2 = _interopRequireDefault(_mapWebGLBlendModesToPixi); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var BLEND = 0; -var DEPTH_TEST = 1; -var FRONT_FACE = 2; -var CULL_FACE = 3; -var BLEND_FUNC = 4; - -/** - * A WebGL state machines - * - * @memberof PIXI - * @class - */ - -var WebGLState = function () { - /** - * @param {WebGLRenderingContext} gl - The current WebGL rendering context - */ - function WebGLState(gl) { - _classCallCheck(this, WebGLState); - - /** - * The current active state - * - * @member {Uint8Array} - */ - this.activeState = new Uint8Array(16); - - /** - * The default state - * - * @member {Uint8Array} - */ - this.defaultState = new Uint8Array(16); - - // default blend mode.. - this.defaultState[0] = 1; - - /** - * The current state index in the stack - * - * @member {number} - * @private - */ - this.stackIndex = 0; - - /** - * The stack holding all the different states - * - * @member {Array<*>} - * @private - */ - this.stack = []; - - /** - * The current WebGL rendering context - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - this.maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); - - this.attribState = { - tempAttribState: new Array(this.maxAttribs), - attribState: new Array(this.maxAttribs) - }; - - this.blendModes = (0, _mapWebGLBlendModesToPixi2.default)(gl); - - // check we have vao.. - this.nativeVaoExtension = gl.getExtension('OES_vertex_array_object') || gl.getExtension('MOZ_OES_vertex_array_object') || gl.getExtension('WEBKIT_OES_vertex_array_object'); - } - - /** - * Pushes a new active state - */ - - - WebGLState.prototype.push = function push() { - // next state.. - var state = this.stack[this.stackIndex]; - - if (!state) { - state = this.stack[this.stackIndex] = new Uint8Array(16); - } - - ++this.stackIndex; - - // copy state.. - // set active state so we can force overrides of gl state - for (var i = 0; i < this.activeState.length; i++) { - state[i] = this.activeState[i]; - } - }; - - /** - * Pops a state out - */ - - - WebGLState.prototype.pop = function pop() { - var state = this.stack[--this.stackIndex]; - - this.setState(state); - }; - - /** - * Sets the current state - * - * @param {*} state - The state to set. - */ - - - WebGLState.prototype.setState = function setState(state) { - this.setBlend(state[BLEND]); - this.setDepthTest(state[DEPTH_TEST]); - this.setFrontFace(state[FRONT_FACE]); - this.setCullFace(state[CULL_FACE]); - this.setBlendMode(state[BLEND_FUNC]); - }; - - /** - * Enables or disabled blending. - * - * @param {boolean} value - Turn on or off webgl blending. - */ - - - WebGLState.prototype.setBlend = function setBlend(value) { - value = value ? 1 : 0; - - if (this.activeState[BLEND] === value) { - return; - } - - this.activeState[BLEND] = value; - this.gl[value ? 'enable' : 'disable'](this.gl.BLEND); - }; - - /** - * Sets the blend mode. - * - * @param {number} value - The blend mode to set to. - */ - - - WebGLState.prototype.setBlendMode = function setBlendMode(value) { - if (value === this.activeState[BLEND_FUNC]) { - return; - } - - this.activeState[BLEND_FUNC] = value; - - var mode = this.blendModes[value]; - - if (mode.length === 2) { - this.gl.blendFunc(mode[0], mode[1]); - } else { - this.gl.blendFuncSeparate(mode[0], mode[1], mode[2], mode[3]); - } - }; - - /** - * Sets whether to enable or disable depth test. - * - * @param {boolean} value - Turn on or off webgl depth testing. - */ - - - WebGLState.prototype.setDepthTest = function setDepthTest(value) { - value = value ? 1 : 0; - - if (this.activeState[DEPTH_TEST] === value) { - return; - } - - this.activeState[DEPTH_TEST] = value; - this.gl[value ? 'enable' : 'disable'](this.gl.DEPTH_TEST); - }; - - /** - * Sets whether to enable or disable cull face. - * - * @param {boolean} value - Turn on or off webgl cull face. - */ - - - WebGLState.prototype.setCullFace = function setCullFace(value) { - value = value ? 1 : 0; - - if (this.activeState[CULL_FACE] === value) { - return; - } - - this.activeState[CULL_FACE] = value; - this.gl[value ? 'enable' : 'disable'](this.gl.CULL_FACE); - }; - - /** - * Sets the gl front face. - * - * @param {boolean} value - true is clockwise and false is counter-clockwise - */ - - - WebGLState.prototype.setFrontFace = function setFrontFace(value) { - value = value ? 1 : 0; - - if (this.activeState[FRONT_FACE] === value) { - return; - } - - this.activeState[FRONT_FACE] = value; - this.gl.frontFace(this.gl[value ? 'CW' : 'CCW']); - }; - - /** - * Disables all the vaos in use - * - */ - - - WebGLState.prototype.resetAttributes = function resetAttributes() { - for (var i = 0; i < this.attribState.tempAttribState.length; i++) { - this.attribState.tempAttribState[i] = 0; - } - - for (var _i = 0; _i < this.attribState.attribState.length; _i++) { - this.attribState.attribState[_i] = 0; - } - - // im going to assume one is always active for performance reasons. - for (var _i2 = 1; _i2 < this.maxAttribs; _i2++) { - this.gl.disableVertexAttribArray(_i2); - } - }; - - // used - /** - * Resets all the logic and disables the vaos - */ - - - WebGLState.prototype.resetToDefault = function resetToDefault() { - // unbind any VAO if they exist.. - if (this.nativeVaoExtension) { - this.nativeVaoExtension.bindVertexArrayOES(null); - } - - // reset all attributes.. - this.resetAttributes(); - - // set active state so we can force overrides of gl state - for (var i = 0; i < this.activeState.length; ++i) { - this.activeState[i] = 32; - } - - this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, false); - - this.setState(this.defaultState); - }; - - return WebGLState; -}(); - -exports.default = WebGLState; - -},{"./utils/mapWebGLBlendModesToPixi":98}],86:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _extractUniformsFromSrc = require('./extractUniformsFromSrc'); - -var _extractUniformsFromSrc2 = _interopRequireDefault(_extractUniformsFromSrc); - -var _utils = require('../../../utils'); - -var _const = require('../../../const'); - -var _settings = require('../../../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var SOURCE_KEY_MAP = {}; - -// let math = require('../../../math'); -/** - * @class - * @memberof PIXI - * @extends PIXI.Shader - */ - -var Filter = function () { - /** - * @param {string} [vertexSrc] - The source of the vertex shader. - * @param {string} [fragmentSrc] - The source of the fragment shader. - * @param {object} [uniformData] - Custom uniforms to use to augment the built-in ones. - */ - function Filter(vertexSrc, fragmentSrc, uniformData) { - _classCallCheck(this, Filter); - - /** - * The vertex shader. - * - * @member {string} - */ - this.vertexSrc = vertexSrc || Filter.defaultVertexSrc; - - /** - * The fragment shader. - * - * @member {string} - */ - this.fragmentSrc = fragmentSrc || Filter.defaultFragmentSrc; - - this._blendMode = _const.BLEND_MODES.NORMAL; - - this.uniformData = uniformData || (0, _extractUniformsFromSrc2.default)(this.vertexSrc, this.fragmentSrc, 'projectionMatrix|uSampler'); - - /** - * An object containing the current values of custom uniforms. - * @example Updating the value of a custom uniform - * filter.uniforms.time = performance.now(); - * - * @member {object} - */ - this.uniforms = {}; - - for (var i in this.uniformData) { - this.uniforms[i] = this.uniformData[i].value; - if (this.uniformData[i].type) { - this.uniformData[i].type = this.uniformData[i].type.toLowerCase(); - } - } - - // this is where we store shader references.. - // TODO we could cache this! - this.glShaders = {}; - - // used for caching.. sure there is a better way! - if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) { - SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = (0, _utils.uid)(); - } - - this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]; - - /** - * The padding of the filter. Some filters require extra space to breath such as a blur. - * Increasing this will add extra width and height to the bounds of the object that the - * filter is applied to. - * - * @member {number} - */ - this.padding = 4; - - /** - * The resolution of the filter. Setting this to be lower will lower the quality but - * increase the performance of the filter. - * - * @member {number} - */ - this.resolution = _settings2.default.FILTER_RESOLUTION; - - /** - * If enabled is true the filter is applied, if false it will not. - * - * @member {boolean} - */ - this.enabled = true; - - /** - * If enabled, PixiJS will fit the filter area into boundaries for better performance. - * Switch it off if it does not work for specific shader. - * - * @member {boolean} - */ - this.autoFit = true; - } - - /** - * Applies the filter - * - * @param {PIXI.FilterManager} filterManager - The renderer to retrieve the filter from - * @param {PIXI.RenderTarget} input - The input render target. - * @param {PIXI.RenderTarget} output - The target to output to. - * @param {boolean} clear - Should the output be cleared before rendering to it - * @param {object} [currentState] - It's current state of filter. - * There are some useful properties in the currentState : - * target, filters, sourceFrame, destinationFrame, renderTarget, resolution - */ - - - Filter.prototype.apply = function apply(filterManager, input, output, clear, currentState) // eslint-disable-line no-unused-vars - { - // --- // - // this.uniforms.filterMatrix = filterManager.calculateSpriteMatrix(tempMatrix, window.panda ); - - // do as you please! - - filterManager.applyFilter(this, input, output, clear); - - // or just do a regular render.. - }; - - /** - * Sets the blendmode of the filter - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - */ - - - _createClass(Filter, [{ - key: 'blendMode', - get: function get() { - return this._blendMode; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._blendMode = value; - } - - /** - * The default vertex shader source - * - * @static - * @constant - */ - - }], [{ - key: 'defaultVertexSrc', - get: function get() { - return ['attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', 'uniform mat3 projectionMatrix;', 'uniform mat3 filterMatrix;', 'varying vec2 vTextureCoord;', 'varying vec2 vFilterCoord;', 'void main(void){', ' gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);', ' vFilterCoord = ( filterMatrix * vec3( aTextureCoord, 1.0) ).xy;', ' vTextureCoord = aTextureCoord ;', '}'].join('\n'); - } - - /** - * The default fragment shader source - * - * @static - * @constant - */ - - }, { - key: 'defaultFragmentSrc', - get: function get() { - return ['varying vec2 vTextureCoord;', 'varying vec2 vFilterCoord;', 'uniform sampler2D uSampler;', 'uniform sampler2D filterSampler;', 'void main(void){', ' vec4 masky = texture2D(filterSampler, vFilterCoord);', ' vec4 sample = texture2D(uSampler, vTextureCoord);', ' vec4 color;', ' if(mod(vFilterCoord.x, 1.0) > 0.5)', ' {', ' color = vec4(1.0, 0.0, 0.0, 1.0);', ' }', ' else', ' {', ' color = vec4(0.0, 1.0, 0.0, 1.0);', ' }', - // ' gl_FragColor = vec4(mod(vFilterCoord.x, 1.5), vFilterCoord.y,0.0,1.0);', - ' gl_FragColor = mix(sample, masky, 0.5);', ' gl_FragColor *= sample.a;', '}'].join('\n'); - } - }]); - - return Filter; -}(); - -exports.default = Filter; - -},{"../../../const":46,"../../../settings":101,"../../../utils":125,"./extractUniformsFromSrc":87}],87:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = extractUniformsFromSrc; - -var _pixiGlCore = require('pixi-gl-core'); - -var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var defaultValue = _pixiGlCore2.default.shader.defaultValue; - -function extractUniformsFromSrc(vertexSrc, fragmentSrc, mask) { - var vertUniforms = extractUniformsFromString(vertexSrc, mask); - var fragUniforms = extractUniformsFromString(fragmentSrc, mask); - - return Object.assign(vertUniforms, fragUniforms); -} - -function extractUniformsFromString(string) { - var maskRegex = new RegExp('^(projectionMatrix|uSampler|filterArea|filterClamp)$'); - - var uniforms = {}; - var nameSplit = void 0; - - // clean the lines a little - remove extra spaces / tabs etc - // then split along ';' - var lines = string.replace(/\s+/g, ' ').split(/\s*;\s*/); - - // loop through.. - for (var i = 0; i < lines.length; i++) { - var line = lines[i].trim(); - - if (line.indexOf('uniform') > -1) { - var splitLine = line.split(' '); - var type = splitLine[1]; - - var name = splitLine[2]; - var size = 1; - - if (name.indexOf('[') > -1) { - // array! - nameSplit = name.split(/\[|]/); - name = nameSplit[0]; - size *= Number(nameSplit[1]); - } - - if (!name.match(maskRegex)) { - uniforms[name] = { - value: defaultValue(type, size), - name: name, - type: type - }; - } - } - } - - return uniforms; -} - -},{"pixi-gl-core":15}],88:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.calculateScreenSpaceMatrix = calculateScreenSpaceMatrix; -exports.calculateNormalizedScreenSpaceMatrix = calculateNormalizedScreenSpaceMatrix; -exports.calculateSpriteMatrix = calculateSpriteMatrix; - -var _math = require('../../../math'); - -/** - * Calculates the mapped matrix - * @param filterArea {Rectangle} The filter area - * @param sprite {Sprite} the target sprite - * @param outputMatrix {Matrix} @alvin - * @private - */ -// TODO playing around here.. this is temporary - (will end up in the shader) -// this returns a matrix that will normalise map filter cords in the filter to screen space -function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - // let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX), - // let texture = {width:1136, height:700};//sprite._texture.baseTexture; - - // TODO unwrap? - var mappedMatrix = outputMatrix.identity(); - - mappedMatrix.translate(filterArea.x / textureSize.width, filterArea.y / textureSize.height); - - mappedMatrix.scale(textureSize.width, textureSize.height); - - return mappedMatrix; -} - -function calculateNormalizedScreenSpaceMatrix(outputMatrix, filterArea, textureSize) { - var mappedMatrix = outputMatrix.identity(); - - mappedMatrix.translate(filterArea.x / textureSize.width, filterArea.y / textureSize.height); - - var translateScaleX = textureSize.width / filterArea.width; - var translateScaleY = textureSize.height / filterArea.height; - - mappedMatrix.scale(translateScaleX, translateScaleY); - - return mappedMatrix; -} - -// this will map the filter coord so that a texture can be used based on the transform of a sprite -function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - var orig = sprite._texture.orig; - var mappedMatrix = outputMatrix.set(textureSize.width, 0, 0, textureSize.height, filterArea.x, filterArea.y); - var worldTransform = sprite.worldTransform.copy(_math.Matrix.TEMP_MATRIX); - - worldTransform.invert(); - mappedMatrix.prepend(worldTransform); - mappedMatrix.scale(1.0 / orig.width, 1.0 / orig.height); - mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y); - - return mappedMatrix; -} - -},{"../../../math":70}],89:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Filter2 = require('../Filter'); - -var _Filter3 = _interopRequireDefault(_Filter2); - -var _math = require('../../../../math'); - -var _path = require('path'); - -var _TextureMatrix = require('../../../../textures/TextureMatrix'); - -var _TextureMatrix2 = _interopRequireDefault(_TextureMatrix); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The SpriteMaskFilter class - * - * @class - * @extends PIXI.Filter - * @memberof PIXI - */ -var SpriteMaskFilter = function (_Filter) { - _inherits(SpriteMaskFilter, _Filter); - - /** - * @param {PIXI.Sprite} sprite - the target sprite - */ - function SpriteMaskFilter(sprite) { - _classCallCheck(this, SpriteMaskFilter); - - var maskMatrix = new _math.Matrix(); - - var _this = _possibleConstructorReturn(this, _Filter.call(this, 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n', 'varying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(maskClamp.x, vMaskCoord.x) +\n step(maskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, maskClamp.z) +\n step(vMaskCoord.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n\n original *= (masky.r * masky.a * alpha * clip);\n\n gl_FragColor = original;\n}\n')); - - sprite.renderable = false; - - _this.maskSprite = sprite; - _this.maskMatrix = maskMatrix; - return _this; - } - - /** - * Applies the filter - * - * @param {PIXI.FilterManager} filterManager - The renderer to retrieve the filter from - * @param {PIXI.RenderTarget} input - The input render target. - * @param {PIXI.RenderTarget} output - The target to output to. - * @param {boolean} clear - Should the output be cleared before rendering to it - */ - - - SpriteMaskFilter.prototype.apply = function apply(filterManager, input, output, clear) { - var maskSprite = this.maskSprite; - var tex = this.maskSprite.texture; - - if (!tex.valid) { - return; - } - if (!tex.transform) { - // margin = 0.0, let it bleed a bit, shader code becomes easier - // assuming that atlas textures were made with 1-pixel padding - tex.transform = new _TextureMatrix2.default(tex, 0.0); - } - tex.transform.update(); - - this.uniforms.mask = tex; - this.uniforms.otherMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, maskSprite).prepend(tex.transform.mapCoord); - this.uniforms.alpha = maskSprite.worldAlpha; - this.uniforms.maskClamp = tex.transform.uClampFrame; - - filterManager.applyFilter(this, input, output, clear); - }; - - return SpriteMaskFilter; -}(_Filter3.default); - -exports.default = SpriteMaskFilter; - -},{"../../../../math":70,"../../../../textures/TextureMatrix":116,"../Filter":86,"path":8}],90:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _WebGLManager2 = require('./WebGLManager'); - -var _WebGLManager3 = _interopRequireDefault(_WebGLManager2); - -var _RenderTarget = require('../utils/RenderTarget'); - -var _RenderTarget2 = _interopRequireDefault(_RenderTarget); - -var _Quad = require('../utils/Quad'); - -var _Quad2 = _interopRequireDefault(_Quad); - -var _math = require('../../../math'); - -var _Shader = require('../../../Shader'); - -var _Shader2 = _interopRequireDefault(_Shader); - -var _filterTransforms = require('../filters/filterTransforms'); - -var filterTransforms = _interopRequireWildcard(_filterTransforms); - -var _bitTwiddle = require('bit-twiddle'); - -var _bitTwiddle2 = _interopRequireDefault(_bitTwiddle); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * @ignore - * @class - */ -var FilterState = function () { - /** - * - */ - function FilterState() { - _classCallCheck(this, FilterState); - - this.renderTarget = null; - this.target = null; - this.resolution = 1; - - // those three objects are used only for root - // re-assigned for everything else - this.sourceFrame = new _math.Rectangle(); - this.destinationFrame = new _math.Rectangle(); - this.filters = []; - } - - /** - * clears the state - */ - - - FilterState.prototype.clear = function clear() { - this.filters = null; - this.target = null; - this.renderTarget = null; - }; - - return FilterState; -}(); - -var screenKey = 'screen'; - -/** - * @class - * @memberof PIXI - * @extends PIXI.WebGLManager - */ - -var FilterManager = function (_WebGLManager) { - _inherits(FilterManager, _WebGLManager); - - /** - * @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for. - */ - function FilterManager(renderer) { - _classCallCheck(this, FilterManager); - - var _this = _possibleConstructorReturn(this, _WebGLManager.call(this, renderer)); - - _this.gl = _this.renderer.gl; - // know about sprites! - _this.quad = new _Quad2.default(_this.gl, renderer.state.attribState); - - _this.shaderCache = {}; - // todo add default! - _this.pool = {}; - - _this.filterData = null; - - _this.managedFilters = []; - - _this.renderer.on('prerender', _this.onPrerender, _this); - - _this._screenWidth = renderer.view.width; - _this._screenHeight = renderer.view.height; - return _this; - } - - /** - * Adds a new filter to the manager. - * - * @param {PIXI.DisplayObject} target - The target of the filter to render. - * @param {PIXI.Filter[]} filters - The filters to apply. - */ - - - FilterManager.prototype.pushFilter = function pushFilter(target, filters) { - var renderer = this.renderer; - - var filterData = this.filterData; - - if (!filterData) { - filterData = this.renderer._activeRenderTarget.filterStack; - - // add new stack - var filterState = new FilterState(); - - filterState.sourceFrame = filterState.destinationFrame = this.renderer._activeRenderTarget.size; - filterState.renderTarget = renderer._activeRenderTarget; - - this.renderer._activeRenderTarget.filterData = filterData = { - index: 0, - stack: [filterState] - }; - - this.filterData = filterData; - } - - // get the current filter state.. - var currentState = filterData.stack[++filterData.index]; - var renderTargetFrame = filterData.stack[0].destinationFrame; - - if (!currentState) { - currentState = filterData.stack[filterData.index] = new FilterState(); - } - - var fullScreen = target.filterArea && target.filterArea.x === 0 && target.filterArea.y === 0 && target.filterArea.width === renderer.screen.width && target.filterArea.height === renderer.screen.height; - - // for now we go off the filter of the first resolution.. - var resolution = filters[0].resolution; - var padding = filters[0].padding | 0; - var targetBounds = fullScreen ? renderer.screen : target.filterArea || target.getBounds(true); - var sourceFrame = currentState.sourceFrame; - var destinationFrame = currentState.destinationFrame; - - sourceFrame.x = (targetBounds.x * resolution | 0) / resolution; - sourceFrame.y = (targetBounds.y * resolution | 0) / resolution; - sourceFrame.width = (targetBounds.width * resolution | 0) / resolution; - sourceFrame.height = (targetBounds.height * resolution | 0) / resolution; - - if (!fullScreen) { - if (filterData.stack[0].renderTarget.transform) {// - - // TODO we should fit the rect around the transform.. - } else if (filters[0].autoFit) { - sourceFrame.fit(renderTargetFrame); - } - - // lets apply the padding After we fit the element to the screen. - // this should stop the strange side effects that can occur when cropping to the edges - sourceFrame.pad(padding); - } - - destinationFrame.width = sourceFrame.width; - destinationFrame.height = sourceFrame.height; - - // lets play the padding after we fit the element to the screen. - // this should stop the strange side effects that can occur when cropping to the edges - - var renderTarget = this.getPotRenderTarget(renderer.gl, sourceFrame.width, sourceFrame.height, resolution); - - currentState.target = target; - currentState.filters = filters; - currentState.resolution = resolution; - currentState.renderTarget = renderTarget; - - // bind the render target to draw the shape in the top corner.. - - renderTarget.setFrame(destinationFrame, sourceFrame); - - // bind the render target - renderer.bindRenderTarget(renderTarget); - renderTarget.clear(); - }; - - /** - * Pops off the filter and applies it. - * - */ - - - FilterManager.prototype.popFilter = function popFilter() { - var filterData = this.filterData; - - var lastState = filterData.stack[filterData.index - 1]; - var currentState = filterData.stack[filterData.index]; - - this.quad.map(currentState.renderTarget.size, currentState.sourceFrame).upload(); - - var filters = currentState.filters; - - if (filters.length === 1) { - filters[0].apply(this, currentState.renderTarget, lastState.renderTarget, false, currentState); - this.freePotRenderTarget(currentState.renderTarget); - } else { - var flip = currentState.renderTarget; - var flop = this.getPotRenderTarget(this.renderer.gl, currentState.sourceFrame.width, currentState.sourceFrame.height, currentState.resolution); - - flop.setFrame(currentState.destinationFrame, currentState.sourceFrame); - - // finally lets clear the render target before drawing to it.. - flop.clear(); - - var i = 0; - - for (i = 0; i < filters.length - 1; ++i) { - filters[i].apply(this, flip, flop, true, currentState); - - var t = flip; - - flip = flop; - flop = t; - } - - filters[i].apply(this, flip, lastState.renderTarget, false, currentState); - - this.freePotRenderTarget(flip); - this.freePotRenderTarget(flop); - } - - currentState.clear(); - filterData.index--; - - if (filterData.index === 0) { - this.filterData = null; - } - }; - - /** - * Draws a filter. - * - * @param {PIXI.Filter} filter - The filter to draw. - * @param {PIXI.RenderTarget} input - The input render target. - * @param {PIXI.RenderTarget} output - The target to output to. - * @param {boolean} clear - Should the output be cleared before rendering to it - */ - - - FilterManager.prototype.applyFilter = function applyFilter(filter, input, output, clear) { - var renderer = this.renderer; - var gl = renderer.gl; - - var shader = filter.glShaders[renderer.CONTEXT_UID]; - - // caching.. - if (!shader) { - if (filter.glShaderKey) { - shader = this.shaderCache[filter.glShaderKey]; - - if (!shader) { - shader = new _Shader2.default(this.gl, filter.vertexSrc, filter.fragmentSrc); - - filter.glShaders[renderer.CONTEXT_UID] = this.shaderCache[filter.glShaderKey] = shader; - this.managedFilters.push(filter); - } - } else { - shader = filter.glShaders[renderer.CONTEXT_UID] = new _Shader2.default(this.gl, filter.vertexSrc, filter.fragmentSrc); - this.managedFilters.push(filter); - } - - // TODO - this only needs to be done once? - renderer.bindVao(null); - - this.quad.initVao(shader); - } - - renderer.bindVao(this.quad.vao); - - renderer.bindRenderTarget(output); - - if (clear) { - gl.disable(gl.SCISSOR_TEST); - renderer.clear(); // [1, 1, 1, 1]); - gl.enable(gl.SCISSOR_TEST); - } - - // in case the render target is being masked using a scissor rect - if (output === renderer.maskManager.scissorRenderTarget) { - renderer.maskManager.pushScissorMask(null, renderer.maskManager.scissorData); - } - - renderer.bindShader(shader); - - // free unit 0 for us, doesn't matter what was there - // don't try to restore it, because syncUniforms can upload it to another slot - // and it'll be a problem - var tex = this.renderer.emptyTextures[0]; - - this.renderer.boundTextures[0] = tex; - // this syncs the PixiJS filters uniforms with glsl uniforms - this.syncUniforms(shader, filter); - - renderer.state.setBlendMode(filter.blendMode); - - gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, input.texture.texture); - - this.quad.vao.draw(this.renderer.gl.TRIANGLES, 6, 0); - - gl.bindTexture(gl.TEXTURE_2D, tex._glTextures[this.renderer.CONTEXT_UID].texture); - }; - - /** - * Uploads the uniforms of the filter. - * - * @param {GLShader} shader - The underlying gl shader. - * @param {PIXI.Filter} filter - The filter we are synchronizing. - */ - - - FilterManager.prototype.syncUniforms = function syncUniforms(shader, filter) { - var uniformData = filter.uniformData; - var uniforms = filter.uniforms; - - // 0 is reserved for the PixiJS texture so we start at 1! - var textureCount = 1; - var currentState = void 0; - - // filterArea and filterClamp that are handled by FilterManager directly - // they must not appear in uniformData - - if (shader.uniforms.filterArea) { - currentState = this.filterData.stack[this.filterData.index]; - - var filterArea = shader.uniforms.filterArea; - - filterArea[0] = currentState.renderTarget.size.width; - filterArea[1] = currentState.renderTarget.size.height; - filterArea[2] = currentState.sourceFrame.x; - filterArea[3] = currentState.sourceFrame.y; - - shader.uniforms.filterArea = filterArea; - } - - // use this to clamp displaced texture coords so they belong to filterArea - // see displacementFilter fragment shader for an example - if (shader.uniforms.filterClamp) { - currentState = currentState || this.filterData.stack[this.filterData.index]; - - var filterClamp = shader.uniforms.filterClamp; - - filterClamp[0] = 0; - filterClamp[1] = 0; - filterClamp[2] = (currentState.sourceFrame.width - 1) / currentState.renderTarget.size.width; - filterClamp[3] = (currentState.sourceFrame.height - 1) / currentState.renderTarget.size.height; - - shader.uniforms.filterClamp = filterClamp; - } - - // TODO Caching layer.. - for (var i in uniformData) { - if (!shader.uniforms.data[i]) { - continue; - } - - var type = uniformData[i].type; - - if (type === 'sampler2d' && uniforms[i] !== 0) { - if (uniforms[i].baseTexture) { - shader.uniforms[i] = this.renderer.bindTexture(uniforms[i].baseTexture, textureCount); - } else { - shader.uniforms[i] = textureCount; - - // TODO - // this is helpful as renderTargets can also be set. - // Although thinking about it, we could probably - // make the filter texture cache return a RenderTexture - // rather than a renderTarget - var gl = this.renderer.gl; - - this.renderer.boundTextures[textureCount] = this.renderer.emptyTextures[textureCount]; - gl.activeTexture(gl.TEXTURE0 + textureCount); - - uniforms[i].texture.bind(); - } - - textureCount++; - } else if (type === 'mat3') { - // check if its PixiJS matrix.. - if (uniforms[i].a !== undefined) { - shader.uniforms[i] = uniforms[i].toArray(true); - } else { - shader.uniforms[i] = uniforms[i]; - } - } else if (type === 'vec2') { - // check if its a point.. - if (uniforms[i].x !== undefined) { - var val = shader.uniforms[i] || new Float32Array(2); - - val[0] = uniforms[i].x; - val[1] = uniforms[i].y; - shader.uniforms[i] = val; - } else { - shader.uniforms[i] = uniforms[i]; - } - } else if (type === 'float') { - if (shader.uniforms.data[i].value !== uniformData[i]) { - shader.uniforms[i] = uniforms[i]; - } - } else { - shader.uniforms[i] = uniforms[i]; - } - } - }; - - /** - * Gets a render target from the pool, or creates a new one. - * - * @param {boolean} clear - Should we clear the render texture when we get it? - * @param {number} resolution - The resolution of the target. - * @return {PIXI.RenderTarget} The new render target - */ - - - FilterManager.prototype.getRenderTarget = function getRenderTarget(clear, resolution) { - var currentState = this.filterData.stack[this.filterData.index]; - var renderTarget = this.getPotRenderTarget(this.renderer.gl, currentState.sourceFrame.width, currentState.sourceFrame.height, resolution || currentState.resolution); - - renderTarget.setFrame(currentState.destinationFrame, currentState.sourceFrame); - - return renderTarget; - }; - - /** - * Returns a render target to the pool. - * - * @param {PIXI.RenderTarget} renderTarget - The render target to return. - */ - - - FilterManager.prototype.returnRenderTarget = function returnRenderTarget(renderTarget) { - this.freePotRenderTarget(renderTarget); - }; - - /** - * Calculates the mapped matrix. - * - * TODO playing around here.. this is temporary - (will end up in the shader) - * this returns a matrix that will normalise map filter cords in the filter to screen space - * - * @param {PIXI.Matrix} outputMatrix - the matrix to output to. - * @return {PIXI.Matrix} The mapped matrix. - */ - - - FilterManager.prototype.calculateScreenSpaceMatrix = function calculateScreenSpaceMatrix(outputMatrix) { - var currentState = this.filterData.stack[this.filterData.index]; - - return filterTransforms.calculateScreenSpaceMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size); - }; - - /** - * Multiply vTextureCoord to this matrix to achieve (0,0,1,1) for filterArea - * - * @param {PIXI.Matrix} outputMatrix - The matrix to output to. - * @return {PIXI.Matrix} The mapped matrix. - */ - - - FilterManager.prototype.calculateNormalizedScreenSpaceMatrix = function calculateNormalizedScreenSpaceMatrix(outputMatrix) { - var currentState = this.filterData.stack[this.filterData.index]; - - return filterTransforms.calculateNormalizedScreenSpaceMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size, currentState.destinationFrame); - }; - - /** - * This will map the filter coord so that a texture can be used based on the transform of a sprite - * - * @param {PIXI.Matrix} outputMatrix - The matrix to output to. - * @param {PIXI.Sprite} sprite - The sprite to map to. - * @return {PIXI.Matrix} The mapped matrix. - */ - - - FilterManager.prototype.calculateSpriteMatrix = function calculateSpriteMatrix(outputMatrix, sprite) { - var currentState = this.filterData.stack[this.filterData.index]; - - return filterTransforms.calculateSpriteMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size, sprite); - }; - - /** - * Destroys this Filter Manager. - * - * @param {boolean} [contextLost=false] context was lost, do not free shaders - * - */ - - - FilterManager.prototype.destroy = function destroy() { - var contextLost = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - - var renderer = this.renderer; - var filters = this.managedFilters; - - renderer.off('prerender', this.onPrerender, this); - - for (var i = 0; i < filters.length; i++) { - if (!contextLost) { - filters[i].glShaders[renderer.CONTEXT_UID].destroy(); - } - delete filters[i].glShaders[renderer.CONTEXT_UID]; - } - - this.shaderCache = {}; - if (!contextLost) { - this.emptyPool(); - } else { - this.pool = {}; - } - }; - - /** - * Gets a Power-of-Two render texture. - * - * TODO move to a separate class could be on renderer? - * also - could cause issue with multiple contexts? - * - * @private - * @param {WebGLRenderingContext} gl - The webgl rendering context - * @param {number} minWidth - The minimum width of the render target. - * @param {number} minHeight - The minimum height of the render target. - * @param {number} resolution - The resolution of the render target. - * @return {PIXI.RenderTarget} The new render target. - */ - - - FilterManager.prototype.getPotRenderTarget = function getPotRenderTarget(gl, minWidth, minHeight, resolution) { - var key = screenKey; - - minWidth *= resolution; - minHeight *= resolution; - - if (minWidth !== this._screenWidth || minHeight !== this._screenHeight) { - // TODO you could return a bigger texture if there is not one in the pool? - minWidth = _bitTwiddle2.default.nextPow2(minWidth); - minHeight = _bitTwiddle2.default.nextPow2(minHeight); - key = (minWidth & 0xFFFF) << 16 | minHeight & 0xFFFF; - } - - if (!this.pool[key]) { - this.pool[key] = []; - } - - var renderTarget = this.pool[key].pop(); - - // creating render target will cause texture to be bound! - if (!renderTarget) { - // temporary bypass cache.. - var tex = this.renderer.boundTextures[0]; - - gl.activeTexture(gl.TEXTURE0); - - // internally - this will cause a texture to be bound.. - renderTarget = new _RenderTarget2.default(gl, minWidth, minHeight, null, 1); - - // set the current one back - gl.bindTexture(gl.TEXTURE_2D, tex._glTextures[this.renderer.CONTEXT_UID].texture); - } - - // manually tweak the resolution... - // this will not modify the size of the frame buffer, just its resolution. - renderTarget.resolution = resolution; - renderTarget.defaultFrame.width = renderTarget.size.width = minWidth / resolution; - renderTarget.defaultFrame.height = renderTarget.size.height = minHeight / resolution; - renderTarget.filterPoolKey = key; - - return renderTarget; - }; - - /** - * Empties the texture pool. - * - */ - - - FilterManager.prototype.emptyPool = function emptyPool() { - for (var i in this.pool) { - var textures = this.pool[i]; - - if (textures) { - for (var j = 0; j < textures.length; j++) { - textures[j].destroy(true); - } - } - } - - this.pool = {}; - }; - - /** - * Frees a render target back into the pool. - * - * @param {PIXI.RenderTarget} renderTarget - The renderTarget to free - */ - - - FilterManager.prototype.freePotRenderTarget = function freePotRenderTarget(renderTarget) { - this.pool[renderTarget.filterPoolKey].push(renderTarget); - }; - - /** - * Called before the renderer starts rendering. - * - */ - - - FilterManager.prototype.onPrerender = function onPrerender() { - if (this._screenWidth !== this.renderer.view.width || this._screenHeight !== this.renderer.view.height) { - this._screenWidth = this.renderer.view.width; - this._screenHeight = this.renderer.view.height; - - var textures = this.pool[screenKey]; - - if (textures) { - for (var j = 0; j < textures.length; j++) { - textures[j].destroy(true); - } - } - this.pool[screenKey] = []; - } - }; - - return FilterManager; -}(_WebGLManager3.default); - -exports.default = FilterManager; - -},{"../../../Shader":44,"../../../math":70,"../filters/filterTransforms":88,"../utils/Quad":95,"../utils/RenderTarget":96,"./WebGLManager":93,"bit-twiddle":1}],91:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _WebGLManager2 = require('./WebGLManager'); - -var _WebGLManager3 = _interopRequireDefault(_WebGLManager2); - -var _SpriteMaskFilter = require('../filters/spriteMask/SpriteMaskFilter'); - -var _SpriteMaskFilter2 = _interopRequireDefault(_SpriteMaskFilter); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * @class - * @extends PIXI.WebGLManager - * @memberof PIXI - */ -var MaskManager = function (_WebGLManager) { - _inherits(MaskManager, _WebGLManager); - - /** - * @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for. - */ - function MaskManager(renderer) { - _classCallCheck(this, MaskManager); - - // TODO - we don't need both! - var _this = _possibleConstructorReturn(this, _WebGLManager.call(this, renderer)); - - _this.scissor = false; - _this.scissorData = null; - _this.scissorRenderTarget = null; - - _this.enableScissor = true; - - _this.alphaMaskPool = []; - _this.alphaMaskIndex = 0; - return _this; - } - - /** - * Applies the Mask and adds it to the current filter stack. - * - * @param {PIXI.DisplayObject} target - Display Object to push the mask to - * @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data. - */ - - - MaskManager.prototype.pushMask = function pushMask(target, maskData) { - // TODO the root check means scissor rect will not - // be used on render textures more info here: - // https://github.com/pixijs/pixi.js/pull/3545 - - if (maskData.texture) { - this.pushSpriteMask(target, maskData); - } else if (this.enableScissor && !this.scissor && this.renderer._activeRenderTarget.root && !this.renderer.stencilManager.stencilMaskStack.length && maskData.isFastRect()) { - var matrix = maskData.worldTransform; - - var rot = Math.atan2(matrix.b, matrix.a); - - // use the nearest degree! - rot = Math.round(rot * (180 / Math.PI)); - - if (rot % 90) { - this.pushStencilMask(maskData); - } else { - this.pushScissorMask(target, maskData); - } - } else { - this.pushStencilMask(maskData); - } - }; - - /** - * Removes the last mask from the mask stack and doesn't return it. - * - * @param {PIXI.DisplayObject} target - Display Object to pop the mask from - * @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data. - */ - - - MaskManager.prototype.popMask = function popMask(target, maskData) { - if (maskData.texture) { - this.popSpriteMask(target, maskData); - } else if (this.enableScissor && !this.renderer.stencilManager.stencilMaskStack.length) { - this.popScissorMask(target, maskData); - } else { - this.popStencilMask(target, maskData); - } - }; - - /** - * Applies the Mask and adds it to the current filter stack. - * - * @param {PIXI.RenderTarget} target - Display Object to push the sprite mask to - * @param {PIXI.Sprite} maskData - Sprite to be used as the mask - */ - - - MaskManager.prototype.pushSpriteMask = function pushSpriteMask(target, maskData) { - var alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex]; - - if (!alphaMaskFilter) { - alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new _SpriteMaskFilter2.default(maskData)]; - } - - alphaMaskFilter[0].resolution = this.renderer.resolution; - alphaMaskFilter[0].maskSprite = maskData; - - var stashFilterArea = target.filterArea; - - target.filterArea = maskData.getBounds(true); - this.renderer.filterManager.pushFilter(target, alphaMaskFilter); - target.filterArea = stashFilterArea; - - this.alphaMaskIndex++; - }; - - /** - * Removes the last filter from the filter stack and doesn't return it. - * - */ - - - MaskManager.prototype.popSpriteMask = function popSpriteMask() { - this.renderer.filterManager.popFilter(); - this.alphaMaskIndex--; - }; - - /** - * Applies the Mask and adds it to the current filter stack. - * - * @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data. - */ - - - MaskManager.prototype.pushStencilMask = function pushStencilMask(maskData) { - this.renderer.currentRenderer.stop(); - this.renderer.stencilManager.pushStencil(maskData); - }; - - /** - * Removes the last filter from the filter stack and doesn't return it. - * - */ - - - MaskManager.prototype.popStencilMask = function popStencilMask() { - this.renderer.currentRenderer.stop(); - this.renderer.stencilManager.popStencil(); - }; - - /** - * - * @param {PIXI.DisplayObject} target - Display Object to push the mask to - * @param {PIXI.Graphics} maskData - The masking data. - */ - - - MaskManager.prototype.pushScissorMask = function pushScissorMask(target, maskData) { - maskData.renderable = true; - - var renderTarget = this.renderer._activeRenderTarget; - - var bounds = maskData.getBounds(); - - bounds.fit(renderTarget.size); - maskData.renderable = false; - - this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST); - - var resolution = this.renderer.resolution; - - this.renderer.gl.scissor(bounds.x * resolution, (renderTarget.root ? renderTarget.size.height - bounds.y - bounds.height : bounds.y) * resolution, bounds.width * resolution, bounds.height * resolution); - - this.scissorRenderTarget = renderTarget; - this.scissorData = maskData; - this.scissor = true; - }; - - /** - * - * - */ - - - MaskManager.prototype.popScissorMask = function popScissorMask() { - this.scissorRenderTarget = null; - this.scissorData = null; - this.scissor = false; - - // must be scissor! - var gl = this.renderer.gl; - - gl.disable(gl.SCISSOR_TEST); - }; - - return MaskManager; -}(_WebGLManager3.default); - -exports.default = MaskManager; - -},{"../filters/spriteMask/SpriteMaskFilter":89,"./WebGLManager":93}],92:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _WebGLManager2 = require('./WebGLManager'); - -var _WebGLManager3 = _interopRequireDefault(_WebGLManager2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * @class - * @extends PIXI.WebGLManager - * @memberof PIXI - */ -var StencilManager = function (_WebGLManager) { - _inherits(StencilManager, _WebGLManager); - - /** - * @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for. - */ - function StencilManager(renderer) { - _classCallCheck(this, StencilManager); - - var _this = _possibleConstructorReturn(this, _WebGLManager.call(this, renderer)); - - _this.stencilMaskStack = null; - return _this; - } - - /** - * Changes the mask stack that is used by this manager. - * - * @param {PIXI.Graphics[]} stencilMaskStack - The mask stack - */ - - - StencilManager.prototype.setMaskStack = function setMaskStack(stencilMaskStack) { - this.stencilMaskStack = stencilMaskStack; - - var gl = this.renderer.gl; - - if (stencilMaskStack.length === 0) { - gl.disable(gl.STENCIL_TEST); - } else { - gl.enable(gl.STENCIL_TEST); - } - }; - - /** - * Applies the Mask and adds it to the current stencil stack. @alvin - * - * @param {PIXI.Graphics} graphics - The mask - */ - - - StencilManager.prototype.pushStencil = function pushStencil(graphics) { - this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - - this.renderer._activeRenderTarget.attachStencilBuffer(); - - var gl = this.renderer.gl; - var prevMaskCount = this.stencilMaskStack.length; - - if (prevMaskCount === 0) { - gl.enable(gl.STENCIL_TEST); - } - - this.stencilMaskStack.push(graphics); - - // Increment the reference stencil value where the new mask overlaps with the old ones. - gl.colorMask(false, false, false, false); - gl.stencilFunc(gl.EQUAL, prevMaskCount, this._getBitwiseMask()); - gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR); - this.renderer.plugins.graphics.render(graphics); - - this._useCurrent(); - }; - - /** - * Removes the last mask from the stencil stack. @alvin - */ - - - StencilManager.prototype.popStencil = function popStencil() { - this.renderer.setObjectRenderer(this.renderer.plugins.graphics); - - var gl = this.renderer.gl; - var graphics = this.stencilMaskStack.pop(); - - if (this.stencilMaskStack.length === 0) { - // the stack is empty! - gl.disable(gl.STENCIL_TEST); - gl.clear(gl.STENCIL_BUFFER_BIT); - gl.clearStencil(0); - } else { - // Decrement the reference stencil value where the popped mask overlaps with the other ones - gl.colorMask(false, false, false, false); - gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR); - this.renderer.plugins.graphics.render(graphics); - - this._useCurrent(); - } - }; - - /** - * Setup renderer to use the current stencil data. - */ - - - StencilManager.prototype._useCurrent = function _useCurrent() { - var gl = this.renderer.gl; - - gl.colorMask(true, true, true, true); - gl.stencilFunc(gl.EQUAL, this.stencilMaskStack.length, this._getBitwiseMask()); - gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); - }; - - /** - * Fill 1s equal to the number of acitve stencil masks. - * - * @return {number} The bitwise mask. - */ - - - StencilManager.prototype._getBitwiseMask = function _getBitwiseMask() { - return (1 << this.stencilMaskStack.length) - 1; - }; - - /** - * Destroys the mask stack. - * - */ - - - StencilManager.prototype.destroy = function destroy() { - _WebGLManager3.default.prototype.destroy.call(this); - - this.stencilMaskStack.stencilStack = null; - }; - - return StencilManager; -}(_WebGLManager3.default); - -exports.default = StencilManager; - -},{"./WebGLManager":93}],93:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * @class - * @memberof PIXI - */ -var WebGLManager = function () { - /** - * @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for. - */ - function WebGLManager(renderer) { - _classCallCheck(this, WebGLManager); - - /** - * The renderer this manager works for. - * - * @member {PIXI.WebGLRenderer} - */ - this.renderer = renderer; - - this.renderer.on('context', this.onContextChange, this); - } - - /** - * Generic method called when there is a WebGL context change. - * - */ - - - WebGLManager.prototype.onContextChange = function onContextChange() {} - // do some codes init! - - - /** - * Generic destroy methods to be overridden by the subclass - * - */ - ; - - WebGLManager.prototype.destroy = function destroy() { - this.renderer.off('context', this.onContextChange, this); - - this.renderer = null; - }; - - return WebGLManager; -}(); - -exports.default = WebGLManager; - -},{}],94:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _WebGLManager2 = require('../managers/WebGLManager'); - -var _WebGLManager3 = _interopRequireDefault(_WebGLManager2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Base for a common object renderer that can be used as a system renderer plugin. - * - * @class - * @extends PIXI.WebGLManager - * @memberof PIXI - */ -var ObjectRenderer = function (_WebGLManager) { - _inherits(ObjectRenderer, _WebGLManager); - - function ObjectRenderer() { - _classCallCheck(this, ObjectRenderer); - - return _possibleConstructorReturn(this, _WebGLManager.apply(this, arguments)); - } - - /** - * Starts the renderer and sets the shader - * - */ - ObjectRenderer.prototype.start = function start() {} - // set the shader.. - - - /** - * Stops the renderer - * - */ - ; - - ObjectRenderer.prototype.stop = function stop() { - this.flush(); - }; - - /** - * Stub method for rendering content and emptying the current batch. - * - */ - - - ObjectRenderer.prototype.flush = function flush() {} - // flush! - - - /** - * Renders an object - * - * @param {PIXI.DisplayObject} object - The object to render. - */ - ; - - ObjectRenderer.prototype.render = function render(object) // eslint-disable-line no-unused-vars - { - // render the object - }; - - return ObjectRenderer; -}(_WebGLManager3.default); - -exports.default = ObjectRenderer; - -},{"../managers/WebGLManager":93}],95:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _pixiGlCore = require('pixi-gl-core'); - -var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore); - -var _createIndicesForQuads = require('../../../utils/createIndicesForQuads'); - -var _createIndicesForQuads2 = _interopRequireDefault(_createIndicesForQuads); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Helper class to create a quad - * - * @class - * @memberof PIXI - */ -var Quad = function () { - /** - * @param {WebGLRenderingContext} gl - The gl context for this quad to use. - * @param {object} state - TODO: Description - */ - function Quad(gl, state) { - _classCallCheck(this, Quad); - - /** - * the current WebGL drawing context - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - /** - * An array of vertices - * - * @member {Float32Array} - */ - this.vertices = new Float32Array([-1, -1, 1, -1, 1, 1, -1, 1]); - - /** - * The Uvs of the quad - * - * @member {Float32Array} - */ - this.uvs = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]); - - this.interleaved = new Float32Array(8 * 2); - - for (var i = 0; i < 4; i++) { - this.interleaved[i * 4] = this.vertices[i * 2]; - this.interleaved[i * 4 + 1] = this.vertices[i * 2 + 1]; - this.interleaved[i * 4 + 2] = this.uvs[i * 2]; - this.interleaved[i * 4 + 3] = this.uvs[i * 2 + 1]; - } - - /** - * An array containing the indices of the vertices - * - * @member {Uint16Array} - */ - this.indices = (0, _createIndicesForQuads2.default)(1); - - /** - * The vertex buffer - * - * @member {glCore.GLBuffer} - */ - this.vertexBuffer = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, this.interleaved, gl.STATIC_DRAW); - - /** - * The index buffer - * - * @member {glCore.GLBuffer} - */ - this.indexBuffer = _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW); - - /** - * The vertex array object - * - * @member {glCore.VertexArrayObject} - */ - this.vao = new _pixiGlCore2.default.VertexArrayObject(gl, state); - } - - /** - * Initialises the vaos and uses the shader. - * - * @param {PIXI.Shader} shader - the shader to use - */ - - - Quad.prototype.initVao = function initVao(shader) { - this.vao.clear().addIndex(this.indexBuffer).addAttribute(this.vertexBuffer, shader.attributes.aVertexPosition, this.gl.FLOAT, false, 4 * 4, 0).addAttribute(this.vertexBuffer, shader.attributes.aTextureCoord, this.gl.FLOAT, false, 4 * 4, 2 * 4); - }; - - /** - * Maps two Rectangle to the quad. - * - * @param {PIXI.Rectangle} targetTextureFrame - the first rectangle - * @param {PIXI.Rectangle} destinationFrame - the second rectangle - * @return {PIXI.Quad} Returns itself. - */ - - - Quad.prototype.map = function map(targetTextureFrame, destinationFrame) { - var x = 0; // destinationFrame.x / targetTextureFrame.width; - var y = 0; // destinationFrame.y / targetTextureFrame.height; - - this.uvs[0] = x; - this.uvs[1] = y; - - this.uvs[2] = x + destinationFrame.width / targetTextureFrame.width; - this.uvs[3] = y; - - this.uvs[4] = x + destinationFrame.width / targetTextureFrame.width; - this.uvs[5] = y + destinationFrame.height / targetTextureFrame.height; - - this.uvs[6] = x; - this.uvs[7] = y + destinationFrame.height / targetTextureFrame.height; - - x = destinationFrame.x; - y = destinationFrame.y; - - this.vertices[0] = x; - this.vertices[1] = y; - - this.vertices[2] = x + destinationFrame.width; - this.vertices[3] = y; - - this.vertices[4] = x + destinationFrame.width; - this.vertices[5] = y + destinationFrame.height; - - this.vertices[6] = x; - this.vertices[7] = y + destinationFrame.height; - - return this; - }; - - /** - * Binds the buffer and uploads the data - * - * @return {PIXI.Quad} Returns itself. - */ - - - Quad.prototype.upload = function upload() { - for (var i = 0; i < 4; i++) { - this.interleaved[i * 4] = this.vertices[i * 2]; - this.interleaved[i * 4 + 1] = this.vertices[i * 2 + 1]; - this.interleaved[i * 4 + 2] = this.uvs[i * 2]; - this.interleaved[i * 4 + 3] = this.uvs[i * 2 + 1]; - } - - this.vertexBuffer.upload(this.interleaved); - - return this; - }; - - /** - * Removes this quad from WebGL - */ - - - Quad.prototype.destroy = function destroy() { - var gl = this.gl; - - gl.deleteBuffer(this.vertexBuffer); - gl.deleteBuffer(this.indexBuffer); - }; - - return Quad; -}(); - -exports.default = Quad; - -},{"../../../utils/createIndicesForQuads":123,"pixi-gl-core":15}],96:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _math = require('../../../math'); - -var _const = require('../../../const'); - -var _settings = require('../../../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _pixiGlCore = require('pixi-gl-core'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * @class - * @memberof PIXI - */ -var RenderTarget = function () { - /** - * @param {WebGLRenderingContext} gl - The current WebGL drawing context - * @param {number} [width=0] - the horizontal range of the filter - * @param {number} [height=0] - the vertical range of the filter - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {number} [resolution=1] - The current resolution / device pixel ratio - * @param {boolean} [root=false] - Whether this object is the root element or not - */ - function RenderTarget(gl, width, height, scaleMode, resolution, root) { - _classCallCheck(this, RenderTarget); - - // TODO Resolution could go here ( eg low res blurs ) - - /** - * The current WebGL drawing context. - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - // next time to create a frame buffer and texture - - /** - * A frame buffer - * - * @member {PIXI.glCore.GLFramebuffer} - */ - this.frameBuffer = null; - - /** - * The texture - * - * @member {PIXI.glCore.GLTexture} - */ - this.texture = null; - - /** - * The background colour of this render target, as an array of [r,g,b,a] values - * - * @member {number[]} - */ - this.clearColor = [0, 0, 0, 0]; - - /** - * The size of the object as a rectangle - * - * @member {PIXI.Rectangle} - */ - this.size = new _math.Rectangle(0, 0, 1, 1); - - /** - * The current resolution / device pixel ratio - * - * @member {number} - * @default 1 - */ - this.resolution = resolution || _settings2.default.RESOLUTION; - - /** - * The projection matrix - * - * @member {PIXI.Matrix} - */ - this.projectionMatrix = new _math.Matrix(); - - /** - * The object's transform - * - * @member {PIXI.Matrix} - */ - this.transform = null; - - /** - * The frame. - * - * @member {PIXI.Rectangle} - */ - this.frame = null; - - /** - * The stencil buffer stores masking data for the render target - * - * @member {glCore.GLBuffer} - */ - this.defaultFrame = new _math.Rectangle(); - this.destinationFrame = null; - this.sourceFrame = null; - - /** - * The stencil buffer stores masking data for the render target - * - * @member {glCore.GLBuffer} - */ - this.stencilBuffer = null; - - /** - * The data structure for the stencil masks - * - * @member {PIXI.Graphics[]} - */ - this.stencilMaskStack = []; - - /** - * Stores filter data for the render target - * - * @member {object[]} - */ - this.filterData = null; - - /** - * The key for pooled texture of FilterSystem - * @private - * @member {string} - */ - this.filterPoolKey = ''; - - /** - * The scale mode. - * - * @member {number} - * @default PIXI.settings.SCALE_MODE - * @see PIXI.SCALE_MODES - */ - this.scaleMode = scaleMode !== undefined ? scaleMode : _settings2.default.SCALE_MODE; - - /** - * Whether this object is the root element or not - * - * @member {boolean} - * @default false - */ - this.root = root || false; - - if (!this.root) { - this.frameBuffer = _pixiGlCore.GLFramebuffer.createRGBA(gl, 100, 100); - - if (this.scaleMode === _const.SCALE_MODES.NEAREST) { - this.frameBuffer.texture.enableNearestScaling(); - } else { - this.frameBuffer.texture.enableLinearScaling(); - } - /* - A frame buffer needs a target to render to.. - create a texture and bind it attach it to the framebuffer.. - */ - - // this is used by the base texture - this.texture = this.frameBuffer.texture; - } else { - // make it a null framebuffer.. - this.frameBuffer = new _pixiGlCore.GLFramebuffer(gl, 100, 100); - this.frameBuffer.framebuffer = null; - } - - this.setFrame(); - - this.resize(width, height); - } - - /** - * Clears the filter texture. - * - * @param {number[]} [clearColor=this.clearColor] - Array of [r,g,b,a] to clear the framebuffer - */ - - - RenderTarget.prototype.clear = function clear(clearColor) { - var cc = clearColor || this.clearColor; - - this.frameBuffer.clear(cc[0], cc[1], cc[2], cc[3]); // r,g,b,a); - }; - - /** - * Binds the stencil buffer. - * - */ - - - RenderTarget.prototype.attachStencilBuffer = function attachStencilBuffer() { - // TODO check if stencil is done? - /** - * The stencil buffer is used for masking in pixi - * lets create one and then add attach it to the framebuffer.. - */ - if (!this.root) { - this.frameBuffer.enableStencil(); - } - }; - - /** - * Sets the frame of the render target. - * - * @param {Rectangle} destinationFrame - The destination frame. - * @param {Rectangle} sourceFrame - The source frame. - */ - - - RenderTarget.prototype.setFrame = function setFrame(destinationFrame, sourceFrame) { - this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame; - this.sourceFrame = sourceFrame || this.sourceFrame || this.destinationFrame; - }; - - /** - * Binds the buffers and initialises the viewport. - * - */ - - - RenderTarget.prototype.activate = function activate() { - // TODO refactor usage of frame.. - var gl = this.gl; - - // make sure the texture is unbound! - this.frameBuffer.bind(); - - this.calculateProjection(this.destinationFrame, this.sourceFrame); - - if (this.transform) { - this.projectionMatrix.append(this.transform); - } - - // TODO add a check as them may be the same! - if (this.destinationFrame !== this.sourceFrame) { - gl.enable(gl.SCISSOR_TEST); - gl.scissor(this.destinationFrame.x | 0, this.destinationFrame.y | 0, this.destinationFrame.width * this.resolution | 0, this.destinationFrame.height * this.resolution | 0); - } else { - gl.disable(gl.SCISSOR_TEST); - } - - // TODO - does not need to be updated all the time?? - gl.viewport(this.destinationFrame.x | 0, this.destinationFrame.y | 0, this.destinationFrame.width * this.resolution | 0, this.destinationFrame.height * this.resolution | 0); - }; - - /** - * Updates the projection matrix based on a projection frame (which is a rectangle) - * - * @param {Rectangle} destinationFrame - The destination frame. - * @param {Rectangle} sourceFrame - The source frame. - */ - - - RenderTarget.prototype.calculateProjection = function calculateProjection(destinationFrame, sourceFrame) { - var pm = this.projectionMatrix; - - sourceFrame = sourceFrame || destinationFrame; - - pm.identity(); - - // TODO: make dest scale source - if (!this.root) { - pm.a = 1 / destinationFrame.width * 2; - pm.d = 1 / destinationFrame.height * 2; - - pm.tx = -1 - sourceFrame.x * pm.a; - pm.ty = -1 - sourceFrame.y * pm.d; - } else { - pm.a = 1 / destinationFrame.width * 2; - pm.d = -1 / destinationFrame.height * 2; - - pm.tx = -1 - sourceFrame.x * pm.a; - pm.ty = 1 - sourceFrame.y * pm.d; - } - }; - - /** - * Resizes the texture to the specified width and height - * - * @param {number} width - the new width of the texture - * @param {number} height - the new height of the texture - */ - - - RenderTarget.prototype.resize = function resize(width, height) { - width = width | 0; - height = height | 0; - - if (this.size.width === width && this.size.height === height) { - return; - } - - this.size.width = width; - this.size.height = height; - - this.defaultFrame.width = width; - this.defaultFrame.height = height; - - this.frameBuffer.resize(width * this.resolution, height * this.resolution); - - var projectionFrame = this.frame || this.size; - - this.calculateProjection(projectionFrame); - }; - - /** - * Destroys the render target. - * - */ - - - RenderTarget.prototype.destroy = function destroy() { - if (this.frameBuffer.stencil) { - this.gl.deleteRenderbuffer(this.frameBuffer.stencil); - } - this.frameBuffer.destroy(); - - this.frameBuffer = null; - this.texture = null; - }; - - return RenderTarget; -}(); - -exports.default = RenderTarget; - -},{"../../../const":46,"../../../math":70,"../../../settings":101,"pixi-gl-core":15}],97:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = checkMaxIfStatmentsInShader; - -var _pixiGlCore = require('pixi-gl-core'); - -var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var fragTemplate = ['precision mediump float;', 'void main(void){', 'float test = 0.1;', '%forloop%', 'gl_FragColor = vec4(0.0);', '}'].join('\n'); - -function checkMaxIfStatmentsInShader(maxIfs, gl) { - var createTempContext = !gl; - - if (maxIfs === 0) { - throw new Error('Invalid value of `0` passed to `checkMaxIfStatementsInShader`'); - } - - if (createTempContext) { - var tinyCanvas = document.createElement('canvas'); - - tinyCanvas.width = 1; - tinyCanvas.height = 1; - - gl = _pixiGlCore2.default.createContext(tinyCanvas); - } - - var shader = gl.createShader(gl.FRAGMENT_SHADER); - - while (true) // eslint-disable-line no-constant-condition - { - var fragmentSrc = fragTemplate.replace(/%forloop%/gi, generateIfTestSrc(maxIfs)); - - gl.shaderSource(shader, fragmentSrc); - gl.compileShader(shader); - - if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - maxIfs = maxIfs / 2 | 0; - } else { - // valid! - break; - } - } - - if (createTempContext) { - // get rid of context - if (gl.getExtension('WEBGL_lose_context')) { - gl.getExtension('WEBGL_lose_context').loseContext(); - } - } - - return maxIfs; -} - -function generateIfTestSrc(maxIfs) { - var src = ''; - - for (var i = 0; i < maxIfs; ++i) { - if (i > 0) { - src += '\nelse '; - } - - if (i < maxIfs - 1) { - src += 'if(test == ' + i + '.0){}'; - } - } - - return src; -} - -},{"pixi-gl-core":15}],98:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = mapWebGLBlendModesToPixi; - -var _const = require('../../../const'); - -/** - * Maps gl blend combinations to WebGL. - * - * @memberof PIXI - * @function mapWebGLBlendModesToPixi - * @private - * @param {WebGLRenderingContext} gl - The rendering context. - * @param {string[]} [array=[]] - The array to output into. - * @return {string[]} Mapped modes. - */ -function mapWebGLBlendModesToPixi(gl) { - var array = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - - // TODO - premultiply alpha would be different. - // add a boolean for that! - array[_const.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.ADD] = [gl.ONE, gl.DST_ALPHA]; - array[_const.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.SCREEN] = [gl.ONE, gl.ONE_MINUS_SRC_COLOR]; - array[_const.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - - // not-premultiplied blend modes - array[_const.BLEND_MODES.NORMAL_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - array[_const.BLEND_MODES.ADD_NPM] = [gl.SRC_ALPHA, gl.DST_ALPHA, gl.ONE, gl.DST_ALPHA]; - array[_const.BLEND_MODES.SCREEN_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_COLOR]; - - return array; -} - -},{"../../../const":46}],99:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = mapWebGLDrawModesToPixi; - -var _const = require('../../../const'); - -/** - * Generic Mask Stack data structure. - * - * @memberof PIXI - * @function mapWebGLDrawModesToPixi - * @private - * @param {WebGLRenderingContext} gl - The current WebGL drawing context - * @param {object} [object={}] - The object to map into - * @return {object} The mapped draw modes. - */ -function mapWebGLDrawModesToPixi(gl) { - var object = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - object[_const.DRAW_MODES.POINTS] = gl.POINTS; - object[_const.DRAW_MODES.LINES] = gl.LINES; - object[_const.DRAW_MODES.LINE_LOOP] = gl.LINE_LOOP; - object[_const.DRAW_MODES.LINE_STRIP] = gl.LINE_STRIP; - object[_const.DRAW_MODES.TRIANGLES] = gl.TRIANGLES; - object[_const.DRAW_MODES.TRIANGLE_STRIP] = gl.TRIANGLE_STRIP; - object[_const.DRAW_MODES.TRIANGLE_FAN] = gl.TRIANGLE_FAN; - - return object; -} - -},{"../../../const":46}],100:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = validateContext; -function validateContext(gl) { - var attributes = gl.getContextAttributes(); - - // this is going to be fairly simple for now.. but at least we have room to grow! - if (!attributes.stencil) { - /* eslint-disable no-console */ - console.warn('Provided WebGL context does not have a stencil buffer, masks may not render correctly'); - /* eslint-enable no-console */ - } -} - -},{}],101:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _maxRecommendedTextures = require('./utils/maxRecommendedTextures'); - -var _maxRecommendedTextures2 = _interopRequireDefault(_maxRecommendedTextures); - -var _canUploadSameBuffer = require('./utils/canUploadSameBuffer'); - -var _canUploadSameBuffer2 = _interopRequireDefault(_canUploadSameBuffer); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * User's customizable globals for overriding the default PIXI settings, such - * as a renderer's default resolution, framerate, float percision, etc. - * @example - * // Use the native window resolution as the default resolution - * // will support high-density displays when rendering - * PIXI.settings.RESOLUTION = window.devicePixelRatio. - * - * // Disable interpolation when scaling, will make texture be pixelated - * PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST; - * @namespace PIXI.settings - */ -exports.default = { - - /** - * Target frames per millisecond. - * - * @static - * @memberof PIXI.settings - * @type {number} - * @default 0.06 - */ - TARGET_FPMS: 0.06, - - /** - * If set to true WebGL will attempt make textures mimpaped by default. - * Mipmapping will only succeed if the base texture uploaded has power of two dimensions. - * - * @static - * @memberof PIXI.settings - * @type {boolean} - * @default true - */ - MIPMAP_TEXTURES: true, - - /** - * Default resolution / device pixel ratio of the renderer. - * - * @static - * @memberof PIXI.settings - * @type {number} - * @default 1 - */ - RESOLUTION: 1, - - /** - * Default filter resolution. - * - * @static - * @memberof PIXI.settings - * @type {number} - * @default 1 - */ - FILTER_RESOLUTION: 1, - - /** - * The maximum textures that this device supports. - * - * @static - * @memberof PIXI.settings - * @type {number} - * @default 32 - */ - SPRITE_MAX_TEXTURES: (0, _maxRecommendedTextures2.default)(32), - - // TODO: maybe change to SPRITE.BATCH_SIZE: 2000 - // TODO: maybe add PARTICLE.BATCH_SIZE: 15000 - - /** - * The default sprite batch size. - * - * The default aims to balance desktop and mobile devices. - * - * @static - * @memberof PIXI.settings - * @type {number} - * @default 4096 - */ - SPRITE_BATCH_SIZE: 4096, - - /** - * The prefix that denotes a URL is for a retina asset. - * - * @static - * @memberof PIXI.settings - * @type {RegExp} - * @example `@2x` - * @default /@([0-9\.]+)x/ - */ - RETINA_PREFIX: /@([0-9\.]+)x/, - - /** - * The default render options if none are supplied to {@link PIXI.WebGLRenderer} - * or {@link PIXI.CanvasRenderer}. - * - * @static - * @constant - * @memberof PIXI.settings - * @type {object} - * @property {HTMLCanvasElement} view=null - * @property {number} resolution=1 - * @property {boolean} antialias=false - * @property {boolean} forceFXAA=false - * @property {boolean} autoResize=false - * @property {boolean} transparent=false - * @property {number} backgroundColor=0x000000 - * @property {boolean} clearBeforeRender=true - * @property {boolean} preserveDrawingBuffer=false - * @property {boolean} roundPixels=false - * @property {number} width=800 - * @property {number} height=600 - * @property {boolean} legacy=false - */ - RENDER_OPTIONS: { - view: null, - antialias: false, - forceFXAA: false, - autoResize: false, - transparent: false, - backgroundColor: 0x000000, - clearBeforeRender: true, - preserveDrawingBuffer: false, - roundPixels: false, - width: 800, - height: 600, - legacy: false - }, - - /** - * Default transform type. - * - * @static - * @memberof PIXI.settings - * @type {PIXI.TRANSFORM_MODE} - * @default PIXI.TRANSFORM_MODE.STATIC - */ - TRANSFORM_MODE: 0, - - /** - * Default Garbage Collection mode. - * - * @static - * @memberof PIXI.settings - * @type {PIXI.GC_MODES} - * @default PIXI.GC_MODES.AUTO - */ - GC_MODE: 0, - - /** - * Default Garbage Collection max idle. - * - * @static - * @memberof PIXI.settings - * @type {number} - * @default 3600 - */ - GC_MAX_IDLE: 60 * 60, - - /** - * Default Garbage Collection maximum check count. - * - * @static - * @memberof PIXI.settings - * @type {number} - * @default 600 - */ - GC_MAX_CHECK_COUNT: 60 * 10, - - /** - * Default wrap modes that are supported by pixi. - * - * @static - * @memberof PIXI.settings - * @type {PIXI.WRAP_MODES} - * @default PIXI.WRAP_MODES.CLAMP - */ - WRAP_MODE: 0, - - /** - * The scale modes that are supported by pixi. - * - * @static - * @memberof PIXI.settings - * @type {PIXI.SCALE_MODES} - * @default PIXI.SCALE_MODES.LINEAR - */ - SCALE_MODE: 0, - - /** - * Default specify float precision in vertex shader. - * - * @static - * @memberof PIXI.settings - * @type {PIXI.PRECISION} - * @default PIXI.PRECISION.HIGH - */ - PRECISION_VERTEX: 'highp', - - /** - * Default specify float precision in fragment shader. - * - * @static - * @memberof PIXI.settings - * @type {PIXI.PRECISION} - * @default PIXI.PRECISION.MEDIUM - */ - PRECISION_FRAGMENT: 'mediump', - - /** - * Can we upload the same buffer in a single frame? - * - * @static - * @constant - * @memberof PIXI.settings - * @type {boolean} - */ - CAN_UPLOAD_SAME_BUFFER: (0, _canUploadSameBuffer2.default)(), - - /** - * Default Mesh `canvasPadding`. - * - * @see PIXI.mesh.Mesh#canvasPadding - * @static - * @constant - * @memberof PIXI.settings - * @type {number} - */ - MESH_CANVAS_PADDING: 0 -}; - -},{"./utils/canUploadSameBuffer":122,"./utils/maxRecommendedTextures":127}],102:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = require('../math'); - -var _utils = require('../utils'); - -var _const = require('../const'); - -var _Texture = require('../textures/Texture'); - -var _Texture2 = _interopRequireDefault(_Texture); - -var _Container2 = require('../display/Container'); - -var _Container3 = _interopRequireDefault(_Container2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var tempPoint = new _math.Point(); - -/** - * The Sprite object is the base for all textured objects that are rendered to the screen - * - * A sprite can be created directly from an image like this: - * - * ```js - * let sprite = new PIXI.Sprite.fromImage('assets/image.png'); - * ``` - * - * The more efficient way to create sprites is using a {@link PIXI.Spritesheet}: - * - * ```js - * PIXI.loader.add("assets/spritesheet.json").load(setup); - * - * function setup() { - * let sheet = PIXI.loader.resources["assets/spritesheet.json"].spritesheet; - * let sprite = new PIXI.Sprite(sheet.textures["image.png"]); - * ... - * } - * ``` - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ - -var Sprite = function (_Container) { - _inherits(Sprite, _Container); - - /** - * @param {PIXI.Texture} texture - The texture for this sprite - */ - function Sprite(texture) { - _classCallCheck(this, Sprite); - - /** - * The anchor sets the origin point of the texture. - * The default is 0,0 or taken from the {@link PIXI.Texture#defaultAnchor|Texture} - * passed to the constructor. A value of 0,0 means the texture's origin is the top left. - * Setting the anchor to 0.5,0.5 means the texture's origin is centered. - * Setting the anchor to 1,1 would mean the texture's origin point will be the bottom right corner. - * Note: Updating the {@link PIXI.Texture#defaultAnchor} after a Texture is - * created does _not_ update the Sprite's anchor values. - * - * @member {PIXI.ObservablePoint} - * @private - */ - var _this = _possibleConstructorReturn(this, _Container.call(this)); - - _this._anchor = new _math.ObservablePoint(_this._onAnchorUpdate, _this, texture ? texture.defaultAnchor.x : 0, texture ? texture.defaultAnchor.y : 0); - - /** - * The texture that the sprite is using - * - * @private - * @member {PIXI.Texture} - */ - _this._texture = null; - - /** - * The width of the sprite (this is initially set by the texture) - * - * @private - * @member {number} - */ - _this._width = 0; - - /** - * The height of the sprite (this is initially set by the texture) - * - * @private - * @member {number} - */ - _this._height = 0; - - /** - * The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect. - * - * @private - * @member {number} - * @default 0xFFFFFF - */ - _this._tint = null; - _this._tintRGB = null; - _this.tint = 0xFFFFFF; - - /** - * The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - _this.blendMode = _const.BLEND_MODES.NORMAL; - - /** - * The shader that will be used to render the sprite. Set to null to remove a current shader. - * - * @member {PIXI.Filter|PIXI.Shader} - */ - _this.shader = null; - - /** - * An internal cached value of the tint. - * - * @private - * @member {number} - * @default 0xFFFFFF - */ - _this.cachedTint = 0xFFFFFF; - - // call texture setter - _this.texture = texture || _Texture2.default.EMPTY; - - /** - * this is used to store the vertex data of the sprite (basically a quad) - * - * @private - * @member {Float32Array} - */ - _this.vertexData = new Float32Array(8); - - /** - * This is used to calculate the bounds of the object IF it is a trimmed sprite - * - * @private - * @member {Float32Array} - */ - _this.vertexTrimmedData = null; - - _this._transformID = -1; - _this._textureID = -1; - - _this._transformTrimmedID = -1; - _this._textureTrimmedID = -1; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_renderWebGL' & '_renderCanvas' methods. - * - * @member {string} - * @default 'sprite' - */ - _this.pluginName = 'sprite'; - return _this; - } - - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - - - Sprite.prototype._onTextureUpdate = function _onTextureUpdate() { - this._textureID = -1; - this._textureTrimmedID = -1; - this.cachedTint = 0xFFFFFF; - - // so if _width is 0 then width was not set.. - if (this._width) { - this.scale.x = (0, _utils.sign)(this.scale.x) * this._width / this._texture.orig.width; - } - - if (this._height) { - this.scale.y = (0, _utils.sign)(this.scale.y) * this._height / this._texture.orig.height; - } - }; - - /** - * Called when the anchor position updates. - * - * @private - */ - - - Sprite.prototype._onAnchorUpdate = function _onAnchorUpdate() { - this._transformID = -1; - this._transformTrimmedID = -1; - }; - - /** - * calculates worldTransform * vertices, store it in vertexData - */ - - - Sprite.prototype.calculateVertices = function calculateVertices() { - if (this._transformID === this.transform._worldID && this._textureID === this._texture._updateID) { - return; - } - - this._transformID = this.transform._worldID; - this._textureID = this._texture._updateID; - - // set the vertex data - - var texture = this._texture; - var wt = this.transform.worldTransform; - var a = wt.a; - var b = wt.b; - var c = wt.c; - var d = wt.d; - var tx = wt.tx; - var ty = wt.ty; - var vertexData = this.vertexData; - var trim = texture.trim; - var orig = texture.orig; - var anchor = this._anchor; - - var w0 = 0; - var w1 = 0; - var h0 = 0; - var h1 = 0; - - if (trim) { - // if the sprite is trimmed and is not a tilingsprite then we need to add the extra - // space before transforming the sprite coords. - w1 = trim.x - anchor._x * orig.width; - w0 = w1 + trim.width; - - h1 = trim.y - anchor._y * orig.height; - h0 = h1 + trim.height; - } else { - w1 = -anchor._x * orig.width; - w0 = w1 + orig.width; - - h1 = -anchor._y * orig.height; - h0 = h1 + orig.height; - } - - // xy - vertexData[0] = a * w1 + c * h1 + tx; - vertexData[1] = d * h1 + b * w1 + ty; - - // xy - vertexData[2] = a * w0 + c * h1 + tx; - vertexData[3] = d * h1 + b * w0 + ty; - - // xy - vertexData[4] = a * w0 + c * h0 + tx; - vertexData[5] = d * h0 + b * w0 + ty; - - // xy - vertexData[6] = a * w1 + c * h0 + tx; - vertexData[7] = d * h0 + b * w1 + ty; - }; - - /** - * calculates worldTransform * vertices for a non texture with a trim. store it in vertexTrimmedData - * This is used to ensure that the true width and height of a trimmed texture is respected - */ - - - Sprite.prototype.calculateTrimmedVertices = function calculateTrimmedVertices() { - if (!this.vertexTrimmedData) { - this.vertexTrimmedData = new Float32Array(8); - } else if (this._transformTrimmedID === this.transform._worldID && this._textureTrimmedID === this._texture._updateID) { - return; - } - - this._transformTrimmedID = this.transform._worldID; - this._textureTrimmedID = this._texture._updateID; - - // lets do some special trim code! - var texture = this._texture; - var vertexData = this.vertexTrimmedData; - var orig = texture.orig; - var anchor = this._anchor; - - // lets calculate the new untrimmed bounds.. - var wt = this.transform.worldTransform; - var a = wt.a; - var b = wt.b; - var c = wt.c; - var d = wt.d; - var tx = wt.tx; - var ty = wt.ty; - - var w1 = -anchor._x * orig.width; - var w0 = w1 + orig.width; - - var h1 = -anchor._y * orig.height; - var h0 = h1 + orig.height; - - // xy - vertexData[0] = a * w1 + c * h1 + tx; - vertexData[1] = d * h1 + b * w1 + ty; - - // xy - vertexData[2] = a * w0 + c * h1 + tx; - vertexData[3] = d * h1 + b * w0 + ty; - - // xy - vertexData[4] = a * w0 + c * h0 + tx; - vertexData[5] = d * h0 + b * w0 + ty; - - // xy - vertexData[6] = a * w1 + c * h0 + tx; - vertexData[7] = d * h0 + b * w1 + ty; - }; - - /** - * - * Renders the object using the WebGL renderer - * - * @private - * @param {PIXI.WebGLRenderer} renderer - The webgl renderer to use. - */ - - - Sprite.prototype._renderWebGL = function _renderWebGL(renderer) { - this.calculateVertices(); - - renderer.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - }; - - /** - * Renders the object using the Canvas renderer - * - * @private - * @param {PIXI.CanvasRenderer} renderer - The renderer - */ - - - Sprite.prototype._renderCanvas = function _renderCanvas(renderer) { - renderer.plugins[this.pluginName].render(this); - }; - - /** - * Updates the bounds of the sprite. - * - * @private - */ - - - Sprite.prototype._calculateBounds = function _calculateBounds() { - var trim = this._texture.trim; - var orig = this._texture.orig; - - // First lets check to see if the current texture has a trim.. - if (!trim || trim.width === orig.width && trim.height === orig.height) { - // no trim! lets use the usual calculations.. - this.calculateVertices(); - this._bounds.addQuad(this.vertexData); - } else { - // lets calculate a special trimmed bounds... - this.calculateTrimmedVertices(); - this._bounds.addQuad(this.vertexTrimmedData); - } - }; - - /** - * Gets the local bounds of the sprite object. - * - * @param {PIXI.Rectangle} rect - The output rectangle. - * @return {PIXI.Rectangle} The bounds. - */ - - - Sprite.prototype.getLocalBounds = function getLocalBounds(rect) { - // we can do a fast local bounds if the sprite has no children! - if (this.children.length === 0) { - this._bounds.minX = this._texture.orig.width * -this._anchor._x; - this._bounds.minY = this._texture.orig.height * -this._anchor._y; - this._bounds.maxX = this._texture.orig.width * (1 - this._anchor._x); - this._bounds.maxY = this._texture.orig.height * (1 - this._anchor._y); - - if (!rect) { - if (!this._localBoundsRect) { - this._localBoundsRect = new _math.Rectangle(); - } - - rect = this._localBoundsRect; - } - - return this._bounds.getRectangle(rect); - } - - return _Container.prototype.getLocalBounds.call(this, rect); - }; - - /** - * Tests if a point is inside this sprite - * - * @param {PIXI.Point} point - the point to test - * @return {boolean} the result of the test - */ - - - Sprite.prototype.containsPoint = function containsPoint(point) { - this.worldTransform.applyInverse(point, tempPoint); - - var width = this._texture.orig.width; - var height = this._texture.orig.height; - var x1 = -width * this.anchor.x; - var y1 = 0; - - if (tempPoint.x >= x1 && tempPoint.x < x1 + width) { - y1 = -height * this.anchor.y; - - if (tempPoint.y >= y1 && tempPoint.y < y1 + height) { - return true; - } - } - - return false; - }; - - /** - * Destroys this sprite and optionally its texture and children - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options - * have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy - * method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well - * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well - */ - - - Sprite.prototype.destroy = function destroy(options) { - _Container.prototype.destroy.call(this, options); - - this._texture.off('update', this._onTextureUpdate, this); - - this._anchor = null; - - var destroyTexture = typeof options === 'boolean' ? options : options && options.texture; - - if (destroyTexture) { - var destroyBaseTexture = typeof options === 'boolean' ? options : options && options.baseTexture; - - this._texture.destroy(!!destroyBaseTexture); - } - - this._texture = null; - this.shader = null; - }; - - // some helper functions.. - - /** - * Helper function that creates a new sprite based on the source you provide. - * The source can be - frame id, image url, video url, canvas element, video element, base texture - * - * @static - * @param {number|string|PIXI.BaseTexture|HTMLCanvasElement|HTMLVideoElement} source Source to create texture from - * @return {PIXI.Sprite} The newly created sprite - */ - - - Sprite.from = function from(source) { - return new Sprite(_Texture2.default.from(source)); - }; - - /** - * Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId - * The frame ids are created when a Texture packer file has been loaded - * - * @static - * @param {string} frameId - The frame Id of the texture in the cache - * @return {PIXI.Sprite} A new Sprite using a texture from the texture cache matching the frameId - */ - - - Sprite.fromFrame = function fromFrame(frameId) { - var texture = _utils.TextureCache[frameId]; - - if (!texture) { - throw new Error('The frameId "' + frameId + '" does not exist in the texture cache'); - } - - return new Sprite(texture); - }; - - /** - * Helper function that creates a sprite that will contain a texture based on an image url - * If the image is not in the texture cache it will be loaded - * - * @static - * @param {string} imageId - The image url of the texture - * @param {boolean} [crossorigin=(auto)] - if you want to specify the cross-origin parameter - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - if you want to specify the scale mode, - * see {@link PIXI.SCALE_MODES} for possible values - * @return {PIXI.Sprite} A new Sprite using a texture from the texture cache matching the image id - */ - - - Sprite.fromImage = function fromImage(imageId, crossorigin, scaleMode) { - return new Sprite(_Texture2.default.fromImage(imageId, crossorigin, scaleMode)); - }; - - /** - * The width of the sprite, setting this will actually modify the scale to achieve the value set - * - * @member {number} - */ - - - _createClass(Sprite, [{ - key: 'width', - get: function get() { - return Math.abs(this.scale.x) * this._texture.orig.width; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - var s = (0, _utils.sign)(this.scale.x) || 1; - - this.scale.x = s * value / this._texture.orig.width; - this._width = value; - } - - /** - * The height of the sprite, setting this will actually modify the scale to achieve the value set - * - * @member {number} - */ - - }, { - key: 'height', - get: function get() { - return Math.abs(this.scale.y) * this._texture.orig.height; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - var s = (0, _utils.sign)(this.scale.y) || 1; - - this.scale.y = s * value / this._texture.orig.height; - this._height = value; - } - - /** - * The anchor sets the origin point of the texture. - * The default is 0,0 or taken from the {@link PIXI.Texture|Texture} passed to the constructor. - * Setting the texture at a later point of time does not change the anchor. - * - * 0,0 means the texture's origin is the top left, 0.5,0.5 is the center, 1,1 the bottom right corner. - * - * @member {PIXI.ObservablePoint} - */ - - }, { - key: 'anchor', - get: function get() { - return this._anchor; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._anchor.copy(value); - } - - /** - * The tint applied to the sprite. This is a hex value. - * A value of 0xFFFFFF will remove any tint effect. - * - * @member {number} - * @default 0xFFFFFF - */ - - }, { - key: 'tint', - get: function get() { - return this._tint; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._tint = value; - this._tintRGB = (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); - } - - /** - * The texture that the sprite is using - * - * @member {PIXI.Texture} - */ - - }, { - key: 'texture', - get: function get() { - return this._texture; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) { - return; - } - - this._texture = value || _Texture2.default.EMPTY; - this.cachedTint = 0xFFFFFF; - - this._textureID = -1; - this._textureTrimmedID = -1; - - if (value) { - // wait for the texture to load - if (value.baseTexture.hasLoaded) { - this._onTextureUpdate(); - } else { - value.once('update', this._onTextureUpdate, this); - } - } - } - }]); - - return Sprite; -}(_Container3.default); - -exports.default = Sprite; - -},{"../const":46,"../display/Container":48,"../math":70,"../textures/Texture":115,"../utils":125}],103:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _CanvasRenderer = require('../../renderers/canvas/CanvasRenderer'); - -var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer); - -var _const = require('../../const'); - -var _math = require('../../math'); - -var _CanvasTinter = require('./CanvasTinter'); - -var _CanvasTinter2 = _interopRequireDefault(_CanvasTinter); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var canvasRenderWorldTransform = new _math.Matrix(); - -/** - * @author Mat Groves - * - * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/ - * for creating the original PixiJS version! - * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they now - * share 4 bytes on the vertex buffer - * - * Heavily inspired by LibGDX's CanvasSpriteRenderer: - * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/CanvasSpriteRenderer.java - */ - -/** - * Renderer dedicated to drawing and batching sprites. - * - * @class - * @private - * @memberof PIXI - */ - -var CanvasSpriteRenderer = function () { - /** - * @param {PIXI.WebGLRenderer} renderer -The renderer sprite this batch works for. - */ - function CanvasSpriteRenderer(renderer) { - _classCallCheck(this, CanvasSpriteRenderer); - - this.renderer = renderer; - } - - /** - * Renders the sprite object. - * - * @param {PIXI.Sprite} sprite - the sprite to render when using this spritebatch - */ - - - CanvasSpriteRenderer.prototype.render = function render(sprite) { - var texture = sprite._texture; - var renderer = this.renderer; - - var width = texture._frame.width; - var height = texture._frame.height; - - var wt = sprite.transform.worldTransform; - var dx = 0; - var dy = 0; - - if (texture.orig.width <= 0 || texture.orig.height <= 0 || !texture.baseTexture.source) { - return; - } - - renderer.setBlendMode(sprite.blendMode); - - // Ignore null sources - if (texture.valid) { - renderer.context.globalAlpha = sprite.worldAlpha; - - // If smoothingEnabled is supported and we need to change the smoothing property for sprite texture - var smoothingEnabled = texture.baseTexture.scaleMode === _const.SCALE_MODES.LINEAR; - - if (renderer.smoothProperty && renderer.context[renderer.smoothProperty] !== smoothingEnabled) { - renderer.context[renderer.smoothProperty] = smoothingEnabled; - } - - if (texture.trim) { - dx = texture.trim.width / 2 + texture.trim.x - sprite.anchor.x * texture.orig.width; - dy = texture.trim.height / 2 + texture.trim.y - sprite.anchor.y * texture.orig.height; - } else { - dx = (0.5 - sprite.anchor.x) * texture.orig.width; - dy = (0.5 - sprite.anchor.y) * texture.orig.height; - } - - if (texture.rotate) { - wt.copy(canvasRenderWorldTransform); - wt = canvasRenderWorldTransform; - _math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy); - // the anchor has already been applied above, so lets set it to zero - dx = 0; - dy = 0; - } - - dx -= width / 2; - dy -= height / 2; - - // Allow for pixel rounding - if (renderer.roundPixels) { - renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderer.resolution | 0, wt.ty * renderer.resolution | 0); - - dx = dx | 0; - dy = dy | 0; - } else { - renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderer.resolution, wt.ty * renderer.resolution); - } - - var resolution = texture.baseTexture.resolution; - - if (sprite.tint !== 0xFFFFFF) { - if (sprite.cachedTint !== sprite.tint || sprite.tintedTexture.tintId !== sprite._texture._updateID) { - sprite.cachedTint = sprite.tint; - - // TODO clean up caching - how to clean up the caches? - sprite.tintedTexture = _CanvasTinter2.default.getTintedTexture(sprite, sprite.tint); - } - - renderer.context.drawImage(sprite.tintedTexture, 0, 0, width * resolution, height * resolution, dx * renderer.resolution, dy * renderer.resolution, width * renderer.resolution, height * renderer.resolution); - } else { - renderer.context.drawImage(texture.baseTexture.source, texture._frame.x * resolution, texture._frame.y * resolution, width * resolution, height * resolution, dx * renderer.resolution, dy * renderer.resolution, width * renderer.resolution, height * renderer.resolution); - } - } - }; - - /** - * destroy the sprite object. - * - */ - - - CanvasSpriteRenderer.prototype.destroy = function destroy() { - this.renderer = null; - }; - - return CanvasSpriteRenderer; -}(); - -exports.default = CanvasSpriteRenderer; - - -_CanvasRenderer2.default.registerPlugin('sprite', CanvasSpriteRenderer); - -},{"../../const":46,"../../math":70,"../../renderers/canvas/CanvasRenderer":77,"./CanvasTinter":104}],104:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _utils = require('../../utils'); - -var _canUseNewCanvasBlendModes = require('../../renderers/canvas/utils/canUseNewCanvasBlendModes'); - -var _canUseNewCanvasBlendModes2 = _interopRequireDefault(_canUseNewCanvasBlendModes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Utility methods for Sprite/Texture tinting. - * - * @class - * @memberof PIXI - */ -var CanvasTinter = { - /** - * Basically this method just needs a sprite and a color and tints the sprite with the given color. - * - * @memberof PIXI.CanvasTinter - * @param {PIXI.Sprite} sprite - the sprite to tint - * @param {number} color - the color to use to tint the sprite with - * @return {HTMLCanvasElement} The tinted canvas - */ - getTintedTexture: function getTintedTexture(sprite, color) { - var texture = sprite._texture; - - color = CanvasTinter.roundColor(color); - - var stringColor = '#' + ('00000' + (color | 0).toString(16)).substr(-6); - - texture.tintCache = texture.tintCache || {}; - - var cachedTexture = texture.tintCache[stringColor]; - - var canvas = void 0; - - if (cachedTexture) { - if (cachedTexture.tintId === texture._updateID) { - return texture.tintCache[stringColor]; - } - - canvas = texture.tintCache[stringColor]; - } else { - canvas = CanvasTinter.canvas || document.createElement('canvas'); - } - - CanvasTinter.tintMethod(texture, color, canvas); - - canvas.tintId = texture._updateID; - - if (CanvasTinter.convertTintToImage) { - // is this better? - var tintImage = new Image(); - - tintImage.src = canvas.toDataURL(); - - texture.tintCache[stringColor] = tintImage; - } else { - texture.tintCache[stringColor] = canvas; - // if we are not converting the texture to an image then we need to lose the reference to the canvas - CanvasTinter.canvas = null; - } - - return canvas; - }, - - /** - * Tint a texture using the 'multiply' operation. - * - * @memberof PIXI.CanvasTinter - * @param {PIXI.Texture} texture - the texture to tint - * @param {number} color - the color to use to tint the sprite with - * @param {HTMLCanvasElement} canvas - the current canvas - */ - tintWithMultiply: function tintWithMultiply(texture, color, canvas) { - var context = canvas.getContext('2d'); - var crop = texture._frame.clone(); - var resolution = texture.baseTexture.resolution; - - crop.x *= resolution; - crop.y *= resolution; - crop.width *= resolution; - crop.height *= resolution; - - canvas.width = Math.ceil(crop.width); - canvas.height = Math.ceil(crop.height); - - context.save(); - context.fillStyle = '#' + ('00000' + (color | 0).toString(16)).substr(-6); - - context.fillRect(0, 0, crop.width, crop.height); - - context.globalCompositeOperation = 'multiply'; - - context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height); - - context.globalCompositeOperation = 'destination-atop'; - - context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height); - context.restore(); - }, - - /** - * Tint a texture using the 'overlay' operation. - * - * @memberof PIXI.CanvasTinter - * @param {PIXI.Texture} texture - the texture to tint - * @param {number} color - the color to use to tint the sprite with - * @param {HTMLCanvasElement} canvas - the current canvas - */ - tintWithOverlay: function tintWithOverlay(texture, color, canvas) { - var context = canvas.getContext('2d'); - var crop = texture._frame.clone(); - var resolution = texture.baseTexture.resolution; - - crop.x *= resolution; - crop.y *= resolution; - crop.width *= resolution; - crop.height *= resolution; - - canvas.width = Math.ceil(crop.width); - canvas.height = Math.ceil(crop.height); - - context.save(); - context.globalCompositeOperation = 'copy'; - context.fillStyle = '#' + ('00000' + (color | 0).toString(16)).substr(-6); - context.fillRect(0, 0, crop.width, crop.height); - - context.globalCompositeOperation = 'destination-atop'; - context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height); - - // context.globalCompositeOperation = 'copy'; - context.restore(); - }, - - - /** - * Tint a texture pixel per pixel. - * - * @memberof PIXI.CanvasTinter - * @param {PIXI.Texture} texture - the texture to tint - * @param {number} color - the color to use to tint the sprite with - * @param {HTMLCanvasElement} canvas - the current canvas - */ - tintWithPerPixel: function tintWithPerPixel(texture, color, canvas) { - var context = canvas.getContext('2d'); - var crop = texture._frame.clone(); - var resolution = texture.baseTexture.resolution; - - crop.x *= resolution; - crop.y *= resolution; - crop.width *= resolution; - crop.height *= resolution; - - canvas.width = Math.ceil(crop.width); - canvas.height = Math.ceil(crop.height); - - context.save(); - context.globalCompositeOperation = 'copy'; - context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height); - context.restore(); - - var rgbValues = (0, _utils.hex2rgb)(color); - var r = rgbValues[0]; - var g = rgbValues[1]; - var b = rgbValues[2]; - - var pixelData = context.getImageData(0, 0, crop.width, crop.height); - - var pixels = pixelData.data; - - for (var i = 0; i < pixels.length; i += 4) { - pixels[i + 0] *= r; - pixels[i + 1] *= g; - pixels[i + 2] *= b; - } - - context.putImageData(pixelData, 0, 0); - }, - - /** - * Rounds the specified color according to the CanvasTinter.cacheStepsPerColorChannel. - * - * @memberof PIXI.CanvasTinter - * @param {number} color - the color to round, should be a hex color - * @return {number} The rounded color. - */ - roundColor: function roundColor(color) { - var step = CanvasTinter.cacheStepsPerColorChannel; - - var rgbValues = (0, _utils.hex2rgb)(color); - - rgbValues[0] = Math.min(255, rgbValues[0] / step * step); - rgbValues[1] = Math.min(255, rgbValues[1] / step * step); - rgbValues[2] = Math.min(255, rgbValues[2] / step * step); - - return (0, _utils.rgb2hex)(rgbValues); - }, - - /** - * Number of steps which will be used as a cap when rounding colors. - * - * @memberof PIXI.CanvasTinter - * @type {number} - */ - cacheStepsPerColorChannel: 8, - - /** - * Tint cache boolean flag. - * - * @memberof PIXI.CanvasTinter - * @type {boolean} - */ - convertTintToImage: false, - - /** - * Whether or not the Canvas BlendModes are supported, consequently the ability to tint using the multiply method. - * - * @memberof PIXI.CanvasTinter - * @type {boolean} - */ - canUseMultiply: (0, _canUseNewCanvasBlendModes2.default)(), - - /** - * The tinting method that will be used. - * - * @memberof PIXI.CanvasTinter - * @type {tintMethodFunctionType} - */ - tintMethod: 0 -}; - -CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel; - -/** - * The tintMethod type. - * - * @memberof PIXI.CanvasTinter - * @callback tintMethodFunctionType - * @param texture {PIXI.Texture} the texture to tint - * @param color {number} the color to use to tint the sprite with - * @param canvas {HTMLCanvasElement} the current canvas - */ - -exports.default = CanvasTinter; - -},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":80,"../../utils":125}],105:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * @class - * @memberof PIXI - */ -var Buffer = function () { - /** - * @param {number} size - The size of the buffer in bytes. - */ - function Buffer(size) { - _classCallCheck(this, Buffer); - - this.vertices = new ArrayBuffer(size); - - /** - * View on the vertices as a Float32Array for positions - * - * @member {Float32Array} - */ - this.float32View = new Float32Array(this.vertices); - - /** - * View on the vertices as a Uint32Array for uvs - * - * @member {Float32Array} - */ - this.uint32View = new Uint32Array(this.vertices); - } - - /** - * Destroys the buffer. - * - */ - - - Buffer.prototype.destroy = function destroy() { - this.vertices = null; - this.positions = null; - this.uvs = null; - this.colors = null; - }; - - return Buffer; -}(); - -exports.default = Buffer; - -},{}],106:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _ObjectRenderer2 = require('../../renderers/webgl/utils/ObjectRenderer'); - -var _ObjectRenderer3 = _interopRequireDefault(_ObjectRenderer2); - -var _WebGLRenderer = require('../../renderers/webgl/WebGLRenderer'); - -var _WebGLRenderer2 = _interopRequireDefault(_WebGLRenderer); - -var _createIndicesForQuads = require('../../utils/createIndicesForQuads'); - -var _createIndicesForQuads2 = _interopRequireDefault(_createIndicesForQuads); - -var _generateMultiTextureShader = require('./generateMultiTextureShader'); - -var _generateMultiTextureShader2 = _interopRequireDefault(_generateMultiTextureShader); - -var _checkMaxIfStatmentsInShader = require('../../renderers/webgl/utils/checkMaxIfStatmentsInShader'); - -var _checkMaxIfStatmentsInShader2 = _interopRequireDefault(_checkMaxIfStatmentsInShader); - -var _BatchBuffer = require('./BatchBuffer'); - -var _BatchBuffer2 = _interopRequireDefault(_BatchBuffer); - -var _settings = require('../../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _utils = require('../../utils'); - -var _pixiGlCore = require('pixi-gl-core'); - -var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore); - -var _bitTwiddle = require('bit-twiddle'); - -var _bitTwiddle2 = _interopRequireDefault(_bitTwiddle); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var TICK = 0; -var TEXTURE_TICK = 0; - -/** - * Renderer dedicated to drawing and batching sprites. - * - * @class - * @private - * @memberof PIXI - * @extends PIXI.ObjectRenderer - */ - -var SpriteRenderer = function (_ObjectRenderer) { - _inherits(SpriteRenderer, _ObjectRenderer); - - /** - * @param {PIXI.WebGLRenderer} renderer - The renderer this sprite batch works for. - */ - function SpriteRenderer(renderer) { - _classCallCheck(this, SpriteRenderer); - - /** - * Number of values sent in the vertex buffer. - * aVertexPosition(2), aTextureCoord(1), aColor(1), aTextureId(1) = 5 - * - * @member {number} - */ - var _this = _possibleConstructorReturn(this, _ObjectRenderer.call(this, renderer)); - - _this.vertSize = 5; - - /** - * The size of the vertex information in bytes. - * - * @member {number} - */ - _this.vertByteSize = _this.vertSize * 4; - - /** - * The number of images in the SpriteRenderer before it flushes. - * - * @member {number} - */ - _this.size = _settings2.default.SPRITE_BATCH_SIZE; // 2000 is a nice balance between mobile / desktop - - // the total number of bytes in our batch - // let numVerts = this.size * 4 * this.vertByteSize; - - _this.buffers = []; - for (var i = 1; i <= _bitTwiddle2.default.nextPow2(_this.size); i *= 2) { - _this.buffers.push(new _BatchBuffer2.default(i * 4 * _this.vertByteSize)); - } - - /** - * Holds the indices of the geometry (quads) to draw - * - * @member {Uint16Array} - */ - _this.indices = (0, _createIndicesForQuads2.default)(_this.size); - - /** - * The default shaders that is used if a sprite doesn't have a more specific one. - * there is a shader for each number of textures that can be rendererd. - * These shaders will also be generated on the fly as required. - * @member {PIXI.Shader[]} - */ - _this.shader = null; - - _this.currentIndex = 0; - _this.groups = []; - - for (var k = 0; k < _this.size; k++) { - _this.groups[k] = { textures: [], textureCount: 0, ids: [], size: 0, start: 0, blend: 0 }; - } - - _this.sprites = []; - - _this.vertexBuffers = []; - _this.vaos = []; - - _this.vaoMax = 2; - _this.vertexCount = 0; - - _this.renderer.on('prerender', _this.onPrerender, _this); - return _this; - } - - /** - * Sets up the renderer context and necessary buffers. - * - * @private - */ - - - SpriteRenderer.prototype.onContextChange = function onContextChange() { - var gl = this.renderer.gl; - - if (this.renderer.legacy) { - this.MAX_TEXTURES = 1; - } else { - // step 1: first check max textures the GPU can handle. - this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), _settings2.default.SPRITE_MAX_TEXTURES); - - // step 2: check the maximum number of if statements the shader can have too.. - this.MAX_TEXTURES = (0, _checkMaxIfStatmentsInShader2.default)(this.MAX_TEXTURES, gl); - } - - this.shader = (0, _generateMultiTextureShader2.default)(gl, this.MAX_TEXTURES); - - // create a couple of buffers - this.indexBuffer = _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW); - - // we use the second shader as the first one depending on your browser may omit aTextureId - // as it is not used by the shader so is optimized out. - - this.renderer.bindVao(null); - - var attrs = this.shader.attributes; - - for (var i = 0; i < this.vaoMax; i++) { - /* eslint-disable max-len */ - var vertexBuffer = this.vertexBuffers[i] = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); - /* eslint-enable max-len */ - - // build the vao object that will render.. - var vao = this.renderer.createVao().addIndex(this.indexBuffer).addAttribute(vertexBuffer, attrs.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0).addAttribute(vertexBuffer, attrs.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4).addAttribute(vertexBuffer, attrs.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4); - - if (attrs.aTextureId) { - vao.addAttribute(vertexBuffer, attrs.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); - } - - this.vaos[i] = vao; - } - - this.vao = this.vaos[0]; - this.currentBlendMode = 99999; - - this.boundTextures = new Array(this.MAX_TEXTURES); - }; - - /** - * Called before the renderer starts rendering. - * - */ - - - SpriteRenderer.prototype.onPrerender = function onPrerender() { - this.vertexCount = 0; - }; - - /** - * Renders the sprite object. - * - * @param {PIXI.Sprite} sprite - the sprite to render when using this spritebatch - */ - - - SpriteRenderer.prototype.render = function render(sprite) { - // TODO set blend modes.. - // check texture.. - if (this.currentIndex >= this.size) { - this.flush(); - } - - // get the uvs for the texture - - // if the uvs have not updated then no point rendering just yet! - if (!sprite._texture._uvs) { - return; - } - - // push a texture. - // increment the batchsize - this.sprites[this.currentIndex++] = sprite; - }; - - /** - * Renders the content and empties the current batch. - * - */ - - - SpriteRenderer.prototype.flush = function flush() { - if (this.currentIndex === 0) { - return; - } - - var gl = this.renderer.gl; - var MAX_TEXTURES = this.MAX_TEXTURES; - - var np2 = _bitTwiddle2.default.nextPow2(this.currentIndex); - var log2 = _bitTwiddle2.default.log2(np2); - var buffer = this.buffers[log2]; - - var sprites = this.sprites; - var groups = this.groups; - - var float32View = buffer.float32View; - var uint32View = buffer.uint32View; - - var boundTextures = this.boundTextures; - var rendererBoundTextures = this.renderer.boundTextures; - var touch = this.renderer.textureGC.count; - - var index = 0; - var nextTexture = void 0; - var currentTexture = void 0; - var groupCount = 1; - var textureCount = 0; - var currentGroup = groups[0]; - var vertexData = void 0; - var uvs = void 0; - var blendMode = _utils.premultiplyBlendMode[sprites[0]._texture.baseTexture.premultipliedAlpha ? 1 : 0][sprites[0].blendMode]; - - currentGroup.textureCount = 0; - currentGroup.start = 0; - currentGroup.blend = blendMode; - - TICK++; - - var i = void 0; - - // copy textures.. - for (i = 0; i < MAX_TEXTURES; ++i) { - var bt = rendererBoundTextures[i]; - - if (bt._enabled === TICK) { - boundTextures[i] = this.renderer.emptyTextures[i]; - continue; - } - - boundTextures[i] = bt; - bt._virtalBoundId = i; - bt._enabled = TICK; - } - TICK++; - - for (i = 0; i < this.currentIndex; ++i) { - // upload the sprite elemetns... - // they have all ready been calculated so we just need to push them into the buffer. - var sprite = sprites[i]; - - sprites[i] = null; - - nextTexture = sprite._texture.baseTexture; - - var spriteBlendMode = _utils.premultiplyBlendMode[Number(nextTexture.premultipliedAlpha)][sprite.blendMode]; - - if (blendMode !== spriteBlendMode) { - // finish a group.. - blendMode = spriteBlendMode; - - // force the batch to break! - currentTexture = null; - textureCount = MAX_TEXTURES; - TICK++; - } - - if (currentTexture !== nextTexture) { - currentTexture = nextTexture; - - if (nextTexture._enabled !== TICK) { - if (textureCount === MAX_TEXTURES) { - TICK++; - - currentGroup.size = i - currentGroup.start; - - textureCount = 0; - - currentGroup = groups[groupCount++]; - currentGroup.blend = blendMode; - currentGroup.textureCount = 0; - currentGroup.start = i; - } - - nextTexture.touched = touch; - - if (nextTexture._virtalBoundId === -1) { - for (var j = 0; j < MAX_TEXTURES; ++j) { - var tIndex = (j + TEXTURE_TICK) % MAX_TEXTURES; - - var t = boundTextures[tIndex]; - - if (t._enabled !== TICK) { - TEXTURE_TICK++; - - t._virtalBoundId = -1; - - nextTexture._virtalBoundId = tIndex; - - boundTextures[tIndex] = nextTexture; - break; - } - } - } - - nextTexture._enabled = TICK; - - currentGroup.textureCount++; - currentGroup.ids[textureCount] = nextTexture._virtalBoundId; - currentGroup.textures[textureCount++] = nextTexture; - } - } - - vertexData = sprite.vertexData; - - // TODO this sum does not need to be set each frame.. - uvs = sprite._texture._uvs.uvsUint32; - - if (this.renderer.roundPixels) { - var resolution = this.renderer.resolution; - - // xy - float32View[index] = (vertexData[0] * resolution | 0) / resolution; - float32View[index + 1] = (vertexData[1] * resolution | 0) / resolution; - - // xy - float32View[index + 5] = (vertexData[2] * resolution | 0) / resolution; - float32View[index + 6] = (vertexData[3] * resolution | 0) / resolution; - - // xy - float32View[index + 10] = (vertexData[4] * resolution | 0) / resolution; - float32View[index + 11] = (vertexData[5] * resolution | 0) / resolution; - - // xy - float32View[index + 15] = (vertexData[6] * resolution | 0) / resolution; - float32View[index + 16] = (vertexData[7] * resolution | 0) / resolution; - } else { - // xy - float32View[index] = vertexData[0]; - float32View[index + 1] = vertexData[1]; - - // xy - float32View[index + 5] = vertexData[2]; - float32View[index + 6] = vertexData[3]; - - // xy - float32View[index + 10] = vertexData[4]; - float32View[index + 11] = vertexData[5]; - - // xy - float32View[index + 15] = vertexData[6]; - float32View[index + 16] = vertexData[7]; - } - - uint32View[index + 2] = uvs[0]; - uint32View[index + 7] = uvs[1]; - uint32View[index + 12] = uvs[2]; - uint32View[index + 17] = uvs[3]; - /* eslint-disable max-len */ - var alpha = Math.min(sprite.worldAlpha, 1.0); - // we dont call extra function if alpha is 1.0, that's faster - var argb = alpha < 1.0 && nextTexture.premultipliedAlpha ? (0, _utils.premultiplyTint)(sprite._tintRGB, alpha) : sprite._tintRGB + (alpha * 255 << 24); - - uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = argb; - float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId; - /* eslint-enable max-len */ - - index += 20; - } - - currentGroup.size = i - currentGroup.start; - - if (!_settings2.default.CAN_UPLOAD_SAME_BUFFER) { - // this is still needed for IOS performance.. - // it really does not like uploading to the same buffer in a single frame! - if (this.vaoMax <= this.vertexCount) { - this.vaoMax++; - - var attrs = this.shader.attributes; - - /* eslint-disable max-len */ - var vertexBuffer = this.vertexBuffers[this.vertexCount] = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); - /* eslint-enable max-len */ - - // build the vao object that will render.. - var vao = this.renderer.createVao().addIndex(this.indexBuffer).addAttribute(vertexBuffer, attrs.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0).addAttribute(vertexBuffer, attrs.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4).addAttribute(vertexBuffer, attrs.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4); - - if (attrs.aTextureId) { - vao.addAttribute(vertexBuffer, attrs.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); - } - - this.vaos[this.vertexCount] = vao; - } - - this.renderer.bindVao(this.vaos[this.vertexCount]); - - this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, false); - - this.vertexCount++; - } else { - // lets use the faster option, always use buffer number 0 - this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, true); - } - - for (i = 0; i < MAX_TEXTURES; ++i) { - rendererBoundTextures[i]._virtalBoundId = -1; - } - - // render the groups.. - for (i = 0; i < groupCount; ++i) { - var group = groups[i]; - var groupTextureCount = group.textureCount; - - for (var _j = 0; _j < groupTextureCount; _j++) { - currentTexture = group.textures[_j]; - - // reset virtual ids.. - // lets do a quick check.. - if (rendererBoundTextures[group.ids[_j]] !== currentTexture) { - this.renderer.bindTexture(currentTexture, group.ids[_j], true); - } - - // reset the virtualId.. - currentTexture._virtalBoundId = -1; - } - - // set the blend mode.. - this.renderer.state.setBlendMode(group.blend); - - gl.drawElements(gl.TRIANGLES, group.size * 6, gl.UNSIGNED_SHORT, group.start * 6 * 2); - } - - // reset elements for the next flush - this.currentIndex = 0; - }; - - /** - * Starts a new sprite batch. - */ - - - SpriteRenderer.prototype.start = function start() { - this.renderer.bindShader(this.shader); - - if (_settings2.default.CAN_UPLOAD_SAME_BUFFER) { - // bind buffer #0, we don't need others - this.renderer.bindVao(this.vaos[this.vertexCount]); - - this.vertexBuffers[this.vertexCount].bind(); - } - }; - - /** - * Stops and flushes the current batch. - * - */ - - - SpriteRenderer.prototype.stop = function stop() { - this.flush(); - }; - - /** - * Destroys the SpriteRenderer. - * - */ - - - SpriteRenderer.prototype.destroy = function destroy() { - for (var i = 0; i < this.vaoMax; i++) { - if (this.vertexBuffers[i]) { - this.vertexBuffers[i].destroy(); - } - if (this.vaos[i]) { - this.vaos[i].destroy(); - } - } - - if (this.indexBuffer) { - this.indexBuffer.destroy(); - } - - this.renderer.off('prerender', this.onPrerender, this); - - _ObjectRenderer.prototype.destroy.call(this); - - if (this.shader) { - this.shader.destroy(); - this.shader = null; - } - - this.vertexBuffers = null; - this.vaos = null; - this.indexBuffer = null; - this.indices = null; - - this.sprites = null; - - for (var _i = 0; _i < this.buffers.length; ++_i) { - this.buffers[_i].destroy(); - } - }; - - return SpriteRenderer; -}(_ObjectRenderer3.default); - -exports.default = SpriteRenderer; - - -_WebGLRenderer2.default.registerPlugin('sprite', SpriteRenderer); - -},{"../../renderers/webgl/WebGLRenderer":84,"../../renderers/webgl/utils/ObjectRenderer":94,"../../renderers/webgl/utils/checkMaxIfStatmentsInShader":97,"../../settings":101,"../../utils":125,"../../utils/createIndicesForQuads":123,"./BatchBuffer":105,"./generateMultiTextureShader":107,"bit-twiddle":1,"pixi-gl-core":15}],107:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = generateMultiTextureShader; - -var _Shader = require('../../Shader'); - -var _Shader2 = _interopRequireDefault(_Shader); - -var _path = require('path'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var fragTemplate = ['varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'varying float vTextureId;', 'uniform sampler2D uSamplers[%count%];', 'void main(void){', 'vec4 color;', '%forloop%', 'gl_FragColor = color * vColor;', '}'].join('\n'); - -function generateMultiTextureShader(gl, maxTextures) { - var vertexSrc = 'precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor;\n}\n'; - var fragmentSrc = fragTemplate; - - fragmentSrc = fragmentSrc.replace(/%count%/gi, maxTextures); - fragmentSrc = fragmentSrc.replace(/%forloop%/gi, generateSampleSrc(maxTextures)); - - var shader = new _Shader2.default(gl, vertexSrc, fragmentSrc); - - var sampleValues = []; - - for (var i = 0; i < maxTextures; i++) { - sampleValues[i] = i; - } - - shader.bind(); - shader.uniforms.uSamplers = sampleValues; - - return shader; -} - -function generateSampleSrc(maxTextures) { - var src = ''; - - src += '\n'; - src += '\n'; - - for (var i = 0; i < maxTextures; i++) { - if (i > 0) { - src += '\nelse '; - } - - if (i < maxTextures - 1) { - src += 'if(vTextureId < ' + i + '.5)'; - } - - src += '\n{'; - src += '\n\tcolor = texture2D(uSamplers[' + i + '], vTextureCoord);'; - src += '\n}'; - } - - src += '\n'; - src += '\n'; - - return src; -} - -},{"../../Shader":44,"path":8}],108:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _Sprite2 = require('../sprites/Sprite'); - -var _Sprite3 = _interopRequireDefault(_Sprite2); - -var _Texture = require('../textures/Texture'); - -var _Texture2 = _interopRequireDefault(_Texture); - -var _math = require('../math'); - -var _utils = require('../utils'); - -var _const = require('../const'); - -var _settings = require('../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _TextStyle = require('./TextStyle'); - -var _TextStyle2 = _interopRequireDefault(_TextStyle); - -var _TextMetrics = require('./TextMetrics'); - -var _TextMetrics2 = _interopRequireDefault(_TextMetrics); - -var _trimCanvas = require('../utils/trimCanvas'); - -var _trimCanvas2 = _interopRequireDefault(_trimCanvas); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint max-depth: [2, 8] */ - - -var defaultDestroyOptions = { - texture: true, - children: false, - baseTexture: true -}; - -/** - * A Text Object will create a line or multiple lines of text. To split a line you can use '\n' in your text string, - * or add a wordWrap property set to true and and wordWrapWidth property with a value in the style object. - * - * A Text can be created directly from a string and a style object, - * which can be generated [here](https://pixijs.io/pixi-text-style). - * - * ```js - * let text = new PIXI.Text('This is a PixiJS text',{fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'}); - * ``` - * - * @class - * @extends PIXI.Sprite - * @memberof PIXI - */ - -var Text = function (_Sprite) { - _inherits(Text, _Sprite); - - /** - * @param {string} text - The string that you would like the text to display - * @param {object|PIXI.TextStyle} [style] - The style parameters - * @param {HTMLCanvasElement} [canvas] - The canvas element for drawing text - */ - function Text(text, style, canvas) { - _classCallCheck(this, Text); - - canvas = canvas || document.createElement('canvas'); - - canvas.width = 3; - canvas.height = 3; - - var texture = _Texture2.default.fromCanvas(canvas, _settings2.default.SCALE_MODE, 'text'); - - texture.orig = new _math.Rectangle(); - texture.trim = new _math.Rectangle(); - - // base texture is already automatically added to the cache, now adding the actual texture - var _this = _possibleConstructorReturn(this, _Sprite.call(this, texture)); - - _Texture2.default.addToCache(_this._texture, _this._texture.baseTexture.textureCacheIds[0]); - - /** - * The canvas element that everything is drawn to - * - * @member {HTMLCanvasElement} - */ - _this.canvas = canvas; - - /** - * The canvas 2d context that everything is drawn with - * @member {CanvasRenderingContext2D} - */ - _this.context = _this.canvas.getContext('2d'); - - /** - * The resolution / device pixel ratio of the canvas. This is set automatically by the renderer. - * @member {number} - * @default 1 - */ - _this.resolution = _settings2.default.RESOLUTION; - - /** - * Private tracker for the current text. - * - * @member {string} - * @private - */ - _this._text = null; - - /** - * Private tracker for the current style. - * - * @member {object} - * @private - */ - _this._style = null; - /** - * Private listener to track style changes. - * - * @member {Function} - * @private - */ - _this._styleListener = null; - - /** - * Private tracker for the current font. - * - * @member {string} - * @private - */ - _this._font = ''; - - _this.text = text; - _this.style = style; - - _this.localStyleID = -1; - return _this; - } - - /** - * Renders text and updates it when needed. - * - * @private - * @param {boolean} respectDirty - Whether to abort updating the text if the Text isn't dirty and the function is called. - */ - - - Text.prototype.updateText = function updateText(respectDirty) { - var style = this._style; - - // check if style has changed.. - if (this.localStyleID !== style.styleID) { - this.dirty = true; - this.localStyleID = style.styleID; - } - - if (!this.dirty && respectDirty) { - return; - } - - this._font = this._style.toFontString(); - - var context = this.context; - var measured = _TextMetrics2.default.measureText(this._text, this._style, this._style.wordWrap, this.canvas); - var width = measured.width; - var height = measured.height; - var lines = measured.lines; - var lineHeight = measured.lineHeight; - var lineWidths = measured.lineWidths; - var maxLineWidth = measured.maxLineWidth; - var fontProperties = measured.fontProperties; - - this.canvas.width = Math.ceil((Math.max(1, width) + style.padding * 2) * this.resolution); - this.canvas.height = Math.ceil((Math.max(1, height) + style.padding * 2) * this.resolution); - - context.scale(this.resolution, this.resolution); - - context.clearRect(0, 0, this.canvas.width, this.canvas.height); - - context.font = this._font; - context.strokeStyle = style.stroke; - context.lineWidth = style.strokeThickness; - context.textBaseline = style.textBaseline; - context.lineJoin = style.lineJoin; - context.miterLimit = style.miterLimit; - - var linePositionX = void 0; - var linePositionY = void 0; - - if (style.dropShadow) { - context.fillStyle = style.dropShadowColor; - context.globalAlpha = style.dropShadowAlpha; - context.shadowBlur = style.dropShadowBlur; - - if (style.dropShadowBlur > 0) { - context.shadowColor = style.dropShadowColor; - } - - var xShadowOffset = Math.cos(style.dropShadowAngle) * style.dropShadowDistance; - var yShadowOffset = Math.sin(style.dropShadowAngle) * style.dropShadowDistance; - - for (var i = 0; i < lines.length; i++) { - linePositionX = style.strokeThickness / 2; - linePositionY = style.strokeThickness / 2 + i * lineHeight + fontProperties.ascent; - - if (style.align === 'right') { - linePositionX += maxLineWidth - lineWidths[i]; - } else if (style.align === 'center') { - linePositionX += (maxLineWidth - lineWidths[i]) / 2; - } - - if (style.fill) { - this.drawLetterSpacing(lines[i], linePositionX + xShadowOffset + style.padding, linePositionY + yShadowOffset + style.padding); - - if (style.stroke && style.strokeThickness) { - context.strokeStyle = style.dropShadowColor; - this.drawLetterSpacing(lines[i], linePositionX + xShadowOffset + style.padding, linePositionY + yShadowOffset + style.padding, true); - context.strokeStyle = style.stroke; - } - } - } - } - - // reset the shadow blur and alpha that was set by the drop shadow, for the regular text - context.shadowBlur = 0; - context.globalAlpha = 1; - - // set canvas text styles - context.fillStyle = this._generateFillStyle(style, lines); - - // draw lines line by line - for (var _i = 0; _i < lines.length; _i++) { - linePositionX = style.strokeThickness / 2; - linePositionY = style.strokeThickness / 2 + _i * lineHeight + fontProperties.ascent; - - if (style.align === 'right') { - linePositionX += maxLineWidth - lineWidths[_i]; - } else if (style.align === 'center') { - linePositionX += (maxLineWidth - lineWidths[_i]) / 2; - } - - if (style.stroke && style.strokeThickness) { - this.drawLetterSpacing(lines[_i], linePositionX + style.padding, linePositionY + style.padding, true); - } - - if (style.fill) { - this.drawLetterSpacing(lines[_i], linePositionX + style.padding, linePositionY + style.padding); - } - } - - this.updateTexture(); - }; - - /** - * Render the text with letter-spacing. - * @param {string} text - The text to draw - * @param {number} x - Horizontal position to draw the text - * @param {number} y - Vertical position to draw the text - * @param {boolean} [isStroke=false] - Is this drawing for the outside stroke of the - * text? If not, it's for the inside fill - * @private - */ - - - Text.prototype.drawLetterSpacing = function drawLetterSpacing(text, x, y) { - var isStroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - - var style = this._style; - - // letterSpacing of 0 means normal - var letterSpacing = style.letterSpacing; - - if (letterSpacing === 0) { - if (isStroke) { - this.context.strokeText(text, x, y); - } else { - this.context.fillText(text, x, y); - } - - return; - } - - var characters = String.prototype.split.call(text, ''); - var currentPosition = x; - var index = 0; - var current = ''; - - while (index < text.length) { - current = characters[index++]; - if (isStroke) { - this.context.strokeText(current, currentPosition, y); - } else { - this.context.fillText(current, currentPosition, y); - } - currentPosition += this.context.measureText(current).width + letterSpacing; - } - }; - - /** - * Updates texture size based on canvas size - * - * @private - */ - - - Text.prototype.updateTexture = function updateTexture() { - var canvas = this.canvas; - - if (this._style.trim) { - var trimmed = (0, _trimCanvas2.default)(canvas); - - if (trimmed.data) { - canvas.width = trimmed.width; - canvas.height = trimmed.height; - this.context.putImageData(trimmed.data, 0, 0); - } - } - - var texture = this._texture; - var style = this._style; - var padding = style.trim ? 0 : style.padding; - var baseTexture = texture.baseTexture; - - baseTexture.hasLoaded = true; - baseTexture.resolution = this.resolution; - - baseTexture.realWidth = canvas.width; - baseTexture.realHeight = canvas.height; - baseTexture.width = canvas.width / this.resolution; - baseTexture.height = canvas.height / this.resolution; - - texture.trim.width = texture._frame.width = canvas.width / this.resolution; - texture.trim.height = texture._frame.height = canvas.height / this.resolution; - texture.trim.x = -padding; - texture.trim.y = -padding; - - texture.orig.width = texture._frame.width - padding * 2; - texture.orig.height = texture._frame.height - padding * 2; - - // call sprite onTextureUpdate to update scale if _width or _height were set - this._onTextureUpdate(); - - baseTexture.emit('update', baseTexture); - - this.dirty = false; - }; - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.WebGLRenderer} renderer - The renderer - */ - - - Text.prototype.renderWebGL = function renderWebGL(renderer) { - if (this.resolution !== renderer.resolution) { - this.resolution = renderer.resolution; - this.dirty = true; - } - - this.updateText(true); - - _Sprite.prototype.renderWebGL.call(this, renderer); - }; - - /** - * Renders the object using the Canvas renderer - * - * @private - * @param {PIXI.CanvasRenderer} renderer - The renderer - */ - - - Text.prototype._renderCanvas = function _renderCanvas(renderer) { - if (this.resolution !== renderer.resolution) { - this.resolution = renderer.resolution; - this.dirty = true; - } - - this.updateText(true); - - _Sprite.prototype._renderCanvas.call(this, renderer); - }; - - /** - * Gets the local bounds of the text object. - * - * @param {Rectangle} rect - The output rectangle. - * @return {Rectangle} The bounds. - */ - - - Text.prototype.getLocalBounds = function getLocalBounds(rect) { - this.updateText(true); - - return _Sprite.prototype.getLocalBounds.call(this, rect); - }; - - /** - * calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account. - */ - - - Text.prototype._calculateBounds = function _calculateBounds() { - this.updateText(true); - this.calculateVertices(); - // if we have already done this on THIS frame. - this._bounds.addQuad(this.vertexData); - }; - - /** - * Method to be called upon a TextStyle change. - * @private - */ - - - Text.prototype._onStyleChange = function _onStyleChange() { - this.dirty = true; - }; - - /** - * Generates the fill style. Can automatically generate a gradient based on the fill style being an array - * - * @private - * @param {object} style - The style. - * @param {string[]} lines - The lines of text. - * @return {string|number|CanvasGradient} The fill style - */ - - - Text.prototype._generateFillStyle = function _generateFillStyle(style, lines) { - if (!Array.isArray(style.fill)) { - return style.fill; - } - - // cocoon on canvas+ cannot generate textures, so use the first colour instead - if (navigator.isCocoonJS) { - return style.fill[0]; - } - - // the gradient will be evenly spaced out according to how large the array is. - // ['#FF0000', '#00FF00', '#0000FF'] would created stops at 0.25, 0.5 and 0.75 - var gradient = void 0; - var totalIterations = void 0; - var currentIteration = void 0; - var stop = void 0; - - var width = this.canvas.width / this.resolution; - var height = this.canvas.height / this.resolution; - - // make a copy of the style settings, so we can manipulate them later - var fill = style.fill.slice(); - var fillGradientStops = style.fillGradientStops.slice(); - - // wanting to evenly distribute the fills. So an array of 4 colours should give fills of 0.25, 0.5 and 0.75 - if (!fillGradientStops.length) { - var lengthPlus1 = fill.length + 1; - - for (var i = 1; i < lengthPlus1; ++i) { - fillGradientStops.push(i / lengthPlus1); - } - } - - // stop the bleeding of the last gradient on the line above to the top gradient of the this line - // by hard defining the first gradient colour at point 0, and last gradient colour at point 1 - fill.unshift(style.fill[0]); - fillGradientStops.unshift(0); - - fill.push(style.fill[style.fill.length - 1]); - fillGradientStops.push(1); - - if (style.fillGradientType === _const.TEXT_GRADIENT.LINEAR_VERTICAL) { - // start the gradient at the top center of the canvas, and end at the bottom middle of the canvas - gradient = this.context.createLinearGradient(width / 2, 0, width / 2, height); - - // we need to repeat the gradient so that each individual line of text has the same vertical gradient effect - // ['#FF0000', '#00FF00', '#0000FF'] over 2 lines would create stops at 0.125, 0.25, 0.375, 0.625, 0.75, 0.875 - totalIterations = (fill.length + 1) * lines.length; - currentIteration = 0; - for (var _i2 = 0; _i2 < lines.length; _i2++) { - currentIteration += 1; - for (var j = 0; j < fill.length; j++) { - if (typeof fillGradientStops[j] === 'number') { - stop = fillGradientStops[j] / lines.length + _i2 / lines.length; - } else { - stop = currentIteration / totalIterations; - } - gradient.addColorStop(stop, fill[j]); - currentIteration++; - } - } - } else { - // start the gradient at the center left of the canvas, and end at the center right of the canvas - gradient = this.context.createLinearGradient(0, height / 2, width, height / 2); - - // can just evenly space out the gradients in this case, as multiple lines makes no difference - // to an even left to right gradient - totalIterations = fill.length + 1; - currentIteration = 1; - - for (var _i3 = 0; _i3 < fill.length; _i3++) { - if (typeof fillGradientStops[_i3] === 'number') { - stop = fillGradientStops[_i3]; - } else { - stop = currentIteration / totalIterations; - } - gradient.addColorStop(stop, fill[_i3]); - currentIteration++; - } - } - - return gradient; - }; - - /** - * Destroys this text object. - * Note* Unlike a Sprite, a Text object will automatically destroy its baseTexture and texture as - * the majority of the time the texture will not be shared with any other Sprites. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options - * have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have their - * destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=true] - Should it destroy the current texture of the sprite as well - * @param {boolean} [options.baseTexture=true] - Should it destroy the base texture of the sprite as well - */ - - - Text.prototype.destroy = function destroy(options) { - if (typeof options === 'boolean') { - options = { children: options }; - } - - options = Object.assign({}, defaultDestroyOptions, options); - - _Sprite.prototype.destroy.call(this, options); - - // make sure to reset the the context and canvas.. dont want this hanging around in memory! - this.context = null; - this.canvas = null; - - this._style = null; - }; - - /** - * The width of the Text, setting this will actually modify the scale to achieve the value set - * - * @member {number} - */ - - - _createClass(Text, [{ - key: 'width', - get: function get() { - this.updateText(true); - - return Math.abs(this.scale.x) * this._texture.orig.width; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.updateText(true); - - var s = (0, _utils.sign)(this.scale.x) || 1; - - this.scale.x = s * value / this._texture.orig.width; - this._width = value; - } - - /** - * The height of the Text, setting this will actually modify the scale to achieve the value set - * - * @member {number} - */ - - }, { - key: 'height', - get: function get() { - this.updateText(true); - - return Math.abs(this.scale.y) * this._texture.orig.height; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.updateText(true); - - var s = (0, _utils.sign)(this.scale.y) || 1; - - this.scale.y = s * value / this._texture.orig.height; - this._height = value; - } - - /** - * Set the style of the text. Set up an event listener to listen for changes on the style - * object and mark the text as dirty. - * - * @member {object|PIXI.TextStyle} - */ - - }, { - key: 'style', - get: function get() { - return this._style; - }, - set: function set(style) // eslint-disable-line require-jsdoc - { - style = style || {}; - - if (style instanceof _TextStyle2.default) { - this._style = style; - } else { - this._style = new _TextStyle2.default(style); - } - - this.localStyleID = -1; - this.dirty = true; - } - - /** - * Set the copy for the text object. To split a line you can use '\n'. - * - * @member {string} - */ - - }, { - key: 'text', - get: function get() { - return this._text; - }, - set: function set(text) // eslint-disable-line require-jsdoc - { - text = String(text === '' || text === null || text === undefined ? ' ' : text); - - if (this._text === text) { - return; - } - this._text = text; - this.dirty = true; - } - }]); - - return Text; -}(_Sprite3.default); - -exports.default = Text; - -},{"../const":46,"../math":70,"../settings":101,"../sprites/Sprite":102,"../textures/Texture":115,"../utils":125,"../utils/trimCanvas":130,"./TextMetrics":109,"./TextStyle":110}],109:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * The TextMetrics object represents the measurement of a block of text with a specified style. - * - * ```js - * let style = new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'}) - * let textMetrics = PIXI.TextMetrics.measureText('Your text', style) - * ``` - * - * @class - * @memberOf PIXI - */ -var TextMetrics = function () { - /** - * @param {string} text - the text that was measured - * @param {PIXI.TextStyle} style - the style that was measured - * @param {number} width - the measured width of the text - * @param {number} height - the measured height of the text - * @param {array} lines - an array of the lines of text broken by new lines and wrapping if specified in style - * @param {array} lineWidths - an array of the line widths for each line matched to `lines` - * @param {number} lineHeight - the measured line height for this style - * @param {number} maxLineWidth - the maximum line width for all measured lines - * @param {Object} fontProperties - the font properties object from TextMetrics.measureFont - */ - function TextMetrics(text, style, width, height, lines, lineWidths, lineHeight, maxLineWidth, fontProperties) { - _classCallCheck(this, TextMetrics); - - this.text = text; - this.style = style; - this.width = width; - this.height = height; - this.lines = lines; - this.lineWidths = lineWidths; - this.lineHeight = lineHeight; - this.maxLineWidth = maxLineWidth; - this.fontProperties = fontProperties; - } - - /** - * Measures the supplied string of text and returns a Rectangle. - * - * @param {string} text - the text to measure. - * @param {PIXI.TextStyle} style - the text style to use for measuring - * @param {boolean} [wordWrap] - optional override for if word-wrap should be applied to the text. - * @param {HTMLCanvasElement} [canvas] - optional specification of the canvas to use for measuring. - * @return {PIXI.TextMetrics} measured width and height of the text. - */ - - - TextMetrics.measureText = function measureText(text, style, wordWrap) { - var canvas = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : TextMetrics._canvas; - - wordWrap = wordWrap === undefined || wordWrap === null ? style.wordWrap : wordWrap; - var font = style.toFontString(); - var fontProperties = TextMetrics.measureFont(font); - var context = canvas.getContext('2d'); - - context.font = font; - - var outputText = wordWrap ? TextMetrics.wordWrap(text, style, canvas) : text; - var lines = outputText.split(/(?:\r\n|\r|\n)/); - var lineWidths = new Array(lines.length); - var maxLineWidth = 0; - - for (var i = 0; i < lines.length; i++) { - var lineWidth = context.measureText(lines[i]).width + (lines[i].length - 1) * style.letterSpacing; - - lineWidths[i] = lineWidth; - maxLineWidth = Math.max(maxLineWidth, lineWidth); - } - var width = maxLineWidth + style.strokeThickness; - - if (style.dropShadow) { - width += style.dropShadowDistance; - } - - var lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness; - var height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + (lines.length - 1) * (lineHeight + style.leading); - - if (style.dropShadow) { - height += style.dropShadowDistance; - } - - return new TextMetrics(text, style, width, height, lines, lineWidths, lineHeight + style.leading, maxLineWidth, fontProperties); - }; - - /** - * Applies newlines to a string to have it optimally fit into the horizontal - * bounds set by the Text object's wordWrapWidth property. - * - * @private - * @param {string} text - String to apply word wrapping to - * @param {PIXI.TextStyle} style - the style to use when wrapping - * @param {HTMLCanvasElement} [canvas] - optional specification of the canvas to use for measuring. - * @return {string} New string with new lines applied where required - */ - - - TextMetrics.wordWrap = function wordWrap(text, style) { - var canvas = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : TextMetrics._canvas; - - var context = canvas.getContext('2d'); - - var width = 0; - var line = ''; - var lines = ''; - - var cache = {}; - var letterSpacing = style.letterSpacing, - whiteSpace = style.whiteSpace; - - // How to handle whitespaces - - var collapseSpaces = TextMetrics.collapseSpaces(whiteSpace); - var collapseNewlines = TextMetrics.collapseNewlines(whiteSpace); - - // whether or not spaces may be added to the beginning of lines - var canPrependSpaces = !collapseSpaces; - - // There is letterSpacing after every char except the last one - // t_h_i_s_' '_i_s_' '_a_n_' '_e_x_a_m_p_l_e_' '_! - // so for convenience the above needs to be compared to width + 1 extra letterSpace - // t_h_i_s_' '_i_s_' '_a_n_' '_e_x_a_m_p_l_e_' '_!_ - // ________________________________________________ - // And then the final space is simply no appended to each line - var wordWrapWidth = style.wordWrapWidth + letterSpacing; - - // break text into words, spaces and newline chars - var tokens = TextMetrics.tokenize(text); - - for (var i = 0; i < tokens.length; i++) { - // get the word, space or newlineChar - var token = tokens[i]; - - // if word is a new line - if (TextMetrics.isNewline(token)) { - // keep the new line - if (!collapseNewlines) { - lines += TextMetrics.addLine(line); - canPrependSpaces = !collapseSpaces; - line = ''; - width = 0; - continue; - } - - // if we should collapse new lines - // we simply convert it into a space - token = ' '; - } - - // if we should collapse repeated whitespaces - if (collapseSpaces) { - // check both this and the last tokens for spaces - var currIsBreakingSpace = TextMetrics.isBreakingSpace(token); - var lastIsBreakingSpace = TextMetrics.isBreakingSpace(line[line.length - 1]); - - if (currIsBreakingSpace && lastIsBreakingSpace) { - continue; - } - } - - // get word width from cache if possible - var tokenWidth = TextMetrics.getFromCache(token, letterSpacing, cache, context); - - // word is longer than desired bounds - if (tokenWidth > wordWrapWidth) { - // if we are not already at the beginning of a line - if (line !== '') { - // start newlines for overflow words - lines += TextMetrics.addLine(line); - line = ''; - width = 0; - } - - // break large word over multiple lines - if (TextMetrics.canBreakWords(token, style.breakWords)) { - // break word into characters - var characters = token.split(''); - - // loop the characters - for (var j = 0; j < characters.length; j++) { - var char = characters[j]; - - var k = 1; - // we are not at the end of the token - - while (characters[j + k]) { - var nextChar = characters[j + k]; - var lastChar = char[char.length - 1]; - - // should not split chars - if (!TextMetrics.canBreakChars(lastChar, nextChar, token, j, style.breakWords)) { - // combine chars & move forward one - char += nextChar; - } else { - break; - } - - k++; - } - - j += char.length - 1; - - var characterWidth = TextMetrics.getFromCache(char, letterSpacing, cache, context); - - if (characterWidth + width > wordWrapWidth) { - lines += TextMetrics.addLine(line); - canPrependSpaces = false; - line = ''; - width = 0; - } - - line += char; - width += characterWidth; - } - } - - // run word out of the bounds - else { - // if there are words in this line already - // finish that line and start a new one - if (line.length > 0) { - lines += TextMetrics.addLine(line); - line = ''; - width = 0; - } - - var isLastToken = i === tokens.length - 1; - - // give it its own line if it's not the end - lines += TextMetrics.addLine(token, !isLastToken); - canPrependSpaces = false; - line = ''; - width = 0; - } - } - - // word could fit - else { - // word won't fit because of existing words - // start a new line - if (tokenWidth + width > wordWrapWidth) { - // if its a space we don't want it - canPrependSpaces = false; - - // add a new line - lines += TextMetrics.addLine(line); - - // start a new line - line = ''; - width = 0; - } - - // don't add spaces to the beginning of lines - if (line.length > 0 || !TextMetrics.isBreakingSpace(token) || canPrependSpaces) { - // add the word to the current line - line += token; - - // update width counter - width += tokenWidth; - } - } - } - - lines += TextMetrics.addLine(line, false); - - return lines; - }; - - /** - * Convienience function for logging each line added during the wordWrap - * method - * - * @private - * @param {string} line - The line of text to add - * @param {boolean} newLine - Add new line character to end - * @return {string} A formatted line - */ - - - TextMetrics.addLine = function addLine(line) { - var newLine = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - - line = TextMetrics.trimRight(line); - - line = newLine ? line + '\n' : line; - - return line; - }; - - /** - * Gets & sets the widths of calculated characters in a cache object - * - * @private - * @param {string} key The key - * @param {number} letterSpacing The letter spacing - * @param {object} cache The cache - * @param {CanvasRenderingContext2D} context The canvas context - * @return {number} The from cache. - */ - - - TextMetrics.getFromCache = function getFromCache(key, letterSpacing, cache, context) { - var width = cache[key]; - - if (width === undefined) { - var spacing = key.length * letterSpacing; - - width = context.measureText(key).width + spacing; - cache[key] = width; - } - - return width; - }; - - /** - * Determines whether we should collapse breaking spaces - * - * @private - * @param {string} whiteSpace The TextStyle property whiteSpace - * @return {boolean} should collapse - */ - - - TextMetrics.collapseSpaces = function collapseSpaces(whiteSpace) { - return whiteSpace === 'normal' || whiteSpace === 'pre-line'; - }; - - /** - * Determines whether we should collapse newLine chars - * - * @private - * @param {string} whiteSpace The white space - * @return {boolean} should collapse - */ - - - TextMetrics.collapseNewlines = function collapseNewlines(whiteSpace) { - return whiteSpace === 'normal'; - }; - - /** - * trims breaking whitespaces from string - * - * @private - * @param {string} text The text - * @return {string} trimmed string - */ - - - TextMetrics.trimRight = function trimRight(text) { - if (typeof text !== 'string') { - return ''; - } - - for (var i = text.length - 1; i >= 0; i--) { - var char = text[i]; - - if (!TextMetrics.isBreakingSpace(char)) { - break; - } - - text = text.slice(0, -1); - } - - return text; - }; - - /** - * Determines if char is a newline. - * - * @private - * @param {string} char The character - * @return {boolean} True if newline, False otherwise. - */ - - - TextMetrics.isNewline = function isNewline(char) { - if (typeof char !== 'string') { - return false; - } - - return TextMetrics._newlines.indexOf(char.charCodeAt(0)) >= 0; - }; - - /** - * Determines if char is a breaking whitespace. - * - * @private - * @param {string} char The character - * @return {boolean} True if whitespace, False otherwise. - */ - - - TextMetrics.isBreakingSpace = function isBreakingSpace(char) { - if (typeof char !== 'string') { - return false; - } - - return TextMetrics._breakingSpaces.indexOf(char.charCodeAt(0)) >= 0; - }; - - /** - * Splits a string into words, breaking-spaces and newLine characters - * - * @private - * @param {string} text The text - * @return {array} A tokenized array - */ - - - TextMetrics.tokenize = function tokenize(text) { - var tokens = []; - var token = ''; - - if (typeof text !== 'string') { - return tokens; - } - - for (var i = 0; i < text.length; i++) { - var char = text[i]; - - if (TextMetrics.isBreakingSpace(char) || TextMetrics.isNewline(char)) { - if (token !== '') { - tokens.push(token); - token = ''; - } - - tokens.push(char); - - continue; - } - - token += char; - } - - if (token !== '') { - tokens.push(token); - } - - return tokens; - }; - - /** - * This method exists to be easily overridden - * It allows one to customise which words should break - * Examples are if the token is CJK or numbers. - * It must return a boolean. - * - * @private - * @param {string} token The token - * @param {boolean} breakWords The style attr break words - * @return {boolean} whether to break word or not - */ - - - TextMetrics.canBreakWords = function canBreakWords(token, breakWords) { - return breakWords; - }; - - /** - * This method exists to be easily overridden - * It allows one to determine whether a pair of characters - * should be broken by newlines - * For example certain characters in CJK langs or numbers. - * It must return a boolean. - * - * @private - * @param {string} char The character - * @param {string} nextChar The next character - * @param {string} token The token/word the characters are from - * @param {number} index The index in the token of the char - * @param {boolean} breakWords The style attr break words - * @return {boolean} whether to break word or not - */ - - - TextMetrics.canBreakChars = function canBreakChars(char, nextChar, token, index, breakWords) // eslint-disable-line no-unused-vars - { - return true; - }; - - /** - * Calculates the ascent, descent and fontSize of a given font-style - * - * @static - * @param {string} font - String representing the style of the font - * @return {PIXI.TextMetrics~FontMetrics} Font properties object - */ - - - TextMetrics.measureFont = function measureFont(font) { - // as this method is used for preparing assets, don't recalculate things if we don't need to - if (TextMetrics._fonts[font]) { - return TextMetrics._fonts[font]; - } - - var properties = {}; - - var canvas = TextMetrics._canvas; - var context = TextMetrics._context; - - context.font = font; - - var metricsString = TextMetrics.METRICS_STRING + TextMetrics.BASELINE_SYMBOL; - var width = Math.ceil(context.measureText(metricsString).width); - var baseline = Math.ceil(context.measureText(TextMetrics.BASELINE_SYMBOL).width); - var height = 2 * baseline; - - baseline = baseline * TextMetrics.BASELINE_MULTIPLIER | 0; - - canvas.width = width; - canvas.height = height; - - context.fillStyle = '#f00'; - context.fillRect(0, 0, width, height); - - context.font = font; - - context.textBaseline = 'alphabetic'; - context.fillStyle = '#000'; - context.fillText(metricsString, 0, baseline); - - var imagedata = context.getImageData(0, 0, width, height).data; - var pixels = imagedata.length; - var line = width * 4; - - var i = 0; - var idx = 0; - var stop = false; - - // ascent. scan from top to bottom until we find a non red pixel - for (i = 0; i < baseline; ++i) { - for (var j = 0; j < line; j += 4) { - if (imagedata[idx + j] !== 255) { - stop = true; - break; - } - } - if (!stop) { - idx += line; - } else { - break; - } - } - - properties.ascent = baseline - i; - - idx = pixels - line; - stop = false; - - // descent. scan from bottom to top until we find a non red pixel - for (i = height; i > baseline; --i) { - for (var _j = 0; _j < line; _j += 4) { - if (imagedata[idx + _j] !== 255) { - stop = true; - break; - } - } - - if (!stop) { - idx -= line; - } else { - break; - } - } - - properties.descent = i - baseline; - properties.fontSize = properties.ascent + properties.descent; - - TextMetrics._fonts[font] = properties; - - return properties; - }; - - /** - * Clear font metrics in metrics cache. - * - * @static - * @param {string} [font] - font name. If font name not set then clear cache for all fonts. - */ - - - TextMetrics.clearMetrics = function clearMetrics() { - var font = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - - if (font) { - delete TextMetrics._fonts[font]; - } else { - TextMetrics._fonts = {}; - } - }; - - return TextMetrics; -}(); - -/** - * Internal return object for {@link PIXI.TextMetrics.measureFont `TextMetrics.measureFont`}. - * @class FontMetrics - * @memberof PIXI.TextMetrics~ - * @property {number} ascent - The ascent distance - * @property {number} descent - The descent distance - * @property {number} fontSize - Font size from ascent to descent - */ - -exports.default = TextMetrics; -var canvas = document.createElement('canvas'); - -canvas.width = canvas.height = 10; - -/** - * Cached canvas element for measuring text - * @memberof PIXI.TextMetrics - * @type {HTMLCanvasElement} - * @private - */ -TextMetrics._canvas = canvas; - -/** - * Cache for context to use. - * @memberof PIXI.TextMetrics - * @type {CanvasRenderingContext2D} - * @private - */ -TextMetrics._context = canvas.getContext('2d'); - -/** - * Cache of PIXI.TextMetrics~FontMetrics objects. - * @memberof PIXI.TextMetrics - * @type {Object} - * @private - */ -TextMetrics._fonts = {}; - -/** - * String used for calculate font metrics. - * @static - * @memberof PIXI.TextMetrics - * @name METRICS_STRING - * @type {string} - * @default |Éq - */ -TextMetrics.METRICS_STRING = '|Éq'; - -/** - * Baseline symbol for calculate font metrics. - * @static - * @memberof PIXI.TextMetrics - * @name BASELINE_SYMBOL - * @type {string} - * @default M - */ -TextMetrics.BASELINE_SYMBOL = 'M'; - -/** - * Baseline multiplier for calculate font metrics. - * @static - * @memberof PIXI.TextMetrics - * @name BASELINE_MULTIPLIER - * @type {number} - * @default 1.4 - */ -TextMetrics.BASELINE_MULTIPLIER = 1.4; - -/** - * Cache of new line chars. - * @memberof PIXI.TextMetrics - * @type {number[]} - * @private - */ -TextMetrics._newlines = [0x000A, // line feed -0x000D]; - -/** - * Cache of breaking spaces. - * @memberof PIXI.TextMetrics - * @type {number[]} - * @private - */ -TextMetrics._breakingSpaces = [0x0009, // character tabulation -0x0020, // space -0x2000, // en quad -0x2001, // em quad -0x2002, // en space -0x2003, // em space -0x2004, // three-per-em space -0x2005, // four-per-em space -0x2006, // six-per-em space -0x2008, // punctuation space -0x2009, // thin space -0x200A, // hair space -0x205F, // medium mathematical space -0x3000]; - -},{}],110:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // disabling eslint for now, going to rewrite this in v5 -/* eslint-disable */ - -var _const = require('../const'); - -var _utils = require('../utils'); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var defaultStyle = { - align: 'left', - breakWords: false, - dropShadow: false, - dropShadowAlpha: 1, - dropShadowAngle: Math.PI / 6, - dropShadowBlur: 0, - dropShadowColor: 'black', - dropShadowDistance: 5, - fill: 'black', - fillGradientType: _const.TEXT_GRADIENT.LINEAR_VERTICAL, - fillGradientStops: [], - fontFamily: 'Arial', - fontSize: 26, - fontStyle: 'normal', - fontVariant: 'normal', - fontWeight: 'normal', - letterSpacing: 0, - lineHeight: 0, - lineJoin: 'miter', - miterLimit: 10, - padding: 0, - stroke: 'black', - strokeThickness: 0, - textBaseline: 'alphabetic', - trim: false, - whiteSpace: 'pre', - wordWrap: false, - wordWrapWidth: 100, - leading: 0 -}; - -var genericFontFamilies = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui']; - -/** - * A TextStyle Object decorates a Text Object. It can be shared between - * multiple Text objects. Changing the style will update all text objects using it. - * It can be generated [here](https://pixijs.io/pixi-text-style). - * - * @class - * @memberof PIXI - */ - -var TextStyle = function () { - /** - * @param {object} [style] - The style parameters - * @param {string} [style.align='left'] - Alignment for multiline text ('left', 'center' or 'right'), - * does not affect single line text - * @param {boolean} [style.breakWords=false] - Indicates if lines can be wrapped within words, it - * needs wordWrap to be set to true - * @param {boolean} [style.dropShadow=false] - Set a drop shadow for the text - * @param {number} [style.dropShadowAlpha=1] - Set alpha for the drop shadow - * @param {number} [style.dropShadowAngle=Math.PI/6] - Set a angle of the drop shadow - * @param {number} [style.dropShadowBlur=0] - Set a shadow blur radius - * @param {string|number} [style.dropShadowColor='black'] - A fill style to be used on the dropshadow e.g 'red', '#00FF00' - * @param {number} [style.dropShadowDistance=5] - Set a distance of the drop shadow - * @param {string|string[]|number|number[]|CanvasGradient|CanvasPattern} [style.fill='black'] - A canvas - * fillstyle that will be used on the text e.g 'red', '#00FF00'. Can be an array to create a gradient - * eg ['#000000','#FFFFFF'] - * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle|MDN} - * @param {number} [style.fillGradientType=PIXI.TEXT_GRADIENT.LINEAR_VERTICAL] - If fill is an array of colours - * to create a gradient, this can change the type/direction of the gradient. See {@link PIXI.TEXT_GRADIENT} - * @param {number[]} [style.fillGradientStops] - If fill is an array of colours to create a gradient, this array can set - * the stop points (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them. - * @param {string|string[]} [style.fontFamily='Arial'] - The font family - * @param {number|string} [style.fontSize=26] - The font size (as a number it converts to px, but as a string, - * equivalents are '26px','20pt','160%' or '1.6em') - * @param {string} [style.fontStyle='normal'] - The font style ('normal', 'italic' or 'oblique') - * @param {string} [style.fontVariant='normal'] - The font variant ('normal' or 'small-caps') - * @param {string} [style.fontWeight='normal'] - The font weight ('normal', 'bold', 'bolder', 'lighter' and '100', - * '200', '300', '400', '500', '600', '700', 800' or '900') - * @param {number} [style.leading=0] - The space between lines - * @param {number} [style.letterSpacing=0] - The amount of spacing between letters, default is 0 - * @param {number} [style.lineHeight] - The line height, a number that represents the vertical space that a letter uses - * @param {string} [style.lineJoin='miter'] - The lineJoin property sets the type of corner created, it can resolve - * spiked text issues. Possible values "miter" (creates a sharp corner), "round" (creates a round corner) or "bevel" - * (creates a squared corner). - * @param {number} [style.miterLimit=10] - The miter limit to use when using the 'miter' lineJoin mode. This can reduce - * or increase the spikiness of rendered text. - * @param {number} [style.padding=0] - Occasionally some fonts are cropped. Adding some padding will prevent this from - * happening by adding padding to all sides of the text. - * @param {string|number} [style.stroke='black'] - A canvas fillstyle that will be used on the text stroke - * e.g 'blue', '#FCFF00' - * @param {number} [style.strokeThickness=0] - A number that represents the thickness of the stroke. - * Default is 0 (no stroke) - * @param {boolean} [style.trim=false] - Trim transparent borders - * @param {string} [style.textBaseline='alphabetic'] - The baseline of the text that is rendered. - * @param {boolean} [style.whiteSpace='pre'] - Determines whether newlines & spaces are collapsed or preserved "normal" - * (collapse, collapse), "pre" (preserve, preserve) | "pre-line" (preserve, collapse). It needs wordWrap to be set to true - * @param {boolean} [style.wordWrap=false] - Indicates if word wrap should be used - * @param {number} [style.wordWrapWidth=100] - The width at which text will wrap, it needs wordWrap to be set to true - */ - function TextStyle(style) { - _classCallCheck(this, TextStyle); - - this.styleID = 0; - - this.reset(); - - deepCopyProperties(this, style, style); - } - - /** - * Creates a new TextStyle object with the same values as this one. - * Note that the only the properties of the object are cloned. - * - * @return {PIXI.TextStyle} New cloned TextStyle object - */ - - - TextStyle.prototype.clone = function clone() { - var clonedProperties = {}; - - deepCopyProperties(clonedProperties, this, defaultStyle); - - return new TextStyle(clonedProperties); - }; - - /** - * Resets all properties to the defaults specified in TextStyle.prototype._default - */ - - - TextStyle.prototype.reset = function reset() { - deepCopyProperties(this, defaultStyle, defaultStyle); - }; - - /** - * Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text - * - * @member {string} - */ - - - /** - * Generates a font style string to use for `TextMetrics.measureFont()`. - * - * @return {string} Font style string, for passing to `TextMetrics.measureFont()` - */ - TextStyle.prototype.toFontString = function toFontString() { - // build canvas api font setting from individual components. Convert a numeric this.fontSize to px - var fontSizeString = typeof this.fontSize === 'number' ? this.fontSize + 'px' : this.fontSize; - - // Clean-up fontFamily property by quoting each font name - // this will support font names with spaces - var fontFamilies = this.fontFamily; - - if (!Array.isArray(this.fontFamily)) { - fontFamilies = this.fontFamily.split(','); - } - - for (var i = fontFamilies.length - 1; i >= 0; i--) { - // Trim any extra white-space - var fontFamily = fontFamilies[i].trim(); - - // Check if font is already escaped in quotes except for CSS generic fonts - if (!/([\"\'])[^\'\"]+\1/.test(fontFamily) && genericFontFamilies.indexOf(fontFamily) < 0) { - fontFamily = '"' + fontFamily + '"'; - } - fontFamilies[i] = fontFamily; - } - - return this.fontStyle + ' ' + this.fontVariant + ' ' + this.fontWeight + ' ' + fontSizeString + ' ' + fontFamilies.join(','); - }; - - _createClass(TextStyle, [{ - key: 'align', - get: function get() { - return this._align; - }, - set: function set(align) // eslint-disable-line require-jsdoc - { - if (this._align !== align) { - this._align = align; - this.styleID++; - } - } - - /** - * Indicates if lines can be wrapped within words, it needs wordWrap to be set to true - * - * @member {boolean} - */ - - }, { - key: 'breakWords', - get: function get() { - return this._breakWords; - }, - set: function set(breakWords) // eslint-disable-line require-jsdoc - { - if (this._breakWords !== breakWords) { - this._breakWords = breakWords; - this.styleID++; - } - } - - /** - * Set a drop shadow for the text - * - * @member {boolean} - */ - - }, { - key: 'dropShadow', - get: function get() { - return this._dropShadow; - }, - set: function set(dropShadow) // eslint-disable-line require-jsdoc - { - if (this._dropShadow !== dropShadow) { - this._dropShadow = dropShadow; - this.styleID++; - } - } - - /** - * Set alpha for the drop shadow - * - * @member {number} - */ - - }, { - key: 'dropShadowAlpha', - get: function get() { - return this._dropShadowAlpha; - }, - set: function set(dropShadowAlpha) // eslint-disable-line require-jsdoc - { - if (this._dropShadowAlpha !== dropShadowAlpha) { - this._dropShadowAlpha = dropShadowAlpha; - this.styleID++; - } - } - - /** - * Set a angle of the drop shadow - * - * @member {number} - */ - - }, { - key: 'dropShadowAngle', - get: function get() { - return this._dropShadowAngle; - }, - set: function set(dropShadowAngle) // eslint-disable-line require-jsdoc - { - if (this._dropShadowAngle !== dropShadowAngle) { - this._dropShadowAngle = dropShadowAngle; - this.styleID++; - } - } - - /** - * Set a shadow blur radius - * - * @member {number} - */ - - }, { - key: 'dropShadowBlur', - get: function get() { - return this._dropShadowBlur; - }, - set: function set(dropShadowBlur) // eslint-disable-line require-jsdoc - { - if (this._dropShadowBlur !== dropShadowBlur) { - this._dropShadowBlur = dropShadowBlur; - this.styleID++; - } - } - - /** - * A fill style to be used on the dropshadow e.g 'red', '#00FF00' - * - * @member {string|number} - */ - - }, { - key: 'dropShadowColor', - get: function get() { - return this._dropShadowColor; - }, - set: function set(dropShadowColor) // eslint-disable-line require-jsdoc - { - var outputColor = getColor(dropShadowColor); - if (this._dropShadowColor !== outputColor) { - this._dropShadowColor = outputColor; - this.styleID++; - } - } - - /** - * Set a distance of the drop shadow - * - * @member {number} - */ - - }, { - key: 'dropShadowDistance', - get: function get() { - return this._dropShadowDistance; - }, - set: function set(dropShadowDistance) // eslint-disable-line require-jsdoc - { - if (this._dropShadowDistance !== dropShadowDistance) { - this._dropShadowDistance = dropShadowDistance; - this.styleID++; - } - } - - /** - * A canvas fillstyle that will be used on the text e.g 'red', '#00FF00'. - * Can be an array to create a gradient eg ['#000000','#FFFFFF'] - * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle|MDN} - * - * @member {string|string[]|number|number[]|CanvasGradient|CanvasPattern} - */ - - }, { - key: 'fill', - get: function get() { - return this._fill; - }, - set: function set(fill) // eslint-disable-line require-jsdoc - { - var outputColor = getColor(fill); - if (this._fill !== outputColor) { - this._fill = outputColor; - this.styleID++; - } - } - - /** - * If fill is an array of colours to create a gradient, this can change the type/direction of the gradient. - * See {@link PIXI.TEXT_GRADIENT} - * - * @member {number} - */ - - }, { - key: 'fillGradientType', - get: function get() { - return this._fillGradientType; - }, - set: function set(fillGradientType) // eslint-disable-line require-jsdoc - { - if (this._fillGradientType !== fillGradientType) { - this._fillGradientType = fillGradientType; - this.styleID++; - } - } - - /** - * If fill is an array of colours to create a gradient, this array can set the stop points - * (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them. - * - * @member {number[]} - */ - - }, { - key: 'fillGradientStops', - get: function get() { - return this._fillGradientStops; - }, - set: function set(fillGradientStops) // eslint-disable-line require-jsdoc - { - if (!areArraysEqual(this._fillGradientStops, fillGradientStops)) { - this._fillGradientStops = fillGradientStops; - this.styleID++; - } - } - - /** - * The font family - * - * @member {string|string[]} - */ - - }, { - key: 'fontFamily', - get: function get() { - return this._fontFamily; - }, - set: function set(fontFamily) // eslint-disable-line require-jsdoc - { - if (this.fontFamily !== fontFamily) { - this._fontFamily = fontFamily; - this.styleID++; - } - } - - /** - * The font size - * (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em') - * - * @member {number|string} - */ - - }, { - key: 'fontSize', - get: function get() { - return this._fontSize; - }, - set: function set(fontSize) // eslint-disable-line require-jsdoc - { - if (this._fontSize !== fontSize) { - this._fontSize = fontSize; - this.styleID++; - } - } - - /** - * The font style - * ('normal', 'italic' or 'oblique') - * - * @member {string} - */ - - }, { - key: 'fontStyle', - get: function get() { - return this._fontStyle; - }, - set: function set(fontStyle) // eslint-disable-line require-jsdoc - { - if (this._fontStyle !== fontStyle) { - this._fontStyle = fontStyle; - this.styleID++; - } - } - - /** - * The font variant - * ('normal' or 'small-caps') - * - * @member {string} - */ - - }, { - key: 'fontVariant', - get: function get() { - return this._fontVariant; - }, - set: function set(fontVariant) // eslint-disable-line require-jsdoc - { - if (this._fontVariant !== fontVariant) { - this._fontVariant = fontVariant; - this.styleID++; - } - } - - /** - * The font weight - * ('normal', 'bold', 'bolder', 'lighter' and '100', '200', '300', '400', '500', '600', '700', 800' or '900') - * - * @member {string} - */ - - }, { - key: 'fontWeight', - get: function get() { - return this._fontWeight; - }, - set: function set(fontWeight) // eslint-disable-line require-jsdoc - { - if (this._fontWeight !== fontWeight) { - this._fontWeight = fontWeight; - this.styleID++; - } - } - - /** - * The amount of spacing between letters, default is 0 - * - * @member {number} - */ - - }, { - key: 'letterSpacing', - get: function get() { - return this._letterSpacing; - }, - set: function set(letterSpacing) // eslint-disable-line require-jsdoc - { - if (this._letterSpacing !== letterSpacing) { - this._letterSpacing = letterSpacing; - this.styleID++; - } - } - - /** - * The line height, a number that represents the vertical space that a letter uses - * - * @member {number} - */ - - }, { - key: 'lineHeight', - get: function get() { - return this._lineHeight; - }, - set: function set(lineHeight) // eslint-disable-line require-jsdoc - { - if (this._lineHeight !== lineHeight) { - this._lineHeight = lineHeight; - this.styleID++; - } - } - - /** - * The space between lines - * - * @member {number} - */ - - }, { - key: 'leading', - get: function get() { - return this._leading; - }, - set: function set(leading) // eslint-disable-line require-jsdoc - { - if (this._leading !== leading) { - this._leading = leading; - this.styleID++; - } - } - - /** - * The lineJoin property sets the type of corner created, it can resolve spiked text issues. - * Default is 'miter' (creates a sharp corner). - * - * @member {string} - */ - - }, { - key: 'lineJoin', - get: function get() { - return this._lineJoin; - }, - set: function set(lineJoin) // eslint-disable-line require-jsdoc - { - if (this._lineJoin !== lineJoin) { - this._lineJoin = lineJoin; - this.styleID++; - } - } - - /** - * The miter limit to use when using the 'miter' lineJoin mode - * This can reduce or increase the spikiness of rendered text. - * - * @member {number} - */ - - }, { - key: 'miterLimit', - get: function get() { - return this._miterLimit; - }, - set: function set(miterLimit) // eslint-disable-line require-jsdoc - { - if (this._miterLimit !== miterLimit) { - this._miterLimit = miterLimit; - this.styleID++; - } - } - - /** - * Occasionally some fonts are cropped. Adding some padding will prevent this from happening - * by adding padding to all sides of the text. - * - * @member {number} - */ - - }, { - key: 'padding', - get: function get() { - return this._padding; - }, - set: function set(padding) // eslint-disable-line require-jsdoc - { - if (this._padding !== padding) { - this._padding = padding; - this.styleID++; - } - } - - /** - * A canvas fillstyle that will be used on the text stroke - * e.g 'blue', '#FCFF00' - * - * @member {string|number} - */ - - }, { - key: 'stroke', - get: function get() { - return this._stroke; - }, - set: function set(stroke) // eslint-disable-line require-jsdoc - { - var outputColor = getColor(stroke); - if (this._stroke !== outputColor) { - this._stroke = outputColor; - this.styleID++; - } - } - - /** - * A number that represents the thickness of the stroke. - * Default is 0 (no stroke) - * - * @member {number} - */ - - }, { - key: 'strokeThickness', - get: function get() { - return this._strokeThickness; - }, - set: function set(strokeThickness) // eslint-disable-line require-jsdoc - { - if (this._strokeThickness !== strokeThickness) { - this._strokeThickness = strokeThickness; - this.styleID++; - } - } - - /** - * The baseline of the text that is rendered. - * - * @member {string} - */ - - }, { - key: 'textBaseline', - get: function get() { - return this._textBaseline; - }, - set: function set(textBaseline) // eslint-disable-line require-jsdoc - { - if (this._textBaseline !== textBaseline) { - this._textBaseline = textBaseline; - this.styleID++; - } - } - - /** - * Trim transparent borders - * - * @member {boolean} - */ - - }, { - key: 'trim', - get: function get() { - return this._trim; - }, - set: function set(trim) // eslint-disable-line require-jsdoc - { - if (this._trim !== trim) { - this._trim = trim; - this.styleID++; - } - } - - /** - * How newlines and spaces should be handled. - * Default is 'pre' (preserve, preserve). - * - * value | New lines | Spaces - * --- | --- | --- - * 'normal' | Collapse | Collapse - * 'pre' | Preserve | Preserve - * 'pre-line' | Preserve | Collapse - * - * @member {string} - */ - - }, { - key: 'whiteSpace', - get: function get() { - return this._whiteSpace; - }, - set: function set(whiteSpace) // eslint-disable-line require-jsdoc - { - if (this._whiteSpace !== whiteSpace) { - this._whiteSpace = whiteSpace; - this.styleID++; - } - } - - /** - * Indicates if word wrap should be used - * - * @member {boolean} - */ - - }, { - key: 'wordWrap', - get: function get() { - return this._wordWrap; - }, - set: function set(wordWrap) // eslint-disable-line require-jsdoc - { - if (this._wordWrap !== wordWrap) { - this._wordWrap = wordWrap; - this.styleID++; - } - } - - /** - * The width at which text will wrap, it needs wordWrap to be set to true - * - * @member {number} - */ - - }, { - key: 'wordWrapWidth', - get: function get() { - return this._wordWrapWidth; - }, - set: function set(wordWrapWidth) // eslint-disable-line require-jsdoc - { - if (this._wordWrapWidth !== wordWrapWidth) { - this._wordWrapWidth = wordWrapWidth; - this.styleID++; - } - } - }]); - - return TextStyle; -}(); - -/** - * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string. - * @private - * @param {number|number[]} color - * @return {string} The color as a string. - */ - - -exports.default = TextStyle; -function getSingleColor(color) { - if (typeof color === 'number') { - return (0, _utils.hex2string)(color); - } else if (typeof color === 'string') { - if (color.indexOf('0x') === 0) { - color = color.replace('0x', '#'); - } - } - - return color; -} - -/** - * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string. - * This version can also convert array of colors - * @private - * @param {number|number[]} color - * @return {string} The color as a string. - */ -function getColor(color) { - if (!Array.isArray(color)) { - return getSingleColor(color); - } else { - for (var i = 0; i < color.length; ++i) { - color[i] = getSingleColor(color[i]); - } - - return color; - } -} - -/** - * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string. - * This version can also convert array of colors - * @private - * @param {Array} array1 First array to compare - * @param {Array} array2 Second array to compare - * @return {boolean} Do the arrays contain the same values in the same order - */ -function areArraysEqual(array1, array2) { - if (!Array.isArray(array1) || !Array.isArray(array2)) { - return false; - } - - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0; i < array1.length; ++i) { - if (array1[i] !== array2[i]) { - return false; - } - } - - return true; -} - -/** - * Utility function to ensure that object properties are copied by value, and not by reference - * @private - * @param {Object} target Target object to copy properties into - * @param {Object} source Source object for the proporties to copy - * @param {string} propertyObj Object containing properties names we want to loop over - */ -function deepCopyProperties(target, source, propertyObj) { - for (var prop in propertyObj) { - if (Array.isArray(source[prop])) { - target[prop] = source[prop].slice(); - } else { - target[prop] = source[prop]; - } - } -} - -},{"../const":46,"../utils":125}],111:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _BaseTexture2 = require('./BaseTexture'); - -var _BaseTexture3 = _interopRequireDefault(_BaseTexture2); - -var _settings = require('../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * A BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it. - * - * __Hint__: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded - * otherwise black rectangles will be drawn instead. - * - * A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position - * and rotation of the given Display Objects is ignored. For example: - * - * ```js - * let renderer = PIXI.autoDetectRenderer(1024, 1024); - * let baseRenderTexture = new PIXI.BaseRenderTexture(800, 600); - * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); - * let sprite = PIXI.Sprite.fromImage("spinObj_01.png"); - * - * sprite.position.x = 800/2; - * sprite.position.y = 600/2; - * sprite.anchor.x = 0.5; - * sprite.anchor.y = 0.5; - * - * renderer.render(sprite, renderTexture); - * ``` - * - * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 - * you can clear the transform - * - * ```js - * - * sprite.setTransform() - * - * let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100); - * let renderTexture = new PIXI.RenderTexture(baseRenderTexture); - * - * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture - * ``` - * - * @class - * @extends PIXI.BaseTexture - * @memberof PIXI - */ -var BaseRenderTexture = function (_BaseTexture) { - _inherits(BaseRenderTexture, _BaseTexture); - - /** - * @param {number} [width=100] - The width of the base render texture - * @param {number} [height=100] - The height of the base render texture - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {number} [resolution=1] - The resolution / device pixel ratio of the texture being generated - */ - function BaseRenderTexture() { - var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100; - var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100; - var scaleMode = arguments[2]; - var resolution = arguments[3]; - - _classCallCheck(this, BaseRenderTexture); - - var _this = _possibleConstructorReturn(this, _BaseTexture.call(this, null, scaleMode)); - - _this.resolution = resolution || _settings2.default.RESOLUTION; - - _this.width = Math.ceil(width); - _this.height = Math.ceil(height); - - _this.realWidth = _this.width * _this.resolution; - _this.realHeight = _this.height * _this.resolution; - - _this.scaleMode = scaleMode !== undefined ? scaleMode : _settings2.default.SCALE_MODE; - _this.hasLoaded = true; - - /** - * A map of renderer IDs to webgl renderTargets - * - * @private - * @member {object} - */ - _this._glRenderTargets = {}; - - /** - * A reference to the canvas render target (we only need one as this can be shared across renderers) - * - * @private - * @member {object} - */ - _this._canvasRenderTarget = null; - - /** - * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. - * - * @member {boolean} - */ - _this.valid = false; - return _this; - } - - /** - * Resizes the BaseRenderTexture. - * - * @param {number} width - The width to resize to. - * @param {number} height - The height to resize to. - */ - - - BaseRenderTexture.prototype.resize = function resize(width, height) { - width = Math.ceil(width); - height = Math.ceil(height); - - if (width === this.width && height === this.height) { - return; - } - - this.valid = width > 0 && height > 0; - - this.width = width; - this.height = height; - - this.realWidth = this.width * this.resolution; - this.realHeight = this.height * this.resolution; - - if (!this.valid) { - return; - } - - this.emit('update', this); - }; - - /** - * Destroys this texture - * - */ - - - BaseRenderTexture.prototype.destroy = function destroy() { - _BaseTexture.prototype.destroy.call(this, true); - this.renderer = null; - }; - - return BaseRenderTexture; -}(_BaseTexture3.default); - -exports.default = BaseRenderTexture; - -},{"../settings":101,"./BaseTexture":112}],112:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _utils = require('../utils'); - -var _settings = require('../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -var _determineCrossOrigin = require('../utils/determineCrossOrigin'); - -var _determineCrossOrigin2 = _interopRequireDefault(_determineCrossOrigin); - -var _bitTwiddle = require('bit-twiddle'); - -var _bitTwiddle2 = _interopRequireDefault(_bitTwiddle); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * A texture stores the information that represents an image. All textures have a base texture. - * - * @class - * @extends EventEmitter - * @memberof PIXI - */ -var BaseTexture = function (_EventEmitter) { - _inherits(BaseTexture, _EventEmitter); - - /** - * @param {HTMLImageElement|HTMLCanvasElement} [source] - the source object of the texture. - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {number} [resolution=1] - The resolution / device pixel ratio of the texture - */ - function BaseTexture(source, scaleMode, resolution) { - _classCallCheck(this, BaseTexture); - - var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - - _this.uid = (0, _utils.uid)(); - - _this.touched = 0; - - /** - * The resolution / device pixel ratio of the texture - * - * @member {number} - * @default 1 - */ - _this.resolution = resolution || _settings2.default.RESOLUTION; - - /** - * The width of the base texture set when the image has loaded - * - * @readonly - * @member {number} - */ - _this.width = 100; - - /** - * The height of the base texture set when the image has loaded - * - * @readonly - * @member {number} - */ - _this.height = 100; - - // TODO docs - // used to store the actual dimensions of the source - /** - * Used to store the actual width of the source of this texture - * - * @readonly - * @member {number} - */ - _this.realWidth = 100; - /** - * Used to store the actual height of the source of this texture - * - * @readonly - * @member {number} - */ - _this.realHeight = 100; - - /** - * The scale mode to apply when scaling this texture - * - * @member {number} - * @default PIXI.settings.SCALE_MODE - * @see PIXI.SCALE_MODES - */ - _this.scaleMode = scaleMode !== undefined ? scaleMode : _settings2.default.SCALE_MODE; - - /** - * Set to true once the base texture has successfully loaded. - * - * This is never true if the underlying source fails to load or has no texture data. - * - * @readonly - * @member {boolean} - */ - _this.hasLoaded = false; - - /** - * Set to true if the source is currently loading. - * - * If an Image source is loading the 'loaded' or 'error' event will be - * dispatched when the operation ends. An underyling source that is - * immediately-available bypasses loading entirely. - * - * @readonly - * @member {boolean} - */ - _this.isLoading = false; - - /** - * The image source that is used to create the texture. - * - * TODO: Make this a setter that calls loadSource(); - * - * @readonly - * @member {HTMLImageElement|HTMLCanvasElement} - */ - _this.source = null; // set in loadSource, if at all - - /** - * The image source that is used to create the texture. This is used to - * store the original Svg source when it is replaced with a canvas element. - * - * TODO: Currently not in use but could be used when re-scaling svg. - * - * @readonly - * @member {Image} - */ - _this.origSource = null; // set in loadSvg, if at all - - /** - * Type of image defined in source, eg. `png` or `svg` - * - * @readonly - * @member {string} - */ - _this.imageType = null; // set in updateImageType - - /** - * Scale for source image. Used with Svg images to scale them before rasterization. - * - * @readonly - * @member {number} - */ - _this.sourceScale = 1.0; - - /** - * Controls if RGB channels should be pre-multiplied by Alpha (WebGL only) - * All blend modes, and shaders written for default value. Change it on your own risk. - * - * @member {boolean} - * @default true - */ - _this.premultipliedAlpha = true; - - /** - * The image url of the texture - * - * @member {string} - */ - _this.imageUrl = null; - - /** - * Whether or not the texture is a power of two, try to use power of two textures as much - * as you can - * - * @private - * @member {boolean} - */ - _this.isPowerOfTwo = false; - - // used for webGL - - /** - * - * Set this to true if a mipmap of this texture needs to be generated. This value needs - * to be set before the texture is used - * Also the texture must be a power of two size to work - * - * @member {boolean} - * @see PIXI.MIPMAP_TEXTURES - */ - _this.mipmap = _settings2.default.MIPMAP_TEXTURES; - - /** - * - * WebGL Texture wrap mode - * - * @member {number} - * @see PIXI.WRAP_MODES - */ - _this.wrapMode = _settings2.default.WRAP_MODE; - - /** - * A map of renderer IDs to webgl textures - * - * @private - * @member {object} - */ - _this._glTextures = {}; - - _this._enabled = 0; - _this._virtalBoundId = -1; - - /** - * If the object has been destroyed via destroy(). If true, it should not be used. - * - * @member {boolean} - * @private - * @readonly - */ - _this._destroyed = false; - - /** - * The ids under which this BaseTexture has been added to the base texture cache. This is - * automatically set as long as BaseTexture.addToCache is used, but may not be set if a - * BaseTexture is added directly to the BaseTextureCache array. - * - * @member {string[]} - */ - _this.textureCacheIds = []; - - // if no source passed don't try to load - if (source) { - _this.loadSource(source); - } - - /** - * Fired when a not-immediately-available source finishes loading. - * - * @protected - * @event PIXI.BaseTexture#loaded - * @param {PIXI.BaseTexture} baseTexture - Resource loaded. - */ - - /** - * Fired when a not-immediately-available source fails to load. - * - * @protected - * @event PIXI.BaseTexture#error - * @param {PIXI.BaseTexture} baseTexture - Resource errored. - */ - - /** - * Fired when BaseTexture is updated. - * - * @protected - * @event PIXI.BaseTexture#update - * @param {PIXI.BaseTexture} baseTexture - Instance of texture being updated. - */ - - /** - * Fired when BaseTexture is destroyed. - * - * @protected - * @event PIXI.BaseTexture#dispose - * @param {PIXI.BaseTexture} baseTexture - Instance of texture being destroyed. - */ - return _this; - } - - /** - * Updates the texture on all the webgl renderers, this also assumes the src has changed. - * - * @fires PIXI.BaseTexture#update - */ - - - BaseTexture.prototype.update = function update() { - // Svg size is handled during load - if (this.imageType !== 'svg') { - this.realWidth = this.source.naturalWidth || this.source.videoWidth || this.source.width; - this.realHeight = this.source.naturalHeight || this.source.videoHeight || this.source.height; - - this._updateDimensions(); - } - - this.emit('update', this); - }; - - /** - * Update dimensions from real values - */ - - - BaseTexture.prototype._updateDimensions = function _updateDimensions() { - this.width = this.realWidth / this.resolution; - this.height = this.realHeight / this.resolution; - - this.isPowerOfTwo = _bitTwiddle2.default.isPow2(this.realWidth) && _bitTwiddle2.default.isPow2(this.realHeight); - }; - - /** - * Load a source. - * - * If the source is not-immediately-available, such as an image that needs to be - * downloaded, then the 'loaded' or 'error' event will be dispatched in the future - * and `hasLoaded` will remain false after this call. - * - * The logic state after calling `loadSource` directly or indirectly (eg. `fromImage`, `new BaseTexture`) is: - * - * if (texture.hasLoaded) { - * // texture ready for use - * } else if (texture.isLoading) { - * // listen to 'loaded' and/or 'error' events on texture - * } else { - * // not loading, not going to load UNLESS the source is reloaded - * // (it may still make sense to listen to the events) - * } - * - * @protected - * @param {HTMLImageElement|HTMLCanvasElement} source - the source object of the texture. - */ - - - BaseTexture.prototype.loadSource = function loadSource(source) { - var wasLoading = this.isLoading; - - this.hasLoaded = false; - this.isLoading = false; - - if (wasLoading && this.source) { - this.source.onload = null; - this.source.onerror = null; - } - - var firstSourceLoaded = !this.source; - - this.source = source; - - // Apply source if loaded. Otherwise setup appropriate loading monitors. - if ((source.src && source.complete || source.getContext) && source.width && source.height) { - this._updateImageType(); - - if (this.imageType === 'svg') { - this._loadSvgSource(); - } else { - this._sourceLoaded(); - } - - if (firstSourceLoaded) { - // send loaded event if previous source was null and we have been passed a pre-loaded IMG element - this.emit('loaded', this); - } - } else if (!source.getContext) { - // Image fail / not ready - this.isLoading = true; - - var scope = this; - - source.onload = function () { - scope._updateImageType(); - source.onload = null; - source.onerror = null; - - if (!scope.isLoading) { - return; - } - - scope.isLoading = false; - scope._sourceLoaded(); - - if (scope.imageType === 'svg') { - scope._loadSvgSource(); - - return; - } - - scope.emit('loaded', scope); - }; - - source.onerror = function () { - source.onload = null; - source.onerror = null; - - if (!scope.isLoading) { - return; - } - - scope.isLoading = false; - scope.emit('error', scope); - }; - - // Per http://www.w3.org/TR/html5/embedded-content-0.html#the-img-element - // "The value of `complete` can thus change while a script is executing." - // So complete needs to be re-checked after the callbacks have been added.. - // NOTE: complete will be true if the image has no src so best to check if the src is set. - if (source.complete && source.src) { - // ..and if we're complete now, no need for callbacks - source.onload = null; - source.onerror = null; - - if (scope.imageType === 'svg') { - scope._loadSvgSource(); - - return; - } - - this.isLoading = false; - - if (source.width && source.height) { - this._sourceLoaded(); - - // If any previous subscribers possible - if (wasLoading) { - this.emit('loaded', this); - } - } - // If any previous subscribers possible - else if (wasLoading) { - this.emit('error', this); - } - } - } - }; - - /** - * Updates type of the source image. - */ - - - BaseTexture.prototype._updateImageType = function _updateImageType() { - if (!this.imageUrl) { - return; - } - - var dataUri = (0, _utils.decomposeDataUri)(this.imageUrl); - var imageType = void 0; - - if (dataUri && dataUri.mediaType === 'image') { - // Check for subType validity - var firstSubType = dataUri.subType.split('+')[0]; - - imageType = (0, _utils.getUrlFileExtension)('.' + firstSubType); - - if (!imageType) { - throw new Error('Invalid image type in data URI.'); - } - } else { - imageType = (0, _utils.getUrlFileExtension)(this.imageUrl); - - if (!imageType) { - imageType = 'png'; - } - } - - this.imageType = imageType; - }; - - /** - * Checks if `source` is an SVG image and whether it's loaded via a URL or a data URI. Then calls - * `_loadSvgSourceUsingDataUri` or `_loadSvgSourceUsingXhr`. - */ - - - BaseTexture.prototype._loadSvgSource = function _loadSvgSource() { - if (this.imageType !== 'svg') { - // Do nothing if source is not svg - return; - } - - var dataUri = (0, _utils.decomposeDataUri)(this.imageUrl); - - if (dataUri) { - this._loadSvgSourceUsingDataUri(dataUri); - } else { - // We got an URL, so we need to do an XHR to check the svg size - this._loadSvgSourceUsingXhr(); - } - }; - - /** - * Reads an SVG string from data URI and then calls `_loadSvgSourceUsingString`. - * - * @param {string} dataUri - The data uri to load from. - */ - - - BaseTexture.prototype._loadSvgSourceUsingDataUri = function _loadSvgSourceUsingDataUri(dataUri) { - var svgString = void 0; - - if (dataUri.encoding === 'base64') { - if (!atob) { - throw new Error('Your browser doesn\'t support base64 conversions.'); - } - svgString = atob(dataUri.data); - } else { - svgString = dataUri.data; - } - - this._loadSvgSourceUsingString(svgString); - }; - - /** - * Loads an SVG string from `imageUrl` using XHR and then calls `_loadSvgSourceUsingString`. - */ - - - BaseTexture.prototype._loadSvgSourceUsingXhr = function _loadSvgSourceUsingXhr() { - var _this2 = this; - - var svgXhr = new XMLHttpRequest(); - - // This throws error on IE, so SVG Document can't be used - // svgXhr.responseType = 'document'; - - // This is not needed since we load the svg as string (breaks IE too) - // but overrideMimeType() can be used to force the response to be parsed as XML - // svgXhr.overrideMimeType('image/svg+xml'); - - svgXhr.onload = function () { - if (svgXhr.readyState !== svgXhr.DONE || svgXhr.status !== 200) { - throw new Error('Failed to load SVG using XHR.'); - } - - _this2._loadSvgSourceUsingString(svgXhr.response); - }; - - svgXhr.onerror = function () { - return _this2.emit('error', _this2); - }; - - svgXhr.open('GET', this.imageUrl, true); - svgXhr.send(); - }; - - /** - * Loads texture using an SVG string. The original SVG Image is stored as `origSource` and the - * created canvas is the new `source`. The SVG is scaled using `sourceScale`. Called by - * `_loadSvgSourceUsingXhr` or `_loadSvgSourceUsingDataUri`. - * - * @param {string} svgString SVG source as string - * - * @fires PIXI.BaseTexture#loaded - */ - - - BaseTexture.prototype._loadSvgSourceUsingString = function _loadSvgSourceUsingString(svgString) { - var svgSize = (0, _utils.getSvgSize)(svgString); - - var svgWidth = svgSize.width; - var svgHeight = svgSize.height; - - if (!svgWidth || !svgHeight) { - throw new Error('The SVG image must have width and height defined (in pixels), canvas API needs them.'); - } - - // Scale realWidth and realHeight - this.realWidth = Math.round(svgWidth * this.sourceScale); - this.realHeight = Math.round(svgHeight * this.sourceScale); - - this._updateDimensions(); - - // Create a canvas element - var canvas = document.createElement('canvas'); - - canvas.width = this.realWidth; - canvas.height = this.realHeight; - canvas._pixiId = 'canvas_' + (0, _utils.uid)(); - - // Draw the Svg to the canvas - canvas.getContext('2d').drawImage(this.source, 0, 0, svgWidth, svgHeight, 0, 0, this.realWidth, this.realHeight); - - // Replace the original source image with the canvas - this.origSource = this.source; - this.source = canvas; - - // Add also the canvas in cache (destroy clears by `imageUrl` and `source._pixiId`) - BaseTexture.addToCache(this, canvas._pixiId); - - this.isLoading = false; - this._sourceLoaded(); - this.emit('loaded', this); - }; - - /** - * Used internally to update the width, height, and some other tracking vars once - * a source has successfully loaded. - * - * @private - */ - - - BaseTexture.prototype._sourceLoaded = function _sourceLoaded() { - this.hasLoaded = true; - this.update(); - }; - - /** - * Destroys this base texture - * - */ - - - BaseTexture.prototype.destroy = function destroy() { - if (this.imageUrl) { - delete _utils.TextureCache[this.imageUrl]; - - this.imageUrl = null; - - if (!navigator.isCocoonJS) { - this.source.src = ''; - } - } - - this.source = null; - - this.dispose(); - - BaseTexture.removeFromCache(this); - this.textureCacheIds = null; - - this._destroyed = true; - }; - - /** - * Frees the texture from WebGL memory without destroying this texture object. - * This means you can still use the texture later which will upload it to GPU - * memory again. - * - * @fires PIXI.BaseTexture#dispose - */ - - - BaseTexture.prototype.dispose = function dispose() { - this.emit('dispose', this); - }; - - /** - * Changes the source image of the texture. - * The original source must be an Image element. - * - * @param {string} newSrc - the path of the image - */ - - - BaseTexture.prototype.updateSourceImage = function updateSourceImage(newSrc) { - this.source.src = newSrc; - - this.loadSource(this.source); - }; - - /** - * Helper function that creates a base texture from the given image url. - * If the image is not in the base texture cache it will be created and loaded. - * - * @static - * @param {string} imageUrl - The image url of the texture - * @param {boolean} [crossorigin=(auto)] - Should use anonymous CORS? Defaults to true if the URL is not a data-URI. - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {number} [sourceScale=(auto)] - Scale for the original image, used with Svg images. - * @return {PIXI.BaseTexture} The new base texture. - */ - - - BaseTexture.fromImage = function fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - var baseTexture = _utils.BaseTextureCache[imageUrl]; - - if (!baseTexture) { - // new Image() breaks tex loading in some versions of Chrome. - // See https://code.google.com/p/chromium/issues/detail?id=238071 - var image = new Image(); // document.createElement('img'); - - if (crossorigin === undefined && imageUrl.indexOf('data:') !== 0) { - image.crossOrigin = (0, _determineCrossOrigin2.default)(imageUrl); - } else if (crossorigin) { - image.crossOrigin = typeof crossorigin === 'string' ? crossorigin : 'anonymous'; - } - - baseTexture = new BaseTexture(image, scaleMode); - baseTexture.imageUrl = imageUrl; - - if (sourceScale) { - baseTexture.sourceScale = sourceScale; - } - - // if there is an @2x at the end of the url we are going to assume its a highres image - baseTexture.resolution = (0, _utils.getResolutionOfUrl)(imageUrl); - - image.src = imageUrl; // Setting this triggers load - - BaseTexture.addToCache(baseTexture, imageUrl); - } - - return baseTexture; - }; - - /** - * Helper function that creates a base texture from the given canvas element. - * - * @static - * @param {HTMLCanvasElement} canvas - The canvas element source of the texture - * @param {number} scaleMode - See {@link PIXI.SCALE_MODES} for possible values - * @param {string} [origin='canvas'] - A string origin of who created the base texture - * @return {PIXI.BaseTexture} The new base texture. - */ - - - BaseTexture.fromCanvas = function fromCanvas(canvas, scaleMode) { - var origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'canvas'; - - if (!canvas._pixiId) { - canvas._pixiId = origin + '_' + (0, _utils.uid)(); - } - - var baseTexture = _utils.BaseTextureCache[canvas._pixiId]; - - if (!baseTexture) { - baseTexture = new BaseTexture(canvas, scaleMode); - BaseTexture.addToCache(baseTexture, canvas._pixiId); - } - - return baseTexture; - }; - - /** - * Helper function that creates a base texture based on the source you provide. - * The source can be - image url, image element, canvas element. If the - * source is an image url or an image element and not in the base texture - * cache, it will be created and loaded. - * - * @static - * @param {string|HTMLImageElement|HTMLCanvasElement} source - The source to create base texture from. - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {number} [sourceScale=(auto)] - Scale for the original image, used with Svg images. - * @return {PIXI.BaseTexture} The new base texture. - */ - - - BaseTexture.from = function from(source, scaleMode, sourceScale) { - if (typeof source === 'string') { - return BaseTexture.fromImage(source, undefined, scaleMode, sourceScale); - } else if (source instanceof HTMLImageElement) { - var imageUrl = source.src; - var baseTexture = _utils.BaseTextureCache[imageUrl]; - - if (!baseTexture) { - baseTexture = new BaseTexture(source, scaleMode); - baseTexture.imageUrl = imageUrl; - - if (sourceScale) { - baseTexture.sourceScale = sourceScale; - } - - // if there is an @2x at the end of the url we are going to assume its a highres image - baseTexture.resolution = (0, _utils.getResolutionOfUrl)(imageUrl); - - BaseTexture.addToCache(baseTexture, imageUrl); - } - - return baseTexture; - } else if (source instanceof HTMLCanvasElement) { - return BaseTexture.fromCanvas(source, scaleMode); - } - - // lets assume its a base texture! - return source; - }; - - /** - * Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object. - * - * @static - * @param {PIXI.BaseTexture} baseTexture - The BaseTexture to add to the cache. - * @param {string} id - The id that the BaseTexture will be stored against. - */ - - - BaseTexture.addToCache = function addToCache(baseTexture, id) { - if (id) { - if (baseTexture.textureCacheIds.indexOf(id) === -1) { - baseTexture.textureCacheIds.push(id); - } - - /* eslint-disable no-console */ - if (_utils.BaseTextureCache[id]) { - console.warn('BaseTexture added to the cache with an id [' + id + '] that already had an entry'); - } - /* eslint-enable no-console */ - - _utils.BaseTextureCache[id] = baseTexture; - } - }; - - /** - * Remove a BaseTexture from the global BaseTextureCache. - * - * @static - * @param {string|PIXI.BaseTexture} baseTexture - id of a BaseTexture to be removed, or a BaseTexture instance itself. - * @return {PIXI.BaseTexture|null} The BaseTexture that was removed. - */ - - - BaseTexture.removeFromCache = function removeFromCache(baseTexture) { - if (typeof baseTexture === 'string') { - var baseTextureFromCache = _utils.BaseTextureCache[baseTexture]; - - if (baseTextureFromCache) { - var index = baseTextureFromCache.textureCacheIds.indexOf(baseTexture); - - if (index > -1) { - baseTextureFromCache.textureCacheIds.splice(index, 1); - } - - delete _utils.BaseTextureCache[baseTexture]; - - return baseTextureFromCache; - } - } else if (baseTexture && baseTexture.textureCacheIds) { - for (var i = 0; i < baseTexture.textureCacheIds.length; ++i) { - delete _utils.BaseTextureCache[baseTexture.textureCacheIds[i]]; - } - - baseTexture.textureCacheIds.length = 0; - - return baseTexture; - } - - return null; - }; - - return BaseTexture; -}(_eventemitter2.default); - -exports.default = BaseTexture; - -},{"../settings":101,"../utils":125,"../utils/determineCrossOrigin":124,"bit-twiddle":1,"eventemitter3":3}],113:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _BaseRenderTexture = require('./BaseRenderTexture'); - -var _BaseRenderTexture2 = _interopRequireDefault(_BaseRenderTexture); - -var _Texture2 = require('./Texture'); - -var _Texture3 = _interopRequireDefault(_Texture2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * A RenderTexture is a special texture that allows any PixiJS display object to be rendered to it. - * - * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded - * otherwise black rectangles will be drawn instead. - * - * A RenderTexture takes a snapshot of any Display Object given to its render method. For example: - * - * ```js - * let renderer = PIXI.autoDetectRenderer(1024, 1024); - * let renderTexture = PIXI.RenderTexture.create(800, 600); - * let sprite = PIXI.Sprite.fromImage("spinObj_01.png"); - * - * sprite.position.x = 800/2; - * sprite.position.y = 600/2; - * sprite.anchor.x = 0.5; - * sprite.anchor.y = 0.5; - * - * renderer.render(sprite, renderTexture); - * ``` - * - * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 - * you can clear the transform - * - * ```js - * - * sprite.setTransform() - * - * let renderTexture = new PIXI.RenderTexture.create(100, 100); - * - * renderer.render(sprite, renderTexture); // Renders to center of RenderTexture - * ``` - * - * @class - * @extends PIXI.Texture - * @memberof PIXI - */ -var RenderTexture = function (_Texture) { - _inherits(RenderTexture, _Texture); - - /** - * @param {PIXI.BaseRenderTexture} baseRenderTexture - The renderer used for this RenderTexture - * @param {PIXI.Rectangle} [frame] - The rectangle frame of the texture to show - */ - function RenderTexture(baseRenderTexture, frame) { - _classCallCheck(this, RenderTexture); - - // support for legacy.. - var _legacyRenderer = null; - - if (!(baseRenderTexture instanceof _BaseRenderTexture2.default)) { - /* eslint-disable prefer-rest-params, no-console */ - var width = arguments[1]; - var height = arguments[2]; - var scaleMode = arguments[3]; - var resolution = arguments[4]; - - // we have an old render texture.. - console.warn('Please use RenderTexture.create(' + width + ', ' + height + ') instead of the ctor directly.'); - _legacyRenderer = arguments[0]; - /* eslint-enable prefer-rest-params, no-console */ - - frame = null; - baseRenderTexture = new _BaseRenderTexture2.default(width, height, scaleMode, resolution); - } - - /** - * The base texture object that this texture uses - * - * @member {BaseTexture} - */ - - var _this = _possibleConstructorReturn(this, _Texture.call(this, baseRenderTexture, frame)); - - _this.legacyRenderer = _legacyRenderer; - - /** - * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. - * - * @member {boolean} - */ - _this.valid = true; - - _this._updateUvs(); - return _this; - } - - /** - * Resizes the RenderTexture. - * - * @param {number} width - The width to resize to. - * @param {number} height - The height to resize to. - * @param {boolean} doNotResizeBaseTexture - Should the baseTexture.width and height values be resized as well? - */ - - - RenderTexture.prototype.resize = function resize(width, height, doNotResizeBaseTexture) { - width = Math.ceil(width); - height = Math.ceil(height); - - // TODO - could be not required.. - this.valid = width > 0 && height > 0; - - this._frame.width = this.orig.width = width; - this._frame.height = this.orig.height = height; - - if (!doNotResizeBaseTexture) { - this.baseTexture.resize(width, height); - } - - this._updateUvs(); - }; - - /** - * A short hand way of creating a render texture. - * - * @param {number} [width=100] - The width of the render texture - * @param {number} [height=100] - The height of the render texture - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {number} [resolution=1] - The resolution / device pixel ratio of the texture being generated - * @return {PIXI.RenderTexture} The new render texture - */ - - - RenderTexture.create = function create(width, height, scaleMode, resolution) { - return new RenderTexture(new _BaseRenderTexture2.default(width, height, scaleMode, resolution)); - }; - - return RenderTexture; -}(_Texture3.default); - -exports.default = RenderTexture; - -},{"./BaseRenderTexture":111,"./Texture":115}],114:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _ = require('../'); - -var _utils = require('../utils'); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Utility class for maintaining reference to a collection - * of Textures on a single Spritesheet. - * - * To access a sprite sheet from your code pass its JSON data file to Pixi's loader: - * - * ```js - * PIXI.loader.add("images/spritesheet.json").load(setup); - * - * function setup() { - * let sheet = PIXI.loader.resources["images/spritesheet.json"].spritesheet; - * ... - * } - * ``` - * With the `sheet.textures` you can create Sprite objects,`sheet.animations` can be used to create an AnimatedSprite. - * - * Sprite sheets can be packed using tools like {@link https://codeandweb.com/texturepacker|TexturePacker}, - * {@link https://renderhjs.net/shoebox/|Shoebox} or {@link https://github.com/krzysztof-o/spritesheet.js|Spritesheet.js}. - * Default anchor points (see {@link PIXI.Texture#defaultAnchor}) and grouping of animation sprites are currently only - * supported by TexturePacker. - * - * @class - * @memberof PIXI - */ -var Spritesheet = function () { - _createClass(Spritesheet, null, [{ - key: 'BATCH_SIZE', - - /** - * The maximum number of Textures to build per process. - * - * @type {number} - * @default 1000 - */ - get: function get() { - return 1000; - } - - /** - * @param {PIXI.BaseTexture} baseTexture Reference to the source BaseTexture object. - * @param {Object} data - Spritesheet image data. - * @param {string} [resolutionFilename] - The filename to consider when determining - * the resolution of the spritesheet. If not provided, the imageUrl will - * be used on the BaseTexture. - */ - - }]); - - function Spritesheet(baseTexture, data) { - var resolutionFilename = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - - _classCallCheck(this, Spritesheet); - - /** - * Reference to ths source texture - * @type {PIXI.BaseTexture} - */ - this.baseTexture = baseTexture; - - /** - * A map containing all textures of the sprite sheet. - * Can be used to create a {@link PIXI.Sprite|Sprite}: - * ```js - * new PIXI.Sprite(sheet.textures["image.png"]); - * ``` - * @member {Object} - */ - this.textures = {}; - - /** - * A map containing the textures for each animation. - * Can be used to create an {@link PIXI.extras.AnimatedSprite|AnimatedSprite}: - * ```js - * new PIXI.extras.AnimatedSprite(sheet.animations["anim_name"]) - * ``` - * @member {Object} - */ - this.animations = {}; - - /** - * Reference to the original JSON data. - * @type {Object} - */ - this.data = data; - - /** - * The resolution of the spritesheet. - * @type {number} - */ - this.resolution = this._updateResolution(resolutionFilename || this.baseTexture.imageUrl); - - /** - * Map of spritesheet frames. - * @type {Object} - * @private - */ - this._frames = this.data.frames; - - /** - * Collection of frame names. - * @type {string[]} - * @private - */ - this._frameKeys = Object.keys(this._frames); - - /** - * Current batch index being processed. - * @type {number} - * @private - */ - this._batchIndex = 0; - - /** - * Callback when parse is completed. - * @type {Function} - * @private - */ - this._callback = null; - } - - /** - * Generate the resolution from the filename or fallback - * to the meta.scale field of the JSON data. - * - * @private - * @param {string} resolutionFilename - The filename to use for resolving - * the default resolution. - * @return {number} Resolution to use for spritesheet. - */ - - - Spritesheet.prototype._updateResolution = function _updateResolution(resolutionFilename) { - var scale = this.data.meta.scale; - - // Use a defaultValue of `null` to check if a url-based resolution is set - var resolution = (0, _utils.getResolutionOfUrl)(resolutionFilename, null); - - // No resolution found via URL - if (resolution === null) { - // Use the scale value or default to 1 - resolution = scale !== undefined ? parseFloat(scale) : 1; - } - - // For non-1 resolutions, update baseTexture - if (resolution !== 1) { - this.baseTexture.resolution = resolution; - this.baseTexture.update(); - } - - return resolution; - }; - - /** - * Parser spritesheet from loaded data. This is done asynchronously - * to prevent creating too many Texture within a single process. - * - * @param {Function} callback - Callback when complete returns - * a map of the Textures for this spritesheet. - */ - - - Spritesheet.prototype.parse = function parse(callback) { - this._batchIndex = 0; - this._callback = callback; - - if (this._frameKeys.length <= Spritesheet.BATCH_SIZE) { - this._processFrames(0); - this._processAnimations(); - this._parseComplete(); - } else { - this._nextBatch(); - } - }; - - /** - * Process a batch of frames - * - * @private - * @param {number} initialFrameIndex - The index of frame to start. - */ - - - Spritesheet.prototype._processFrames = function _processFrames(initialFrameIndex) { - var frameIndex = initialFrameIndex; - var maxFrames = Spritesheet.BATCH_SIZE; - var sourceScale = this.baseTexture.sourceScale; - - while (frameIndex - initialFrameIndex < maxFrames && frameIndex < this._frameKeys.length) { - var i = this._frameKeys[frameIndex]; - var data = this._frames[i]; - var rect = data.frame; - - if (rect) { - var frame = null; - var trim = null; - var sourceSize = data.trimmed !== false && data.sourceSize ? data.sourceSize : data.frame; - - var orig = new _.Rectangle(0, 0, Math.floor(sourceSize.w * sourceScale) / this.resolution, Math.floor(sourceSize.h * sourceScale) / this.resolution); - - if (data.rotated) { - frame = new _.Rectangle(Math.floor(rect.x * sourceScale) / this.resolution, Math.floor(rect.y * sourceScale) / this.resolution, Math.floor(rect.h * sourceScale) / this.resolution, Math.floor(rect.w * sourceScale) / this.resolution); - } else { - frame = new _.Rectangle(Math.floor(rect.x * sourceScale) / this.resolution, Math.floor(rect.y * sourceScale) / this.resolution, Math.floor(rect.w * sourceScale) / this.resolution, Math.floor(rect.h * sourceScale) / this.resolution); - } - - // Check to see if the sprite is trimmed - if (data.trimmed !== false && data.spriteSourceSize) { - trim = new _.Rectangle(Math.floor(data.spriteSourceSize.x * sourceScale) / this.resolution, Math.floor(data.spriteSourceSize.y * sourceScale) / this.resolution, Math.floor(rect.w * sourceScale) / this.resolution, Math.floor(rect.h * sourceScale) / this.resolution); - } - - this.textures[i] = new _.Texture(this.baseTexture, frame, orig, trim, data.rotated ? 2 : 0, data.anchor); - - // lets also add the frame to pixi's global cache for fromFrame and fromImage functions - _.Texture.addToCache(this.textures[i], i); - } - - frameIndex++; - } - }; - - /** - * Parse animations config - * - * @private - */ - - - Spritesheet.prototype._processAnimations = function _processAnimations() { - var animations = this.data.animations || {}; - - for (var animName in animations) { - this.animations[animName] = []; - for (var _iterator = animations[animName], _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { - var _ref; - - if (_isArray) { - if (_i >= _iterator.length) break; - _ref = _iterator[_i++]; - } else { - _i = _iterator.next(); - if (_i.done) break; - _ref = _i.value; - } - - var frameName = _ref; - - this.animations[animName].push(this.textures[frameName]); - } - } - }; - - /** - * The parse has completed. - * - * @private - */ - - - Spritesheet.prototype._parseComplete = function _parseComplete() { - var callback = this._callback; - - this._callback = null; - this._batchIndex = 0; - callback.call(this, this.textures); - }; - - /** - * Begin the next batch of textures. - * - * @private - */ - - - Spritesheet.prototype._nextBatch = function _nextBatch() { - var _this = this; - - this._processFrames(this._batchIndex * Spritesheet.BATCH_SIZE); - this._batchIndex++; - setTimeout(function () { - if (_this._batchIndex * Spritesheet.BATCH_SIZE < _this._frameKeys.length) { - _this._nextBatch(); - } else { - _this._processAnimations(); - _this._parseComplete(); - } - }, 0); - }; - - /** - * Destroy Spritesheet and don't use after this. - * - * @param {boolean} [destroyBase=false] Whether to destroy the base texture as well - */ - - - Spritesheet.prototype.destroy = function destroy() { - var destroyBase = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - - for (var i in this.textures) { - this.textures[i].destroy(); - } - this._frames = null; - this._frameKeys = null; - this.data = null; - this.textures = null; - if (destroyBase) { - this.baseTexture.destroy(); - } - this.baseTexture = null; - }; - - return Spritesheet; -}(); - -exports.default = Spritesheet; - -},{"../":65,"../utils":125}],115:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _BaseTexture = require('./BaseTexture'); - -var _BaseTexture2 = _interopRequireDefault(_BaseTexture); - -var _VideoBaseTexture = require('./VideoBaseTexture'); - -var _VideoBaseTexture2 = _interopRequireDefault(_VideoBaseTexture); - -var _TextureUvs = require('./TextureUvs'); - -var _TextureUvs2 = _interopRequireDefault(_TextureUvs); - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -var _math = require('../math'); - -var _utils = require('../utils'); - -var _settings = require('../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * A texture stores the information that represents an image or part of an image. It cannot be added - * to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided - * then the whole image is used. - * - * You can directly create a texture from an image and then reuse it multiple times like this : - * - * ```js - * let texture = PIXI.Texture.fromImage('assets/image.png'); - * let sprite1 = new PIXI.Sprite(texture); - * let sprite2 = new PIXI.Sprite(texture); - * ``` - * - * Textures made from SVGs, loaded or not, cannot be used before the file finishes processing. - * You can check for this by checking the sprite's _textureID property. - * ```js - * var texture = PIXI.Texture.fromImage('assets/image.svg'); - * var sprite1 = new PIXI.Sprite(texture); - * //sprite1._textureID should not be undefined if the texture has finished processing the SVG file - * ``` - * You can use a ticker or rAF to ensure your sprites load the finished textures after processing. See issue #3068. - * - * @class - * @extends EventEmitter - * @memberof PIXI - */ -var Texture = function (_EventEmitter) { - _inherits(Texture, _EventEmitter); - - /** - * @param {PIXI.BaseTexture} baseTexture - The base texture source to create the texture from - * @param {PIXI.Rectangle} [frame] - The rectangle frame of the texture to show - * @param {PIXI.Rectangle} [orig] - The area of original texture - * @param {PIXI.Rectangle} [trim] - Trimmed rectangle of original texture - * @param {number} [rotate] - indicates how the texture was rotated by texture packer. See {@link PIXI.GroupD8} - * @param {PIXI.Point} [anchor] - Default anchor point used for sprite placement / rotation - */ - function Texture(baseTexture, frame, orig, trim, rotate, anchor) { - _classCallCheck(this, Texture); - - /** - * Does this Texture have any frame data assigned to it? - * - * @member {boolean} - */ - var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - - _this.noFrame = false; - - if (!frame) { - _this.noFrame = true; - frame = new _math.Rectangle(0, 0, 1, 1); - } - - if (baseTexture instanceof Texture) { - baseTexture = baseTexture.baseTexture; - } - - /** - * The base texture that this texture uses. - * - * @member {PIXI.BaseTexture} - */ - _this.baseTexture = baseTexture; - - /** - * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, - * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases) - * - * @member {PIXI.Rectangle} - */ - _this._frame = frame; - - /** - * This is the trimmed area of original texture, before it was put in atlas - * Please call `_updateUvs()` after you change coordinates of `trim` manually. - * - * @member {PIXI.Rectangle} - */ - _this.trim = trim; - - /** - * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. - * - * @member {boolean} - */ - _this.valid = false; - - /** - * This will let a renderer know that a texture has been updated (used mainly for webGL uv updates) - * - * @member {boolean} - */ - _this.requiresUpdate = false; - - /** - * The WebGL UV data cache. - * - * @member {PIXI.TextureUvs} - * @private - */ - _this._uvs = null; - - /** - * This is the area of original texture, before it was put in atlas - * - * @member {PIXI.Rectangle} - */ - _this.orig = orig || frame; // new Rectangle(0, 0, 1, 1); - - _this._rotate = Number(rotate || 0); - - if (rotate === true) { - // this is old texturepacker legacy, some games/libraries are passing "true" for rotated textures - _this._rotate = 2; - } else if (_this._rotate % 2 !== 0) { - throw new Error('attempt to use diamond-shaped UVs. If you are sure, set rotation manually'); - } - - if (baseTexture.hasLoaded) { - if (_this.noFrame) { - frame = new _math.Rectangle(0, 0, baseTexture.width, baseTexture.height); - - // if there is no frame we should monitor for any base texture changes.. - baseTexture.on('update', _this.onBaseTextureUpdated, _this); - } - _this.frame = frame; - } else { - baseTexture.once('loaded', _this.onBaseTextureLoaded, _this); - } - - /** - * Anchor point that is used as default if sprite is created with this texture. - * Changing the `defaultAnchor` at a later point of time will not update Sprite's anchor point. - * @member {PIXI.Point} - * @default {0,0} - */ - _this.defaultAnchor = anchor ? new _math.Point(anchor.x, anchor.y) : new _math.Point(0, 0); - - /** - * Fired when the texture is updated. This happens if the frame or the baseTexture is updated. - * - * @event PIXI.Texture#update - * @protected - * @param {PIXI.Texture} texture - Instance of texture being updated. - */ - - _this._updateID = 0; - - /** - * Contains data for uvs. May contain clamp settings and some matrices. - * Its a bit heavy, so by default that object is not created. - * @member {PIXI.TextureMatrix} - * @default null - */ - _this.transform = null; - - /** - * The ids under which this Texture has been added to the texture cache. This is - * automatically set as long as Texture.addToCache is used, but may not be set if a - * Texture is added directly to the TextureCache array. - * - * @member {string[]} - */ - _this.textureCacheIds = []; - return _this; - } - - /** - * Updates this texture on the gpu. - * - */ - - - Texture.prototype.update = function update() { - this.baseTexture.update(); - }; - - /** - * Called when the base texture is loaded - * - * @private - * @param {PIXI.BaseTexture} baseTexture - The base texture. - */ - - - Texture.prototype.onBaseTextureLoaded = function onBaseTextureLoaded(baseTexture) { - this._updateID++; - - // TODO this code looks confusing.. boo to abusing getters and setters! - if (this.noFrame) { - this.frame = new _math.Rectangle(0, 0, baseTexture.width, baseTexture.height); - } else { - this.frame = this._frame; - } - - this.baseTexture.on('update', this.onBaseTextureUpdated, this); - this.emit('update', this); - }; - - /** - * Called when the base texture is updated - * - * @private - * @param {PIXI.BaseTexture} baseTexture - The base texture. - */ - - - Texture.prototype.onBaseTextureUpdated = function onBaseTextureUpdated(baseTexture) { - this._updateID++; - - this._frame.width = baseTexture.width; - this._frame.height = baseTexture.height; - - this.emit('update', this); - }; - - /** - * Destroys this texture - * - * @param {boolean} [destroyBase=false] Whether to destroy the base texture as well - */ - - - Texture.prototype.destroy = function destroy(destroyBase) { - if (this.baseTexture) { - if (destroyBase) { - // delete the texture if it exists in the texture cache.. - // this only needs to be removed if the base texture is actually destroyed too.. - if (_utils.TextureCache[this.baseTexture.imageUrl]) { - Texture.removeFromCache(this.baseTexture.imageUrl); - } - - this.baseTexture.destroy(); - } - - this.baseTexture.off('update', this.onBaseTextureUpdated, this); - this.baseTexture.off('loaded', this.onBaseTextureLoaded, this); - - this.baseTexture = null; - } - - this._frame = null; - this._uvs = null; - this.trim = null; - this.orig = null; - - this.valid = false; - - Texture.removeFromCache(this); - this.textureCacheIds = null; - }; - - /** - * Creates a new texture object that acts the same as this one. - * - * @return {PIXI.Texture} The new texture - */ - - - Texture.prototype.clone = function clone() { - return new Texture(this.baseTexture, this.frame, this.orig, this.trim, this.rotate, this.defaultAnchor); - }; - - /** - * Updates the internal WebGL UV cache. Use it after you change `frame` or `trim` of the texture. - */ - - - Texture.prototype._updateUvs = function _updateUvs() { - if (!this._uvs) { - this._uvs = new _TextureUvs2.default(); - } - - this._uvs.set(this._frame, this.baseTexture, this.rotate); - - this._updateID++; - }; - - /** - * Helper function that creates a Texture object from the given image url. - * If the image is not in the texture cache it will be created and loaded. - * - * @static - * @param {string} imageUrl - The image url of the texture - * @param {boolean} [crossorigin] - Whether requests should be treated as crossorigin - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {number} [sourceScale=(auto)] - Scale for the original image, used with SVG images. - * @return {PIXI.Texture} The newly created texture - */ - - - Texture.fromImage = function fromImage(imageUrl, crossorigin, scaleMode, sourceScale) { - var texture = _utils.TextureCache[imageUrl]; - - if (!texture) { - texture = new Texture(_BaseTexture2.default.fromImage(imageUrl, crossorigin, scaleMode, sourceScale)); - Texture.addToCache(texture, imageUrl); - } - - return texture; - }; - - /** - * Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId - * The frame ids are created when a Texture packer file has been loaded - * - * @static - * @param {string} frameId - The frame Id of the texture in the cache - * @return {PIXI.Texture} The newly created texture - */ - - - Texture.fromFrame = function fromFrame(frameId) { - var texture = _utils.TextureCache[frameId]; - - if (!texture) { - throw new Error('The frameId "' + frameId + '" does not exist in the texture cache'); - } - - return texture; - }; - - /** - * Helper function that creates a new Texture based on the given canvas element. - * - * @static - * @param {HTMLCanvasElement} canvas - The canvas element source of the texture - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {string} [origin='canvas'] - A string origin of who created the base texture - * @return {PIXI.Texture} The newly created texture - */ - - - Texture.fromCanvas = function fromCanvas(canvas, scaleMode) { - var origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'canvas'; - - return new Texture(_BaseTexture2.default.fromCanvas(canvas, scaleMode, origin)); - }; - - /** - * Helper function that creates a new Texture based on the given video element. - * - * @static - * @param {HTMLVideoElement|string} video - The URL or actual element of the video - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {boolean} [crossorigin=(auto)] - Should use anonymous CORS? Defaults to true if the URL is not a data-URI. - * @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded - * @return {PIXI.Texture} The newly created texture - */ - - - Texture.fromVideo = function fromVideo(video, scaleMode, crossorigin, autoPlay) { - if (typeof video === 'string') { - return Texture.fromVideoUrl(video, scaleMode, crossorigin, autoPlay); - } - - return new Texture(_VideoBaseTexture2.default.fromVideo(video, scaleMode, autoPlay)); - }; - - /** - * Helper function that creates a new Texture based on the video url. - * - * @static - * @param {string} videoUrl - URL of the video - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {boolean} [crossorigin=(auto)] - Should use anonymous CORS? Defaults to true if the URL is not a data-URI. - * @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded - * @return {PIXI.Texture} The newly created texture - */ - - - Texture.fromVideoUrl = function fromVideoUrl(videoUrl, scaleMode, crossorigin, autoPlay) { - return new Texture(_VideoBaseTexture2.default.fromUrl(videoUrl, scaleMode, crossorigin, autoPlay)); - }; - - /** - * Helper function that creates a new Texture based on the source you provide. - * The source can be - frame id, image url, video url, canvas element, video element, base texture - * - * @static - * @param {number|string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|PIXI.BaseTexture} - * source - Source to create texture from - * @return {PIXI.Texture} The newly created texture - */ - - - Texture.from = function from(source) { - // TODO auto detect cross origin.. - // TODO pass in scale mode? - if (typeof source === 'string') { - var texture = _utils.TextureCache[source]; - - if (!texture) { - // check if its a video.. - var isVideo = source.match(/\.(mp4|webm|ogg|h264|avi|mov)$/) !== null; - - if (isVideo) { - return Texture.fromVideoUrl(source); - } - - return Texture.fromImage(source); - } - - return texture; - } else if (source instanceof HTMLImageElement) { - return new Texture(_BaseTexture2.default.from(source)); - } else if (source instanceof HTMLCanvasElement) { - return Texture.fromCanvas(source, _settings2.default.SCALE_MODE, 'HTMLCanvasElement'); - } else if (source instanceof HTMLVideoElement) { - return Texture.fromVideo(source); - } else if (source instanceof _BaseTexture2.default) { - return new Texture(source); - } - - // lets assume its a texture! - return source; - }; - - /** - * Create a texture from a source and add to the cache. - * - * @static - * @param {HTMLImageElement|HTMLCanvasElement} source - The input source. - * @param {String} imageUrl - File name of texture, for cache and resolving resolution. - * @param {String} [name] - Human readible name for the texture cache. If no name is - * specified, only `imageUrl` will be used as the cache ID. - * @return {PIXI.Texture} Output texture - */ - - - Texture.fromLoader = function fromLoader(source, imageUrl, name) { - var baseTexture = new _BaseTexture2.default(source, undefined, (0, _utils.getResolutionOfUrl)(imageUrl)); - var texture = new Texture(baseTexture); - - baseTexture.imageUrl = imageUrl; - - // No name, use imageUrl instead - if (!name) { - name = imageUrl; - } - - // lets also add the frame to pixi's global cache for fromFrame and fromImage fucntions - _BaseTexture2.default.addToCache(texture.baseTexture, name); - Texture.addToCache(texture, name); - - // also add references by url if they are different. - if (name !== imageUrl) { - _BaseTexture2.default.addToCache(texture.baseTexture, imageUrl); - Texture.addToCache(texture, imageUrl); - } - - return texture; - }; - - /** - * Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object. - * - * @static - * @param {PIXI.Texture} texture - The Texture to add to the cache. - * @param {string} id - The id that the Texture will be stored against. - */ - - - Texture.addToCache = function addToCache(texture, id) { - if (id) { - if (texture.textureCacheIds.indexOf(id) === -1) { - texture.textureCacheIds.push(id); - } - - /* eslint-disable no-console */ - if (_utils.TextureCache[id]) { - console.warn('Texture added to the cache with an id [' + id + '] that already had an entry'); - } - /* eslint-enable no-console */ - - _utils.TextureCache[id] = texture; - } - }; - - /** - * Remove a Texture from the global TextureCache. - * - * @static - * @param {string|PIXI.Texture} texture - id of a Texture to be removed, or a Texture instance itself - * @return {PIXI.Texture|null} The Texture that was removed - */ - - - Texture.removeFromCache = function removeFromCache(texture) { - if (typeof texture === 'string') { - var textureFromCache = _utils.TextureCache[texture]; - - if (textureFromCache) { - var index = textureFromCache.textureCacheIds.indexOf(texture); - - if (index > -1) { - textureFromCache.textureCacheIds.splice(index, 1); - } - - delete _utils.TextureCache[texture]; - - return textureFromCache; - } - } else if (texture && texture.textureCacheIds) { - for (var i = 0; i < texture.textureCacheIds.length; ++i) { - // Check that texture matches the one being passed in before deleting it from the cache. - if (_utils.TextureCache[texture.textureCacheIds[i]] === texture) { - delete _utils.TextureCache[texture.textureCacheIds[i]]; - } - } - - texture.textureCacheIds.length = 0; - - return texture; - } - - return null; - }; - - /** - * The frame specifies the region of the base texture that this texture uses. - * Please call `_updateUvs()` after you change coordinates of `frame` manually. - * - * @member {PIXI.Rectangle} - */ - - - _createClass(Texture, [{ - key: 'frame', - get: function get() { - return this._frame; - }, - set: function set(frame) // eslint-disable-line require-jsdoc - { - this._frame = frame; - - this.noFrame = false; - - var x = frame.x, - y = frame.y, - width = frame.width, - height = frame.height; - - var xNotFit = x + width > this.baseTexture.width; - var yNotFit = y + height > this.baseTexture.height; - - if (xNotFit || yNotFit) { - var relationship = xNotFit && yNotFit ? 'and' : 'or'; - var errorX = 'X: ' + x + ' + ' + width + ' = ' + (x + width) + ' > ' + this.baseTexture.width; - var errorY = 'Y: ' + y + ' + ' + height + ' = ' + (y + height) + ' > ' + this.baseTexture.height; - - throw new Error('Texture Error: frame does not fit inside the base Texture dimensions: ' + (errorX + ' ' + relationship + ' ' + errorY)); - } - - // this.valid = width && height && this.baseTexture.source && this.baseTexture.hasLoaded; - this.valid = width && height && this.baseTexture.hasLoaded; - - if (!this.trim && !this.rotate) { - this.orig = frame; - } - - if (this.valid) { - this._updateUvs(); - } - } - - /** - * Indicates whether the texture is rotated inside the atlas - * set to 2 to compensate for texture packer rotation - * set to 6 to compensate for spine packer rotation - * can be used to rotate or mirror sprites - * See {@link PIXI.GroupD8} for explanation - * - * @member {number} - */ - - }, { - key: 'rotate', - get: function get() { - return this._rotate; - }, - set: function set(rotate) // eslint-disable-line require-jsdoc - { - this._rotate = rotate; - if (this.valid) { - this._updateUvs(); - } - } - - /** - * The width of the Texture in pixels. - * - * @member {number} - */ - - }, { - key: 'width', - get: function get() { - return this.orig.width; - } - - /** - * The height of the Texture in pixels. - * - * @member {number} - */ - - }, { - key: 'height', - get: function get() { - return this.orig.height; - } - }]); - - return Texture; -}(_eventemitter2.default); - -exports.default = Texture; - - -function createWhiteTexture() { - var canvas = document.createElement('canvas'); - - canvas.width = 10; - canvas.height = 10; - - var context = canvas.getContext('2d'); - - context.fillStyle = 'white'; - context.fillRect(0, 0, 10, 10); - - return new Texture(new _BaseTexture2.default(canvas)); -} - -function removeAllHandlers(tex) { - tex.destroy = function _emptyDestroy() {/* empty */}; - tex.on = function _emptyOn() {/* empty */}; - tex.once = function _emptyOnce() {/* empty */}; - tex.emit = function _emptyEmit() {/* empty */}; -} - -/** - * An empty texture, used often to not have to create multiple empty textures. - * Can not be destroyed. - * - * @static - * @constant - */ -Texture.EMPTY = new Texture(new _BaseTexture2.default()); -removeAllHandlers(Texture.EMPTY); -removeAllHandlers(Texture.EMPTY.baseTexture); - -/** - * A white texture of 10x10 size, used for graphics and other things - * Can not be destroyed. - * - * @static - * @constant - */ -Texture.WHITE = createWhiteTexture(); -removeAllHandlers(Texture.WHITE); -removeAllHandlers(Texture.WHITE.baseTexture); - -},{"../math":70,"../settings":101,"../utils":125,"./BaseTexture":112,"./TextureUvs":117,"./VideoBaseTexture":118,"eventemitter3":3}],116:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _Matrix = require('../math/Matrix'); - -var _Matrix2 = _interopRequireDefault(_Matrix); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var tempMat = new _Matrix2.default(); - -/** - * Class controls uv transform and frame clamp for texture - * Can be used in Texture "transform" field, or separately, you can use different clamp settings on the same texture. - * If you want to add support for texture region of certain feature or filter, that's what you're looking for. - * - * @see PIXI.Texture - * @see PIXI.mesh.Mesh - * @see PIXI.extras.TilingSprite - * @class - * @memberof PIXI - */ - -var TextureMatrix = function () { - /** - * - * @param {PIXI.Texture} texture observed texture - * @param {number} [clampMargin] Changes frame clamping, 0.5 by default. Use -0.5 for extra border. - * @constructor - */ - function TextureMatrix(texture, clampMargin) { - _classCallCheck(this, TextureMatrix); - - this._texture = texture; - - this.mapCoord = new _Matrix2.default(); - - this.uClampFrame = new Float32Array(4); - - this.uClampOffset = new Float32Array(2); - - this._lastTextureID = -1; - - /** - * Changes frame clamping - * Works with TilingSprite and Mesh - * Change to 1.5 if you texture has repeated right and bottom lines, that leads to smoother borders - * - * @default 0 - * @member {number} - */ - this.clampOffset = 0; - - /** - * Changes frame clamping - * Works with TilingSprite and Mesh - * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas - * - * @default 0.5 - * @member {number} - */ - this.clampMargin = typeof clampMargin === 'undefined' ? 0.5 : clampMargin; - } - - /** - * texture property - * @member {PIXI.Texture} - */ - - - /** - * Multiplies uvs array to transform - * @param {Float32Array} uvs mesh uvs - * @param {Float32Array} [out=uvs] output - * @returns {Float32Array} output - */ - TextureMatrix.prototype.multiplyUvs = function multiplyUvs(uvs, out) { - if (out === undefined) { - out = uvs; - } - - var mat = this.mapCoord; - - for (var i = 0; i < uvs.length; i += 2) { - var x = uvs[i]; - var y = uvs[i + 1]; - - out[i] = x * mat.a + y * mat.c + mat.tx; - out[i + 1] = x * mat.b + y * mat.d + mat.ty; - } - - return out; - }; - - /** - * updates matrices if texture was changed - * @param {boolean} forceUpdate if true, matrices will be updated any case - * @returns {boolean} whether or not it was updated - */ - - - TextureMatrix.prototype.update = function update(forceUpdate) { - var tex = this._texture; - - if (!tex || !tex.valid) { - return false; - } - - if (!forceUpdate && this._lastTextureID === tex._updateID) { - return false; - } - - this._lastTextureID = tex._updateID; - - var uvs = tex._uvs; - - this.mapCoord.set(uvs.x1 - uvs.x0, uvs.y1 - uvs.y0, uvs.x3 - uvs.x0, uvs.y3 - uvs.y0, uvs.x0, uvs.y0); - - var orig = tex.orig; - var trim = tex.trim; - - if (trim) { - tempMat.set(orig.width / trim.width, 0, 0, orig.height / trim.height, -trim.x / trim.width, -trim.y / trim.height); - this.mapCoord.append(tempMat); - } - - var texBase = tex.baseTexture; - var frame = this.uClampFrame; - var margin = this.clampMargin / texBase.resolution; - var offset = this.clampOffset; - - frame[0] = (tex._frame.x + margin + offset) / texBase.width; - frame[1] = (tex._frame.y + margin + offset) / texBase.height; - frame[2] = (tex._frame.x + tex._frame.width - margin + offset) / texBase.width; - frame[3] = (tex._frame.y + tex._frame.height - margin + offset) / texBase.height; - this.uClampOffset[0] = offset / texBase.realWidth; - this.uClampOffset[1] = offset / texBase.realHeight; - - return true; - }; - - _createClass(TextureMatrix, [{ - key: 'texture', - get: function get() { - return this._texture; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._texture = value; - this._lastTextureID = -1; - } - }]); - - return TextureMatrix; -}(); - -exports.default = TextureMatrix; - -},{"../math/Matrix":67}],117:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _GroupD = require('../math/GroupD8'); - -var _GroupD2 = _interopRequireDefault(_GroupD); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * A standard object to store the Uvs of a texture - * - * @class - * @private - * @memberof PIXI - */ -var TextureUvs = function () { - /** - * - */ - function TextureUvs() { - _classCallCheck(this, TextureUvs); - - this.x0 = 0; - this.y0 = 0; - - this.x1 = 1; - this.y1 = 0; - - this.x2 = 1; - this.y2 = 1; - - this.x3 = 0; - this.y3 = 1; - - this.uvsUint32 = new Uint32Array(4); - } - - /** - * Sets the texture Uvs based on the given frame information. - * - * @private - * @param {PIXI.Rectangle} frame - The frame of the texture - * @param {PIXI.Rectangle} baseFrame - The base frame of the texture - * @param {number} rotate - Rotation of frame, see {@link PIXI.GroupD8} - */ - - - TextureUvs.prototype.set = function set(frame, baseFrame, rotate) { - var tw = baseFrame.width; - var th = baseFrame.height; - - if (rotate) { - // width and height div 2 div baseFrame size - var w2 = frame.width / 2 / tw; - var h2 = frame.height / 2 / th; - - // coordinates of center - var cX = frame.x / tw + w2; - var cY = frame.y / th + h2; - - rotate = _GroupD2.default.add(rotate, _GroupD2.default.NW); // NW is top-left corner - this.x0 = cX + w2 * _GroupD2.default.uX(rotate); - this.y0 = cY + h2 * _GroupD2.default.uY(rotate); - - rotate = _GroupD2.default.add(rotate, 2); // rotate 90 degrees clockwise - this.x1 = cX + w2 * _GroupD2.default.uX(rotate); - this.y1 = cY + h2 * _GroupD2.default.uY(rotate); - - rotate = _GroupD2.default.add(rotate, 2); - this.x2 = cX + w2 * _GroupD2.default.uX(rotate); - this.y2 = cY + h2 * _GroupD2.default.uY(rotate); - - rotate = _GroupD2.default.add(rotate, 2); - this.x3 = cX + w2 * _GroupD2.default.uX(rotate); - this.y3 = cY + h2 * _GroupD2.default.uY(rotate); - } else { - this.x0 = frame.x / tw; - this.y0 = frame.y / th; - - this.x1 = (frame.x + frame.width) / tw; - this.y1 = frame.y / th; - - this.x2 = (frame.x + frame.width) / tw; - this.y2 = (frame.y + frame.height) / th; - - this.x3 = frame.x / tw; - this.y3 = (frame.y + frame.height) / th; - } - - this.uvsUint32[0] = (Math.round(this.y0 * 65535) & 0xFFFF) << 16 | Math.round(this.x0 * 65535) & 0xFFFF; - this.uvsUint32[1] = (Math.round(this.y1 * 65535) & 0xFFFF) << 16 | Math.round(this.x1 * 65535) & 0xFFFF; - this.uvsUint32[2] = (Math.round(this.y2 * 65535) & 0xFFFF) << 16 | Math.round(this.x2 * 65535) & 0xFFFF; - this.uvsUint32[3] = (Math.round(this.y3 * 65535) & 0xFFFF) << 16 | Math.round(this.x3 * 65535) & 0xFFFF; - }; - - return TextureUvs; -}(); - -exports.default = TextureUvs; - -},{"../math/GroupD8":66}],118:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _BaseTexture2 = require('./BaseTexture'); - -var _BaseTexture3 = _interopRequireDefault(_BaseTexture2); - -var _utils = require('../utils'); - -var _ticker = require('../ticker'); - -var _const = require('../const'); - -var _determineCrossOrigin = require('../utils/determineCrossOrigin'); - -var _determineCrossOrigin2 = _interopRequireDefault(_determineCrossOrigin); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * A texture of a [playing] Video. - * - * Video base textures mimic PixiJS BaseTexture.from.... method in their creation process. - * - * This can be used in several ways, such as: - * - * ```js - * let texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); - * - * let texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); - * - * let texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); - * - * let texture = PIXI.VideoBaseTexture.fromUrls([ - * { src: '/video.webm', mime: 'video/webm' }, - * { src: '/video.mp4', mime: 'video/mp4' } - * ]); - * ``` - * - * See the ["deus" demo](http://www.goodboydigital.com/pixijs/examples/deus/). - * - * @class - * @extends PIXI.BaseTexture - * @memberof PIXI - */ -var VideoBaseTexture = function (_BaseTexture) { - _inherits(VideoBaseTexture, _BaseTexture); - - /** - * @param {HTMLVideoElement} source - Video source - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded - */ - function VideoBaseTexture(source, scaleMode) { - var autoPlay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; - - _classCallCheck(this, VideoBaseTexture); - - if (!source) { - throw new Error('No video source element specified.'); - } - - // hook in here to check if video is already available. - // BaseTexture looks for a source.complete boolean, plus width & height. - - if ((source.readyState === source.HAVE_ENOUGH_DATA || source.readyState === source.HAVE_FUTURE_DATA) && source.width && source.height) { - source.complete = true; - } - - var _this = _possibleConstructorReturn(this, _BaseTexture.call(this, source, scaleMode)); - - _this.width = source.videoWidth; - _this.height = source.videoHeight; - - _this._autoUpdate = true; - _this._isAutoUpdating = false; - - /** - * When set to true will automatically play videos used by this texture once - * they are loaded. If false, it will not modify the playing state. - * - * @member {boolean} - * @default true - */ - _this.autoPlay = autoPlay; - - _this.update = _this.update.bind(_this); - _this._onCanPlay = _this._onCanPlay.bind(_this); - - source.addEventListener('play', _this._onPlayStart.bind(_this)); - source.addEventListener('pause', _this._onPlayStop.bind(_this)); - _this.hasLoaded = false; - _this.__loaded = false; - - if (!_this._isSourceReady()) { - source.addEventListener('canplay', _this._onCanPlay); - source.addEventListener('canplaythrough', _this._onCanPlay); - } else { - _this._onCanPlay(); - } - return _this; - } - - /** - * Returns true if the underlying source is playing. - * - * @private - * @return {boolean} True if playing. - */ - - - VideoBaseTexture.prototype._isSourcePlaying = function _isSourcePlaying() { - var source = this.source; - - return source.currentTime > 0 && source.paused === false && source.ended === false && source.readyState > 2; - }; - - /** - * Returns true if the underlying source is ready for playing. - * - * @private - * @return {boolean} True if ready. - */ - - - VideoBaseTexture.prototype._isSourceReady = function _isSourceReady() { - return this.source.readyState === 3 || this.source.readyState === 4; - }; - - /** - * Runs the update loop when the video is ready to play - * - * @private - */ - - - VideoBaseTexture.prototype._onPlayStart = function _onPlayStart() { - // Just in case the video has not received its can play even yet.. - if (!this.hasLoaded) { - this._onCanPlay(); - } - - if (!this._isAutoUpdating && this.autoUpdate) { - _ticker.shared.add(this.update, this, _const.UPDATE_PRIORITY.HIGH); - this._isAutoUpdating = true; - } - }; - - /** - * Fired when a pause event is triggered, stops the update loop - * - * @private - */ - - - VideoBaseTexture.prototype._onPlayStop = function _onPlayStop() { - if (this._isAutoUpdating) { - _ticker.shared.remove(this.update, this); - this._isAutoUpdating = false; - } - }; - - /** - * Fired when the video is loaded and ready to play - * - * @private - */ - - - VideoBaseTexture.prototype._onCanPlay = function _onCanPlay() { - this.hasLoaded = true; - - if (this.source) { - this.source.removeEventListener('canplay', this._onCanPlay); - this.source.removeEventListener('canplaythrough', this._onCanPlay); - - this.width = this.source.videoWidth; - this.height = this.source.videoHeight; - - // prevent multiple loaded dispatches.. - if (!this.__loaded) { - this.__loaded = true; - this.emit('loaded', this); - } - - if (this._isSourcePlaying()) { - this._onPlayStart(); - } else if (this.autoPlay) { - this.source.play(); - } - } - }; - - /** - * Destroys this texture - * - */ - - - VideoBaseTexture.prototype.destroy = function destroy() { - if (this._isAutoUpdating) { - _ticker.shared.remove(this.update, this); - } - - if (this.source && this.source._pixiId) { - _BaseTexture3.default.removeFromCache(this.source._pixiId); - delete this.source._pixiId; - - this.source.pause(); - this.source.src = ''; - this.source.load(); - } - - _BaseTexture.prototype.destroy.call(this); - }; - - /** - * Mimic PixiJS BaseTexture.from.... method. - * - * @static - * @param {HTMLVideoElement} video - Video to create texture from - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values - * @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded - * @return {PIXI.VideoBaseTexture} Newly created VideoBaseTexture - */ - - - VideoBaseTexture.fromVideo = function fromVideo(video, scaleMode, autoPlay) { - if (!video._pixiId) { - video._pixiId = 'video_' + (0, _utils.uid)(); - } - - var baseTexture = _utils.BaseTextureCache[video._pixiId]; - - if (!baseTexture) { - baseTexture = new VideoBaseTexture(video, scaleMode, autoPlay); - _BaseTexture3.default.addToCache(baseTexture, video._pixiId); - } - - return baseTexture; - }; - - /** - * Helper function that creates a new BaseTexture based on the given video element. - * This BaseTexture can then be used to create a texture - * - * @static - * @param {string|object|string[]|object[]} videoSrc - The URL(s) for the video. - * @param {string} [videoSrc.src] - One of the source urls for the video - * @param {string} [videoSrc.mime] - The mimetype of the video (e.g. 'video/mp4'). If not specified - * the url's extension will be used as the second part of the mime type. - * @param {number} scaleMode - See {@link PIXI.SCALE_MODES} for possible values - * @param {boolean} [crossorigin=(auto)] - Should use anonymous CORS? Defaults to true if the URL is not a data-URI. - * @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded - * @return {PIXI.VideoBaseTexture} Newly created VideoBaseTexture - */ - - - VideoBaseTexture.fromUrl = function fromUrl(videoSrc, scaleMode, crossorigin, autoPlay) { - var video = document.createElement('video'); - - video.setAttribute('webkit-playsinline', ''); - video.setAttribute('playsinline', ''); - - var url = Array.isArray(videoSrc) ? videoSrc[0].src || videoSrc[0] : videoSrc.src || videoSrc; - - if (crossorigin === undefined && url.indexOf('data:') !== 0) { - video.crossOrigin = (0, _determineCrossOrigin2.default)(url); - } else if (crossorigin) { - video.crossOrigin = typeof crossorigin === 'string' ? crossorigin : 'anonymous'; - } - - // array of objects or strings - if (Array.isArray(videoSrc)) { - for (var i = 0; i < videoSrc.length; ++i) { - video.appendChild(createSource(videoSrc[i].src || videoSrc[i], videoSrc[i].mime)); - } - } - // single object or string - else { - video.appendChild(createSource(url, videoSrc.mime)); - } - - video.load(); - - return VideoBaseTexture.fromVideo(video, scaleMode, autoPlay); - }; - - /** - * Should the base texture automatically update itself, set to true by default - * - * @member {boolean} - */ - - - _createClass(VideoBaseTexture, [{ - key: 'autoUpdate', - get: function get() { - return this._autoUpdate; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (value !== this._autoUpdate) { - this._autoUpdate = value; - - if (!this._autoUpdate && this._isAutoUpdating) { - _ticker.shared.remove(this.update, this); - this._isAutoUpdating = false; - } else if (this._autoUpdate && !this._isAutoUpdating) { - _ticker.shared.add(this.update, this, _const.UPDATE_PRIORITY.HIGH); - this._isAutoUpdating = true; - } - } - } - }]); - - return VideoBaseTexture; -}(_BaseTexture3.default); - -exports.default = VideoBaseTexture; - - -VideoBaseTexture.fromUrls = VideoBaseTexture.fromUrl; - -function createSource(path, type) { - if (!type) { - var purePath = path.split('?').shift().toLowerCase(); - - type = 'video/' + purePath.substr(purePath.lastIndexOf('.') + 1); - } - - var source = document.createElement('source'); - - source.src = path; - source.type = type; - - return source; -} - -},{"../const":46,"../ticker":121,"../utils":125,"../utils/determineCrossOrigin":124,"./BaseTexture":112}],119:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _settings = require('../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _const = require('../const'); - -var _TickerListener = require('./TickerListener'); - -var _TickerListener2 = _interopRequireDefault(_TickerListener); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * A Ticker class that runs an update loop that other objects listen to. - * This class is composed around listeners - * meant for execution on the next requested animation frame. - * Animation frames are requested only when necessary, - * e.g. When the ticker is started and the emitter has listeners. - * - * @class - * @memberof PIXI.ticker - */ -var Ticker = function () { - /** - * - */ - function Ticker() { - var _this = this; - - _classCallCheck(this, Ticker); - - /** - * The first listener. All new listeners added are chained on this. - * @private - * @type {TickerListener} - */ - this._head = new _TickerListener2.default(null, null, Infinity); - - /** - * Internal current frame request ID - * @private - */ - this._requestId = null; - - /** - * Internal value managed by minFPS property setter and getter. - * This is the maximum allowed milliseconds between updates. - * @private - */ - this._maxElapsedMS = 100; - - /** - * Whether or not this ticker should invoke the method - * {@link PIXI.ticker.Ticker#start} automatically - * when a listener is added. - * - * @member {boolean} - * @default false - */ - this.autoStart = false; - - /** - * Scalar time value from last frame to this frame. - * This value is capped by setting {@link PIXI.ticker.Ticker#minFPS} - * and is scaled with {@link PIXI.ticker.Ticker#speed}. - * **Note:** The cap may be exceeded by scaling. - * - * @member {number} - * @default 1 - */ - this.deltaTime = 1; - - /** - * Time elapsed in milliseconds from last frame to this frame. - * Opposed to what the scalar {@link PIXI.ticker.Ticker#deltaTime} - * is based, this value is neither capped nor scaled. - * If the platform supports DOMHighResTimeStamp, - * this value will have a precision of 1 µs. - * Defaults to target frame time - * - * @member {number} - * @default 16.66 - */ - this.elapsedMS = 1 / _settings2.default.TARGET_FPMS; - - /** - * The last time {@link PIXI.ticker.Ticker#update} was invoked. - * This value is also reset internally outside of invoking - * update, but only when a new animation frame is requested. - * If the platform supports DOMHighResTimeStamp, - * this value will have a precision of 1 µs. - * - * @member {number} - * @default -1 - */ - this.lastTime = -1; - - /** - * Factor of current {@link PIXI.ticker.Ticker#deltaTime}. - * @example - * // Scales ticker.deltaTime to what would be - * // the equivalent of approximately 120 FPS - * ticker.speed = 2; - * - * @member {number} - * @default 1 - */ - this.speed = 1; - - /** - * Whether or not this ticker has been started. - * `true` if {@link PIXI.ticker.Ticker#start} has been called. - * `false` if {@link PIXI.ticker.Ticker#stop} has been called. - * While `false`, this value may change to `true` in the - * event of {@link PIXI.ticker.Ticker#autoStart} being `true` - * and a listener is added. - * - * @member {boolean} - * @default false - */ - this.started = false; - - /** - * Internal tick method bound to ticker instance. - * This is because in early 2015, Function.bind - * is still 60% slower in high performance scenarios. - * Also separating frame requests from update method - * so listeners may be called at any time and with - * any animation API, just invoke ticker.update(time). - * - * @private - * @param {number} time - Time since last tick. - */ - this._tick = function (time) { - _this._requestId = null; - - if (_this.started) { - // Invoke listeners now - _this.update(time); - // Listener side effects may have modified ticker state. - if (_this.started && _this._requestId === null && _this._head.next) { - _this._requestId = requestAnimationFrame(_this._tick); - } - } - }; - } - - /** - * Conditionally requests a new animation frame. - * If a frame has not already been requested, and if the internal - * emitter has listeners, a new frame is requested. - * - * @private - */ - - - Ticker.prototype._requestIfNeeded = function _requestIfNeeded() { - if (this._requestId === null && this._head.next) { - // ensure callbacks get correct delta - this.lastTime = performance.now(); - this._requestId = requestAnimationFrame(this._tick); - } - }; - - /** - * Conditionally cancels a pending animation frame. - * - * @private - */ - - - Ticker.prototype._cancelIfNeeded = function _cancelIfNeeded() { - if (this._requestId !== null) { - cancelAnimationFrame(this._requestId); - this._requestId = null; - } - }; - - /** - * Conditionally requests a new animation frame. - * If the ticker has been started it checks if a frame has not already - * been requested, and if the internal emitter has listeners. If these - * conditions are met, a new frame is requested. If the ticker has not - * been started, but autoStart is `true`, then the ticker starts now, - * and continues with the previous conditions to request a new frame. - * - * @private - */ - - - Ticker.prototype._startIfPossible = function _startIfPossible() { - if (this.started) { - this._requestIfNeeded(); - } else if (this.autoStart) { - this.start(); - } - }; - - /** - * Register a handler for tick events. Calls continuously unless - * it is removed or the ticker is stopped. - * - * @param {Function} fn - The listener function to be added for updates - * @param {Function} [context] - The listener context - * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting - * @returns {PIXI.ticker.Ticker} This instance of a ticker - */ - - - Ticker.prototype.add = function add(fn, context) { - var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _const.UPDATE_PRIORITY.NORMAL; - - return this._addListener(new _TickerListener2.default(fn, context, priority)); - }; - - /** - * Add a handler for the tick event which is only execute once. - * - * @param {Function} fn - The listener function to be added for one update - * @param {Function} [context] - The listener context - * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting - * @returns {PIXI.ticker.Ticker} This instance of a ticker - */ - - - Ticker.prototype.addOnce = function addOnce(fn, context) { - var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _const.UPDATE_PRIORITY.NORMAL; - - return this._addListener(new _TickerListener2.default(fn, context, priority, true)); - }; - - /** - * Internally adds the event handler so that it can be sorted by priority. - * Priority allows certain handler (user, AnimatedSprite, Interaction) to be run - * before the rendering. - * - * @private - * @param {TickerListener} listener - Current listener being added. - * @returns {PIXI.ticker.Ticker} This instance of a ticker - */ - - - Ticker.prototype._addListener = function _addListener(listener) { - // For attaching to head - var current = this._head.next; - var previous = this._head; - - // Add the first item - if (!current) { - listener.connect(previous); - } else { - // Go from highest to lowest priority - while (current) { - if (listener.priority > current.priority) { - listener.connect(previous); - break; - } - previous = current; - current = current.next; - } - - // Not yet connected - if (!listener.previous) { - listener.connect(previous); - } - } - - this._startIfPossible(); - - return this; - }; - - /** - * Removes any handlers matching the function and context parameters. - * If no handlers are left after removing, then it cancels the animation frame. - * - * @param {Function} fn - The listener function to be removed - * @param {Function} [context] - The listener context to be removed - * @returns {PIXI.ticker.Ticker} This instance of a ticker - */ - - - Ticker.prototype.remove = function remove(fn, context) { - var listener = this._head.next; - - while (listener) { - // We found a match, lets remove it - // no break to delete all possible matches - // incase a listener was added 2+ times - if (listener.match(fn, context)) { - listener = listener.destroy(); - } else { - listener = listener.next; - } - } - - if (!this._head.next) { - this._cancelIfNeeded(); - } - - return this; - }; - - /** - * Starts the ticker. If the ticker has listeners - * a new animation frame is requested at this point. - */ - - - Ticker.prototype.start = function start() { - if (!this.started) { - this.started = true; - this._requestIfNeeded(); - } - }; - - /** - * Stops the ticker. If the ticker has requested - * an animation frame it is canceled at this point. - */ - - - Ticker.prototype.stop = function stop() { - if (this.started) { - this.started = false; - this._cancelIfNeeded(); - } - }; - - /** - * Destroy the ticker and don't use after this. Calling - * this method removes all references to internal events. - */ - - - Ticker.prototype.destroy = function destroy() { - this.stop(); - - var listener = this._head.next; - - while (listener) { - listener = listener.destroy(true); - } - - this._head.destroy(); - this._head = null; - }; - - /** - * Triggers an update. An update entails setting the - * current {@link PIXI.ticker.Ticker#elapsedMS}, - * the current {@link PIXI.ticker.Ticker#deltaTime}, - * invoking all listeners with current deltaTime, - * and then finally setting {@link PIXI.ticker.Ticker#lastTime} - * with the value of currentTime that was provided. - * This method will be called automatically by animation - * frame callbacks if the ticker instance has been started - * and listeners are added. - * - * @param {number} [currentTime=performance.now()] - the current time of execution - */ - - - Ticker.prototype.update = function update() { - var currentTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : performance.now(); - - var elapsedMS = void 0; - - // If the difference in time is zero or negative, we ignore most of the work done here. - // If there is no valid difference, then should be no reason to let anyone know about it. - // A zero delta, is exactly that, nothing should update. - // - // The difference in time can be negative, and no this does not mean time traveling. - // This can be the result of a race condition between when an animation frame is requested - // on the current JavaScript engine event loop, and when the ticker's start method is invoked - // (which invokes the internal _requestIfNeeded method). If a frame is requested before - // _requestIfNeeded is invoked, then the callback for the animation frame the ticker requests, - // can receive a time argument that can be less than the lastTime value that was set within - // _requestIfNeeded. This difference is in microseconds, but this is enough to cause problems. - // - // This check covers this browser engine timing issue, as well as if consumers pass an invalid - // currentTime value. This may happen if consumers opt-out of the autoStart, and update themselves. - - if (currentTime > this.lastTime) { - // Save uncapped elapsedMS for measurement - elapsedMS = this.elapsedMS = currentTime - this.lastTime; - - // cap the milliseconds elapsed used for deltaTime - if (elapsedMS > this._maxElapsedMS) { - elapsedMS = this._maxElapsedMS; - } - - this.deltaTime = elapsedMS * _settings2.default.TARGET_FPMS * this.speed; - - // Cache a local reference, in-case ticker is destroyed - // during the emit, we can still check for head.next - var head = this._head; - - // Invoke listeners added to internal emitter - var listener = head.next; - - while (listener) { - listener = listener.emit(this.deltaTime); - } - - if (!head.next) { - this._cancelIfNeeded(); - } - } else { - this.deltaTime = this.elapsedMS = 0; - } - - this.lastTime = currentTime; - }; - - /** - * The frames per second at which this ticker is running. - * The default is approximately 60 in most modern browsers. - * **Note:** This does not factor in the value of - * {@link PIXI.ticker.Ticker#speed}, which is specific - * to scaling {@link PIXI.ticker.Ticker#deltaTime}. - * - * @member {number} - * @readonly - */ - - - _createClass(Ticker, [{ - key: 'FPS', - get: function get() { - return 1000 / this.elapsedMS; - } - - /** - * Manages the maximum amount of milliseconds allowed to - * elapse between invoking {@link PIXI.ticker.Ticker#update}. - * This value is used to cap {@link PIXI.ticker.Ticker#deltaTime}, - * but does not effect the measured value of {@link PIXI.ticker.Ticker#FPS}. - * When setting this property it is clamped to a value between - * `0` and `PIXI.settings.TARGET_FPMS * 1000`. - * - * @member {number} - * @default 10 - */ - - }, { - key: 'minFPS', - get: function get() { - return 1000 / this._maxElapsedMS; - }, - set: function set(fps) // eslint-disable-line require-jsdoc - { - // Clamp: 0 to TARGET_FPMS - var minFPMS = Math.min(Math.max(0, fps) / 1000, _settings2.default.TARGET_FPMS); - - this._maxElapsedMS = 1 / minFPMS; - } - }]); - - return Ticker; -}(); - -exports.default = Ticker; - -},{"../const":46,"../settings":101,"./TickerListener":120}],120:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Internal class for handling the priority sorting of ticker handlers. - * - * @private - * @class - * @memberof PIXI.ticker - */ -var TickerListener = function () { - /** - * Constructor - * - * @param {Function} fn - The listener function to be added for one update - * @param {Function} [context=null] - The listener context - * @param {number} [priority=0] - The priority for emitting - * @param {boolean} [once=false] - If the handler should fire once - */ - function TickerListener(fn) { - var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - - _classCallCheck(this, TickerListener); - - /** - * The handler function to execute. - * @member {Function} - */ - this.fn = fn; - - /** - * The calling to execute. - * @member {Function} - */ - this.context = context; - - /** - * The current priority. - * @member {number} - */ - this.priority = priority; - - /** - * If this should only execute once. - * @member {boolean} - */ - this.once = once; - - /** - * The next item in chain. - * @member {TickerListener} - */ - this.next = null; - - /** - * The previous item in chain. - * @member {TickerListener} - */ - this.previous = null; - - /** - * `true` if this listener has been destroyed already. - * @member {boolean} - * @private - */ - this._destroyed = false; - } - - /** - * Simple compare function to figure out if a function and context match. - * - * @param {Function} fn - The listener function to be added for one update - * @param {Function} context - The listener context - * @return {boolean} `true` if the listener match the arguments - */ - - - TickerListener.prototype.match = function match(fn, context) { - context = context || null; - - return this.fn === fn && this.context === context; - }; - - /** - * Emit by calling the current function. - * @param {number} deltaTime - time since the last emit. - * @return {TickerListener} Next ticker - */ - - - TickerListener.prototype.emit = function emit(deltaTime) { - if (this.fn) { - if (this.context) { - this.fn.call(this.context, deltaTime); - } else { - this.fn(deltaTime); - } - } - - var redirect = this.next; - - if (this.once) { - this.destroy(true); - } - - // Soft-destroying should remove - // the next reference - if (this._destroyed) { - this.next = null; - } - - return redirect; - }; - - /** - * Connect to the list. - * @param {TickerListener} previous - Input node, previous listener - */ - - - TickerListener.prototype.connect = function connect(previous) { - this.previous = previous; - if (previous.next) { - previous.next.previous = this; - } - this.next = previous.next; - previous.next = this; - }; - - /** - * Destroy and don't use after this. - * @param {boolean} [hard = false] `true` to remove the `next` reference, this - * is considered a hard destroy. Soft destroy maintains the next reference. - * @return {TickerListener} The listener to redirect while emitting or removing. - */ - - - TickerListener.prototype.destroy = function destroy() { - var hard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - - this._destroyed = true; - this.fn = null; - this.context = null; - - // Disconnect, hook up next and previous - if (this.previous) { - this.previous.next = this.next; - } - - if (this.next) { - this.next.previous = this.previous; - } - - // Redirect to the next item - var redirect = this.next; - - // Remove references - this.next = hard ? null : redirect; - this.previous = null; - - return redirect; - }; - - return TickerListener; -}(); - -exports.default = TickerListener; - -},{}],121:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.Ticker = exports.shared = undefined; - -var _Ticker = require('./Ticker'); - -var _Ticker2 = _interopRequireDefault(_Ticker); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * The shared ticker instance used by {@link PIXI.extras.AnimatedSprite}. - * and by {@link PIXI.interaction.InteractionManager}. - * The property {@link PIXI.ticker.Ticker#autoStart} is set to `true` - * for this instance. Please follow the examples for usage, including - * how to opt-out of auto-starting the shared ticker. - * - * @example - * let ticker = PIXI.ticker.shared; - * // Set this to prevent starting this ticker when listeners are added. - * // By default this is true only for the PIXI.ticker.shared instance. - * ticker.autoStart = false; - * // FYI, call this to ensure the ticker is stopped. It should be stopped - * // if you have not attempted to render anything yet. - * ticker.stop(); - * // Call this when you are ready for a running shared ticker. - * ticker.start(); - * - * @example - * // You may use the shared ticker to render... - * let renderer = PIXI.autoDetectRenderer(800, 600); - * let stage = new PIXI.Container(); - * let interactionManager = PIXI.interaction.InteractionManager(renderer); - * document.body.appendChild(renderer.view); - * ticker.add(function (time) { - * renderer.render(stage); - * }); - * - * @example - * // Or you can just update it manually. - * ticker.autoStart = false; - * ticker.stop(); - * function animate(time) { - * ticker.update(time); - * renderer.render(stage); - * requestAnimationFrame(animate); - * } - * animate(performance.now()); - * - * @type {PIXI.ticker.Ticker} - * @memberof PIXI.ticker - */ -var shared = new _Ticker2.default(); - -shared.autoStart = true; -shared.destroy = function () { - // protect destroying shared ticker - // this is used by other internal systems - // like AnimatedSprite and InteractionManager -}; - -/** - * This namespace contains an API for interacting with PIXI's internal global update loop. - * - * This ticker is used for rendering, {@link PIXI.extras.AnimatedSprite AnimatedSprite}, - * {@link PIXI.interaction.InteractionManager InteractionManager} and many other time-based PIXI systems. - * @example - * const ticker = new PIXI.ticker.Ticker(); - * ticker.stop(); - * ticker.add((deltaTime) => { - * // do something every frame - * }); - * ticker.start(); - * @namespace PIXI.ticker - */ -exports.shared = shared; -exports.Ticker = _Ticker2.default; - -},{"./Ticker":119}],122:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; -exports.default = canUploadSameBuffer; -function canUploadSameBuffer() { - // Uploading the same buffer multiple times in a single frame can cause perf issues. - // Apparent on IOS so only check for that at the moment - // this check may become more complex if this issue pops up elsewhere. - var ios = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); - - return !ios; -} - -},{}],123:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; -exports.default = createIndicesForQuads; -/** - * Generic Mask Stack data structure - * - * @memberof PIXI - * @function createIndicesForQuads - * @private - * @param {number} size - Number of quads - * @return {Uint16Array} indices - */ -function createIndicesForQuads(size) { - // the total number of indices in our array, there are 6 points per quad. - - var totalIndices = size * 6; - - var indices = new Uint16Array(totalIndices); - - // fill the indices with the quads to draw - for (var i = 0, j = 0; i < totalIndices; i += 6, j += 4) { - indices[i + 0] = j + 0; - indices[i + 1] = j + 1; - indices[i + 2] = j + 2; - indices[i + 3] = j + 0; - indices[i + 4] = j + 2; - indices[i + 5] = j + 3; - } - - return indices; -} - -},{}],124:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = determineCrossOrigin; - -var _url2 = require('url'); - -var _url3 = _interopRequireDefault(_url2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var tempAnchor = void 0; - -/** - * Sets the `crossOrigin` property for this resource based on if the url - * for this resource is cross-origin. If crossOrigin was manually set, this - * function does nothing. - * Nipped from the resource loader! - * - * @ignore - * @param {string} url - The url to test. - * @param {object} [loc=window.location] - The location object to test against. - * @return {string} The crossOrigin value to use (or empty string for none). - */ -function determineCrossOrigin(url) { - var loc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location; - - // data: and javascript: urls are considered same-origin - if (url.indexOf('data:') === 0) { - return ''; - } - - // default is window.location - loc = loc || window.location; - - if (!tempAnchor) { - tempAnchor = document.createElement('a'); - } - - // let the browser determine the full href for the url of this resource and then - // parse with the node url lib, we can't use the properties of the anchor element - // because they don't work in IE9 :( - tempAnchor.href = url; - url = _url3.default.parse(tempAnchor.href); - - var samePort = !url.port && loc.port === '' || url.port === loc.port; - - // if cross origin - if (url.hostname !== loc.hostname || !samePort || url.protocol !== loc.protocol) { - return 'anonymous'; - } - - return ''; -} - -},{"url":38}],125:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.premultiplyBlendMode = exports.BaseTextureCache = exports.TextureCache = exports.earcut = exports.mixins = exports.pluginTarget = exports.EventEmitter = exports.removeItems = exports.isMobile = undefined; -exports.uid = uid; -exports.hex2rgb = hex2rgb; -exports.hex2string = hex2string; -exports.rgb2hex = rgb2hex; -exports.getResolutionOfUrl = getResolutionOfUrl; -exports.decomposeDataUri = decomposeDataUri; -exports.getUrlFileExtension = getUrlFileExtension; -exports.getSvgSize = getSvgSize; -exports.skipHello = skipHello; -exports.sayHello = sayHello; -exports.isWebGLSupported = isWebGLSupported; -exports.sign = sign; -exports.destroyTextureCache = destroyTextureCache; -exports.clearTextureCache = clearTextureCache; -exports.correctBlendMode = correctBlendMode; -exports.premultiplyTint = premultiplyTint; -exports.premultiplyRgba = premultiplyRgba; -exports.premultiplyTintToRgba = premultiplyTintToRgba; - -var _const = require('../const'); - -var _settings = require('../settings'); - -var _settings2 = _interopRequireDefault(_settings); - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -var _pluginTarget = require('./pluginTarget'); - -var _pluginTarget2 = _interopRequireDefault(_pluginTarget); - -var _mixin = require('./mixin'); - -var mixins = _interopRequireWildcard(_mixin); - -var _ismobilejs = require('ismobilejs'); - -var isMobile = _interopRequireWildcard(_ismobilejs); - -var _removeArrayItems = require('remove-array-items'); - -var _removeArrayItems2 = _interopRequireDefault(_removeArrayItems); - -var _mapPremultipliedBlendModes = require('./mapPremultipliedBlendModes'); - -var _mapPremultipliedBlendModes2 = _interopRequireDefault(_mapPremultipliedBlendModes); - -var _earcut = require('earcut'); - -var _earcut2 = _interopRequireDefault(_earcut); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var nextUid = 0; -var saidHello = false; - -/** - * Generalized convenience utilities for PIXI. - * @example - * // Extend PIXI's internal Event Emitter. - * class MyEmitter extends PIXI.utils.EventEmitter { - * constructor() { - * super(); - * console.log("Emitter created!"); - * } - * } - * - * // Get info on current device - * console.log(PIXI.utils.isMobile); - * - * // Convert hex color to string - * console.log(PIXI.utils.hex2string(0xff00ff)); // returns: "#ff00ff" - * @namespace PIXI.utils - */ -exports.isMobile = isMobile; -exports.removeItems = _removeArrayItems2.default; -exports.EventEmitter = _eventemitter2.default; -exports.pluginTarget = _pluginTarget2.default; -exports.mixins = mixins; -exports.earcut = _earcut2.default; - -/** - * Gets the next unique identifier - * - * @memberof PIXI.utils - * @function uid - * @return {number} The next unique identifier to use. - */ - -function uid() { - return ++nextUid; -} - -/** - * Converts a hex color number to an [R, G, B] array - * - * @memberof PIXI.utils - * @function hex2rgb - * @param {number} hex - The number to convert - * @param {number[]} [out=[]] If supplied, this array will be used rather than returning a new one - * @return {number[]} An array representing the [R, G, B] of the color. - */ -function hex2rgb(hex, out) { - out = out || []; - - out[0] = (hex >> 16 & 0xFF) / 255; - out[1] = (hex >> 8 & 0xFF) / 255; - out[2] = (hex & 0xFF) / 255; - - return out; -} - -/** - * Converts a hex color number to a string. - * - * @memberof PIXI.utils - * @function hex2string - * @param {number} hex - Number in hex - * @return {string} The string color. - */ -function hex2string(hex) { - hex = hex.toString(16); - hex = '000000'.substr(0, 6 - hex.length) + hex; - - return '#' + hex; -} - -/** - * Converts a color as an [R, G, B] array to a hex number - * - * @memberof PIXI.utils - * @function rgb2hex - * @param {number[]} rgb - rgb array - * @return {number} The color number - */ -function rgb2hex(rgb) { - return (rgb[0] * 255 << 16) + (rgb[1] * 255 << 8) + (rgb[2] * 255 | 0); -} - -/** - * get the resolution / device pixel ratio of an asset by looking for the prefix - * used by spritesheets and image urls - * - * @memberof PIXI.utils - * @function getResolutionOfUrl - * @param {string} url - the image path - * @param {number} [defaultValue=1] - the defaultValue if no filename prefix is set. - * @return {number} resolution / device pixel ratio of an asset - */ -function getResolutionOfUrl(url, defaultValue) { - var resolution = _settings2.default.RETINA_PREFIX.exec(url); - - if (resolution) { - return parseFloat(resolution[1]); - } - - return defaultValue !== undefined ? defaultValue : 1; -} - -/** - * Typedef for decomposeDataUri return object. - * - * @typedef {object} PIXI.utils~DecomposedDataUri - * @property {mediaType} Media type, eg. `image` - * @property {subType} Sub type, eg. `png` - * @property {encoding} Data encoding, eg. `base64` - * @property {data} The actual data - */ - -/** - * Split a data URI into components. Returns undefined if - * parameter `dataUri` is not a valid data URI. - * - * @memberof PIXI.utils - * @function decomposeDataUri - * @param {string} dataUri - the data URI to check - * @return {PIXI.utils~DecomposedDataUri|undefined} The decomposed data uri or undefined - */ -function decomposeDataUri(dataUri) { - var dataUriMatch = _const.DATA_URI.exec(dataUri); - - if (dataUriMatch) { - return { - mediaType: dataUriMatch[1] ? dataUriMatch[1].toLowerCase() : undefined, - subType: dataUriMatch[2] ? dataUriMatch[2].toLowerCase() : undefined, - charset: dataUriMatch[3] ? dataUriMatch[3].toLowerCase() : undefined, - encoding: dataUriMatch[4] ? dataUriMatch[4].toLowerCase() : undefined, - data: dataUriMatch[5] - }; - } - - return undefined; -} - -/** - * Get type of the image by regexp for extension. Returns undefined for unknown extensions. - * - * @memberof PIXI.utils - * @function getUrlFileExtension - * @param {string} url - the image path - * @return {string|undefined} image extension - */ -function getUrlFileExtension(url) { - var extension = _const.URL_FILE_EXTENSION.exec(url); - - if (extension) { - return extension[1].toLowerCase(); - } - - return undefined; -} - -/** - * Typedef for Size object. - * - * @typedef {object} PIXI.utils~Size - * @property {width} Width component - * @property {height} Height component - */ - -/** - * Get size from an svg string using regexp. - * - * @memberof PIXI.utils - * @function getSvgSize - * @param {string} svgString - a serialized svg element - * @return {PIXI.utils~Size|undefined} image extension - */ -function getSvgSize(svgString) { - var sizeMatch = _const.SVG_SIZE.exec(svgString); - var size = {}; - - if (sizeMatch) { - size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[3])); - size[sizeMatch[5]] = Math.round(parseFloat(sizeMatch[7])); - } - - return size; -} - -/** - * Skips the hello message of renderers that are created after this is run. - * - * @function skipHello - * @memberof PIXI.utils - */ -function skipHello() { - saidHello = true; -} - -/** - * Logs out the version and renderer information for this running instance of PIXI. - * If you don't want to see this message you can run `PIXI.utils.skipHello()` before - * creating your renderer. Keep in mind that doing that will forever makes you a jerk face. - * - * @static - * @function sayHello - * @memberof PIXI.utils - * @param {string} type - The string renderer type to log. - */ -function sayHello(type) { - if (saidHello) { - return; - } - - if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) { - var args = ['\n %c %c %c PixiJS ' + _const.VERSION + ' - \u2730 ' + type + ' \u2730 %c %c http://www.pixijs.com/ %c %c \u2665%c\u2665%c\u2665 \n\n', 'background: #ff66a5; padding:5px 0;', 'background: #ff66a5; padding:5px 0;', 'color: #ff66a5; background: #030307; padding:5px 0;', 'background: #ff66a5; padding:5px 0;', 'background: #ffc3dc; padding:5px 0;', 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;']; - - window.console.log.apply(console, args); - } else if (window.console) { - window.console.log('PixiJS ' + _const.VERSION + ' - ' + type + ' - http://www.pixijs.com/'); - } - - saidHello = true; -} - -/** - * Helper for checking for webgl support - * - * @memberof PIXI.utils - * @function isWebGLSupported - * @return {boolean} is webgl supported - */ -function isWebGLSupported() { - var contextOptions = { stencil: true, failIfMajorPerformanceCaveat: true }; - - try { - if (!window.WebGLRenderingContext) { - return false; - } - - var canvas = document.createElement('canvas'); - var gl = canvas.getContext('webgl', contextOptions) || canvas.getContext('experimental-webgl', contextOptions); - - var success = !!(gl && gl.getContextAttributes().stencil); - - if (gl) { - var loseContext = gl.getExtension('WEBGL_lose_context'); - - if (loseContext) { - loseContext.loseContext(); - } - } - - gl = null; - - return success; - } catch (e) { - return false; - } -} - -/** - * Returns sign of number - * - * @memberof PIXI.utils - * @function sign - * @param {number} n - the number to check the sign of - * @returns {number} 0 if `n` is 0, -1 if `n` is negative, 1 if `n` is positive - */ -function sign(n) { - if (n === 0) return 0; - - return n < 0 ? -1 : 1; -} - -/** - * @todo Describe property usage - * - * @memberof PIXI.utils - * @private - */ -var TextureCache = exports.TextureCache = Object.create(null); - -/** - * @todo Describe property usage - * - * @memberof PIXI.utils - * @private - */ -var BaseTextureCache = exports.BaseTextureCache = Object.create(null); - -/** - * Destroys all texture in the cache - * - * @memberof PIXI.utils - * @function destroyTextureCache - */ -function destroyTextureCache() { - var key = void 0; - - for (key in TextureCache) { - TextureCache[key].destroy(); - } - for (key in BaseTextureCache) { - BaseTextureCache[key].destroy(); - } -} - -/** - * Removes all textures from cache, but does not destroy them - * - * @memberof PIXI.utils - * @function clearTextureCache - */ -function clearTextureCache() { - var key = void 0; - - for (key in TextureCache) { - delete TextureCache[key]; - } - for (key in BaseTextureCache) { - delete BaseTextureCache[key]; - } -} - -/** - * maps premultiply flag and blendMode to adjusted blendMode - * @memberof PIXI.utils - * @const premultiplyBlendMode - * @type {Array} - */ -var premultiplyBlendMode = exports.premultiplyBlendMode = (0, _mapPremultipliedBlendModes2.default)(); - -/** - * changes blendMode according to texture format - * - * @memberof PIXI.utils - * @function correctBlendMode - * @param {number} blendMode supposed blend mode - * @param {boolean} premultiplied whether source is premultiplied - * @returns {number} true blend mode for this texture - */ -function correctBlendMode(blendMode, premultiplied) { - return premultiplyBlendMode[premultiplied ? 1 : 0][blendMode]; -} - -/** - * premultiplies tint - * - * @memberof PIXI.utils - * @param {number} tint integet RGB - * @param {number} alpha floating point alpha (0.0-1.0) - * @returns {number} tint multiplied by alpha - */ -function premultiplyTint(tint, alpha) { - if (alpha === 1.0) { - return (alpha * 255 << 24) + tint; - } - if (alpha === 0.0) { - return 0; - } - var R = tint >> 16 & 0xFF; - var G = tint >> 8 & 0xFF; - var B = tint & 0xFF; - - R = R * alpha + 0.5 | 0; - G = G * alpha + 0.5 | 0; - B = B * alpha + 0.5 | 0; - - return (alpha * 255 << 24) + (R << 16) + (G << 8) + B; -} - -/** - * combines rgb and alpha to out array - * - * @memberof PIXI.utils - * @param {Float32Array|number[]} rgb input rgb - * @param {number} alpha alpha param - * @param {Float32Array} [out] output - * @param {boolean} [premultiply=true] do premultiply it - * @returns {Float32Array} vec4 rgba - */ -function premultiplyRgba(rgb, alpha, out, premultiply) { - out = out || new Float32Array(4); - if (premultiply || premultiply === undefined) { - out[0] = rgb[0] * alpha; - out[1] = rgb[1] * alpha; - out[2] = rgb[2] * alpha; - } else { - out[0] = rgb[0]; - out[1] = rgb[1]; - out[2] = rgb[2]; - } - out[3] = alpha; - - return out; -} - -/** - * converts integer tint and float alpha to vec4 form, premultiplies by default - * - * @memberof PIXI.utils - * @param {number} tint input tint - * @param {number} alpha alpha param - * @param {Float32Array} [out] output - * @param {boolean} [premultiply=true] do premultiply it - * @returns {Float32Array} vec4 rgba - */ -function premultiplyTintToRgba(tint, alpha, out, premultiply) { - out = out || new Float32Array(4); - out[0] = (tint >> 16 & 0xFF) / 255.0; - out[1] = (tint >> 8 & 0xFF) / 255.0; - out[2] = (tint & 0xFF) / 255.0; - if (premultiply || premultiply === undefined) { - out[0] *= alpha; - out[1] *= alpha; - out[2] *= alpha; - } - out[3] = alpha; - - return out; -} - -},{"../const":46,"../settings":101,"./mapPremultipliedBlendModes":126,"./mixin":128,"./pluginTarget":129,"earcut":2,"eventemitter3":3,"ismobilejs":4,"remove-array-items":31}],126:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = mapPremultipliedBlendModes; - -var _const = require('../const'); - -/** - * Corrects PixiJS blend, takes premultiplied alpha into account - * - * @memberof PIXI - * @function mapPremultipliedBlendModes - * @private - * @param {Array} [array] - The array to output into. - * @return {Array} Mapped modes. - */ - -function mapPremultipliedBlendModes() { - var pm = []; - var npm = []; - - for (var i = 0; i < 32; i++) { - pm[i] = i; - npm[i] = i; - } - - pm[_const.BLEND_MODES.NORMAL_NPM] = _const.BLEND_MODES.NORMAL; - pm[_const.BLEND_MODES.ADD_NPM] = _const.BLEND_MODES.ADD; - pm[_const.BLEND_MODES.SCREEN_NPM] = _const.BLEND_MODES.SCREEN; - - npm[_const.BLEND_MODES.NORMAL] = _const.BLEND_MODES.NORMAL_NPM; - npm[_const.BLEND_MODES.ADD] = _const.BLEND_MODES.ADD_NPM; - npm[_const.BLEND_MODES.SCREEN] = _const.BLEND_MODES.SCREEN_NPM; - - var array = []; - - array.push(npm); - array.push(pm); - - return array; -} - -},{"../const":46}],127:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = maxRecommendedTextures; - -var _ismobilejs = require('ismobilejs'); - -var _ismobilejs2 = _interopRequireDefault(_ismobilejs); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function maxRecommendedTextures(max) { - if (_ismobilejs2.default.tablet || _ismobilejs2.default.phone) { - // check if the res is iphone 6 or higher.. - return 4; - } - - // desktop should be ok - return max; -} - -},{"ismobilejs":4}],128:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; -exports.mixin = mixin; -exports.delayMixin = delayMixin; -exports.performMixins = performMixins; -/** - * Mixes all enumerable properties and methods from a source object to a target object. - * - * @memberof PIXI.utils.mixins - * @function mixin - * @param {object} target The prototype or instance that properties and methods should be added to. - * @param {object} source The source of properties and methods to mix in. - */ -function mixin(target, source) { - if (!target || !source) return; - // in ES8/ES2017, this would be really easy: - // Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - - // get all the enumerable property keys - var keys = Object.keys(source); - - // loop through properties - for (var i = 0; i < keys.length; ++i) { - var propertyName = keys[i]; - - // Set the property using the property descriptor - this works for accessors and normal value properties - Object.defineProperty(target, propertyName, Object.getOwnPropertyDescriptor(source, propertyName)); - } -} - -var mixins = []; - -/** - * Queues a mixin to be handled towards the end of the initialization of PIXI, so that deprecation - * can take effect. - * - * @memberof PIXI.utils.mixins - * @function delayMixin - * @private - * @param {object} target The prototype or instance that properties and methods should be added to. - * @param {object} source The source of properties and methods to mix in. - */ -function delayMixin(target, source) { - mixins.push(target, source); -} - -/** - * Handles all mixins queued via delayMixin(). - * - * @memberof PIXI.utils.mixins - * @function performMixins - * @private - */ -function performMixins() { - for (var i = 0; i < mixins.length; i += 2) { - mixin(mixins[i], mixins[i + 1]); - } - mixins.length = 0; -} - -},{}],129:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; -/** - * Mixins functionality to make an object have "plugins". - * - * @example - * function MyObject() {} - * - * pluginTarget.mixin(MyObject); - * - * @mixin - * @memberof PIXI.utils - * @param {object} obj - The object to mix into. - */ -function pluginTarget(obj) { - obj.__plugins = {}; - - /** - * Adds a plugin to an object - * - * @param {string} pluginName - The events that should be listed. - * @param {Function} ctor - The constructor function for the plugin. - */ - obj.registerPlugin = function registerPlugin(pluginName, ctor) { - obj.__plugins[pluginName] = ctor; - }; - - /** - * Instantiates all the plugins of this object - * - */ - obj.prototype.initPlugins = function initPlugins() { - this.plugins = this.plugins || {}; - - for (var o in obj.__plugins) { - this.plugins[o] = new obj.__plugins[o](this); - } - }; - - /** - * Removes all the plugins of this object - * - */ - obj.prototype.destroyPlugins = function destroyPlugins() { - for (var o in this.plugins) { - this.plugins[o].destroy(); - this.plugins[o] = null; - } - - this.plugins = null; - }; -} - -exports.default = { - /** - * Mixes in the properties of the pluginTarget into another object - * - * @param {object} obj - The obj to mix into - */ - mixin: function mixin(obj) { - pluginTarget(obj); - } -}; - -},{}],130:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = trimCanvas; -/** - * Trim transparent borders from a canvas - * - * @memberof PIXI - * @function trimCanvas - * @private - * @param {HTMLCanvasElement} canvas - the canvas to trim - * @returns {object} Trim data - */ -function trimCanvas(canvas) { - // https://gist.github.com/remy/784508 - - var width = canvas.width; - var height = canvas.height; - - var context = canvas.getContext('2d'); - var imageData = context.getImageData(0, 0, width, height); - var pixels = imageData.data; - var len = pixels.length; - - var bound = { - top: null, - left: null, - right: null, - bottom: null - }; - var data = null; - var i = void 0; - var x = void 0; - var y = void 0; - - for (i = 0; i < len; i += 4) { - if (pixels[i + 3] !== 0) { - x = i / 4 % width; - y = ~~(i / 4 / width); - - if (bound.top === null) { - bound.top = y; - } - - if (bound.left === null) { - bound.left = x; - } else if (x < bound.left) { - bound.left = x; - } - - if (bound.right === null) { - bound.right = x + 1; - } else if (bound.right < x) { - bound.right = x + 1; - } - - if (bound.bottom === null) { - bound.bottom = y; - } else if (bound.bottom < y) { - bound.bottom = y; - } - } - } - - if (bound.top !== null) { - width = bound.right - bound.left; - height = bound.bottom - bound.top + 1; - data = context.getImageData(bound.left, bound.top, width, height); - } - - return { - height: height, - width: width, - data: data - }; -} - -},{}],131:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = deprecation; -// provide method to give a stack track for warnings -// useful for tracking-down where deprecated methods/properties/classes -// are being used within the code - -// A map of warning messages already fired -var warnings = {}; - -// provide method to give a stack track for warnings -// useful for tracking-down where deprecated methods/properties/classes -// are being used within the code -function warn(msg) { - // Ignore duplicat - if (warnings[msg]) { - return; - } - - /* eslint-disable no-console */ - var stack = new Error().stack; - - // Handle IE < 10 and Safari < 6 - if (typeof stack === 'undefined') { - console.warn('Deprecation Warning: ', msg); - } else { - // chop off the stack trace which includes pixi.js internal calls - stack = stack.split('\n').splice(3).join('\n'); - - if (console.groupCollapsed) { - console.groupCollapsed('%cDeprecation Warning: %c%s', 'color:#614108;background:#fffbe6', 'font-weight:normal;color:#614108;background:#fffbe6', msg); - console.warn(stack); - console.groupEnd(); - } else { - console.warn('Deprecation Warning: ', msg); - console.warn(stack); - } - } - /* eslint-enable no-console */ - - warnings[msg] = true; -} - -function deprecation(core) { - var mesh = core.mesh, - particles = core.particles, - extras = core.extras, - filters = core.filters, - prepare = core.prepare, - loaders = core.loaders, - interaction = core.interaction; - - - Object.defineProperties(core, { - - /** - * @class - * @private - * @name SpriteBatch - * @memberof PIXI - * @see PIXI.ParticleContainer - * @throws {ReferenceError} SpriteBatch does not exist any more, please use the new ParticleContainer instead. - * @deprecated since version 3.0.0 - */ - SpriteBatch: { - get: function get() { - throw new ReferenceError('SpriteBatch does not exist any more, ' + 'please use the new ParticleContainer instead.'); - } - }, - - /** - * @class - * @private - * @name AssetLoader - * @memberof PIXI - * @see PIXI.loaders.Loader - * @throws {ReferenceError} The loader system was overhauled in PixiJS v3, - * please see the new PIXI.loaders.Loader class. - * @deprecated since version 3.0.0 - */ - AssetLoader: { - get: function get() { - throw new ReferenceError('The loader system was overhauled in PixiJS v3, ' + 'please see the new PIXI.loaders.Loader class.'); - } - }, - - /** - * @class - * @private - * @name Stage - * @memberof PIXI - * @see PIXI.Container - * @deprecated since version 3.0.0 - */ - Stage: { - get: function get() { - warn('You do not need to use a PIXI Stage any more, you can simply render any container.'); - - return core.Container; - } - }, - - /** - * @class - * @private - * @name DisplayObjectContainer - * @memberof PIXI - * @see PIXI.Container - * @deprecated since version 3.0.0 - */ - DisplayObjectContainer: { - get: function get() { - warn('DisplayObjectContainer has been shortened to Container, please use Container from now on.'); - - return core.Container; - } - }, - - /** - * @class - * @private - * @name Strip - * @memberof PIXI - * @see PIXI.mesh.Mesh - * @deprecated since version 3.0.0 - */ - Strip: { - get: function get() { - warn('The Strip class has been renamed to Mesh and moved to mesh.Mesh, please use mesh.Mesh from now on.'); - - return mesh.Mesh; - } - }, - - /** - * @class - * @private - * @name Rope - * @memberof PIXI - * @see PIXI.mesh.Rope - * @deprecated since version 3.0.0 - */ - Rope: { - get: function get() { - warn('The Rope class has been moved to mesh.Rope, please use mesh.Rope from now on.'); - - return mesh.Rope; - } - }, - - /** - * @class - * @private - * @name ParticleContainer - * @memberof PIXI - * @see PIXI.particles.ParticleContainer - * @deprecated since version 4.0.0 - */ - ParticleContainer: { - get: function get() { - warn('The ParticleContainer class has been moved to particles.ParticleContainer, ' + 'please use particles.ParticleContainer from now on.'); - - return particles.ParticleContainer; - } - }, - - /** - * @class - * @private - * @name MovieClip - * @memberof PIXI - * @see PIXI.extras.MovieClip - * @deprecated since version 3.0.0 - */ - MovieClip: { - get: function get() { - warn('The MovieClip class has been moved to extras.AnimatedSprite, please use extras.AnimatedSprite.'); - - return extras.AnimatedSprite; - } - }, - - /** - * @class - * @private - * @name TilingSprite - * @memberof PIXI - * @see PIXI.extras.TilingSprite - * @deprecated since version 3.0.0 - */ - TilingSprite: { - get: function get() { - warn('The TilingSprite class has been moved to extras.TilingSprite, ' + 'please use extras.TilingSprite from now on.'); - - return extras.TilingSprite; - } - }, - - /** - * @class - * @private - * @name BitmapText - * @memberof PIXI - * @see PIXI.extras.BitmapText - * @deprecated since version 3.0.0 - */ - BitmapText: { - get: function get() { - warn('The BitmapText class has been moved to extras.BitmapText, ' + 'please use extras.BitmapText from now on.'); - - return extras.BitmapText; - } - }, - - /** - * @class - * @private - * @name blendModes - * @memberof PIXI - * @see PIXI.BLEND_MODES - * @deprecated since version 3.0.0 - */ - blendModes: { - get: function get() { - warn('The blendModes has been moved to BLEND_MODES, please use BLEND_MODES from now on.'); - - return core.BLEND_MODES; - } - }, - - /** - * @class - * @private - * @name scaleModes - * @memberof PIXI - * @see PIXI.SCALE_MODES - * @deprecated since version 3.0.0 - */ - scaleModes: { - get: function get() { - warn('The scaleModes has been moved to SCALE_MODES, please use SCALE_MODES from now on.'); - - return core.SCALE_MODES; - } - }, - - /** - * @class - * @private - * @name BaseTextureCache - * @memberof PIXI - * @see PIXI.utils.BaseTextureCache - * @deprecated since version 3.0.0 - */ - BaseTextureCache: { - get: function get() { - warn('The BaseTextureCache class has been moved to utils.BaseTextureCache, ' + 'please use utils.BaseTextureCache from now on.'); - - return core.utils.BaseTextureCache; - } - }, - - /** - * @class - * @private - * @name TextureCache - * @memberof PIXI - * @see PIXI.utils.TextureCache - * @deprecated since version 3.0.0 - */ - TextureCache: { - get: function get() { - warn('The TextureCache class has been moved to utils.TextureCache, ' + 'please use utils.TextureCache from now on.'); - - return core.utils.TextureCache; - } - }, - - /** - * @namespace - * @private - * @name math - * @memberof PIXI - * @see PIXI - * @deprecated since version 3.0.6 - */ - math: { - get: function get() { - warn('The math namespace is deprecated, please access members already accessible on PIXI.'); - - return core; - } - }, - - /** - * @class - * @private - * @name PIXI.AbstractFilter - * @see PIXI.Filter - * @deprecated since version 3.0.6 - */ - AbstractFilter: { - get: function get() { - warn('AstractFilter has been renamed to Filter, please use PIXI.Filter'); - - return core.Filter; - } - }, - - /** - * @class - * @private - * @name PIXI.TransformManual - * @see PIXI.TransformBase - * @deprecated since version 4.0.0 - */ - TransformManual: { - get: function get() { - warn('TransformManual has been renamed to TransformBase, please update your pixi-spine'); - - return core.TransformBase; - } - }, - - /** - * @static - * @constant - * @name PIXI.TARGET_FPMS - * @see PIXI.settings.TARGET_FPMS - * @deprecated since version 4.2.0 - */ - TARGET_FPMS: { - get: function get() { - warn('PIXI.TARGET_FPMS has been deprecated, please use PIXI.settings.TARGET_FPMS'); - - return core.settings.TARGET_FPMS; - }, - set: function set(value) { - warn('PIXI.TARGET_FPMS has been deprecated, please use PIXI.settings.TARGET_FPMS'); - - core.settings.TARGET_FPMS = value; - } - }, - - /** - * @static - * @constant - * @name PIXI.FILTER_RESOLUTION - * @see PIXI.settings.FILTER_RESOLUTION - * @deprecated since version 4.2.0 - */ - FILTER_RESOLUTION: { - get: function get() { - warn('PIXI.FILTER_RESOLUTION has been deprecated, please use PIXI.settings.FILTER_RESOLUTION'); - - return core.settings.FILTER_RESOLUTION; - }, - set: function set(value) { - warn('PIXI.FILTER_RESOLUTION has been deprecated, please use PIXI.settings.FILTER_RESOLUTION'); - - core.settings.FILTER_RESOLUTION = value; - } - }, - - /** - * @static - * @constant - * @name PIXI.RESOLUTION - * @see PIXI.settings.RESOLUTION - * @deprecated since version 4.2.0 - */ - RESOLUTION: { - get: function get() { - warn('PIXI.RESOLUTION has been deprecated, please use PIXI.settings.RESOLUTION'); - - return core.settings.RESOLUTION; - }, - set: function set(value) { - warn('PIXI.RESOLUTION has been deprecated, please use PIXI.settings.RESOLUTION'); - - core.settings.RESOLUTION = value; - } - }, - - /** - * @static - * @constant - * @name PIXI.MIPMAP_TEXTURES - * @see PIXI.settings.MIPMAP_TEXTURES - * @deprecated since version 4.2.0 - */ - MIPMAP_TEXTURES: { - get: function get() { - warn('PIXI.MIPMAP_TEXTURES has been deprecated, please use PIXI.settings.MIPMAP_TEXTURES'); - - return core.settings.MIPMAP_TEXTURES; - }, - set: function set(value) { - warn('PIXI.MIPMAP_TEXTURES has been deprecated, please use PIXI.settings.MIPMAP_TEXTURES'); - - core.settings.MIPMAP_TEXTURES = value; - } - }, - - /** - * @static - * @constant - * @name PIXI.SPRITE_BATCH_SIZE - * @see PIXI.settings.SPRITE_BATCH_SIZE - * @deprecated since version 4.2.0 - */ - SPRITE_BATCH_SIZE: { - get: function get() { - warn('PIXI.SPRITE_BATCH_SIZE has been deprecated, please use PIXI.settings.SPRITE_BATCH_SIZE'); - - return core.settings.SPRITE_BATCH_SIZE; - }, - set: function set(value) { - warn('PIXI.SPRITE_BATCH_SIZE has been deprecated, please use PIXI.settings.SPRITE_BATCH_SIZE'); - - core.settings.SPRITE_BATCH_SIZE = value; - } - }, - - /** - * @static - * @constant - * @name PIXI.SPRITE_MAX_TEXTURES - * @see PIXI.settings.SPRITE_MAX_TEXTURES - * @deprecated since version 4.2.0 - */ - SPRITE_MAX_TEXTURES: { - get: function get() { - warn('PIXI.SPRITE_MAX_TEXTURES has been deprecated, please use PIXI.settings.SPRITE_MAX_TEXTURES'); - - return core.settings.SPRITE_MAX_TEXTURES; - }, - set: function set(value) { - warn('PIXI.SPRITE_MAX_TEXTURES has been deprecated, please use PIXI.settings.SPRITE_MAX_TEXTURES'); - - core.settings.SPRITE_MAX_TEXTURES = value; - } - }, - - /** - * @static - * @constant - * @name PIXI.RETINA_PREFIX - * @see PIXI.settings.RETINA_PREFIX - * @deprecated since version 4.2.0 - */ - RETINA_PREFIX: { - get: function get() { - warn('PIXI.RETINA_PREFIX has been deprecated, please use PIXI.settings.RETINA_PREFIX'); - - return core.settings.RETINA_PREFIX; - }, - set: function set(value) { - warn('PIXI.RETINA_PREFIX has been deprecated, please use PIXI.settings.RETINA_PREFIX'); - - core.settings.RETINA_PREFIX = value; - } - }, - - /** - * @static - * @constant - * @name PIXI.DEFAULT_RENDER_OPTIONS - * @see PIXI.settings.RENDER_OPTIONS - * @deprecated since version 4.2.0 - */ - DEFAULT_RENDER_OPTIONS: { - get: function get() { - warn('PIXI.DEFAULT_RENDER_OPTIONS has been deprecated, please use PIXI.settings.DEFAULT_RENDER_OPTIONS'); - - return core.settings.RENDER_OPTIONS; - } - } - }); - - // Move the default properties to settings - var defaults = [{ parent: 'TRANSFORM_MODE', target: 'TRANSFORM_MODE' }, { parent: 'GC_MODES', target: 'GC_MODE' }, { parent: 'WRAP_MODES', target: 'WRAP_MODE' }, { parent: 'SCALE_MODES', target: 'SCALE_MODE' }, { parent: 'PRECISION', target: 'PRECISION_FRAGMENT' }]; - - var _loop = function _loop(i) { - var deprecation = defaults[i]; - - Object.defineProperty(core[deprecation.parent], 'DEFAULT', { - get: function get() { - warn('PIXI.' + deprecation.parent + '.DEFAULT has been deprecated, ' + ('please use PIXI.settings.' + deprecation.target)); - - return core.settings[deprecation.target]; - }, - set: function set(value) { - warn('PIXI.' + deprecation.parent + '.DEFAULT has been deprecated, ' + ('please use PIXI.settings.' + deprecation.target)); - - core.settings[deprecation.target] = value; - } - }); - }; - - for (var i = 0; i < defaults.length; i++) { - _loop(i); - } - - Object.defineProperties(core.settings, { - - /** - * @static - * @name PRECISION - * @memberof PIXI.settings - * @see PIXI.PRECISION - * @deprecated since version 4.4.0 - */ - PRECISION: { - get: function get() { - warn('PIXI.settings.PRECISION has been deprecated, please use PIXI.settings.PRECISION_FRAGMENT'); - - return core.settings.PRECISION_FRAGMENT; - }, - set: function set(value) { - warn('PIXI.settings.PRECISION has been deprecated, please use PIXI.settings.PRECISION_FRAGMENT'); - - core.settings.PRECISION_FRAGMENT = value; - } - } - }); - - if (extras.AnimatedSprite) { - Object.defineProperties(extras, { - - /** - * @class - * @name MovieClip - * @memberof PIXI.extras - * @see PIXI.extras.AnimatedSprite - * @deprecated since version 4.2.0 - */ - MovieClip: { - get: function get() { - warn('The MovieClip class has been renamed to AnimatedSprite, please use AnimatedSprite from now on.'); - - return extras.AnimatedSprite; - } - } - }); - } - - if (extras) { - Object.defineProperties(extras, { - /** - * @class - * @name TextureTransform - * @memberof PIXI.extras - * @see PIXI.TextureMatrix - * @deprecated since version 4.6.0 - */ - TextureTransform: { - get: function get() { - warn('The TextureTransform class has been renamed to TextureMatrix, ' + 'please use PIXI.TextureMatrix from now on.'); - - return core.TextureMatrix; - } - } - }); - } - - core.DisplayObject.prototype.generateTexture = function generateTexture(renderer, scaleMode, resolution) { - warn('generateTexture has moved to the renderer, please use renderer.generateTexture(displayObject)'); - - return renderer.generateTexture(this, scaleMode, resolution); - }; - - core.Graphics.prototype.generateTexture = function generateTexture(scaleMode, resolution) { - warn('graphics generate texture has moved to the renderer. ' + 'Or to render a graphics to a texture using canvas please use generateCanvasTexture'); - - return this.generateCanvasTexture(scaleMode, resolution); - }; - - /** - * @method - * @name PIXI.GroupD8.isSwapWidthHeight - * @see PIXI.GroupD8.isVertical - * @param {number} rotation - The number to check. - * @returns {boolean} Whether or not the direction is vertical - * @deprecated since version 4.6.0 - */ - core.GroupD8.isSwapWidthHeight = function isSwapWidthHeight(rotation) { - warn('GroupD8.isSwapWidthHeight was renamed to GroupD8.isVertical'); - - return core.GroupD8.isVertical(rotation); - }; - - core.RenderTexture.prototype.render = function render(displayObject, matrix, clear, updateTransform) { - this.legacyRenderer.render(displayObject, this, clear, matrix, !updateTransform); - warn('RenderTexture.render is now deprecated, please use renderer.render(displayObject, renderTexture)'); - }; - - core.RenderTexture.prototype.getImage = function getImage(target) { - warn('RenderTexture.getImage is now deprecated, please use renderer.extract.image(target)'); - - return this.legacyRenderer.extract.image(target); - }; - - core.RenderTexture.prototype.getBase64 = function getBase64(target) { - warn('RenderTexture.getBase64 is now deprecated, please use renderer.extract.base64(target)'); - - return this.legacyRenderer.extract.base64(target); - }; - - core.RenderTexture.prototype.getCanvas = function getCanvas(target) { - warn('RenderTexture.getCanvas is now deprecated, please use renderer.extract.canvas(target)'); - - return this.legacyRenderer.extract.canvas(target); - }; - - core.RenderTexture.prototype.getPixels = function getPixels(target) { - warn('RenderTexture.getPixels is now deprecated, please use renderer.extract.pixels(target)'); - - return this.legacyRenderer.pixels(target); - }; - - /** - * @method - * @private - * @name PIXI.Sprite#setTexture - * @see PIXI.Sprite#texture - * @deprecated since version 3.0.0 - * @param {PIXI.Texture} texture - The texture to set to. - */ - core.Sprite.prototype.setTexture = function setTexture(texture) { - this.texture = texture; - warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;'); - }; - - if (extras.BitmapText) { - /** - * @method - * @name PIXI.extras.BitmapText#setText - * @see PIXI.extras.BitmapText#text - * @deprecated since version 3.0.0 - * @param {string} text - The text to set to. - */ - extras.BitmapText.prototype.setText = function setText(text) { - this.text = text; - warn('setText is now deprecated, please use the text property, e.g : myBitmapText.text = \'my text\';'); - }; - } - - /** - * @method - * @name PIXI.Text#setText - * @see PIXI.Text#text - * @deprecated since version 3.0.0 - * @param {string} text - The text to set to. - */ - core.Text.prototype.setText = function setText(text) { - this.text = text; - warn('setText is now deprecated, please use the text property, e.g : myText.text = \'my text\';'); - }; - - /** - * Calculates the ascent, descent and fontSize of a given fontStyle - * - * @name PIXI.Text.calculateFontProperties - * @see PIXI.TextMetrics.measureFont - * @deprecated since version 4.5.0 - * @param {string} font - String representing the style of the font - * @return {Object} Font properties object - */ - core.Text.calculateFontProperties = function calculateFontProperties(font) { - warn('Text.calculateFontProperties is now deprecated, please use the TextMetrics.measureFont'); - - return core.TextMetrics.measureFont(font); - }; - - Object.defineProperties(core.Text, { - fontPropertiesCache: { - get: function get() { - warn('Text.fontPropertiesCache is deprecated'); - - return core.TextMetrics._fonts; - } - }, - fontPropertiesCanvas: { - get: function get() { - warn('Text.fontPropertiesCanvas is deprecated'); - - return core.TextMetrics._canvas; - } - }, - fontPropertiesContext: { - get: function get() { - warn('Text.fontPropertiesContext is deprecated'); - - return core.TextMetrics._context; - } - } - }); - - /** - * @method - * @name PIXI.Text#setStyle - * @see PIXI.Text#style - * @deprecated since version 3.0.0 - * @param {*} style - The style to set to. - */ - core.Text.prototype.setStyle = function setStyle(style) { - this.style = style; - warn('setStyle is now deprecated, please use the style property, e.g : myText.style = style;'); - }; - - /** - * @method - * @name PIXI.Text#determineFontProperties - * @see PIXI.Text#measureFontProperties - * @deprecated since version 4.2.0 - * @private - * @param {string} fontStyle - String representing the style of the font - * @return {Object} Font properties object - */ - core.Text.prototype.determineFontProperties = function determineFontProperties(fontStyle) { - warn('determineFontProperties is now deprecated, please use TextMetrics.measureFont method'); - - return core.TextMetrics.measureFont(fontStyle); - }; - - /** - * @method - * @name PIXI.Text.getFontStyle - * @see PIXI.TextMetrics.getFontStyle - * @deprecated since version 4.5.0 - * @param {PIXI.TextStyle} style - The style to use. - * @return {string} Font string - */ - core.Text.getFontStyle = function getFontStyle(style) { - warn('getFontStyle is now deprecated, please use TextStyle.toFontString() instead'); - - style = style || {}; - - if (!(style instanceof core.TextStyle)) { - style = new core.TextStyle(style); - } - - return style.toFontString(); - }; - - Object.defineProperties(core.TextStyle.prototype, { - /** - * Set all properties of a font as a single string - * - * @name PIXI.TextStyle#font - * @deprecated since version 4.0.0 - */ - font: { - get: function get() { - warn('text style property \'font\' is now deprecated, please use the ' + '\'fontFamily\', \'fontSize\', \'fontStyle\', \'fontVariant\' and \'fontWeight\' properties from now on'); - - var fontSizeString = typeof this._fontSize === 'number' ? this._fontSize + 'px' : this._fontSize; - - return this._fontStyle + ' ' + this._fontVariant + ' ' + this._fontWeight + ' ' + fontSizeString + ' ' + this._fontFamily; - }, - set: function set(font) { - warn('text style property \'font\' is now deprecated, please use the ' + '\'fontFamily\',\'fontSize\',fontStyle\',\'fontVariant\' and \'fontWeight\' properties from now on'); - - // can work out fontStyle from search of whole string - if (font.indexOf('italic') > 1) { - this._fontStyle = 'italic'; - } else if (font.indexOf('oblique') > -1) { - this._fontStyle = 'oblique'; - } else { - this._fontStyle = 'normal'; - } - - // can work out fontVariant from search of whole string - if (font.indexOf('small-caps') > -1) { - this._fontVariant = 'small-caps'; - } else { - this._fontVariant = 'normal'; - } - - // fontWeight and fontFamily are tricker to find, but it's easier to find the fontSize due to it's units - var splits = font.split(' '); - var fontSizeIndex = -1; - - this._fontSize = 26; - for (var i = 0; i < splits.length; ++i) { - if (splits[i].match(/(px|pt|em|%)/)) { - fontSizeIndex = i; - this._fontSize = splits[i]; - break; - } - } - - // we can now search for fontWeight as we know it must occur before the fontSize - this._fontWeight = 'normal'; - for (var _i = 0; _i < fontSizeIndex; ++_i) { - if (splits[_i].match(/(bold|bolder|lighter|100|200|300|400|500|600|700|800|900)/)) { - this._fontWeight = splits[_i]; - break; - } - } - - // and finally join everything together after the fontSize in case the font family has multiple words - if (fontSizeIndex > -1 && fontSizeIndex < splits.length - 1) { - this._fontFamily = ''; - for (var _i2 = fontSizeIndex + 1; _i2 < splits.length; ++_i2) { - this._fontFamily += splits[_i2] + ' '; - } - - this._fontFamily = this._fontFamily.slice(0, -1); - } else { - this._fontFamily = 'Arial'; - } - - this.styleID++; - } - } - }); - - /** - * @method - * @name PIXI.Texture#setFrame - * @see PIXI.Texture#setFrame - * @deprecated since version 3.0.0 - * @param {PIXI.Rectangle} frame - The frame to set. - */ - core.Texture.prototype.setFrame = function setFrame(frame) { - this.frame = frame; - warn('setFrame is now deprecated, please use the frame property, e.g: myTexture.frame = frame;'); - }; - - /** - * @static - * @function - * @name PIXI.Texture.addTextureToCache - * @see PIXI.Texture.addToCache - * @deprecated since 4.5.0 - * @param {PIXI.Texture} texture - The Texture to add to the cache. - * @param {string} id - The id that the texture will be stored against. - */ - core.Texture.addTextureToCache = function addTextureToCache(texture, id) { - core.Texture.addToCache(texture, id); - warn('Texture.addTextureToCache is deprecated, please use Texture.addToCache from now on.'); - }; - - /** - * @static - * @function - * @name PIXI.Texture.removeTextureFromCache - * @see PIXI.Texture.removeFromCache - * @deprecated since 4.5.0 - * @param {string} id - The id of the texture to be removed - * @return {PIXI.Texture|null} The texture that was removed - */ - core.Texture.removeTextureFromCache = function removeTextureFromCache(id) { - warn('Texture.removeTextureFromCache is deprecated, please use Texture.removeFromCache from now on. ' + 'Be aware that Texture.removeFromCache does not automatically its BaseTexture from the BaseTextureCache. ' + 'For that, use BaseTexture.removeFromCache'); - - core.BaseTexture.removeFromCache(id); - - return core.Texture.removeFromCache(id); - }; - - Object.defineProperties(filters, { - - /** - * @class - * @private - * @name PIXI.filters.AbstractFilter - * @see PIXI.AbstractFilter - * @deprecated since version 3.0.6 - */ - AbstractFilter: { - get: function get() { - warn('AstractFilter has been renamed to Filter, please use PIXI.Filter'); - - return core.AbstractFilter; - } - }, - - /** - * @class - * @private - * @name PIXI.filters.SpriteMaskFilter - * @see PIXI.SpriteMaskFilter - * @deprecated since version 3.0.6 - */ - SpriteMaskFilter: { - get: function get() { - warn('filters.SpriteMaskFilter is an undocumented alias, please use SpriteMaskFilter from now on.'); - - return core.SpriteMaskFilter; - } - }, - - /** - * @class - * @private - * @name PIXI.filters.VoidFilter - * @see PIXI.filters.AlphaFilter - * @deprecated since version 4.5.7 - */ - VoidFilter: { - get: function get() { - warn('VoidFilter has been renamed to AlphaFilter, please use PIXI.filters.AlphaFilter'); - - return filters.AlphaFilter; - } - } - }); - - /** - * @method - * @name PIXI.utils.uuid - * @see PIXI.utils.uid - * @deprecated since version 3.0.6 - * @return {number} The uid - */ - core.utils.uuid = function () { - warn('utils.uuid() is deprecated, please use utils.uid() from now on.'); - - return core.utils.uid(); - }; - - /** - * @method - * @name PIXI.utils.canUseNewCanvasBlendModes - * @see PIXI.CanvasTinter - * @deprecated - * @return {boolean} Can use blend modes. - */ - core.utils.canUseNewCanvasBlendModes = function () { - warn('utils.canUseNewCanvasBlendModes() is deprecated, please use CanvasTinter.canUseMultiply from now on'); - - return core.CanvasTinter.canUseMultiply; - }; - - var saidHello = true; - - /** - * @name PIXI.utils._saidHello - * @type {boolean} - * @see PIXI.utils.skipHello - * @deprecated since 4.1.0 - */ - Object.defineProperty(core.utils, '_saidHello', { - set: function set(bool) { - if (bool) { - warn('PIXI.utils._saidHello is deprecated, please use PIXI.utils.skipHello()'); - this.skipHello(); - } - saidHello = bool; - }, - get: function get() { - return saidHello; - } - }); - - if (prepare.BasePrepare) { - /** - * @method - * @name PIXI.prepare.BasePrepare#register - * @see PIXI.prepare.BasePrepare#registerFindHook - * @deprecated since version 4.4.2 - * @param {Function} [addHook] - Function call that takes two parameters: `item:*, queue:Array` - * function must return `true` if it was able to add item to the queue. - * @param {Function} [uploadHook] - Function call that takes two parameters: `prepare:CanvasPrepare, item:*` and - * function must return `true` if it was able to handle upload of item. - * @return {PIXI.BasePrepare} Instance of plugin for chaining. - */ - prepare.BasePrepare.prototype.register = function register(addHook, uploadHook) { - warn('renderer.plugins.prepare.register is now deprecated, ' + 'please use renderer.plugins.prepare.registerFindHook & renderer.plugins.prepare.registerUploadHook'); - - if (addHook) { - this.registerFindHook(addHook); - } - - if (uploadHook) { - this.registerUploadHook(uploadHook); - } - - return this; - }; - } - - if (prepare.canvas) { - /** - * The number of graphics or textures to upload to the GPU. - * - * @name PIXI.prepare.canvas.UPLOADS_PER_FRAME - * @static - * @type {number} - * @see PIXI.prepare.BasePrepare.limiter - * @deprecated since 4.2.0 - */ - Object.defineProperty(prepare.canvas, 'UPLOADS_PER_FRAME', { - set: function set() { - warn('PIXI.CanvasPrepare.UPLOADS_PER_FRAME has been removed. Please set ' + 'renderer.plugins.prepare.limiter.maxItemsPerFrame on your renderer'); - // because we don't have a reference to the renderer, we can't actually set - // the uploads per frame, so we'll have to stick with the warning. - }, - get: function get() { - warn('PIXI.CanvasPrepare.UPLOADS_PER_FRAME has been removed. Please use ' + 'renderer.plugins.prepare.limiter'); - - return NaN; - } - }); - } - - if (prepare.webgl) { - /** - * The number of graphics or textures to upload to the GPU. - * - * @name PIXI.prepare.webgl.UPLOADS_PER_FRAME - * @static - * @type {number} - * @see PIXI.prepare.BasePrepare.limiter - * @deprecated since 4.2.0 - */ - Object.defineProperty(prepare.webgl, 'UPLOADS_PER_FRAME', { - set: function set() { - warn('PIXI.WebGLPrepare.UPLOADS_PER_FRAME has been removed. Please set ' + 'renderer.plugins.prepare.limiter.maxItemsPerFrame on your renderer'); - // because we don't have a reference to the renderer, we can't actually set - // the uploads per frame, so we'll have to stick with the warning. - }, - get: function get() { - warn('PIXI.WebGLPrepare.UPLOADS_PER_FRAME has been removed. Please use ' + 'renderer.plugins.prepare.limiter'); - - return NaN; - } - }); - } - - if (loaders.Loader) { - var Resource = loaders.Resource; - var Loader = loaders.Loader; - - Object.defineProperties(Resource.prototype, { - isJson: { - get: function get() { - warn('The isJson property is deprecated, please use `resource.type === Resource.TYPE.JSON`.'); - - return this.type === Resource.TYPE.JSON; - } - }, - isXml: { - get: function get() { - warn('The isXml property is deprecated, please use `resource.type === Resource.TYPE.XML`.'); - - return this.type === Resource.TYPE.XML; - } - }, - isImage: { - get: function get() { - warn('The isImage property is deprecated, please use `resource.type === Resource.TYPE.IMAGE`.'); - - return this.type === Resource.TYPE.IMAGE; - } - }, - isAudio: { - get: function get() { - warn('The isAudio property is deprecated, please use `resource.type === Resource.TYPE.AUDIO`.'); - - return this.type === Resource.TYPE.AUDIO; - } - }, - isVideo: { - get: function get() { - warn('The isVideo property is deprecated, please use `resource.type === Resource.TYPE.VIDEO`.'); - - return this.type === Resource.TYPE.VIDEO; - } - } - }); - - Object.defineProperties(Loader.prototype, { - before: { - get: function get() { - warn('The before() method is deprecated, please use pre().'); - - return this.pre; - } - }, - after: { - get: function get() { - warn('The after() method is deprecated, please use use().'); - - return this.use; - } - } - }); - } - - if (interaction.interactiveTarget) { - /** - * @name PIXI.interaction.interactiveTarget#defaultCursor - * @static - * @type {number} - * @see PIXI.interaction.interactiveTarget#cursor - * @deprecated since 4.3.0 - */ - Object.defineProperty(interaction.interactiveTarget, 'defaultCursor', { - set: function set(value) { - warn('Property defaultCursor has been replaced with \'cursor\'. '); - this.cursor = value; - }, - get: function get() { - warn('Property defaultCursor has been replaced with \'cursor\'. '); - - return this.cursor; - } - }); - } - - if (interaction.InteractionManager) { - /** - * @name PIXI.interaction.InteractionManager#defaultCursorStyle - * @static - * @type {string} - * @see PIXI.interaction.InteractionManager#cursorStyles - * @deprecated since 4.3.0 - */ - Object.defineProperty(interaction.InteractionManager, 'defaultCursorStyle', { - set: function set(value) { - warn('Property defaultCursorStyle has been replaced with \'cursorStyles.default\'. '); - this.cursorStyles.default = value; - }, - get: function get() { - warn('Property defaultCursorStyle has been replaced with \'cursorStyles.default\'. '); - - return this.cursorStyles.default; - } - }); - - /** - * @name PIXI.interaction.InteractionManager#currentCursorStyle - * @static - * @type {string} - * @see PIXI.interaction.InteractionManager#cursorStyles - * @deprecated since 4.3.0 - */ - Object.defineProperty(interaction.InteractionManager, 'currentCursorStyle', { - set: function set(value) { - warn('Property currentCursorStyle has been removed.' + 'See the currentCursorMode property, which works differently.'); - this.currentCursorMode = value; - }, - get: function get() { - warn('Property currentCursorStyle has been removed.' + 'See the currentCursorMode property, which works differently.'); - - return this.currentCursorMode; - } - }); - } -} - -},{}],132:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var TEMP_RECT = new core.Rectangle(); - -/** - * The extract manager provides functionality to export content from the renderers. - * - * An instance of this class is automatically created by default, and can be found at renderer.plugins.extract - * - * @class - * @memberof PIXI.extract - */ - -var CanvasExtract = function () { - /** - * @param {PIXI.CanvasRenderer} renderer - A reference to the current renderer - */ - function CanvasExtract(renderer) { - _classCallCheck(this, CanvasExtract); - - this.renderer = renderer; - /** - * Collection of methods for extracting data (image, pixels, etc.) from a display object or render texture - * - * @member {PIXI.extract.CanvasExtract} extract - * @memberof PIXI.CanvasRenderer# - * @see PIXI.extract.CanvasExtract - */ - renderer.extract = this; - } - - /** - * Will return a HTML Image of the target - * - * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture - * to convert. If left empty will use use the main renderer - * @return {HTMLImageElement} HTML Image of the target - */ - - - CanvasExtract.prototype.image = function image(target) { - var image = new Image(); - - image.src = this.base64(target); - - return image; - }; - - /** - * Will return a a base64 encoded string of this target. It works by calling - * `CanvasExtract.getCanvas` and then running toDataURL on that. - * - * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture - * to convert. If left empty will use use the main renderer - * @return {string} A base64 encoded string of the texture. - */ - - - CanvasExtract.prototype.base64 = function base64(target) { - return this.canvas(target).toDataURL(); - }; - - /** - * Creates a Canvas element, renders this target to it and then returns it. - * - * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture - * to convert. If left empty will use use the main renderer - * @return {HTMLCanvasElement} A Canvas element with the texture rendered on. - */ - - - CanvasExtract.prototype.canvas = function canvas(target) { - var renderer = this.renderer; - var context = void 0; - var resolution = void 0; - var frame = void 0; - var renderTexture = void 0; - - if (target) { - if (target instanceof core.RenderTexture) { - renderTexture = target; - } else { - renderTexture = renderer.generateTexture(target); - } - } - - if (renderTexture) { - context = renderTexture.baseTexture._canvasRenderTarget.context; - resolution = renderTexture.baseTexture._canvasRenderTarget.resolution; - frame = renderTexture.frame; - } else { - context = renderer.rootContext; - resolution = renderer.resolution; - frame = TEMP_RECT; - frame.width = this.renderer.width; - frame.height = this.renderer.height; - } - - var width = frame.width * resolution; - var height = frame.height * resolution; - - var canvasBuffer = new core.CanvasRenderTarget(width, height, 1); - var canvasData = context.getImageData(frame.x * resolution, frame.y * resolution, width, height); - - canvasBuffer.context.putImageData(canvasData, 0, 0); - - // send the canvas back.. - return canvasBuffer.canvas; - }; - - /** - * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA - * order, with integer values between 0 and 255 (included). - * - * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture - * to convert. If left empty will use use the main renderer - * @return {Uint8ClampedArray} One-dimensional array containing the pixel data of the entire texture - */ - - - CanvasExtract.prototype.pixels = function pixels(target) { - var renderer = this.renderer; - var context = void 0; - var resolution = void 0; - var frame = void 0; - var renderTexture = void 0; - - if (target) { - if (target instanceof core.RenderTexture) { - renderTexture = target; - } else { - renderTexture = renderer.generateTexture(target); - } - } - - if (renderTexture) { - context = renderTexture.baseTexture._canvasRenderTarget.context; - resolution = renderTexture.baseTexture._canvasRenderTarget.resolution; - frame = renderTexture.frame; - } else { - context = renderer.rootContext; - - frame = TEMP_RECT; - frame.width = renderer.width; - frame.height = renderer.height; - } - - return context.getImageData(0, 0, frame.width * resolution, frame.height * resolution).data; - }; - - /** - * Destroys the extract - * - */ - - - CanvasExtract.prototype.destroy = function destroy() { - this.renderer.extract = null; - this.renderer = null; - }; - - return CanvasExtract; -}(); - -exports.default = CanvasExtract; - - -core.CanvasRenderer.registerPlugin('extract', CanvasExtract); - -},{"../../core":65}],133:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _WebGLExtract = require('./webgl/WebGLExtract'); - -Object.defineProperty(exports, 'webgl', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_WebGLExtract).default; - } -}); - -var _CanvasExtract = require('./canvas/CanvasExtract'); - -Object.defineProperty(exports, 'canvas', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_CanvasExtract).default; - } -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"./canvas/CanvasExtract":132,"./webgl/WebGLExtract":134}],134:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var TEMP_RECT = new core.Rectangle(); -var BYTES_PER_PIXEL = 4; - -/** - * The extract manager provides functionality to export content from the renderers. - * - * An instance of this class is automatically created by default, and can be found at renderer.plugins.extract - * - * @class - * @memberof PIXI.extract - */ - -var WebGLExtract = function () { - /** - * @param {PIXI.WebGLRenderer} renderer - A reference to the current renderer - */ - function WebGLExtract(renderer) { - _classCallCheck(this, WebGLExtract); - - this.renderer = renderer; - /** - * Collection of methods for extracting data (image, pixels, etc.) from a display object or render texture - * - * @member {PIXI.extract.WebGLExtract} extract - * @memberof PIXI.WebGLRenderer# - * @see PIXI.extract.WebGLExtract - */ - renderer.extract = this; - } - - /** - * Will return a HTML Image of the target - * - * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture - * to convert. If left empty will use use the main renderer - * @return {HTMLImageElement} HTML Image of the target - */ - - - WebGLExtract.prototype.image = function image(target) { - var image = new Image(); - - image.src = this.base64(target); - - return image; - }; - - /** - * Will return a a base64 encoded string of this target. It works by calling - * `WebGLExtract.getCanvas` and then running toDataURL on that. - * - * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture - * to convert. If left empty will use use the main renderer - * @return {string} A base64 encoded string of the texture. - */ - - - WebGLExtract.prototype.base64 = function base64(target) { - return this.canvas(target).toDataURL(); - }; - - /** - * Creates a Canvas element, renders this target to it and then returns it. - * - * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture - * to convert. If left empty will use use the main renderer - * @return {HTMLCanvasElement} A Canvas element with the texture rendered on. - */ - - - WebGLExtract.prototype.canvas = function canvas(target) { - var renderer = this.renderer; - var textureBuffer = void 0; - var resolution = void 0; - var frame = void 0; - var flipY = false; - var renderTexture = void 0; - var generated = false; - - if (target) { - if (target instanceof core.RenderTexture) { - renderTexture = target; - } else { - renderTexture = this.renderer.generateTexture(target); - generated = true; - } - } - - if (renderTexture) { - textureBuffer = renderTexture.baseTexture._glRenderTargets[this.renderer.CONTEXT_UID]; - resolution = textureBuffer.resolution; - frame = renderTexture.frame; - flipY = false; - } else { - textureBuffer = this.renderer.rootRenderTarget; - resolution = textureBuffer.resolution; - flipY = true; - - frame = TEMP_RECT; - frame.width = textureBuffer.size.width; - frame.height = textureBuffer.size.height; - } - - var width = frame.width * resolution; - var height = frame.height * resolution; - - var canvasBuffer = new core.CanvasRenderTarget(width, height, 1); - - if (textureBuffer) { - // bind the buffer - renderer.bindRenderTarget(textureBuffer); - - // set up an array of pixels - var webglPixels = new Uint8Array(BYTES_PER_PIXEL * width * height); - - // read pixels to the array - var gl = renderer.gl; - - gl.readPixels(frame.x * resolution, frame.y * resolution, width, height, gl.RGBA, gl.UNSIGNED_BYTE, webglPixels); - - // add the pixels to the canvas - var canvasData = canvasBuffer.context.getImageData(0, 0, width, height); - - canvasData.data.set(webglPixels); - - canvasBuffer.context.putImageData(canvasData, 0, 0); - - // pulling pixels - if (flipY) { - canvasBuffer.context.scale(1, -1); - canvasBuffer.context.drawImage(canvasBuffer.canvas, 0, -height); - } - } - - if (generated) { - renderTexture.destroy(true); - } - // send the canvas back.. - - return canvasBuffer.canvas; - }; - - /** - * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA - * order, with integer values between 0 and 255 (included). - * - * @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture - * to convert. If left empty will use use the main renderer - * @return {Uint8ClampedArray} One-dimensional array containing the pixel data of the entire texture - */ - - - WebGLExtract.prototype.pixels = function pixels(target) { - var renderer = this.renderer; - var textureBuffer = void 0; - var resolution = void 0; - var frame = void 0; - var renderTexture = void 0; - var generated = false; - - if (target) { - if (target instanceof core.RenderTexture) { - renderTexture = target; - } else { - renderTexture = this.renderer.generateTexture(target); - generated = true; - } - } - - if (renderTexture) { - textureBuffer = renderTexture.baseTexture._glRenderTargets[this.renderer.CONTEXT_UID]; - resolution = textureBuffer.resolution; - frame = renderTexture.frame; - } else { - textureBuffer = this.renderer.rootRenderTarget; - resolution = textureBuffer.resolution; - - frame = TEMP_RECT; - frame.width = textureBuffer.size.width; - frame.height = textureBuffer.size.height; - } - - var width = frame.width * resolution; - var height = frame.height * resolution; - - var webglPixels = new Uint8Array(BYTES_PER_PIXEL * width * height); - - if (textureBuffer) { - // bind the buffer - renderer.bindRenderTarget(textureBuffer); - // read pixels to the array - var gl = renderer.gl; - - gl.readPixels(frame.x * resolution, frame.y * resolution, width, height, gl.RGBA, gl.UNSIGNED_BYTE, webglPixels); - } - - if (generated) { - renderTexture.destroy(true); - } - - return webglPixels; - }; - - /** - * Destroys the extract - * - */ - - - WebGLExtract.prototype.destroy = function destroy() { - this.renderer.extract = null; - this.renderer = null; - }; - - return WebGLExtract; -}(); - -exports.default = WebGLExtract; - - -core.WebGLRenderer.registerPlugin('extract', WebGLExtract); - -},{"../../core":65}],135:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * @typedef PIXI.extras.AnimatedSprite~FrameObject - * @type {object} - * @property {PIXI.Texture} texture - The {@link PIXI.Texture} of the frame - * @property {number} time - the duration of the frame in ms - */ - -/** - * An AnimatedSprite is a simple way to display an animation depicted by a list of textures. - * - * ```js - * let alienImages = ["image_sequence_01.png","image_sequence_02.png","image_sequence_03.png","image_sequence_04.png"]; - * let textureArray = []; - * - * for (let i=0; i < 4; i++) - * { - * let texture = PIXI.Texture.fromImage(alienImages[i]); - * textureArray.push(texture); - * }; - * - * let animatedSprite = new PIXI.extras.AnimatedSprite(textureArray); - * ``` - * - * The more efficient and simpler way to create an animated sprite is using a {@link PIXI.Spritesheet} - * containing the animation definitions: - * - * ```js - * PIXI.loader.add("assets/spritesheet.json").load(setup); - * - * function setup() { - * let sheet = PIXI.loader.resources["assets/spritesheet.json"].spritesheet; - * animatedSprite = new PIXI.extras.AnimatedSprite(sheet.animations["image_sequence"]); - * ... - * } - * ``` - * - * @class - * @extends PIXI.Sprite - * @memberof PIXI.extras - */ -var AnimatedSprite = function (_core$Sprite) { - _inherits(AnimatedSprite, _core$Sprite); - - /** - * @param {PIXI.Texture[]|PIXI.extras.AnimatedSprite~FrameObject[]} textures - an array of {@link PIXI.Texture} or frame - * objects that make up the animation - * @param {boolean} [autoUpdate=true] - Whether to use PIXI.ticker.shared to auto update animation time. - */ - function AnimatedSprite(textures, autoUpdate) { - _classCallCheck(this, AnimatedSprite); - - /** - * @private - */ - var _this = _possibleConstructorReturn(this, _core$Sprite.call(this, textures[0] instanceof core.Texture ? textures[0] : textures[0].texture)); - - _this._textures = null; - - /** - * @private - */ - _this._durations = null; - - _this.textures = textures; - - /** - * `true` uses PIXI.ticker.shared to auto update animation time. - * @type {boolean} - * @default true - * @private - */ - _this._autoUpdate = autoUpdate !== false; - - /** - * The speed that the AnimatedSprite will play at. Higher is faster, lower is slower - * - * @member {number} - * @default 1 - */ - _this.animationSpeed = 1; - - /** - * Whether or not the animate sprite repeats after playing. - * - * @member {boolean} - * @default true - */ - _this.loop = true; - - /** - * Update anchor to [Texture's defaultAnchor]{@link PIXI.Texture#defaultAnchor} when frame changes. - * - * Useful with [sprite sheet animations]{@link PIXI.Spritesheet#animations} created with tools. - * Changing anchor for each frame allows to pin sprite origin to certain moving feature - * of the frame (e.g. left foot). - * - * Note: Enabling this will override any previously set `anchor` on each frame change. - * - * @member {boolean} - * @default false - */ - _this.updateAnchor = false; - - /** - * Function to call when a AnimatedSprite finishes playing - * - * @member {Function} - */ - _this.onComplete = null; - - /** - * Function to call when a AnimatedSprite changes which texture is being rendered - * - * @member {Function} - */ - _this.onFrameChange = null; - - /** - * Function to call when 'loop' is true, and an AnimatedSprite is played and loops around to start again - * - * @member {Function} - */ - _this.onLoop = null; - - /** - * Elapsed time since animation has been started, used internally to display current texture - * - * @member {number} - * @private - */ - _this._currentTime = 0; - - /** - * Indicates if the AnimatedSprite is currently playing - * - * @member {boolean} - * @readonly - */ - _this.playing = false; - return _this; - } - - /** - * Stops the AnimatedSprite - * - */ - - - AnimatedSprite.prototype.stop = function stop() { - if (!this.playing) { - return; - } - - this.playing = false; - if (this._autoUpdate) { - core.ticker.shared.remove(this.update, this); - } - }; - - /** - * Plays the AnimatedSprite - * - */ - - - AnimatedSprite.prototype.play = function play() { - if (this.playing) { - return; - } - - this.playing = true; - if (this._autoUpdate) { - core.ticker.shared.add(this.update, this, core.UPDATE_PRIORITY.HIGH); - } - }; - - /** - * Stops the AnimatedSprite and goes to a specific frame - * - * @param {number} frameNumber - frame index to stop at - */ - - - AnimatedSprite.prototype.gotoAndStop = function gotoAndStop(frameNumber) { - this.stop(); - - var previousFrame = this.currentFrame; - - this._currentTime = frameNumber; - - if (previousFrame !== this.currentFrame) { - this.updateTexture(); - } - }; - - /** - * Goes to a specific frame and begins playing the AnimatedSprite - * - * @param {number} frameNumber - frame index to start at - */ - - - AnimatedSprite.prototype.gotoAndPlay = function gotoAndPlay(frameNumber) { - var previousFrame = this.currentFrame; - - this._currentTime = frameNumber; - - if (previousFrame !== this.currentFrame) { - this.updateTexture(); - } - - this.play(); - }; - - /** - * Updates the object transform for rendering. - * - * @private - * @param {number} deltaTime - Time since last tick. - */ - - - AnimatedSprite.prototype.update = function update(deltaTime) { - var elapsed = this.animationSpeed * deltaTime; - var previousFrame = this.currentFrame; - - if (this._durations !== null) { - var lag = this._currentTime % 1 * this._durations[this.currentFrame]; - - lag += elapsed / 60 * 1000; - - while (lag < 0) { - this._currentTime--; - lag += this._durations[this.currentFrame]; - } - - var sign = Math.sign(this.animationSpeed * deltaTime); - - this._currentTime = Math.floor(this._currentTime); - - while (lag >= this._durations[this.currentFrame]) { - lag -= this._durations[this.currentFrame] * sign; - this._currentTime += sign; - } - - this._currentTime += lag / this._durations[this.currentFrame]; - } else { - this._currentTime += elapsed; - } - - if (this._currentTime < 0 && !this.loop) { - this.gotoAndStop(0); - - if (this.onComplete) { - this.onComplete(); - } - } else if (this._currentTime >= this._textures.length && !this.loop) { - this.gotoAndStop(this._textures.length - 1); - - if (this.onComplete) { - this.onComplete(); - } - } else if (previousFrame !== this.currentFrame) { - if (this.loop && this.onLoop) { - if (this.animationSpeed > 0 && this.currentFrame < previousFrame) { - this.onLoop(); - } else if (this.animationSpeed < 0 && this.currentFrame > previousFrame) { - this.onLoop(); - } - } - - this.updateTexture(); - } - }; - - /** - * Updates the displayed texture to match the current frame index - * - * @private - */ - - - AnimatedSprite.prototype.updateTexture = function updateTexture() { - this._texture = this._textures[this.currentFrame]; - this._textureID = -1; - this.cachedTint = 0xFFFFFF; - - if (this.updateAnchor) { - this._anchor.copy(this._texture.defaultAnchor); - } - - if (this.onFrameChange) { - this.onFrameChange(this.currentFrame); - } - }; - - /** - * Stops the AnimatedSprite and destroys it - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options - * have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy - * method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well - * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well - */ - - - AnimatedSprite.prototype.destroy = function destroy(options) { - this.stop(); - _core$Sprite.prototype.destroy.call(this, options); - }; - - /** - * A short hand way of creating a movieclip from an array of frame ids - * - * @static - * @param {string[]} frames - The array of frames ids the movieclip will use as its texture frames - * @return {AnimatedSprite} The new animated sprite with the specified frames. - */ - - - AnimatedSprite.fromFrames = function fromFrames(frames) { - var textures = []; - - for (var i = 0; i < frames.length; ++i) { - textures.push(core.Texture.fromFrame(frames[i])); - } - - return new AnimatedSprite(textures); - }; - - /** - * A short hand way of creating a movieclip from an array of image ids - * - * @static - * @param {string[]} images - the array of image urls the movieclip will use as its texture frames - * @return {AnimatedSprite} The new animate sprite with the specified images as frames. - */ - - - AnimatedSprite.fromImages = function fromImages(images) { - var textures = []; - - for (var i = 0; i < images.length; ++i) { - textures.push(core.Texture.fromImage(images[i])); - } - - return new AnimatedSprite(textures); - }; - - /** - * totalFrames is the total number of frames in the AnimatedSprite. This is the same as number of textures - * assigned to the AnimatedSprite. - * - * @readonly - * @member {number} - * @default 0 - */ - - - _createClass(AnimatedSprite, [{ - key: 'totalFrames', - get: function get() { - return this._textures.length; - } - - /** - * The array of textures used for this AnimatedSprite - * - * @member {PIXI.Texture[]} - */ - - }, { - key: 'textures', - get: function get() { - return this._textures; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (value[0] instanceof core.Texture) { - this._textures = value; - this._durations = null; - } else { - this._textures = []; - this._durations = []; - - for (var i = 0; i < value.length; i++) { - this._textures.push(value[i].texture); - this._durations.push(value[i].time); - } - } - this.gotoAndStop(0); - this.updateTexture(); - } - - /** - * The AnimatedSprites current frame index - * - * @member {number} - * @readonly - */ - - }, { - key: 'currentFrame', - get: function get() { - var currentFrame = Math.floor(this._currentTime) % this._textures.length; - - if (currentFrame < 0) { - currentFrame += this._textures.length; - } - - return currentFrame; - } - }]); - - return AnimatedSprite; -}(core.Sprite); - -exports.default = AnimatedSprite; - -},{"../core":65}],136:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -var _ObservablePoint = require('../core/math/ObservablePoint'); - -var _ObservablePoint2 = _interopRequireDefault(_ObservablePoint); - -var _utils = require('../core/utils'); - -var _settings = require('../core/settings'); - -var _settings2 = _interopRequireDefault(_settings); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * A BitmapText object will create a line or multiple lines of text using bitmap font. To - * split a line you can use '\n', '\r' or '\r\n' in your string. You can generate the fnt files using: - * - * A BitmapText can only be created when the font is loaded - * - * ```js - * // in this case the font is in a file called 'desyrel.fnt' - * let bitmapText = new PIXI.extras.BitmapText("text using a fancy font!", {font: "35px Desyrel", align: "right"}); - * ``` - * - * http://www.angelcode.com/products/bmfont/ for windows or - * http://www.bmglyph.com/ for mac. - * - * @class - * @extends PIXI.Container - * @memberof PIXI.extras - */ -var BitmapText = function (_core$Container) { - _inherits(BitmapText, _core$Container); - - /** - * @param {string} text - The copy that you would like the text to display - * @param {object} style - The style parameters - * @param {string|object} style.font - The font descriptor for the object, can be passed as a string of form - * "24px FontName" or "FontName" or as an object with explicit name/size properties. - * @param {string} [style.font.name] - The bitmap font id - * @param {number} [style.font.size] - The size of the font in pixels, e.g. 24 - * @param {string} [style.align='left'] - Alignment for multiline text ('left', 'center' or 'right'), does not affect - * single line text - * @param {number} [style.tint=0xFFFFFF] - The tint color - */ - function BitmapText(text) { - var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, BitmapText); - - /** - * Private tracker for the width of the overall text - * - * @member {number} - * @private - */ - var _this = _possibleConstructorReturn(this, _core$Container.call(this)); - - _this._textWidth = 0; - - /** - * Private tracker for the height of the overall text - * - * @member {number} - * @private - */ - _this._textHeight = 0; - - /** - * Private tracker for the letter sprite pool. - * - * @member {PIXI.Sprite[]} - * @private - */ - _this._glyphs = []; - - /** - * Private tracker for the current style. - * - * @member {object} - * @private - */ - _this._font = { - tint: style.tint !== undefined ? style.tint : 0xFFFFFF, - align: style.align || 'left', - name: null, - size: 0 - }; - - /** - * Private tracker for the current font. - * - * @member {object} - * @private - */ - _this.font = style.font; // run font setter - - /** - * Private tracker for the current text. - * - * @member {string} - * @private - */ - _this._text = text; - - /** - * The max width of this bitmap text in pixels. If the text provided is longer than the - * value provided, line breaks will be automatically inserted in the last whitespace. - * Disable by setting value to 0 - * - * @member {number} - * @private - */ - _this._maxWidth = 0; - - /** - * The max line height. This is useful when trying to use the total height of the Text, - * ie: when trying to vertically align. - * - * @member {number} - * @private - */ - _this._maxLineHeight = 0; - - /** - * Letter spacing. This is useful for setting the space between characters. - * @member {number} - * @private - */ - _this._letterSpacing = 0; - - /** - * Text anchor. read-only - * - * @member {PIXI.ObservablePoint} - * @private - */ - _this._anchor = new _ObservablePoint2.default(function () { - _this.dirty = true; - }, _this, 0, 0); - - /** - * The dirty state of this object. - * - * @member {boolean} - */ - _this.dirty = false; - - _this.updateText(); - return _this; - } - - /** - * Renders text and updates it when needed - * - * @private - */ - - - BitmapText.prototype.updateText = function updateText() { - var data = BitmapText.fonts[this._font.name]; - var scale = this._font.size / data.size; - var pos = new core.Point(); - var chars = []; - var lineWidths = []; - var text = this.text.replace(/(?:\r\n|\r)/g, '\n'); - var textLength = text.length; - var maxWidth = this._maxWidth * data.size / this._font.size; - - var prevCharCode = null; - var lastLineWidth = 0; - var maxLineWidth = 0; - var line = 0; - var lastBreakPos = -1; - var lastBreakWidth = 0; - var spacesRemoved = 0; - var maxLineHeight = 0; - - for (var i = 0; i < textLength; i++) { - var charCode = text.charCodeAt(i); - var char = text.charAt(i); - - if (/(?:\s)/.test(char)) { - lastBreakPos = i; - lastBreakWidth = lastLineWidth; - } - - if (char === '\r' || char === '\n') { - lineWidths.push(lastLineWidth); - maxLineWidth = Math.max(maxLineWidth, lastLineWidth); - ++line; - ++spacesRemoved; - - pos.x = 0; - pos.y += data.lineHeight; - prevCharCode = null; - continue; - } - - var charData = data.chars[charCode]; - - if (!charData) { - continue; - } - - if (prevCharCode && charData.kerning[prevCharCode]) { - pos.x += charData.kerning[prevCharCode]; - } - - chars.push({ - texture: charData.texture, - line: line, - charCode: charCode, - position: new core.Point(pos.x + charData.xOffset + this._letterSpacing / 2, pos.y + charData.yOffset) - }); - pos.x += charData.xAdvance + this._letterSpacing; - lastLineWidth = pos.x; - maxLineHeight = Math.max(maxLineHeight, charData.yOffset + charData.texture.height); - prevCharCode = charCode; - - if (lastBreakPos !== -1 && maxWidth > 0 && pos.x > maxWidth) { - ++spacesRemoved; - core.utils.removeItems(chars, 1 + lastBreakPos - spacesRemoved, 1 + i - lastBreakPos); - i = lastBreakPos; - lastBreakPos = -1; - - lineWidths.push(lastBreakWidth); - maxLineWidth = Math.max(maxLineWidth, lastBreakWidth); - line++; - - pos.x = 0; - pos.y += data.lineHeight; - prevCharCode = null; - } - } - - var lastChar = text.charAt(text.length - 1); - - if (lastChar !== '\r' && lastChar !== '\n') { - if (/(?:\s)/.test(lastChar)) { - lastLineWidth = lastBreakWidth; - } - - lineWidths.push(lastLineWidth); - maxLineWidth = Math.max(maxLineWidth, lastLineWidth); - } - - var lineAlignOffsets = []; - - for (var _i = 0; _i <= line; _i++) { - var alignOffset = 0; - - if (this._font.align === 'right') { - alignOffset = maxLineWidth - lineWidths[_i]; - } else if (this._font.align === 'center') { - alignOffset = (maxLineWidth - lineWidths[_i]) / 2; - } - - lineAlignOffsets.push(alignOffset); - } - - var lenChars = chars.length; - var tint = this.tint; - - for (var _i2 = 0; _i2 < lenChars; _i2++) { - var c = this._glyphs[_i2]; // get the next glyph sprite - - if (c) { - c.texture = chars[_i2].texture; - } else { - c = new core.Sprite(chars[_i2].texture); - this._glyphs.push(c); - } - - c.position.x = (chars[_i2].position.x + lineAlignOffsets[chars[_i2].line]) * scale; - c.position.y = chars[_i2].position.y * scale; - c.scale.x = c.scale.y = scale; - c.tint = tint; - - if (!c.parent) { - this.addChild(c); - } - } - - // remove unnecessary children. - for (var _i3 = lenChars; _i3 < this._glyphs.length; ++_i3) { - this.removeChild(this._glyphs[_i3]); - } - - this._textWidth = maxLineWidth * scale; - this._textHeight = (pos.y + data.lineHeight) * scale; - - // apply anchor - if (this.anchor.x !== 0 || this.anchor.y !== 0) { - for (var _i4 = 0; _i4 < lenChars; _i4++) { - this._glyphs[_i4].x -= this._textWidth * this.anchor.x; - this._glyphs[_i4].y -= this._textHeight * this.anchor.y; - } - } - this._maxLineHeight = maxLineHeight * scale; - }; - - /** - * Updates the transform of this object - * - * @private - */ - - - BitmapText.prototype.updateTransform = function updateTransform() { - this.validate(); - this.containerUpdateTransform(); - }; - - /** - * Validates text before calling parent's getLocalBounds - * - * @return {PIXI.Rectangle} The rectangular bounding area - */ - - - BitmapText.prototype.getLocalBounds = function getLocalBounds() { - this.validate(); - - return _core$Container.prototype.getLocalBounds.call(this); - }; - - /** - * Updates text when needed - * - * @private - */ - - - BitmapText.prototype.validate = function validate() { - if (this.dirty) { - this.updateText(); - this.dirty = false; - } - }; - - /** - * The tint of the BitmapText object - * - * @member {number} - */ - - - /** - * Register a bitmap font with data and a texture. - * - * @static - * @param {XMLDocument} xml - The XML document data. - * @param {Object.|PIXI.Texture|PIXI.Texture[]} textures - List of textures for each page. - * If providing an object, the key is the `` element's `file` attribute in the FNT file. - * @return {Object} Result font object with font, size, lineHeight and char fields. - */ - BitmapText.registerFont = function registerFont(xml, textures) { - var data = {}; - var info = xml.getElementsByTagName('info')[0]; - var common = xml.getElementsByTagName('common')[0]; - var pages = xml.getElementsByTagName('page'); - var res = (0, _utils.getResolutionOfUrl)(pages[0].getAttribute('file'), _settings2.default.RESOLUTION); - var pagesTextures = {}; - - data.font = info.getAttribute('face'); - data.size = parseInt(info.getAttribute('size'), 10); - data.lineHeight = parseInt(common.getAttribute('lineHeight'), 10) / res; - data.chars = {}; - - // Single texture, convert to list - if (textures instanceof core.Texture) { - textures = [textures]; - } - - // Convert the input Texture, Textures or object - // into a page Texture lookup by "id" - for (var i = 0; i < pages.length; i++) { - var id = pages[i].getAttribute('id'); - var file = pages[i].getAttribute('file'); - - pagesTextures[id] = textures instanceof Array ? textures[i] : textures[file]; - } - - // parse letters - var letters = xml.getElementsByTagName('char'); - - for (var _i5 = 0; _i5 < letters.length; _i5++) { - var letter = letters[_i5]; - var charCode = parseInt(letter.getAttribute('id'), 10); - var page = letter.getAttribute('page') || 0; - var textureRect = new core.Rectangle(parseInt(letter.getAttribute('x'), 10) / res + pagesTextures[page].frame.x / res, parseInt(letter.getAttribute('y'), 10) / res + pagesTextures[page].frame.y / res, parseInt(letter.getAttribute('width'), 10) / res, parseInt(letter.getAttribute('height'), 10) / res); - - data.chars[charCode] = { - xOffset: parseInt(letter.getAttribute('xoffset'), 10) / res, - yOffset: parseInt(letter.getAttribute('yoffset'), 10) / res, - xAdvance: parseInt(letter.getAttribute('xadvance'), 10) / res, - kerning: {}, - texture: new core.Texture(pagesTextures[page].baseTexture, textureRect), - page: page - }; - } - - // parse kernings - var kernings = xml.getElementsByTagName('kerning'); - - for (var _i6 = 0; _i6 < kernings.length; _i6++) { - var kerning = kernings[_i6]; - var first = parseInt(kerning.getAttribute('first'), 10) / res; - var second = parseInt(kerning.getAttribute('second'), 10) / res; - var amount = parseInt(kerning.getAttribute('amount'), 10) / res; - - if (data.chars[second]) { - data.chars[second].kerning[first] = amount; - } - } - - // I'm leaving this as a temporary fix so we can test the bitmap fonts in v3 - // but it's very likely to change - BitmapText.fonts[data.font] = data; - - return data; - }; - - _createClass(BitmapText, [{ - key: 'tint', - get: function get() { - return this._font.tint; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._font.tint = typeof value === 'number' && value >= 0 ? value : 0xFFFFFF; - - this.dirty = true; - } - - /** - * The alignment of the BitmapText object - * - * @member {string} - * @default 'left' - */ - - }, { - key: 'align', - get: function get() { - return this._font.align; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._font.align = value || 'left'; - - this.dirty = true; - } - - /** - * The anchor sets the origin point of the text. - * The default is 0,0 this means the text's origin is the top left - * Setting the anchor to 0.5,0.5 means the text's origin is centered - * Setting the anchor to 1,1 would mean the text's origin point will be the bottom right corner - * - * @member {PIXI.Point | number} - */ - - }, { - key: 'anchor', - get: function get() { - return this._anchor; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (typeof value === 'number') { - this._anchor.set(value); - } else { - this._anchor.copy(value); - } - } - - /** - * The font descriptor of the BitmapText object - * - * @member {string|object} - */ - - }, { - key: 'font', - get: function get() { - return this._font; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (!value) { - return; - } - - if (typeof value === 'string') { - value = value.split(' '); - - this._font.name = value.length === 1 ? value[0] : value.slice(1).join(' '); - this._font.size = value.length >= 2 ? parseInt(value[0], 10) : BitmapText.fonts[this._font.name].size; - } else { - this._font.name = value.name; - this._font.size = typeof value.size === 'number' ? value.size : parseInt(value.size, 10); - } - - this.dirty = true; - } - - /** - * The text of the BitmapText object - * - * @member {string} - */ - - }, { - key: 'text', - get: function get() { - return this._text; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - value = value.toString() || ' '; - if (this._text === value) { - return; - } - this._text = value; - this.dirty = true; - } - - /** - * The max width of this bitmap text in pixels. If the text provided is longer than the - * value provided, line breaks will be automatically inserted in the last whitespace. - * Disable by setting value to 0 - * - * @member {number} - */ - - }, { - key: 'maxWidth', - get: function get() { - return this._maxWidth; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (this._maxWidth === value) { - return; - } - this._maxWidth = value; - this.dirty = true; - } - - /** - * The max line height. This is useful when trying to use the total height of the Text, - * ie: when trying to vertically align. - * - * @member {number} - * @readonly - */ - - }, { - key: 'maxLineHeight', - get: function get() { - this.validate(); - - return this._maxLineHeight; - } - - /** - * The width of the overall text, different from fontSize, - * which is defined in the style object - * - * @member {number} - * @readonly - */ - - }, { - key: 'textWidth', - get: function get() { - this.validate(); - - return this._textWidth; - } - - /** - * Additional space between characters. - * - * @member {number} - */ - - }, { - key: 'letterSpacing', - get: function get() { - return this._letterSpacing; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (this._letterSpacing !== value) { - this._letterSpacing = value; - this.dirty = true; - } - } - - /** - * The height of the overall text, different from fontSize, - * which is defined in the style object - * - * @member {number} - * @readonly - */ - - }, { - key: 'textHeight', - get: function get() { - this.validate(); - - return this._textHeight; - } - }]); - - return BitmapText; -}(core.Container); - -exports.default = BitmapText; - - -BitmapText.fonts = {}; - -},{"../core":65,"../core/math/ObservablePoint":68,"../core/settings":101,"../core/utils":125}],137:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -var _CanvasTinter = require('../core/sprites/canvas/CanvasTinter'); - -var _CanvasTinter2 = _interopRequireDefault(_CanvasTinter); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var tempPoint = new core.Point(); - -/** - * A tiling sprite is a fast way of rendering a tiling image - * - * @class - * @extends PIXI.Sprite - * @memberof PIXI.extras - */ - -var TilingSprite = function (_core$Sprite) { - _inherits(TilingSprite, _core$Sprite); - - /** - * @param {PIXI.Texture} texture - the texture of the tiling sprite - * @param {number} [width=100] - the width of the tiling sprite - * @param {number} [height=100] - the height of the tiling sprite - */ - function TilingSprite(texture) { - var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100; - var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100; - - _classCallCheck(this, TilingSprite); - - /** - * Tile transform - * - * @member {PIXI.TransformStatic} - */ - var _this = _possibleConstructorReturn(this, _core$Sprite.call(this, texture)); - - _this.tileTransform = new core.TransformStatic(); - - // /// private - - /** - * The with of the tiling sprite - * - * @member {number} - * @private - */ - _this._width = width; - - /** - * The height of the tiling sprite - * - * @member {number} - * @private - */ - _this._height = height; - - /** - * Canvas pattern - * - * @type {CanvasPattern} - * @private - */ - _this._canvasPattern = null; - - /** - * transform that is applied to UV to get the texture coords - * - * @member {PIXI.TextureMatrix} - */ - _this.uvTransform = texture.transform || new core.TextureMatrix(texture); - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_renderWebGL' method. - * - * @member {string} - * @default 'tilingSprite' - */ - _this.pluginName = 'tilingSprite'; - - /** - * Whether or not anchor affects uvs - * - * @member {boolean} - * @default false - */ - _this.uvRespectAnchor = false; - return _this; - } - /** - * Changes frame clamping in corresponding textureTransform, shortcut - * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas - * - * @default 0.5 - * @member {number} - */ - - - /** - * @private - */ - TilingSprite.prototype._onTextureUpdate = function _onTextureUpdate() { - if (this.uvTransform) { - this.uvTransform.texture = this._texture; - } - this.cachedTint = 0xFFFFFF; - }; - - /** - * Renders the object using the WebGL renderer - * - * @private - * @param {PIXI.WebGLRenderer} renderer - The renderer - */ - - - TilingSprite.prototype._renderWebGL = function _renderWebGL(renderer) { - // tweak our texture temporarily.. - var texture = this._texture; - - if (!texture || !texture.valid) { - return; - } - - this.tileTransform.updateLocalTransform(); - this.uvTransform.update(); - - renderer.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - }; - - /** - * Renders the object using the Canvas renderer - * - * @private - * @param {PIXI.CanvasRenderer} renderer - a reference to the canvas renderer - */ - - - TilingSprite.prototype._renderCanvas = function _renderCanvas(renderer) { - var texture = this._texture; - - if (!texture.baseTexture.hasLoaded) { - return; - } - - var context = renderer.context; - var transform = this.worldTransform; - var resolution = renderer.resolution; - var isTextureRotated = texture.rotate === 2; - var baseTexture = texture.baseTexture; - var baseTextureResolution = baseTexture.resolution; - var modX = this.tilePosition.x / this.tileScale.x % texture.orig.width * baseTextureResolution; - var modY = this.tilePosition.y / this.tileScale.y % texture.orig.height * baseTextureResolution; - - // create a nice shiny pattern! - if (this._textureID !== this._texture._updateID || this.cachedTint !== this.tint) { - this._textureID = this._texture._updateID; - // cut an object from a spritesheet.. - var tempCanvas = new core.CanvasRenderTarget(texture.orig.width, texture.orig.height, baseTextureResolution); - - // Tint the tiling sprite - if (this.tint !== 0xFFFFFF) { - this.tintedTexture = _CanvasTinter2.default.getTintedTexture(this, this.tint); - tempCanvas.context.drawImage(this.tintedTexture, 0, 0); - } else { - var sx = texture._frame.x * baseTextureResolution; - var sy = texture._frame.y * baseTextureResolution; - var sWidth = texture._frame.width * baseTextureResolution; - var sHeight = texture._frame.height * baseTextureResolution; - var dWidth = (texture.trim ? texture.trim.width : texture.orig.width) * baseTextureResolution; - var dHeight = (texture.trim ? texture.trim.height : texture.orig.height) * baseTextureResolution; - var dx = (texture.trim ? texture.trim.x : 0) * baseTextureResolution; - var dy = (texture.trim ? texture.trim.y : 0) * baseTextureResolution; - - if (isTextureRotated) { - // Apply rotation and transform - tempCanvas.context.rotate(-Math.PI / 2); - tempCanvas.context.translate(-dHeight, 0); - tempCanvas.context.drawImage(baseTexture.source, sx, sy, sWidth, sHeight, -dy, dx, dHeight, dWidth); - } else { - tempCanvas.context.drawImage(baseTexture.source, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); - } - } - - this.cachedTint = this.tint; - this._canvasPattern = tempCanvas.context.createPattern(tempCanvas.canvas, 'repeat'); - } - - // set context state.. - context.globalAlpha = this.worldAlpha; - context.setTransform(transform.a * resolution, transform.b * resolution, transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution); - - renderer.setBlendMode(this.blendMode); - - // fill the pattern! - context.fillStyle = this._canvasPattern; - - // TODO - this should be rolled into the setTransform above.. - context.scale(this.tileScale.x / baseTextureResolution, this.tileScale.y / baseTextureResolution); - - var anchorX = this.anchor.x * -this._width * baseTextureResolution; - var anchorY = this.anchor.y * -this._height * baseTextureResolution; - - if (this.uvRespectAnchor) { - context.translate(modX, modY); - - context.fillRect(-modX + anchorX, -modY + anchorY, this._width / this.tileScale.x * baseTextureResolution, this._height / this.tileScale.y * baseTextureResolution); - } else { - context.translate(modX + anchorX, modY + anchorY); - - context.fillRect(-modX, -modY, this._width / this.tileScale.x * baseTextureResolution, this._height / this.tileScale.y * baseTextureResolution); - } - }; - - /** - * Updates the bounds of the tiling sprite. - * - * @private - */ - - - TilingSprite.prototype._calculateBounds = function _calculateBounds() { - var minX = this._width * -this._anchor._x; - var minY = this._height * -this._anchor._y; - var maxX = this._width * (1 - this._anchor._x); - var maxY = this._height * (1 - this._anchor._y); - - this._bounds.addFrame(this.transform, minX, minY, maxX, maxY); - }; - - /** - * Gets the local bounds of the sprite object. - * - * @param {PIXI.Rectangle} rect - The output rectangle. - * @return {PIXI.Rectangle} The bounds. - */ - - - TilingSprite.prototype.getLocalBounds = function getLocalBounds(rect) { - // we can do a fast local bounds if the sprite has no children! - if (this.children.length === 0) { - this._bounds.minX = this._width * -this._anchor._x; - this._bounds.minY = this._height * -this._anchor._y; - this._bounds.maxX = this._width * (1 - this._anchor._x); - this._bounds.maxY = this._height * (1 - this._anchor._y); - - if (!rect) { - if (!this._localBoundsRect) { - this._localBoundsRect = new core.Rectangle(); - } - - rect = this._localBoundsRect; - } - - return this._bounds.getRectangle(rect); - } - - return _core$Sprite.prototype.getLocalBounds.call(this, rect); - }; - - /** - * Checks if a point is inside this tiling sprite. - * - * @param {PIXI.Point} point - the point to check - * @return {boolean} Whether or not the sprite contains the point. - */ - - - TilingSprite.prototype.containsPoint = function containsPoint(point) { - this.worldTransform.applyInverse(point, tempPoint); - - var width = this._width; - var height = this._height; - var x1 = -width * this.anchor._x; - - if (tempPoint.x >= x1 && tempPoint.x < x1 + width) { - var y1 = -height * this.anchor._y; - - if (tempPoint.y >= y1 && tempPoint.y < y1 + height) { - return true; - } - } - - return false; - }; - - /** - * Destroys this sprite and optionally its texture and children - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options - * have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy - * method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well - * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well - */ - - - TilingSprite.prototype.destroy = function destroy(options) { - _core$Sprite.prototype.destroy.call(this, options); - - this.tileTransform = null; - this.uvTransform = null; - }; - - /** - * Helper function that creates a new tiling sprite based on the source you provide. - * The source can be - frame id, image url, video url, canvas element, video element, base texture - * - * @static - * @param {number|string|PIXI.BaseTexture|HTMLCanvasElement|HTMLVideoElement} source - Source to create texture from - * @param {number} width - the width of the tiling sprite - * @param {number} height - the height of the tiling sprite - * @return {PIXI.Texture} The newly created texture - */ - - - TilingSprite.from = function from(source, width, height) { - return new TilingSprite(core.Texture.from(source), width, height); - }; - - /** - * Helper function that creates a tiling sprite that will use a texture from the TextureCache based on the frameId - * The frame ids are created when a Texture packer file has been loaded - * - * @static - * @param {string} frameId - The frame Id of the texture in the cache - * @param {number} width - the width of the tiling sprite - * @param {number} height - the height of the tiling sprite - * @return {PIXI.extras.TilingSprite} A new TilingSprite using a texture from the texture cache matching the frameId - */ - - - TilingSprite.fromFrame = function fromFrame(frameId, width, height) { - var texture = core.utils.TextureCache[frameId]; - - if (!texture) { - throw new Error('The frameId "' + frameId + '" does not exist in the texture cache ' + this); - } - - return new TilingSprite(texture, width, height); - }; - - /** - * Helper function that creates a sprite that will contain a texture based on an image url - * If the image is not in the texture cache it will be loaded - * - * @static - * @param {string} imageId - The image url of the texture - * @param {number} width - the width of the tiling sprite - * @param {number} height - the height of the tiling sprite - * @param {boolean} [crossorigin] - if you want to specify the cross-origin parameter - * @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - if you want to specify the scale mode, - * see {@link PIXI.SCALE_MODES} for possible values - * @return {PIXI.extras.TilingSprite} A new TilingSprite using a texture from the texture cache matching the image id - */ - - - TilingSprite.fromImage = function fromImage(imageId, width, height, crossorigin, scaleMode) { - return new TilingSprite(core.Texture.fromImage(imageId, crossorigin, scaleMode), width, height); - }; - - /** - * The width of the sprite, setting this will actually modify the scale to achieve the value set - * - * @member {number} - */ - - - _createClass(TilingSprite, [{ - key: 'clampMargin', - get: function get() { - return this.uvTransform.clampMargin; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.uvTransform.clampMargin = value; - this.uvTransform.update(true); - } - - /** - * The scaling of the image that is being tiled - * - * @member {PIXI.ObservablePoint} - */ - - }, { - key: 'tileScale', - get: function get() { - return this.tileTransform.scale; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.tileTransform.scale.copy(value); - } - - /** - * The offset of the image that is being tiled - * - * @member {PIXI.ObservablePoint} - */ - - }, { - key: 'tilePosition', - get: function get() { - return this.tileTransform.position; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.tileTransform.position.copy(value); - } - }, { - key: 'width', - get: function get() { - return this._width; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._width = value; - } - - /** - * The height of the TilingSprite, setting this will actually modify the scale to achieve the value set - * - * @member {number} - */ - - }, { - key: 'height', - get: function get() { - return this._height; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._height = value; - } - }]); - - return TilingSprite; -}(core.Sprite); - -exports.default = TilingSprite; - -},{"../core":65,"../core/sprites/canvas/CanvasTinter":104}],138:[function(require,module,exports){ -'use strict'; - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -var _Texture = require('../core/textures/Texture'); - -var _Texture2 = _interopRequireDefault(_Texture); - -var _BaseTexture = require('../core/textures/BaseTexture'); - -var _BaseTexture2 = _interopRequireDefault(_BaseTexture); - -var _utils = require('../core/utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var DisplayObject = core.DisplayObject; -var _tempMatrix = new core.Matrix(); - -DisplayObject.prototype._cacheAsBitmap = false; -DisplayObject.prototype._cacheData = false; - -// figured theres no point adding ALL the extra variables to prototype. -// this model can hold the information needed. This can also be generated on demand as -// most objects are not cached as bitmaps. -/** - * @class - * @ignore - */ - -var CacheData = -/** - * - */ -function CacheData() { - _classCallCheck(this, CacheData); - - this.textureCacheId = null; - - this.originalRenderWebGL = null; - this.originalRenderCanvas = null; - this.originalCalculateBounds = null; - this.originalGetLocalBounds = null; - - this.originalUpdateTransform = null; - this.originalHitTest = null; - this.originalDestroy = null; - this.originalMask = null; - this.originalFilterArea = null; - this.sprite = null; -}; - -Object.defineProperties(DisplayObject.prototype, { - /** - * Set this to true if you want this display object to be cached as a bitmap. - * This basically takes a snap shot of the display object as it is at that moment. It can - * provide a performance benefit for complex static displayObjects. - * To remove simply set this property to 'false' - * - * IMPORTANT GOTCHA - make sure that all your textures are preloaded BEFORE setting this property to true - * as it will take a snapshot of what is currently there. If the textures have not loaded then they will not appear. - * - * @member {boolean} - * @memberof PIXI.DisplayObject# - */ - cacheAsBitmap: { - get: function get() { - return this._cacheAsBitmap; - }, - set: function set(value) { - if (this._cacheAsBitmap === value) { - return; - } - - this._cacheAsBitmap = value; - - var data = void 0; - - if (value) { - if (!this._cacheData) { - this._cacheData = new CacheData(); - } - - data = this._cacheData; - - data.originalRenderWebGL = this.renderWebGL; - data.originalRenderCanvas = this.renderCanvas; - - data.originalUpdateTransform = this.updateTransform; - data.originalCalculateBounds = this.calculateBounds; - data.originalGetLocalBounds = this.getLocalBounds; - - data.originalDestroy = this.destroy; - - data.originalContainsPoint = this.containsPoint; - - data.originalMask = this._mask; - data.originalFilterArea = this.filterArea; - - this.renderWebGL = this._renderCachedWebGL; - this.renderCanvas = this._renderCachedCanvas; - - this.destroy = this._cacheAsBitmapDestroy; - } else { - data = this._cacheData; - - if (data.sprite) { - this._destroyCachedDisplayObject(); - } - - this.renderWebGL = data.originalRenderWebGL; - this.renderCanvas = data.originalRenderCanvas; - this.calculateBounds = data.originalCalculateBounds; - this.getLocalBounds = data.originalGetLocalBounds; - - this.destroy = data.originalDestroy; - - this.updateTransform = data.originalUpdateTransform; - this.containsPoint = data.originalContainsPoint; - - this._mask = data.originalMask; - this.filterArea = data.originalFilterArea; - } - } - } -}); - -/** - * Renders a cached version of the sprite with WebGL - * - * @private - * @memberof PIXI.DisplayObject# - * @param {PIXI.WebGLRenderer} renderer - the WebGL renderer - */ -DisplayObject.prototype._renderCachedWebGL = function _renderCachedWebGL(renderer) { - if (!this.visible || this.worldAlpha <= 0 || !this.renderable) { - return; - } - - this._initCachedDisplayObject(renderer); - - this._cacheData.sprite.transform._worldID = this.transform._worldID; - this._cacheData.sprite.worldAlpha = this.worldAlpha; - this._cacheData.sprite._renderWebGL(renderer); -}; - -/** - * Prepares the WebGL renderer to cache the sprite - * - * @private - * @memberof PIXI.DisplayObject# - * @param {PIXI.WebGLRenderer} renderer - the WebGL renderer - */ -DisplayObject.prototype._initCachedDisplayObject = function _initCachedDisplayObject(renderer) { - if (this._cacheData && this._cacheData.sprite) { - return; - } - - // make sure alpha is set to 1 otherwise it will get rendered as invisible! - var cacheAlpha = this.alpha; - - this.alpha = 1; - - // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) - renderer.currentRenderer.flush(); - // this.filters= []; - - // next we find the dimensions of the untransformed object - // this function also calls updatetransform on all its children as part of the measuring. - // This means we don't need to update the transform again in this function - // TODO pass an object to clone too? saves having to create a new one each time! - var bounds = this.getLocalBounds().clone(); - - // add some padding! - if (this._filters && this._filters.length) { - var padding = this._filters[0].padding; - - bounds.pad(padding); - } - - bounds.ceil(core.settings.RESOLUTION); - - // for now we cache the current renderTarget that the webGL renderer is currently using. - // this could be more elegent.. - var cachedRenderTarget = renderer._activeRenderTarget; - // We also store the filter stack - I will definitely look to change how this works a little later down the line. - var stack = renderer.filterManager.filterStack; - - // this renderTexture will be used to store the cached DisplayObject - - var renderTexture = core.RenderTexture.create(bounds.width, bounds.height); - - var textureCacheId = 'cacheAsBitmap_' + (0, _utils.uid)(); - - this._cacheData.textureCacheId = textureCacheId; - - _BaseTexture2.default.addToCache(renderTexture.baseTexture, textureCacheId); - _Texture2.default.addToCache(renderTexture, textureCacheId); - - // need to set // - var m = _tempMatrix; - - m.tx = -bounds.x; - m.ty = -bounds.y; - - // reset - this.transform.worldTransform.identity(); - - // set all properties to there original so we can render to a texture - this.renderWebGL = this._cacheData.originalRenderWebGL; - - renderer.render(this, renderTexture, true, m, true); - // now restore the state be setting the new properties - - renderer.bindRenderTarget(cachedRenderTarget); - - renderer.filterManager.filterStack = stack; - - this.renderWebGL = this._renderCachedWebGL; - // the rest is the same as for Canvas - this.updateTransform = this.displayObjectUpdateTransform; - this.calculateBounds = this._calculateCachedBounds; - this.getLocalBounds = this._getCachedLocalBounds; - - this._mask = null; - this.filterArea = null; - - // create our cached sprite - var cachedSprite = new core.Sprite(renderTexture); - - cachedSprite.transform.worldTransform = this.transform.worldTransform; - cachedSprite.anchor.x = -(bounds.x / bounds.width); - cachedSprite.anchor.y = -(bounds.y / bounds.height); - cachedSprite.alpha = cacheAlpha; - cachedSprite._bounds = this._bounds; - - this._cacheData.sprite = cachedSprite; - - this.transform._parentID = -1; - // restore the transform of the cached sprite to avoid the nasty flicker.. - if (!this.parent) { - this.parent = renderer._tempDisplayObjectParent; - this.updateTransform(); - this.parent = null; - } else { - this.updateTransform(); - } - - // map the hit test.. - this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite); -}; - -/** - * Renders a cached version of the sprite with canvas - * - * @private - * @memberof PIXI.DisplayObject# - * @param {PIXI.WebGLRenderer} renderer - the WebGL renderer - */ -DisplayObject.prototype._renderCachedCanvas = function _renderCachedCanvas(renderer) { - if (!this.visible || this.worldAlpha <= 0 || !this.renderable) { - return; - } - - this._initCachedDisplayObjectCanvas(renderer); - - this._cacheData.sprite.worldAlpha = this.worldAlpha; - this._cacheData.sprite._renderCanvas(renderer); -}; - -// TODO this can be the same as the webGL verison.. will need to do a little tweaking first though.. -/** - * Prepares the Canvas renderer to cache the sprite - * - * @private - * @memberof PIXI.DisplayObject# - * @param {PIXI.WebGLRenderer} renderer - the WebGL renderer - */ -DisplayObject.prototype._initCachedDisplayObjectCanvas = function _initCachedDisplayObjectCanvas(renderer) { - if (this._cacheData && this._cacheData.sprite) { - return; - } - - // get bounds actually transforms the object for us already! - var bounds = this.getLocalBounds(); - - var cacheAlpha = this.alpha; - - this.alpha = 1; - - var cachedRenderTarget = renderer.context; - - bounds.ceil(core.settings.RESOLUTION); - - var renderTexture = core.RenderTexture.create(bounds.width, bounds.height); - - var textureCacheId = 'cacheAsBitmap_' + (0, _utils.uid)(); - - this._cacheData.textureCacheId = textureCacheId; - - _BaseTexture2.default.addToCache(renderTexture.baseTexture, textureCacheId); - _Texture2.default.addToCache(renderTexture, textureCacheId); - - // need to set // - var m = _tempMatrix; - - this.transform.localTransform.copy(m); - m.invert(); - - m.tx -= bounds.x; - m.ty -= bounds.y; - - // m.append(this.transform.worldTransform.) - // set all properties to there original so we can render to a texture - this.renderCanvas = this._cacheData.originalRenderCanvas; - - // renderTexture.render(this, m, true); - renderer.render(this, renderTexture, true, m, false); - - // now restore the state be setting the new properties - renderer.context = cachedRenderTarget; - - this.renderCanvas = this._renderCachedCanvas; - // the rest is the same as for WebGL - this.updateTransform = this.displayObjectUpdateTransform; - this.calculateBounds = this._calculateCachedBounds; - this.getLocalBounds = this._getCachedLocalBounds; - - this._mask = null; - this.filterArea = null; - - // create our cached sprite - var cachedSprite = new core.Sprite(renderTexture); - - cachedSprite.transform.worldTransform = this.transform.worldTransform; - cachedSprite.anchor.x = -(bounds.x / bounds.width); - cachedSprite.anchor.y = -(bounds.y / bounds.height); - cachedSprite.alpha = cacheAlpha; - cachedSprite._bounds = this._bounds; - - this._cacheData.sprite = cachedSprite; - - this.transform._parentID = -1; - // restore the transform of the cached sprite to avoid the nasty flicker.. - if (!this.parent) { - this.parent = renderer._tempDisplayObjectParent; - this.updateTransform(); - this.parent = null; - } else { - this.updateTransform(); - } - - // map the hit test.. - this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite); -}; - -/** - * Calculates the bounds of the cached sprite - * - * @private - */ -DisplayObject.prototype._calculateCachedBounds = function _calculateCachedBounds() { - this._bounds.clear(); - this._cacheData.sprite.transform._worldID = this.transform._worldID; - this._cacheData.sprite._calculateBounds(); - this._lastBoundsID = this._boundsID; -}; - -/** - * Gets the bounds of the cached sprite. - * - * @private - * @return {Rectangle} The local bounds. - */ -DisplayObject.prototype._getCachedLocalBounds = function _getCachedLocalBounds() { - return this._cacheData.sprite.getLocalBounds(); -}; - -/** - * Destroys the cached sprite. - * - * @private - */ -DisplayObject.prototype._destroyCachedDisplayObject = function _destroyCachedDisplayObject() { - this._cacheData.sprite._texture.destroy(true); - this._cacheData.sprite = null; - - _BaseTexture2.default.removeFromCache(this._cacheData.textureCacheId); - _Texture2.default.removeFromCache(this._cacheData.textureCacheId); - - this._cacheData.textureCacheId = null; -}; - -/** - * Destroys the cached object. - * - * @private - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options - * have been set to that value. - * Used when destroying containers, see the Container.destroy method. - */ -DisplayObject.prototype._cacheAsBitmapDestroy = function _cacheAsBitmapDestroy(options) { - this.cacheAsBitmap = false; - this.destroy(options); -}; - -},{"../core":65,"../core/textures/BaseTexture":112,"../core/textures/Texture":115,"../core/utils":125}],139:[function(require,module,exports){ -'use strict'; - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -/** - * The instance name of the object. - * - * @memberof PIXI.DisplayObject# - * @member {string} name - */ -core.DisplayObject.prototype.name = null; - -/** - * Returns the display object in the container - * - * @method getChildByName - * @memberof PIXI.Container# - * @param {string} name - instance name - * @return {PIXI.DisplayObject} The child with the specified name. - */ -core.Container.prototype.getChildByName = function getChildByName(name) { - for (var i = 0; i < this.children.length; i++) { - if (this.children[i].name === name) { - return this.children[i]; - } - } - - return null; -}; - -},{"../core":65}],140:[function(require,module,exports){ -'use strict'; - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -/** - * Returns the global position of the displayObject. Does not depend on object scale, rotation and pivot. - * - * @method getGlobalPosition - * @memberof PIXI.DisplayObject# - * @param {Point} point - the point to write the global value to. If null a new point will be returned - * @param {boolean} skipUpdate - setting to true will stop the transforms of the scene graph from - * being updated. This means the calculation returned MAY be out of date BUT will give you a - * nice performance boost - * @return {Point} The updated point - */ -core.DisplayObject.prototype.getGlobalPosition = function getGlobalPosition() { - var point = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new core.Point(); - var skipUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - if (this.parent) { - this.parent.toGlobal(this.position, point, skipUpdate); - } else { - point.x = this.position.x; - point.y = this.position.y; - } - - return point; -}; - -},{"../core":65}],141:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.BitmapText = exports.TilingSpriteRenderer = exports.TilingSprite = exports.AnimatedSprite = undefined; - -var _AnimatedSprite = require('./AnimatedSprite'); - -Object.defineProperty(exports, 'AnimatedSprite', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_AnimatedSprite).default; - } -}); - -var _TilingSprite = require('./TilingSprite'); - -Object.defineProperty(exports, 'TilingSprite', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TilingSprite).default; - } -}); - -var _TilingSpriteRenderer = require('./webgl/TilingSpriteRenderer'); - -Object.defineProperty(exports, 'TilingSpriteRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TilingSpriteRenderer).default; - } -}); - -var _BitmapText = require('./BitmapText'); - -Object.defineProperty(exports, 'BitmapText', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_BitmapText).default; - } -}); - -require('./cacheAsBitmap'); - -require('./getChildByName'); - -require('./getGlobalPosition'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// imported for side effect of extending the prototype only, contains no exports - -},{"./AnimatedSprite":135,"./BitmapText":136,"./TilingSprite":137,"./cacheAsBitmap":138,"./getChildByName":139,"./getGlobalPosition":140,"./webgl/TilingSpriteRenderer":142}],142:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _const = require('../../core/const'); - -var _path = require('path'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var tempMat = new core.Matrix(); - -/** - * WebGL renderer plugin for tiling sprites - * - * @class - * @memberof PIXI.extras - * @extends PIXI.ObjectRenderer - */ - -var TilingSpriteRenderer = function (_core$ObjectRenderer) { - _inherits(TilingSpriteRenderer, _core$ObjectRenderer); - - /** - * constructor for renderer - * - * @param {WebGLRenderer} renderer The renderer this tiling awesomeness works for. - */ - function TilingSpriteRenderer(renderer) { - _classCallCheck(this, TilingSpriteRenderer); - - var _this = _possibleConstructorReturn(this, _core$ObjectRenderer.call(this, renderer)); - - _this.shader = null; - _this.simpleShader = null; - _this.quad = null; - return _this; - } - - /** - * Sets up the renderer context and necessary buffers. - * - * @private - */ - - - TilingSpriteRenderer.prototype.onContextChange = function onContextChange() { - var gl = this.renderer.gl; - - this.shader = new core.Shader(gl, 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n', 'varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = mod(vTextureCoord - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 sample = texture2D(uSampler, coord);\n gl_FragColor = sample * uColor;\n}\n'); - this.simpleShader = new core.Shader(gl, 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n', 'varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 sample = texture2D(uSampler, vTextureCoord);\n gl_FragColor = sample * uColor;\n}\n'); - - this.renderer.bindVao(null); - this.quad = new core.Quad(gl, this.renderer.state.attribState); - this.quad.initVao(this.shader); - }; - - /** - * - * @param {PIXI.extras.TilingSprite} ts tilingSprite to be rendered - */ - - - TilingSpriteRenderer.prototype.render = function render(ts) { - var renderer = this.renderer; - var quad = this.quad; - - renderer.bindVao(quad.vao); - - var vertices = quad.vertices; - - vertices[0] = vertices[6] = ts._width * -ts.anchor.x; - vertices[1] = vertices[3] = ts._height * -ts.anchor.y; - - vertices[2] = vertices[4] = ts._width * (1.0 - ts.anchor.x); - vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); - - if (ts.uvRespectAnchor) { - vertices = quad.uvs; - - vertices[0] = vertices[6] = -ts.anchor.x; - vertices[1] = vertices[3] = -ts.anchor.y; - - vertices[2] = vertices[4] = 1.0 - ts.anchor.x; - vertices[5] = vertices[7] = 1.0 - ts.anchor.y; - } - - quad.upload(); - - var tex = ts._texture; - var baseTex = tex.baseTexture; - var lt = ts.tileTransform.localTransform; - var uv = ts.uvTransform; - var isSimple = baseTex.isPowerOfTwo && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height; - - // auto, force repeat wrapMode for big tiling textures - if (isSimple) { - if (!baseTex._glTextures[renderer.CONTEXT_UID]) { - if (baseTex.wrapMode === _const.WRAP_MODES.CLAMP) { - baseTex.wrapMode = _const.WRAP_MODES.REPEAT; - } - } else { - isSimple = baseTex.wrapMode !== _const.WRAP_MODES.CLAMP; - } - } - - var shader = isSimple ? this.simpleShader : this.shader; - - renderer.bindShader(shader); - - var w = tex.width; - var h = tex.height; - var W = ts._width; - var H = ts._height; - - tempMat.set(lt.a * w / W, lt.b * w / H, lt.c * h / W, lt.d * h / H, lt.tx / W, lt.ty / H); - - // that part is the same as above: - // tempMat.identity(); - // tempMat.scale(tex.width, tex.height); - // tempMat.prepend(lt); - // tempMat.scale(1.0 / ts._width, 1.0 / ts._height); - - tempMat.invert(); - if (isSimple) { - tempMat.prepend(uv.mapCoord); - } else { - shader.uniforms.uMapCoord = uv.mapCoord.toArray(true); - shader.uniforms.uClampFrame = uv.uClampFrame; - shader.uniforms.uClampOffset = uv.uClampOffset; - } - - shader.uniforms.uTransform = tempMat.toArray(true); - shader.uniforms.uColor = core.utils.premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, baseTex.premultipliedAlpha); - shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true); - - shader.uniforms.uSampler = renderer.bindTexture(tex); - - renderer.setBlendMode(core.utils.correctBlendMode(ts.blendMode, baseTex.premultipliedAlpha)); - - quad.vao.draw(this.renderer.gl.TRIANGLES, 6, 0); - }; - - return TilingSpriteRenderer; -}(core.ObjectRenderer); - -exports.default = TilingSpriteRenderer; - - -core.WebGLRenderer.registerPlugin('tilingSprite', TilingSpriteRenderer); - -},{"../../core":65,"../../core/const":46,"path":8}],143:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _path = require('path'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Simplest filter - applies alpha - * - * Use this instead of Container's alpha property to avoid visual layering of individual elements. - * AlphaFilter applies alpha evenly across the entire display object and any opaque elements it contains. - * If elements are not opaque, they will blend with each other anyway. - * - * Very handy if you want to use common features of all filters: - * - * 1. Assign a blendMode to this filter, blend all elements inside display object with background. - * - * 2. To use clipping in display coordinates, assign a filterArea to the same container that has this filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -var AlphaFilter = function (_core$Filter) { - _inherits(AlphaFilter, _core$Filter); - - /** - * @param {number} [alpha=1] Amount of alpha from 0 to 1, where 0 is transparent - */ - function AlphaFilter() { - var alpha = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1.0; - - _classCallCheck(this, AlphaFilter); - - var _this = _possibleConstructorReturn(this, _core$Filter.call(this, - // vertex shader - 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}', - // fragment shader - 'varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float uAlpha;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;\n}\n')); - - _this.alpha = alpha; - _this.glShaderKey = 'alpha'; - return _this; - } - - /** - * Coefficient for alpha multiplication - * - * @member {number} - * @default 1 - */ - - - _createClass(AlphaFilter, [{ - key: 'alpha', - get: function get() { - return this.uniforms.uAlpha; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.uniforms.uAlpha = value; - } - }]); - - return AlphaFilter; -}(core.Filter); - -exports.default = AlphaFilter; - -},{"../../core":65,"path":8}],144:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _BlurXFilter = require('./BlurXFilter'); - -var _BlurXFilter2 = _interopRequireDefault(_BlurXFilter); - -var _BlurYFilter = require('./BlurYFilter'); - -var _BlurYFilter2 = _interopRequireDefault(_BlurYFilter); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The BlurFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -var BlurFilter = function (_core$Filter) { - _inherits(BlurFilter, _core$Filter); - - /** - * @param {number} strength - The strength of the blur filter. - * @param {number} quality - The quality of the blur filter. - * @param {number} resolution - The resolution of the blur filter. - * @param {number} [kernelSize=5] - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15. - */ - function BlurFilter(strength, quality, resolution, kernelSize) { - _classCallCheck(this, BlurFilter); - - var _this = _possibleConstructorReturn(this, _core$Filter.call(this)); - - _this.blurXFilter = new _BlurXFilter2.default(strength, quality, resolution, kernelSize); - _this.blurYFilter = new _BlurYFilter2.default(strength, quality, resolution, kernelSize); - - _this.padding = 0; - _this.resolution = resolution || core.settings.RESOLUTION; - _this.quality = quality || 4; - _this.blur = strength || 8; - return _this; - } - - /** - * Applies the filter. - * - * @param {PIXI.FilterManager} filterManager - The manager. - * @param {PIXI.RenderTarget} input - The input target. - * @param {PIXI.RenderTarget} output - The output target. - */ - - - BlurFilter.prototype.apply = function apply(filterManager, input, output) { - var renderTarget = filterManager.getRenderTarget(true); - - this.blurXFilter.apply(filterManager, input, renderTarget, true); - this.blurYFilter.apply(filterManager, renderTarget, output, false); - - filterManager.returnRenderTarget(renderTarget); - }; - - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @default 2 - */ - - - _createClass(BlurFilter, [{ - key: 'blur', - get: function get() { - return this.blurXFilter.blur; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2; - } - - /** - * Sets the number of passes for blur. More passes means higher quaility bluring. - * - * @member {number} - * @default 1 - */ - - }, { - key: 'quality', - get: function get() { - return this.blurXFilter.quality; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.blurXFilter.quality = this.blurYFilter.quality = value; - } - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @default 2 - */ - - }, { - key: 'blurX', - get: function get() { - return this.blurXFilter.blur; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.blurXFilter.blur = value; - this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2; - } - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @default 2 - */ - - }, { - key: 'blurY', - get: function get() { - return this.blurYFilter.blur; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.blurYFilter.blur = value; - this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2; - } - - /** - * Sets the blendmode of the filter - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - */ - - }, { - key: 'blendMode', - get: function get() { - return this.blurYFilter._blendMode; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.blurYFilter._blendMode = value; - } - }]); - - return BlurFilter; -}(core.Filter); - -exports.default = BlurFilter; - -},{"../../core":65,"./BlurXFilter":145,"./BlurYFilter":146}],145:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _generateBlurVertSource = require('./generateBlurVertSource'); - -var _generateBlurVertSource2 = _interopRequireDefault(_generateBlurVertSource); - -var _generateBlurFragSource = require('./generateBlurFragSource'); - -var _generateBlurFragSource2 = _interopRequireDefault(_generateBlurFragSource); - -var _getMaxBlurKernelSize = require('./getMaxBlurKernelSize'); - -var _getMaxBlurKernelSize2 = _interopRequireDefault(_getMaxBlurKernelSize); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The BlurXFilter applies a horizontal Gaussian blur to an object. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -var BlurXFilter = function (_core$Filter) { - _inherits(BlurXFilter, _core$Filter); - - /** - * @param {number} strength - The strength of the blur filter. - * @param {number} quality - The quality of the blur filter. - * @param {number} resolution - The resolution of the blur filter. - * @param {number} [kernelSize=5] - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15. - */ - function BlurXFilter(strength, quality, resolution, kernelSize) { - _classCallCheck(this, BlurXFilter); - - kernelSize = kernelSize || 5; - var vertSrc = (0, _generateBlurVertSource2.default)(kernelSize, true); - var fragSrc = (0, _generateBlurFragSource2.default)(kernelSize); - - var _this = _possibleConstructorReturn(this, _core$Filter.call(this, - // vertex shader - vertSrc, - // fragment shader - fragSrc)); - - _this.resolution = resolution || core.settings.RESOLUTION; - - _this._quality = 0; - - _this.quality = quality || 4; - _this.strength = strength || 8; - - _this.firstRun = true; - return _this; - } - - /** - * Applies the filter. - * - * @param {PIXI.FilterManager} filterManager - The manager. - * @param {PIXI.RenderTarget} input - The input target. - * @param {PIXI.RenderTarget} output - The output target. - * @param {boolean} clear - Should the output be cleared before rendering? - */ - - - BlurXFilter.prototype.apply = function apply(filterManager, input, output, clear) { - if (this.firstRun) { - var gl = filterManager.renderer.gl; - var kernelSize = (0, _getMaxBlurKernelSize2.default)(gl); - - this.vertexSrc = (0, _generateBlurVertSource2.default)(kernelSize, true); - this.fragmentSrc = (0, _generateBlurFragSource2.default)(kernelSize); - - this.firstRun = false; - } - - this.uniforms.strength = 1 / output.size.width * (output.size.width / input.size.width); - - // screen space! - this.uniforms.strength *= this.strength; - this.uniforms.strength /= this.passes; // / this.passes//Math.pow(1, this.passes); - - if (this.passes === 1) { - filterManager.applyFilter(this, input, output, clear); - } else { - var renderTarget = filterManager.getRenderTarget(true); - var flip = input; - var flop = renderTarget; - - for (var i = 0; i < this.passes - 1; i++) { - filterManager.applyFilter(this, flip, flop, true); - - var temp = flop; - - flop = flip; - flip = temp; - } - - filterManager.applyFilter(this, flip, output, clear); - - filterManager.returnRenderTarget(renderTarget); - } - }; - - /** - * Sets the strength of both the blur. - * - * @member {number} - * @default 16 - */ - - - _createClass(BlurXFilter, [{ - key: 'blur', - get: function get() { - return this.strength; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.padding = Math.abs(value) * 2; - this.strength = value; - } - - /** - * Sets the quality of the blur by modifying the number of passes. More passes means higher - * quaility bluring but the lower the performance. - * - * @member {number} - * @default 4 - */ - - }, { - key: 'quality', - get: function get() { - return this._quality; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._quality = value; - this.passes = value; - } - }]); - - return BlurXFilter; -}(core.Filter); - -exports.default = BlurXFilter; - -},{"../../core":65,"./generateBlurFragSource":147,"./generateBlurVertSource":148,"./getMaxBlurKernelSize":149}],146:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _generateBlurVertSource = require('./generateBlurVertSource'); - -var _generateBlurVertSource2 = _interopRequireDefault(_generateBlurVertSource); - -var _generateBlurFragSource = require('./generateBlurFragSource'); - -var _generateBlurFragSource2 = _interopRequireDefault(_generateBlurFragSource); - -var _getMaxBlurKernelSize = require('./getMaxBlurKernelSize'); - -var _getMaxBlurKernelSize2 = _interopRequireDefault(_getMaxBlurKernelSize); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The BlurYFilter applies a horizontal Gaussian blur to an object. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -var BlurYFilter = function (_core$Filter) { - _inherits(BlurYFilter, _core$Filter); - - /** - * @param {number} strength - The strength of the blur filter. - * @param {number} quality - The quality of the blur filter. - * @param {number} resolution - The resolution of the blur filter. - * @param {number} [kernelSize=5] - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15. - */ - function BlurYFilter(strength, quality, resolution, kernelSize) { - _classCallCheck(this, BlurYFilter); - - kernelSize = kernelSize || 5; - var vertSrc = (0, _generateBlurVertSource2.default)(kernelSize, false); - var fragSrc = (0, _generateBlurFragSource2.default)(kernelSize); - - var _this = _possibleConstructorReturn(this, _core$Filter.call(this, - // vertex shader - vertSrc, - // fragment shader - fragSrc)); - - _this.resolution = resolution || core.settings.RESOLUTION; - - _this._quality = 0; - - _this.quality = quality || 4; - _this.strength = strength || 8; - - _this.firstRun = true; - return _this; - } - - /** - * Applies the filter. - * - * @param {PIXI.FilterManager} filterManager - The manager. - * @param {PIXI.RenderTarget} input - The input target. - * @param {PIXI.RenderTarget} output - The output target. - * @param {boolean} clear - Should the output be cleared before rendering? - */ - - - BlurYFilter.prototype.apply = function apply(filterManager, input, output, clear) { - if (this.firstRun) { - var gl = filterManager.renderer.gl; - var kernelSize = (0, _getMaxBlurKernelSize2.default)(gl); - - this.vertexSrc = (0, _generateBlurVertSource2.default)(kernelSize, false); - this.fragmentSrc = (0, _generateBlurFragSource2.default)(kernelSize); - - this.firstRun = false; - } - - this.uniforms.strength = 1 / output.size.height * (output.size.height / input.size.height); - - this.uniforms.strength *= this.strength; - this.uniforms.strength /= this.passes; - - if (this.passes === 1) { - filterManager.applyFilter(this, input, output, clear); - } else { - var renderTarget = filterManager.getRenderTarget(true); - var flip = input; - var flop = renderTarget; - - for (var i = 0; i < this.passes - 1; i++) { - filterManager.applyFilter(this, flip, flop, true); - - var temp = flop; - - flop = flip; - flip = temp; - } - - filterManager.applyFilter(this, flip, output, clear); - - filterManager.returnRenderTarget(renderTarget); - } - }; - - /** - * Sets the strength of both the blur. - * - * @member {number} - * @default 2 - */ - - - _createClass(BlurYFilter, [{ - key: 'blur', - get: function get() { - return this.strength; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.padding = Math.abs(value) * 2; - this.strength = value; - } - - /** - * Sets the quality of the blur by modifying the number of passes. More passes means higher - * quaility bluring but the lower the performance. - * - * @member {number} - * @default 4 - */ - - }, { - key: 'quality', - get: function get() { - return this._quality; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._quality = value; - this.passes = value; - } - }]); - - return BlurYFilter; -}(core.Filter); - -exports.default = BlurYFilter; - -},{"../../core":65,"./generateBlurFragSource":147,"./generateBlurVertSource":148,"./getMaxBlurKernelSize":149}],147:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = generateFragBlurSource; -var GAUSSIAN_VALUES = { - 5: [0.153388, 0.221461, 0.250301], - 7: [0.071303, 0.131514, 0.189879, 0.214607], - 9: [0.028532, 0.067234, 0.124009, 0.179044, 0.20236], - 11: [0.0093, 0.028002, 0.065984, 0.121703, 0.175713, 0.198596], - 13: [0.002406, 0.009255, 0.027867, 0.065666, 0.121117, 0.174868, 0.197641], - 15: [0.000489, 0.002403, 0.009246, 0.02784, 0.065602, 0.120999, 0.174697, 0.197448] -}; - -var fragTemplate = ['varying vec2 vBlurTexCoords[%size%];', 'uniform sampler2D uSampler;', 'void main(void)', '{', ' gl_FragColor = vec4(0.0);', ' %blur%', '}'].join('\n'); - -function generateFragBlurSource(kernelSize) { - var kernel = GAUSSIAN_VALUES[kernelSize]; - var halfLength = kernel.length; - - var fragSource = fragTemplate; - - var blurLoop = ''; - var template = 'gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;'; - var value = void 0; - - for (var i = 0; i < kernelSize; i++) { - var blur = template.replace('%index%', i); - - value = i; - - if (i >= halfLength) { - value = kernelSize - i - 1; - } - - blur = blur.replace('%value%', kernel[value]); - - blurLoop += blur; - blurLoop += '\n'; - } - - fragSource = fragSource.replace('%blur%', blurLoop); - fragSource = fragSource.replace('%size%', kernelSize); - - return fragSource; -} - -},{}],148:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.default = generateVertBlurSource; -var vertTemplate = ['attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', 'uniform float strength;', 'uniform mat3 projectionMatrix;', 'varying vec2 vBlurTexCoords[%size%];', 'void main(void)', '{', 'gl_Position = vec4((projectionMatrix * vec3((aVertexPosition), 1.0)).xy, 0.0, 1.0);', '%blur%', '}'].join('\n'); - -function generateVertBlurSource(kernelSize, x) { - var halfLength = Math.ceil(kernelSize / 2); - - var vertSource = vertTemplate; - - var blurLoop = ''; - var template = void 0; - // let value; - - if (x) { - template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(%sampleIndex% * strength, 0.0);'; - } else { - template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(0.0, %sampleIndex% * strength);'; - } - - for (var i = 0; i < kernelSize; i++) { - var blur = template.replace('%index%', i); - - // value = i; - - // if(i >= halfLength) - // { - // value = kernelSize - i - 1; - // } - - blur = blur.replace('%sampleIndex%', i - (halfLength - 1) + '.0'); - - blurLoop += blur; - blurLoop += '\n'; - } - - vertSource = vertSource.replace('%blur%', blurLoop); - vertSource = vertSource.replace('%size%', kernelSize); - - return vertSource; -} - -},{}],149:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; -exports.default = getMaxKernelSize; -function getMaxKernelSize(gl) { - var maxVaryings = gl.getParameter(gl.MAX_VARYING_VECTORS); - var kernelSize = 15; - - while (kernelSize > maxVaryings) { - kernelSize -= 2; - } - - return kernelSize; -} - -},{}],150:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _path = require('path'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The ColorMatrixFilter class lets you apply a 5x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * ```js - * let colorMatrix = new PIXI.filters.ColorMatrixFilter(); - * container.filters = [colorMatrix]; - * colorMatrix.contrast(2); - * ``` - * @author Clément Chenebault - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -var ColorMatrixFilter = function (_core$Filter) { - _inherits(ColorMatrixFilter, _core$Filter); - - /** - * - */ - function ColorMatrixFilter() { - _classCallCheck(this, ColorMatrixFilter); - - var _this = _possibleConstructorReturn(this, _core$Filter.call(this, - // vertex shader - 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}', - // fragment shader - 'varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\nuniform float uAlpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (uAlpha == 0.0) {\n gl_FragColor = c;\n return;\n }\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (c.a > 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n')); - - _this.uniforms.m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]; - - _this.alpha = 1; - return _this; - } - - /** - * Transforms current matrix and set the new one - * - * @param {number[]} matrix - 5x4 matrix - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype._loadMatrix = function _loadMatrix(matrix) { - var multiply = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - var newMatrix = matrix; - - if (multiply) { - this._multiply(newMatrix, this.uniforms.m, matrix); - newMatrix = this._colorMatrix(newMatrix); - } - - // set the new matrix - this.uniforms.m = newMatrix; - }; - - /** - * Multiplies two mat5's - * - * @private - * @param {number[]} out - 5x4 matrix the receiving matrix - * @param {number[]} a - 5x4 matrix the first operand - * @param {number[]} b - 5x4 matrix the second operand - * @returns {number[]} 5x4 matrix - */ - - - ColorMatrixFilter.prototype._multiply = function _multiply(out, a, b) { - // Red Channel - out[0] = a[0] * b[0] + a[1] * b[5] + a[2] * b[10] + a[3] * b[15]; - out[1] = a[0] * b[1] + a[1] * b[6] + a[2] * b[11] + a[3] * b[16]; - out[2] = a[0] * b[2] + a[1] * b[7] + a[2] * b[12] + a[3] * b[17]; - out[3] = a[0] * b[3] + a[1] * b[8] + a[2] * b[13] + a[3] * b[18]; - out[4] = a[0] * b[4] + a[1] * b[9] + a[2] * b[14] + a[3] * b[19] + a[4]; - - // Green Channel - out[5] = a[5] * b[0] + a[6] * b[5] + a[7] * b[10] + a[8] * b[15]; - out[6] = a[5] * b[1] + a[6] * b[6] + a[7] * b[11] + a[8] * b[16]; - out[7] = a[5] * b[2] + a[6] * b[7] + a[7] * b[12] + a[8] * b[17]; - out[8] = a[5] * b[3] + a[6] * b[8] + a[7] * b[13] + a[8] * b[18]; - out[9] = a[5] * b[4] + a[6] * b[9] + a[7] * b[14] + a[8] * b[19] + a[9]; - - // Blue Channel - out[10] = a[10] * b[0] + a[11] * b[5] + a[12] * b[10] + a[13] * b[15]; - out[11] = a[10] * b[1] + a[11] * b[6] + a[12] * b[11] + a[13] * b[16]; - out[12] = a[10] * b[2] + a[11] * b[7] + a[12] * b[12] + a[13] * b[17]; - out[13] = a[10] * b[3] + a[11] * b[8] + a[12] * b[13] + a[13] * b[18]; - out[14] = a[10] * b[4] + a[11] * b[9] + a[12] * b[14] + a[13] * b[19] + a[14]; - - // Alpha Channel - out[15] = a[15] * b[0] + a[16] * b[5] + a[17] * b[10] + a[18] * b[15]; - out[16] = a[15] * b[1] + a[16] * b[6] + a[17] * b[11] + a[18] * b[16]; - out[17] = a[15] * b[2] + a[16] * b[7] + a[17] * b[12] + a[18] * b[17]; - out[18] = a[15] * b[3] + a[16] * b[8] + a[17] * b[13] + a[18] * b[18]; - out[19] = a[15] * b[4] + a[16] * b[9] + a[17] * b[14] + a[18] * b[19] + a[19]; - - return out; - }; - - /** - * Create a Float32 Array and normalize the offset component to 0-1 - * - * @private - * @param {number[]} matrix - 5x4 matrix - * @return {number[]} 5x4 matrix with all values between 0-1 - */ - - - ColorMatrixFilter.prototype._colorMatrix = function _colorMatrix(matrix) { - // Create a Float32 Array and normalize the offset component to 0-1 - var m = new Float32Array(matrix); - - m[4] /= 255; - m[9] /= 255; - m[14] /= 255; - m[19] /= 255; - - return m; - }; - - /** - * Adjusts brightness - * - * @param {number} b - value of the brigthness (0-1, where 0 is black) - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.brightness = function brightness(b, multiply) { - var matrix = [b, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Set the matrices in grey scales - * - * @param {number} scale - value of the grey (0-1, where 0 is black) - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.greyscale = function greyscale(scale, multiply) { - var matrix = [scale, scale, scale, 0, 0, scale, scale, scale, 0, 0, scale, scale, scale, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Set the black and white matrice. - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.blackAndWhite = function blackAndWhite(multiply) { - var matrix = [0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Set the hue property of the color - * - * @param {number} rotation - in degrees - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.hue = function hue(rotation, multiply) { - rotation = (rotation || 0) / 180 * Math.PI; - - var cosR = Math.cos(rotation); - var sinR = Math.sin(rotation); - var sqrt = Math.sqrt; - - /* a good approximation for hue rotation - This matrix is far better than the versions with magic luminance constants - formerly used here, but also used in the starling framework (flash) and known from this - old part of the internet: quasimondo.com/archives/000565.php - This new matrix is based on rgb cube rotation in space. Look here for a more descriptive - implementation as a shader not a general matrix: - https://github.com/evanw/glfx.js/blob/58841c23919bd59787effc0333a4897b43835412/src/filters/adjust/huesaturation.js - This is the source for the code: - see http://stackoverflow.com/questions/8507885/shift-hue-of-an-rgb-color/8510751#8510751 - */ - - var w = 1 / 3; - var sqrW = sqrt(w); // weight is - - var a00 = cosR + (1.0 - cosR) * w; - var a01 = w * (1.0 - cosR) - sqrW * sinR; - var a02 = w * (1.0 - cosR) + sqrW * sinR; - - var a10 = w * (1.0 - cosR) + sqrW * sinR; - var a11 = cosR + w * (1.0 - cosR); - var a12 = w * (1.0 - cosR) - sqrW * sinR; - - var a20 = w * (1.0 - cosR) - sqrW * sinR; - var a21 = w * (1.0 - cosR) + sqrW * sinR; - var a22 = cosR + w * (1.0 - cosR); - - var matrix = [a00, a01, a02, 0, 0, a10, a11, a12, 0, 0, a20, a21, a22, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Set the contrast matrix, increase the separation between dark and bright - * Increase contrast : shadows darker and highlights brighter - * Decrease contrast : bring the shadows up and the highlights down - * - * @param {number} amount - value of the contrast (0-1) - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.contrast = function contrast(amount, multiply) { - var v = (amount || 0) + 1; - var o = -0.5 * (v - 1); - - var matrix = [v, 0, 0, 0, o, 0, v, 0, 0, o, 0, 0, v, 0, o, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Set the saturation matrix, increase the separation between colors - * Increase saturation : increase contrast, brightness, and sharpness - * - * @param {number} amount - The saturation amount (0-1) - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.saturate = function saturate() { - var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; - var multiply = arguments[1]; - - var x = amount * 2 / 3 + 1; - var y = (x - 1) * -0.5; - - var matrix = [x, y, y, 0, 0, y, x, y, 0, 0, y, y, x, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Desaturate image (remove color) - * - * Call the saturate function - * - */ - - - ColorMatrixFilter.prototype.desaturate = function desaturate() // eslint-disable-line no-unused-vars - { - this.saturate(-1); - }; - - /** - * Negative image (inverse of classic rgb matrix) - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.negative = function negative(multiply) { - var matrix = [-1, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 1, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Sepia image - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.sepia = function sepia(multiply) { - var matrix = [0.393, 0.7689999, 0.18899999, 0, 0, 0.349, 0.6859999, 0.16799999, 0, 0, 0.272, 0.5339999, 0.13099999, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Color motion picture process invented in 1916 (thanks Dominic Szablewski) - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.technicolor = function technicolor(multiply) { - var matrix = [1.9125277891456083, -0.8545344976951645, -0.09155508482755585, 0, 11.793603434377337, -0.3087833385928097, 1.7658908555458428, -0.10601743074722245, 0, -70.35205161461398, -0.231103377548616, -0.7501899197440212, 1.847597816108189, 0, 30.950940869491138, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Polaroid filter - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.polaroid = function polaroid(multiply) { - var matrix = [1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016, 1.483, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Filter who transforms : Red -> Blue and Blue -> Red - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.toBGR = function toBGR(multiply) { - var matrix = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Color reversal film introduced by Eastman Kodak in 1935. (thanks Dominic Szablewski) - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.kodachrome = function kodachrome(multiply) { - var matrix = [1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502, -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203, -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Brown delicious browni filter (thanks Dominic Szablewski) - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.browni = function browni(multiply) { - var matrix = [0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, 47.43192855600873, -0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, -36.96841498319127, 0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, -7.562075277591283, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Vintage filter (thanks Dominic Szablewski) - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.vintage = function vintage(multiply) { - var matrix = [0.6279345635605994, 0.3202183420819367, -0.03965408211312453, 0, 9.651285835294123, 0.02578397704808868, 0.6441188644374771, 0.03259127616149294, 0, 7.462829176470591, 0.0466055556782719, -0.0851232987247891, 0.5241648018700465, 0, 5.159190588235296, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * We don't know exactly what it does, kind of gradient map, but funny to play with! - * - * @param {number} desaturation - Tone values. - * @param {number} toned - Tone values. - * @param {string} lightColor - Tone values, example: `0xFFE580` - * @param {string} darkColor - Tone values, example: `0xFFE580` - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.colorTone = function colorTone(desaturation, toned, lightColor, darkColor, multiply) { - desaturation = desaturation || 0.2; - toned = toned || 0.15; - lightColor = lightColor || 0xFFE580; - darkColor = darkColor || 0x338000; - - var lR = (lightColor >> 16 & 0xFF) / 255; - var lG = (lightColor >> 8 & 0xFF) / 255; - var lB = (lightColor & 0xFF) / 255; - - var dR = (darkColor >> 16 & 0xFF) / 255; - var dG = (darkColor >> 8 & 0xFF) / 255; - var dB = (darkColor & 0xFF) / 255; - - var matrix = [0.3, 0.59, 0.11, 0, 0, lR, lG, lB, desaturation, 0, dR, dG, dB, toned, 0, lR - dR, lG - dG, lB - dB, 0, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Night effect - * - * @param {number} intensity - The intensity of the night effect. - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.night = function night(intensity, multiply) { - intensity = intensity || 0.1; - var matrix = [intensity * -2.0, -intensity, 0, 0, 0, -intensity, 0, intensity, 0, 0, 0, intensity, intensity * 2.0, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Predator effect - * - * Erase the current matrix by setting a new indepent one - * - * @param {number} amount - how much the predator feels his future victim - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.predator = function predator(amount, multiply) { - var matrix = [ - // row 1 - 11.224130630493164 * amount, -4.794486999511719 * amount, -2.8746118545532227 * amount, 0 * amount, 0.40342438220977783 * amount, - // row 2 - -3.6330697536468506 * amount, 9.193157196044922 * amount, -2.951810836791992 * amount, 0 * amount, -1.316135048866272 * amount, - // row 3 - -3.2184197902679443 * amount, -4.2375030517578125 * amount, 7.476448059082031 * amount, 0 * amount, 0.8044459223747253 * amount, - // row 4 - 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * LSD effect - * - * Multiply the current matrix - * - * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, - * just set the current matrix with @param matrix - */ - - - ColorMatrixFilter.prototype.lsd = function lsd(multiply) { - var matrix = [2, -0.4, 0.5, 0, 0, -0.5, 2, -0.4, 0, 0, -0.4, -0.5, 3, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, multiply); - }; - - /** - * Erase the current matrix by setting the default one - * - */ - - - ColorMatrixFilter.prototype.reset = function reset() { - var matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]; - - this._loadMatrix(matrix, false); - }; - - /** - * The matrix of the color matrix filter - * - * @member {number[]} - * @default [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0] - */ - - - _createClass(ColorMatrixFilter, [{ - key: 'matrix', - get: function get() { - return this.uniforms.m; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.uniforms.m = value; - } - - /** - * The opacity value to use when mixing the original and resultant colors. - * - * When the value is 0, the original color is used without modification. - * When the value is 1, the result color is used. - * When in the range (0, 1) the color is interpolated between the original and result by this amount. - * - * @member {number} - * @default 1 - */ - - }, { - key: 'alpha', - get: function get() { - return this.uniforms.uAlpha; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.uniforms.uAlpha = value; - } - }]); - - return ColorMatrixFilter; -}(core.Filter); - -// Americanized alias - - -exports.default = ColorMatrixFilter; -ColorMatrixFilter.prototype.grayscale = ColorMatrixFilter.prototype.greyscale; - -},{"../../core":65,"path":8}],151:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _path = require('path'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The DisplacementFilter class uses the pixel values from the specified texture - * (called the displacement map) to perform a displacement of an object. You can - * use this filter to apply all manor of crazy warping effects. Currently the r - * property of the texture is used to offset the x and the g property of the texture - * is used to offset the y. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -var DisplacementFilter = function (_core$Filter) { - _inherits(DisplacementFilter, _core$Filter); - - /** - * @param {PIXI.Sprite} sprite - The sprite used for the displacement map. (make sure its added to the scene!) - * @param {number} scale - The scale of the displacement - */ - function DisplacementFilter(sprite, scale) { - _classCallCheck(this, DisplacementFilter); - - var maskMatrix = new core.Matrix(); - - sprite.renderable = false; - - var _this = _possibleConstructorReturn(this, _core$Filter.call(this, - // vertex shader - 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 filterMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vFilterCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vFilterCoord = ( filterMatrix * vec3( aTextureCoord, 1.0) ).xy;\n vTextureCoord = aTextureCoord;\n}', - // fragment shader - 'varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\n\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy *= scale / filterArea.xy;\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), filterClamp.xy, filterClamp.zw));\n}\n')); - - _this.maskSprite = sprite; - _this.maskMatrix = maskMatrix; - - _this.uniforms.mapSampler = sprite._texture; - _this.uniforms.filterMatrix = maskMatrix; - _this.uniforms.scale = { x: 1, y: 1 }; - - if (scale === null || scale === undefined) { - scale = 20; - } - - _this.scale = new core.Point(scale, scale); - return _this; - } - - /** - * Applies the filter. - * - * @param {PIXI.FilterManager} filterManager - The manager. - * @param {PIXI.RenderTarget} input - The input target. - * @param {PIXI.RenderTarget} output - The output target. - */ - - - DisplacementFilter.prototype.apply = function apply(filterManager, input, output) { - this.uniforms.filterMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, this.maskSprite); - this.uniforms.scale.x = this.scale.x; - this.uniforms.scale.y = this.scale.y; - - // draw the filter... - filterManager.applyFilter(this, input, output); - }; - - /** - * The texture used for the displacement map. Must be power of 2 sized texture. - * - * @member {PIXI.Texture} - */ - - - _createClass(DisplacementFilter, [{ - key: 'map', - get: function get() { - return this.uniforms.mapSampler; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.uniforms.mapSampler = value; - } - }]); - - return DisplacementFilter; -}(core.Filter); - -exports.default = DisplacementFilter; - -},{"../../core":65,"path":8}],152:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _path = require('path'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * - * Basic FXAA implementation based on the code on geeks3d.com with the - * modification that the texture2DLod stuff was removed since it's - * unsupported by WebGL. - * - * @see https://github.com/mitsuhiko/webgl-meincraft - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * - */ -var FXAAFilter = function (_core$Filter) { - _inherits(FXAAFilter, _core$Filter); - - /** - * - */ - function FXAAFilter() { - _classCallCheck(this, FXAAFilter); - - // TODO - needs work - return _possibleConstructorReturn(this, _core$Filter.call(this, - // vertex shader - '\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nuniform vec4 filterArea;\n\nvarying vec2 vTextureCoord;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvoid texcoords(vec2 fragCoord, vec2 resolution,\n out vec2 v_rgbNW, out vec2 v_rgbNE,\n out vec2 v_rgbSW, out vec2 v_rgbSE,\n out vec2 v_rgbM) {\n vec2 inverseVP = 1.0 / resolution.xy;\n v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\n v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\n v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\n v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\n v_rgbM = vec2(fragCoord * inverseVP);\n}\n\nvoid main(void) {\n\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n\n vec2 fragCoord = vTextureCoord * filterArea.xy;\n\n texcoords(fragCoord, filterArea.xy, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}', - // fragment shader - 'varying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\n/**\n Basic FXAA implementation based on the code on geeks3d.com with the\n modification that the texture2DLod stuff was removed since it\'s\n unsupported by WebGL.\n \n --\n \n From:\n https://github.com/mitsuhiko/webgl-meincraft\n \n Copyright (c) 2011 by Armin Ronacher.\n \n Some rights reserved.\n \n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are\n met:\n \n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n \n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n \n * The names of the contributors may not be used to endorse or\n promote products derived from this software without specific\n prior written permission.\n \n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef FXAA_REDUCE_MIN\n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n#define FXAA_SPAN_MAX 8.0\n#endif\n\n//optimized version for mobile, where dependent\n//texture reads can be a bottleneck\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\n vec2 v_rgbNW, vec2 v_rgbNE,\n vec2 v_rgbSW, vec2 v_rgbSE,\n vec2 v_rgbM) {\n vec4 color;\n mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n \n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n \n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n \n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n \n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n \n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\nvoid main() {\n\n vec2 fragCoord = vTextureCoord * filterArea.xy;\n\n vec4 color;\n\n color = fxaa(uSampler, fragCoord, filterArea.xy, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n gl_FragColor = color;\n}\n')); - } - - return FXAAFilter; -}(core.Filter); - -exports.default = FXAAFilter; - -},{"../../core":65,"path":8}],153:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _FXAAFilter = require('./fxaa/FXAAFilter'); - -Object.defineProperty(exports, 'FXAAFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_FXAAFilter).default; - } -}); - -var _NoiseFilter = require('./noise/NoiseFilter'); - -Object.defineProperty(exports, 'NoiseFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_NoiseFilter).default; - } -}); - -var _DisplacementFilter = require('./displacement/DisplacementFilter'); - -Object.defineProperty(exports, 'DisplacementFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_DisplacementFilter).default; - } -}); - -var _BlurFilter = require('./blur/BlurFilter'); - -Object.defineProperty(exports, 'BlurFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_BlurFilter).default; - } -}); - -var _BlurXFilter = require('./blur/BlurXFilter'); - -Object.defineProperty(exports, 'BlurXFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_BlurXFilter).default; - } -}); - -var _BlurYFilter = require('./blur/BlurYFilter'); - -Object.defineProperty(exports, 'BlurYFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_BlurYFilter).default; - } -}); - -var _ColorMatrixFilter = require('./colormatrix/ColorMatrixFilter'); - -Object.defineProperty(exports, 'ColorMatrixFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_ColorMatrixFilter).default; - } -}); - -var _AlphaFilter = require('./alpha/AlphaFilter'); - -Object.defineProperty(exports, 'AlphaFilter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_AlphaFilter).default; - } -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"./alpha/AlphaFilter":143,"./blur/BlurFilter":144,"./blur/BlurXFilter":145,"./blur/BlurYFilter":146,"./colormatrix/ColorMatrixFilter":150,"./displacement/DisplacementFilter":151,"./fxaa/FXAAFilter":152,"./noise/NoiseFilter":154}],154:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _path = require('path'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * @author Vico @vicocotea - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/noise.js - */ - -/** - * A Noise effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -var NoiseFilter = function (_core$Filter) { - _inherits(NoiseFilter, _core$Filter); - - /** - * @param {number} noise - The noise intensity, should be a normalized value in the range [0, 1]. - * @param {number} seed - A random seed for the noise generation. Default is `Math.random()`. - */ - function NoiseFilter() { - var noise = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.5; - var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.random(); - - _classCallCheck(this, NoiseFilter); - - var _this = _possibleConstructorReturn(this, _core$Filter.call(this, - // vertex shader - 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}', - // fragment shader - 'precision highp float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform float uNoise;\nuniform float uSeed;\nuniform sampler2D uSampler;\n\nfloat rand(vec2 co)\n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float randomValue = rand(gl_FragCoord.xy * uSeed);\n float diff = (randomValue - 0.5) * uNoise;\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (color.a > 0.0) {\n color.rgb /= color.a;\n }\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n // Premultiply alpha again.\n color.rgb *= color.a;\n\n gl_FragColor = color;\n}\n')); - - _this.noise = noise; - _this.seed = seed; - return _this; - } - - /** - * The amount of noise to apply, this value should be in the range (0, 1]. - * - * @member {number} - * @default 0.5 - */ - - - _createClass(NoiseFilter, [{ - key: 'noise', - get: function get() { - return this.uniforms.uNoise; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.uniforms.uNoise = value; - } - - /** - * A seed value to apply to the random noise generation. `Math.random()` is a good value to use. - * - * @member {number} - */ - - }, { - key: 'seed', - get: function get() { - return this.uniforms.uSeed; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.uniforms.uSeed = value; - } - }]); - - return NoiseFilter; -}(core.Filter); - -exports.default = NoiseFilter; - -},{"../../core":65,"path":8}],155:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Holds all information related to an Interaction event - * - * @class - * @memberof PIXI.interaction - */ -var InteractionData = function () { - /** - * - */ - function InteractionData() { - _classCallCheck(this, InteractionData); - - /** - * This point stores the global coords of where the touch/mouse event happened - * - * @member {PIXI.Point} - */ - this.global = new core.Point(); - - /** - * The target DisplayObject that was interacted with - * - * @member {PIXI.DisplayObject} - */ - this.target = null; - - /** - * When passed to an event handler, this will be the original DOM Event that was captured - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent - * @see https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent - * @member {MouseEvent|TouchEvent|PointerEvent} - */ - this.originalEvent = null; - - /** - * Unique identifier for this interaction - * - * @member {number} - */ - this.identifier = null; - - /** - * Indicates whether or not the pointer device that created the event is the primary pointer. - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary - * @type {Boolean} - */ - this.isPrimary = false; - - /** - * Indicates which button was pressed on the mouse or pointer device to trigger the event. - * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button - * @type {number} - */ - this.button = 0; - - /** - * Indicates which buttons are pressed on the mouse or pointer device when the event is triggered. - * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons - * @type {number} - */ - this.buttons = 0; - - /** - * The width of the pointer's contact along the x-axis, measured in CSS pixels. - * radiusX of TouchEvents will be represented by this value. - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width - * @type {number} - */ - this.width = 0; - - /** - * The height of the pointer's contact along the y-axis, measured in CSS pixels. - * radiusY of TouchEvents will be represented by this value. - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height - * @type {number} - */ - this.height = 0; - - /** - * The angle, in degrees, between the pointer device and the screen. - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX - * @type {number} - */ - this.tiltX = 0; - - /** - * The angle, in degrees, between the pointer device and the screen. - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY - * @type {number} - */ - this.tiltY = 0; - - /** - * The type of pointer that triggered the event. - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType - * @type {string} - */ - this.pointerType = null; - - /** - * Pressure applied by the pointing device during the event. A Touch's force property - * will be represented by this value. - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure - * @type {number} - */ - this.pressure = 0; - - /** - * From TouchEvents (not PointerEvents triggered by touches), the rotationAngle of the Touch. - * @see https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle - * @type {number} - */ - this.rotationAngle = 0; - - /** - * Twist of a stylus pointer. - * @see https://w3c.github.io/pointerevents/#pointerevent-interface - * @type {number} - */ - this.twist = 0; - - /** - * Barrel pressure on a stylus pointer. - * @see https://w3c.github.io/pointerevents/#pointerevent-interface - * @type {number} - */ - this.tangentialPressure = 0; - } - - /** - * The unique identifier of the pointer. It will be the same as `identifier`. - * @readonly - * @member {number} - * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId - */ - - - /** - * This will return the local coordinates of the specified displayObject for this InteractionData - * - * @param {PIXI.DisplayObject} displayObject - The DisplayObject that you would like the local - * coords off - * @param {PIXI.Point} [point] - A Point object in which to store the value, optional (otherwise - * will create a new point) - * @param {PIXI.Point} [globalPos] - A Point object containing your custom global coords, optional - * (otherwise will use the current global coords) - * @return {PIXI.Point} A point containing the coordinates of the InteractionData position relative - * to the DisplayObject - */ - InteractionData.prototype.getLocalPosition = function getLocalPosition(displayObject, point, globalPos) { - return displayObject.worldTransform.applyInverse(globalPos || this.global, point); - }; - - /** - * Copies properties from normalized event data. - * - * @param {Touch|MouseEvent|PointerEvent} event The normalized event data - */ - - - InteractionData.prototype.copyEvent = function copyEvent(event) { - // isPrimary should only change on touchstart/pointerdown, so we don't want to overwrite - // it with "false" on later events when our shim for it on touch events might not be - // accurate - if (event.isPrimary) { - this.isPrimary = true; - } - this.button = event.button; - // event.buttons is not available in all browsers (ie. Safari), but it does have a non-standard - // event.which property instead, which conveys the same information. - this.buttons = Number.isInteger(event.buttons) ? event.buttons : event.which; - this.width = event.width; - this.height = event.height; - this.tiltX = event.tiltX; - this.tiltY = event.tiltY; - this.pointerType = event.pointerType; - this.pressure = event.pressure; - this.rotationAngle = event.rotationAngle; - this.twist = event.twist || 0; - this.tangentialPressure = event.tangentialPressure || 0; - }; - - /** - * Resets the data for pooling. - */ - - - InteractionData.prototype.reset = function reset() { - // isPrimary is the only property that we really need to reset - everything else is - // guaranteed to be overwritten - this.isPrimary = false; - }; - - _createClass(InteractionData, [{ - key: 'pointerId', - get: function get() { - return this.identifier; - } - }]); - - return InteractionData; -}(); - -exports.default = InteractionData; - -},{"../core":65}],156:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Event class that mimics native DOM events. - * - * @class - * @memberof PIXI.interaction - */ -var InteractionEvent = function () { - /** - * - */ - function InteractionEvent() { - _classCallCheck(this, InteractionEvent); - - /** - * Whether this event will continue propagating in the tree - * - * @member {boolean} - */ - this.stopped = false; - - /** - * The object which caused this event to be dispatched. - * For listener callback see {@link PIXI.interaction.InteractionEvent.currentTarget}. - * - * @member {PIXI.DisplayObject} - */ - this.target = null; - - /** - * The object whose event listener’s callback is currently being invoked. - * - * @member {PIXI.DisplayObject} - */ - this.currentTarget = null; - - /** - * Type of the event - * - * @member {string} - */ - this.type = null; - - /** - * InteractionData related to this event - * - * @member {PIXI.interaction.InteractionData} - */ - this.data = null; - } - - /** - * Prevents event from reaching any objects other than the current object. - * - */ - - - InteractionEvent.prototype.stopPropagation = function stopPropagation() { - this.stopped = true; - }; - - /** - * Resets the event. - */ - - - InteractionEvent.prototype.reset = function reset() { - this.stopped = false; - this.currentTarget = null; - this.target = null; - }; - - return InteractionEvent; -}(); - -exports.default = InteractionEvent; - -},{}],157:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -var _InteractionData = require('./InteractionData'); - -var _InteractionData2 = _interopRequireDefault(_InteractionData); - -var _InteractionEvent = require('./InteractionEvent'); - -var _InteractionEvent2 = _interopRequireDefault(_InteractionEvent); - -var _InteractionTrackingData = require('./InteractionTrackingData'); - -var _InteractionTrackingData2 = _interopRequireDefault(_InteractionTrackingData); - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -var _interactiveTarget = require('./interactiveTarget'); - -var _interactiveTarget2 = _interopRequireDefault(_interactiveTarget); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -// Mix interactiveTarget into core.DisplayObject.prototype, after deprecation has been handled -core.utils.mixins.delayMixin(core.DisplayObject.prototype, _interactiveTarget2.default); - -var MOUSE_POINTER_ID = 1; - -// helpers for hitTest() - only used inside hitTest() -var hitTestEvent = { - target: null, - data: { - global: null - } -}; - -/** - * The interaction manager deals with mouse, touch and pointer events. Any DisplayObject can be interactive - * if its interactive parameter is set to true - * This manager also supports multitouch. - * - * An instance of this class is automatically created by default, and can be found at renderer.plugins.interaction - * - * @class - * @extends EventEmitter - * @memberof PIXI.interaction - */ - -var InteractionManager = function (_EventEmitter) { - _inherits(InteractionManager, _EventEmitter); - - /** - * @param {PIXI.CanvasRenderer|PIXI.WebGLRenderer} renderer - A reference to the current renderer - * @param {object} [options] - The options for the manager. - * @param {boolean} [options.autoPreventDefault=true] - Should the manager automatically prevent default browser actions. - * @param {number} [options.interactionFrequency=10] - Frequency increases the interaction events will be checked. - */ - function InteractionManager(renderer, options) { - _classCallCheck(this, InteractionManager); - - var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); - - options = options || {}; - - /** - * The renderer this interaction manager works for. - * - * @member {PIXI.SystemRenderer} - */ - _this.renderer = renderer; - - /** - * Should default browser actions automatically be prevented. - * Does not apply to pointer events for backwards compatibility - * preventDefault on pointer events stops mouse events from firing - * Thus, for every pointer event, there will always be either a mouse of touch event alongside it. - * - * @member {boolean} - * @default true - */ - _this.autoPreventDefault = options.autoPreventDefault !== undefined ? options.autoPreventDefault : true; - - /** - * Frequency in milliseconds that the mousemove, moveover & mouseout interaction events will be checked. - * - * @member {number} - * @default 10 - */ - _this.interactionFrequency = options.interactionFrequency || 10; - - /** - * The mouse data - * - * @member {PIXI.interaction.InteractionData} - */ - _this.mouse = new _InteractionData2.default(); - _this.mouse.identifier = MOUSE_POINTER_ID; - - // setting the mouse to start off far off screen will mean that mouse over does - // not get called before we even move the mouse. - _this.mouse.global.set(-999999); - - /** - * Actively tracked InteractionData - * - * @private - * @member {Object.} - */ - _this.activeInteractionData = {}; - _this.activeInteractionData[MOUSE_POINTER_ID] = _this.mouse; - - /** - * Pool of unused InteractionData - * - * @private - * @member {PIXI.interation.InteractionData[]} - */ - _this.interactionDataPool = []; - - /** - * An event data object to handle all the event tracking/dispatching - * - * @member {object} - */ - _this.eventData = new _InteractionEvent2.default(); - - /** - * The DOM element to bind to. - * - * @private - * @member {HTMLElement} - */ - _this.interactionDOMElement = null; - - /** - * This property determines if mousemove and touchmove events are fired only when the cursor - * is over the object. - * Setting to true will make things work more in line with how the DOM verison works. - * Setting to false can make things easier for things like dragging - * It is currently set to false as this is how PixiJS used to work. This will be set to true in - * future versions of pixi. - * - * @member {boolean} - * @default false - */ - _this.moveWhenInside = false; - - /** - * Have events been attached to the dom element? - * - * @private - * @member {boolean} - */ - _this.eventsAdded = false; - - /** - * Is the mouse hovering over the renderer? - * - * @private - * @member {boolean} - */ - _this.mouseOverRenderer = false; - - /** - * Does the device support touch events - * https://www.w3.org/TR/touch-events/ - * - * @readonly - * @member {boolean} - */ - _this.supportsTouchEvents = 'ontouchstart' in window; - - /** - * Does the device support pointer events - * https://www.w3.org/Submission/pointer-events/ - * - * @readonly - * @member {boolean} - */ - _this.supportsPointerEvents = !!window.PointerEvent; - - // this will make it so that you don't have to call bind all the time - - /** - * @private - * @member {Function} - */ - _this.onPointerUp = _this.onPointerUp.bind(_this); - _this.processPointerUp = _this.processPointerUp.bind(_this); - - /** - * @private - * @member {Function} - */ - _this.onPointerCancel = _this.onPointerCancel.bind(_this); - _this.processPointerCancel = _this.processPointerCancel.bind(_this); - - /** - * @private - * @member {Function} - */ - _this.onPointerDown = _this.onPointerDown.bind(_this); - _this.processPointerDown = _this.processPointerDown.bind(_this); - - /** - * @private - * @member {Function} - */ - _this.onPointerMove = _this.onPointerMove.bind(_this); - _this.processPointerMove = _this.processPointerMove.bind(_this); - - /** - * @private - * @member {Function} - */ - _this.onPointerOut = _this.onPointerOut.bind(_this); - _this.processPointerOverOut = _this.processPointerOverOut.bind(_this); - - /** - * @private - * @member {Function} - */ - _this.onPointerOver = _this.onPointerOver.bind(_this); - - /** - * Dictionary of how different cursor modes are handled. Strings are handled as CSS cursor - * values, objects are handled as dictionaries of CSS values for interactionDOMElement, - * and functions are called instead of changing the CSS. - * Default CSS cursor values are provided for 'default' and 'pointer' modes. - * @member {Object.)>} - */ - _this.cursorStyles = { - default: 'inherit', - pointer: 'pointer' - }; - - /** - * The mode of the cursor that is being used. - * The value of this is a key from the cursorStyles dictionary. - * - * @member {string} - */ - _this.currentCursorMode = null; - - /** - * Internal cached let. - * - * @private - * @member {string} - */ - _this.cursor = null; - - /** - * Internal cached let. - * - * @private - * @member {PIXI.Point} - */ - _this._tempPoint = new core.Point(); - - /** - * The current resolution / device pixel ratio. - * - * @member {number} - * @default 1 - */ - _this.resolution = 1; - - _this.setTargetElement(_this.renderer.view, _this.renderer.resolution); - - /** - * Fired when a pointer device button (usually a mouse left-button) is pressed on the display - * object. - * - * @event PIXI.interaction.InteractionManager#mousedown - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device secondary button (usually a mouse right-button) is pressed - * on the display object. - * - * @event PIXI.interaction.InteractionManager#rightdown - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button (usually a mouse left-button) is released over the display - * object. - * - * @event PIXI.interaction.InteractionManager#mouseup - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device secondary button (usually a mouse right-button) is released - * over the display object. - * - * @event PIXI.interaction.InteractionManager#rightup - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button (usually a mouse left-button) is pressed and released on - * the display object. - * - * @event PIXI.interaction.InteractionManager#click - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device secondary button (usually a mouse right-button) is pressed - * and released on the display object. - * - * @event PIXI.interaction.InteractionManager#rightclick - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button (usually a mouse left-button) is released outside the - * display object that initially registered a - * [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown}. - * - * @event PIXI.interaction.InteractionManager#mouseupoutside - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device secondary button (usually a mouse right-button) is released - * outside the display object that initially registered a - * [rightdown]{@link PIXI.interaction.InteractionManager#event:rightdown}. - * - * @event PIXI.interaction.InteractionManager#rightupoutside - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device (usually a mouse) is moved while over the display object - * - * @event PIXI.interaction.InteractionManager#mousemove - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device (usually a mouse) is moved onto the display object - * - * @event PIXI.interaction.InteractionManager#mouseover - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device (usually a mouse) is moved off the display object - * - * @event PIXI.interaction.InteractionManager#mouseout - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button is pressed on the display object. - * - * @event PIXI.interaction.InteractionManager#pointerdown - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button is released over the display object. - * Not always fired when some buttons are held down while others are released. In those cases, - * use [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown} and - * [mouseup]{@link PIXI.interaction.InteractionManager#event:mouseup} instead. - * - * @event PIXI.interaction.InteractionManager#pointerup - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when the operating system cancels a pointer event - * - * @event PIXI.interaction.InteractionManager#pointercancel - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button is pressed and released on the display object. - * - * @event PIXI.interaction.InteractionManager#pointertap - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button is released outside the display object that initially - * registered a [pointerdown]{@link PIXI.interaction.InteractionManager#event:pointerdown}. - * - * @event PIXI.interaction.InteractionManager#pointerupoutside - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device is moved while over the display object - * - * @event PIXI.interaction.InteractionManager#pointermove - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device is moved onto the display object - * - * @event PIXI.interaction.InteractionManager#pointerover - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device is moved off the display object - * - * @event PIXI.interaction.InteractionManager#pointerout - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is placed on the display object. - * - * @event PIXI.interaction.InteractionManager#touchstart - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is removed from the display object. - * - * @event PIXI.interaction.InteractionManager#touchend - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when the operating system cancels a touch - * - * @event PIXI.interaction.InteractionManager#touchcancel - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is placed and removed from the display object. - * - * @event PIXI.interaction.InteractionManager#tap - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is removed outside of the display object that initially - * registered a [touchstart]{@link PIXI.interaction.InteractionManager#event:touchstart}. - * - * @event PIXI.interaction.InteractionManager#touchendoutside - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is moved along the display object. - * - * @event PIXI.interaction.InteractionManager#touchmove - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button (usually a mouse left-button) is pressed on the display. - * object. DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#mousedown - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device secondary button (usually a mouse right-button) is pressed - * on the display object. DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#rightdown - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button (usually a mouse left-button) is released over the display - * object. DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#mouseup - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device secondary button (usually a mouse right-button) is released - * over the display object. DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#rightup - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button (usually a mouse left-button) is pressed and released on - * the display object. DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#click - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device secondary button (usually a mouse right-button) is pressed - * and released on the display object. DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#rightclick - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button (usually a mouse left-button) is released outside the - * display object that initially registered a - * [mousedown]{@link PIXI.DisplayObject#event:mousedown}. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#mouseupoutside - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device secondary button (usually a mouse right-button) is released - * outside the display object that initially registered a - * [rightdown]{@link PIXI.DisplayObject#event:rightdown}. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#rightupoutside - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device (usually a mouse) is moved while over the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#mousemove - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device (usually a mouse) is moved onto the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#mouseover - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device (usually a mouse) is moved off the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#mouseout - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button is pressed on the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#pointerdown - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button is released over the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#pointerup - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when the operating system cancels a pointer event. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#pointercancel - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button is pressed and released on the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#pointertap - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device button is released outside the display object that initially - * registered a [pointerdown]{@link PIXI.DisplayObject#event:pointerdown}. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#pointerupoutside - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device is moved while over the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#pointermove - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device is moved onto the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#pointerover - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a pointer device is moved off the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#pointerout - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is placed on the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#touchstart - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is removed from the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#touchend - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when the operating system cancels a touch. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#touchcancel - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is placed and removed from the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#tap - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is removed outside of the display object that initially - * registered a [touchstart]{@link PIXI.DisplayObject#event:touchstart}. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#touchendoutside - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - - /** - * Fired when a touch point is moved along the display object. - * DisplayObject's `interactive` property must be set to `true` to fire event. - * - * @event PIXI.DisplayObject#touchmove - * @param {PIXI.interaction.InteractionEvent} event - Interaction event - */ - return _this; - } - - /** - * Hit tests a point against the display tree, returning the first interactive object that is hit. - * - * @param {PIXI.Point} globalPoint - A point to hit test with, in global space. - * @param {PIXI.Container} [root] - The root display object to start from. If omitted, defaults - * to the last rendered root of the associated renderer. - * @return {PIXI.DisplayObject} The hit display object, if any. - */ - - - InteractionManager.prototype.hitTest = function hitTest(globalPoint, root) { - // clear the target for our hit test - hitTestEvent.target = null; - // assign the global point - hitTestEvent.data.global = globalPoint; - // ensure safety of the root - if (!root) { - root = this.renderer._lastObjectRendered; - } - // run the hit test - this.processInteractive(hitTestEvent, root, null, true); - // return our found object - it'll be null if we didn't hit anything - - return hitTestEvent.target; - }; - - /** - * Sets the DOM element which will receive mouse/touch events. This is useful for when you have - * other DOM elements on top of the renderers Canvas element. With this you'll be bale to deletegate - * another DOM element to receive those events. - * - * @param {HTMLCanvasElement} element - the DOM element which will receive mouse and touch events. - * @param {number} [resolution=1] - The resolution / device pixel ratio of the new element (relative to the canvas). - */ - - - InteractionManager.prototype.setTargetElement = function setTargetElement(element) { - var resolution = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - - this.removeEvents(); - - this.interactionDOMElement = element; - - this.resolution = resolution; - - this.addEvents(); - }; - - /** - * Registers all the DOM events - * - * @private - */ - - - InteractionManager.prototype.addEvents = function addEvents() { - if (!this.interactionDOMElement) { - return; - } - - core.ticker.shared.add(this.update, this, core.UPDATE_PRIORITY.INTERACTION); - - if (window.navigator.msPointerEnabled) { - this.interactionDOMElement.style['-ms-content-zooming'] = 'none'; - this.interactionDOMElement.style['-ms-touch-action'] = 'none'; - } else if (this.supportsPointerEvents) { - this.interactionDOMElement.style['touch-action'] = 'none'; - } - - /** - * These events are added first, so that if pointer events are normalised, they are fired - * in the same order as non-normalised events. ie. pointer event 1st, mouse / touch 2nd - */ - if (this.supportsPointerEvents) { - window.document.addEventListener('pointermove', this.onPointerMove, true); - this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, true); - // pointerout is fired in addition to pointerup (for touch events) and pointercancel - // we already handle those, so for the purposes of what we do in onPointerOut, we only - // care about the pointerleave event - this.interactionDOMElement.addEventListener('pointerleave', this.onPointerOut, true); - this.interactionDOMElement.addEventListener('pointerover', this.onPointerOver, true); - window.addEventListener('pointercancel', this.onPointerCancel, true); - window.addEventListener('pointerup', this.onPointerUp, true); - } else { - window.document.addEventListener('mousemove', this.onPointerMove, true); - this.interactionDOMElement.addEventListener('mousedown', this.onPointerDown, true); - this.interactionDOMElement.addEventListener('mouseout', this.onPointerOut, true); - this.interactionDOMElement.addEventListener('mouseover', this.onPointerOver, true); - window.addEventListener('mouseup', this.onPointerUp, true); - } - - // always look directly for touch events so that we can provide original data - // In a future version we should change this to being just a fallback and rely solely on - // PointerEvents whenever available - if (this.supportsTouchEvents) { - this.interactionDOMElement.addEventListener('touchstart', this.onPointerDown, true); - this.interactionDOMElement.addEventListener('touchcancel', this.onPointerCancel, true); - this.interactionDOMElement.addEventListener('touchend', this.onPointerUp, true); - this.interactionDOMElement.addEventListener('touchmove', this.onPointerMove, true); - } - - this.eventsAdded = true; - }; - - /** - * Removes all the DOM events that were previously registered - * - * @private - */ - - - InteractionManager.prototype.removeEvents = function removeEvents() { - if (!this.interactionDOMElement) { - return; - } - - core.ticker.shared.remove(this.update, this); - - if (window.navigator.msPointerEnabled) { - this.interactionDOMElement.style['-ms-content-zooming'] = ''; - this.interactionDOMElement.style['-ms-touch-action'] = ''; - } else if (this.supportsPointerEvents) { - this.interactionDOMElement.style['touch-action'] = ''; - } - - if (this.supportsPointerEvents) { - window.document.removeEventListener('pointermove', this.onPointerMove, true); - this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, true); - this.interactionDOMElement.removeEventListener('pointerleave', this.onPointerOut, true); - this.interactionDOMElement.removeEventListener('pointerover', this.onPointerOver, true); - window.removeEventListener('pointercancel', this.onPointerCancel, true); - window.removeEventListener('pointerup', this.onPointerUp, true); - } else { - window.document.removeEventListener('mousemove', this.onPointerMove, true); - this.interactionDOMElement.removeEventListener('mousedown', this.onPointerDown, true); - this.interactionDOMElement.removeEventListener('mouseout', this.onPointerOut, true); - this.interactionDOMElement.removeEventListener('mouseover', this.onPointerOver, true); - window.removeEventListener('mouseup', this.onPointerUp, true); - } - - if (this.supportsTouchEvents) { - this.interactionDOMElement.removeEventListener('touchstart', this.onPointerDown, true); - this.interactionDOMElement.removeEventListener('touchcancel', this.onPointerCancel, true); - this.interactionDOMElement.removeEventListener('touchend', this.onPointerUp, true); - this.interactionDOMElement.removeEventListener('touchmove', this.onPointerMove, true); - } - - this.interactionDOMElement = null; - - this.eventsAdded = false; - }; - - /** - * Updates the state of interactive objects. - * Invoked by a throttled ticker update from {@link PIXI.ticker.shared}. - * - * @param {number} deltaTime - time delta since last tick - */ - - - InteractionManager.prototype.update = function update(deltaTime) { - this._deltaTime += deltaTime; - - if (this._deltaTime < this.interactionFrequency) { - return; - } - - this._deltaTime = 0; - - if (!this.interactionDOMElement) { - return; - } - - // if the user move the mouse this check has already been done using the mouse move! - if (this.didMove) { - this.didMove = false; - - return; - } - - this.cursor = null; - - // Resets the flag as set by a stopPropagation call. This flag is usually reset by a user interaction of any kind, - // but there was a scenario of a display object moving under a static mouse cursor. - // In this case, mouseover and mouseevents would not pass the flag test in dispatchEvent function - for (var k in this.activeInteractionData) { - // eslint-disable-next-line no-prototype-builtins - if (this.activeInteractionData.hasOwnProperty(k)) { - var interactionData = this.activeInteractionData[k]; - - if (interactionData.originalEvent && interactionData.pointerType !== 'touch') { - var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, interactionData.originalEvent, interactionData); - - this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerOverOut, true); - } - } - } - - this.setCursorMode(this.cursor); - - // TODO - }; - - /** - * Sets the current cursor mode, handling any callbacks or CSS style changes. - * - * @param {string} mode - cursor mode, a key from the cursorStyles dictionary - */ - - - InteractionManager.prototype.setCursorMode = function setCursorMode(mode) { - mode = mode || 'default'; - // if the mode didn't actually change, bail early - if (this.currentCursorMode === mode) { - return; - } - this.currentCursorMode = mode; - var style = this.cursorStyles[mode]; - - // only do things if there is a cursor style for it - if (style) { - switch (typeof style === 'undefined' ? 'undefined' : _typeof(style)) { - case 'string': - // string styles are handled as cursor CSS - this.interactionDOMElement.style.cursor = style; - break; - case 'function': - // functions are just called, and passed the cursor mode - style(mode); - break; - case 'object': - // if it is an object, assume that it is a dictionary of CSS styles, - // apply it to the interactionDOMElement - Object.assign(this.interactionDOMElement.style, style); - break; - } - } else if (typeof mode === 'string' && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) { - // if it mode is a string (not a Symbol) and cursorStyles doesn't have any entry - // for the mode, then assume that the dev wants it to be CSS for the cursor. - this.interactionDOMElement.style.cursor = mode; - } - }; - - /** - * Dispatches an event on the display object that was interacted with - * - * @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - the display object in question - * @param {string} eventString - the name of the event (e.g, mousedown) - * @param {object} eventData - the event data object - * @private - */ - - - InteractionManager.prototype.dispatchEvent = function dispatchEvent(displayObject, eventString, eventData) { - if (!eventData.stopped) { - eventData.currentTarget = displayObject; - eventData.type = eventString; - - displayObject.emit(eventString, eventData); - - if (displayObject[eventString]) { - displayObject[eventString](eventData); - } - } - }; - - /** - * Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The - * resulting value is stored in the point. This takes into account the fact that the DOM - * element could be scaled and positioned anywhere on the screen. - * - * @param {PIXI.Point} point - the point that the result will be stored in - * @param {number} x - the x coord of the position to map - * @param {number} y - the y coord of the position to map - */ - - - InteractionManager.prototype.mapPositionToPoint = function mapPositionToPoint(point, x, y) { - var rect = void 0; - - // IE 11 fix - if (!this.interactionDOMElement.parentElement) { - rect = { x: 0, y: 0, width: 0, height: 0 }; - } else { - rect = this.interactionDOMElement.getBoundingClientRect(); - } - - var resolutionMultiplier = navigator.isCocoonJS ? this.resolution : 1.0 / this.resolution; - - point.x = (x - rect.left) * (this.interactionDOMElement.width / rect.width) * resolutionMultiplier; - point.y = (y - rect.top) * (this.interactionDOMElement.height / rect.height) * resolutionMultiplier; - }; - - /** - * This function is provides a neat way of crawling through the scene graph and running a - * specified function on all interactive objects it finds. It will also take care of hit - * testing the interactive objects and passes the hit across in the function. - * - * @private - * @param {PIXI.interaction.InteractionEvent} interactionEvent - event containing the point that - * is tested for collision - * @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - the displayObject - * that will be hit test (recursively crawls its children) - * @param {Function} [func] - the function that will be called on each interactive object. The - * interactionEvent, displayObject and hit will be passed to the function - * @param {boolean} [hitTest] - this indicates if the objects inside should be hit test against the point - * @param {boolean} [interactive] - Whether the displayObject is interactive - * @return {boolean} returns true if the displayObject hit the point - */ - - - InteractionManager.prototype.processInteractive = function processInteractive(interactionEvent, displayObject, func, hitTest, interactive) { - if (!displayObject || !displayObject.visible) { - return false; - } - - var point = interactionEvent.data.global; - - // Took a little while to rework this function correctly! But now it is done and nice and optimised. ^_^ - // - // This function will now loop through all objects and then only hit test the objects it HAS - // to, not all of them. MUCH faster.. - // An object will be hit test if the following is true: - // - // 1: It is interactive. - // 2: It belongs to a parent that is interactive AND one of the parents children have not already been hit. - // - // As another little optimisation once an interactive object has been hit we can carry on - // through the scenegraph, but we know that there will be no more hits! So we can avoid extra hit tests - // A final optimisation is that an object is not hit test directly if a child has already been hit. - - interactive = displayObject.interactive || interactive; - - var hit = false; - var interactiveParent = interactive; - - // Flag here can set to false if the event is outside the parents hitArea or mask - var hitTestChildren = true; - - // If there is a hitArea, no need to test against anything else if the pointer is not within the hitArea - // There is also no longer a need to hitTest children. - if (displayObject.hitArea) { - if (hitTest) { - displayObject.worldTransform.applyInverse(point, this._tempPoint); - if (!displayObject.hitArea.contains(this._tempPoint.x, this._tempPoint.y)) { - hitTest = false; - hitTestChildren = false; - } else { - hit = true; - } - } - interactiveParent = false; - } - // If there is a mask, no need to test against anything else if the pointer is not within the mask - else if (displayObject._mask) { - if (hitTest) { - if (!displayObject._mask.containsPoint(point)) { - hitTest = false; - hitTestChildren = false; - } - } - } - - // ** FREE TIP **! If an object is not interactive or has no buttons in it - // (such as a game scene!) set interactiveChildren to false for that displayObject. - // This will allow PixiJS to completely ignore and bypass checking the displayObjects children. - if (hitTestChildren && displayObject.interactiveChildren && displayObject.children) { - var children = displayObject.children; - - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - - // time to get recursive.. if this function will return if something is hit.. - var childHit = this.processInteractive(interactionEvent, child, func, hitTest, interactiveParent); - - if (childHit) { - // its a good idea to check if a child has lost its parent. - // this means it has been removed whilst looping so its best - if (!child.parent) { - continue; - } - - // we no longer need to hit test any more objects in this container as we we - // now know the parent has been hit - interactiveParent = false; - - // If the child is interactive , that means that the object hit was actually - // interactive and not just the child of an interactive object. - // This means we no longer need to hit test anything else. We still need to run - // through all objects, but we don't need to perform any hit tests. - - if (childHit) { - if (interactionEvent.target) { - hitTest = false; - } - hit = true; - } - } - } - } - - // no point running this if the item is not interactive or does not have an interactive parent. - if (interactive) { - // if we are hit testing (as in we have no hit any objects yet) - // We also don't need to worry about hit testing if once of the displayObjects children - // has already been hit - but only if it was interactive, otherwise we need to keep - // looking for an interactive child, just in case we hit one - if (hitTest && !interactionEvent.target) { - // already tested against hitArea if it is defined - if (!displayObject.hitArea && displayObject.containsPoint) { - if (displayObject.containsPoint(point)) { - hit = true; - } - } - } - - if (displayObject.interactive) { - if (hit && !interactionEvent.target) { - interactionEvent.target = displayObject; - } - - if (func) { - func(interactionEvent, displayObject, !!hit); - } - } - } - - return hit; - }; - - /** - * Is called when the pointer button is pressed down on the renderer element - * - * @private - * @param {PointerEvent} originalEvent - The DOM event of a pointer button being pressed down - */ - - - InteractionManager.prototype.onPointerDown = function onPointerDown(originalEvent) { - // if we support touch events, then only use those for touch events, not pointer events - if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') return; - - var events = this.normalizeToPointerData(originalEvent); - - /** - * No need to prevent default on natural pointer events, as there are no side effects - * Normalized events, however, may have the double mousedown/touchstart issue on the native android browser, - * so still need to be prevented. - */ - - // Guaranteed that there will be at least one event in events, and all events must have the same pointer type - - if (this.autoPreventDefault && events[0].isNormalized) { - originalEvent.preventDefault(); - } - - var eventLen = events.length; - - for (var i = 0; i < eventLen; i++) { - var event = events[i]; - - var interactionData = this.getInteractionDataForPointerId(event); - - var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); - - interactionEvent.data.originalEvent = originalEvent; - - this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerDown, true); - - this.emit('pointerdown', interactionEvent); - if (event.pointerType === 'touch') { - this.emit('touchstart', interactionEvent); - } - // emit a mouse event for "pen" pointers, the way a browser would emit a fallback event - else if (event.pointerType === 'mouse' || event.pointerType === 'pen') { - var isRightButton = event.button === 2; - - this.emit(isRightButton ? 'rightdown' : 'mousedown', this.eventData); - } - } - }; - - /** - * Processes the result of the pointer down check and dispatches the event if need be - * - * @private - * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event - * @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested - * @param {boolean} hit - the result of the hit test on the display object - */ - - - InteractionManager.prototype.processPointerDown = function processPointerDown(interactionEvent, displayObject, hit) { - var data = interactionEvent.data; - var id = interactionEvent.data.identifier; - - if (hit) { - if (!displayObject.trackedPointers[id]) { - displayObject.trackedPointers[id] = new _InteractionTrackingData2.default(id); - } - this.dispatchEvent(displayObject, 'pointerdown', interactionEvent); - - if (data.pointerType === 'touch') { - this.dispatchEvent(displayObject, 'touchstart', interactionEvent); - } else if (data.pointerType === 'mouse' || data.pointerType === 'pen') { - var isRightButton = data.button === 2; - - if (isRightButton) { - displayObject.trackedPointers[id].rightDown = true; - } else { - displayObject.trackedPointers[id].leftDown = true; - } - - this.dispatchEvent(displayObject, isRightButton ? 'rightdown' : 'mousedown', interactionEvent); - } - } - }; - - /** - * Is called when the pointer button is released on the renderer element - * - * @private - * @param {PointerEvent} originalEvent - The DOM event of a pointer button being released - * @param {boolean} cancelled - true if the pointer is cancelled - * @param {Function} func - Function passed to {@link processInteractive} - */ - - - InteractionManager.prototype.onPointerComplete = function onPointerComplete(originalEvent, cancelled, func) { - var events = this.normalizeToPointerData(originalEvent); - - var eventLen = events.length; - - // if the event wasn't targeting our canvas, then consider it to be pointerupoutside - // in all cases (unless it was a pointercancel) - var eventAppend = originalEvent.target !== this.interactionDOMElement ? 'outside' : ''; - - for (var i = 0; i < eventLen; i++) { - var event = events[i]; - - var interactionData = this.getInteractionDataForPointerId(event); - - var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); - - interactionEvent.data.originalEvent = originalEvent; - - // perform hit testing for events targeting our canvas or cancel events - this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, func, cancelled || !eventAppend); - - this.emit(cancelled ? 'pointercancel' : 'pointerup' + eventAppend, interactionEvent); - - if (event.pointerType === 'mouse' || event.pointerType === 'pen') { - var isRightButton = event.button === 2; - - this.emit(isRightButton ? 'rightup' + eventAppend : 'mouseup' + eventAppend, interactionEvent); - } else if (event.pointerType === 'touch') { - this.emit(cancelled ? 'touchcancel' : 'touchend' + eventAppend, interactionEvent); - this.releaseInteractionDataForPointerId(event.pointerId, interactionData); - } - } - }; - - /** - * Is called when the pointer button is cancelled - * - * @private - * @param {PointerEvent} event - The DOM event of a pointer button being released - */ - - - InteractionManager.prototype.onPointerCancel = function onPointerCancel(event) { - // if we support touch events, then only use those for touch events, not pointer events - if (this.supportsTouchEvents && event.pointerType === 'touch') return; - - this.onPointerComplete(event, true, this.processPointerCancel); - }; - - /** - * Processes the result of the pointer cancel check and dispatches the event if need be - * - * @private - * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event - * @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested - */ - - - InteractionManager.prototype.processPointerCancel = function processPointerCancel(interactionEvent, displayObject) { - var data = interactionEvent.data; - - var id = interactionEvent.data.identifier; - - if (displayObject.trackedPointers[id] !== undefined) { - delete displayObject.trackedPointers[id]; - this.dispatchEvent(displayObject, 'pointercancel', interactionEvent); - - if (data.pointerType === 'touch') { - this.dispatchEvent(displayObject, 'touchcancel', interactionEvent); - } - } - }; - - /** - * Is called when the pointer button is released on the renderer element - * - * @private - * @param {PointerEvent} event - The DOM event of a pointer button being released - */ - - - InteractionManager.prototype.onPointerUp = function onPointerUp(event) { - // if we support touch events, then only use those for touch events, not pointer events - if (this.supportsTouchEvents && event.pointerType === 'touch') return; - - this.onPointerComplete(event, false, this.processPointerUp); - }; - - /** - * Processes the result of the pointer up check and dispatches the event if need be - * - * @private - * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event - * @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested - * @param {boolean} hit - the result of the hit test on the display object - */ - - - InteractionManager.prototype.processPointerUp = function processPointerUp(interactionEvent, displayObject, hit) { - var data = interactionEvent.data; - - var id = interactionEvent.data.identifier; - - var trackingData = displayObject.trackedPointers[id]; - - var isTouch = data.pointerType === 'touch'; - - var isMouse = data.pointerType === 'mouse' || data.pointerType === 'pen'; - // need to track mouse down status in the mouse block so that we can emit - // event in a later block - var isMouseTap = false; - - // Mouse only - if (isMouse) { - var isRightButton = data.button === 2; - - var flags = _InteractionTrackingData2.default.FLAGS; - - var test = isRightButton ? flags.RIGHT_DOWN : flags.LEFT_DOWN; - - var isDown = trackingData !== undefined && trackingData.flags & test; - - if (hit) { - this.dispatchEvent(displayObject, isRightButton ? 'rightup' : 'mouseup', interactionEvent); - - if (isDown) { - this.dispatchEvent(displayObject, isRightButton ? 'rightclick' : 'click', interactionEvent); - // because we can confirm that the mousedown happened on this object, flag for later emit of pointertap - isMouseTap = true; - } - } else if (isDown) { - this.dispatchEvent(displayObject, isRightButton ? 'rightupoutside' : 'mouseupoutside', interactionEvent); - } - // update the down state of the tracking data - if (trackingData) { - if (isRightButton) { - trackingData.rightDown = false; - } else { - trackingData.leftDown = false; - } - } - } - - // Pointers and Touches, and Mouse - if (hit) { - this.dispatchEvent(displayObject, 'pointerup', interactionEvent); - if (isTouch) this.dispatchEvent(displayObject, 'touchend', interactionEvent); - - if (trackingData) { - // emit pointertap if not a mouse, or if the mouse block decided it was a tap - if (!isMouse || isMouseTap) { - this.dispatchEvent(displayObject, 'pointertap', interactionEvent); - } - if (isTouch) { - this.dispatchEvent(displayObject, 'tap', interactionEvent); - // touches are no longer over (if they ever were) when we get the touchend - // so we should ensure that we don't keep pretending that they are - trackingData.over = false; - } - } - } else if (trackingData) { - this.dispatchEvent(displayObject, 'pointerupoutside', interactionEvent); - if (isTouch) this.dispatchEvent(displayObject, 'touchendoutside', interactionEvent); - } - // Only remove the tracking data if there is no over/down state still associated with it - if (trackingData && trackingData.none) { - delete displayObject.trackedPointers[id]; - } - }; - - /** - * Is called when the pointer moves across the renderer element - * - * @private - * @param {PointerEvent} originalEvent - The DOM event of a pointer moving - */ - - - InteractionManager.prototype.onPointerMove = function onPointerMove(originalEvent) { - // if we support touch events, then only use those for touch events, not pointer events - if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') return; - - var events = this.normalizeToPointerData(originalEvent); - - if (events[0].pointerType === 'mouse' || events[0].pointerType === 'pen') { - this.didMove = true; - - this.cursor = null; - } - - var eventLen = events.length; - - for (var i = 0; i < eventLen; i++) { - var event = events[i]; - - var interactionData = this.getInteractionDataForPointerId(event); - - var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); - - interactionEvent.data.originalEvent = originalEvent; - - var interactive = event.pointerType === 'touch' ? this.moveWhenInside : true; - - this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerMove, interactive); - this.emit('pointermove', interactionEvent); - if (event.pointerType === 'touch') this.emit('touchmove', interactionEvent); - if (event.pointerType === 'mouse' || event.pointerType === 'pen') this.emit('mousemove', interactionEvent); - } - - if (events[0].pointerType === 'mouse') { - this.setCursorMode(this.cursor); - - // TODO BUG for parents interactive object (border order issue) - } - }; - - /** - * Processes the result of the pointer move check and dispatches the event if need be - * - * @private - * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event - * @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested - * @param {boolean} hit - the result of the hit test on the display object - */ - - - InteractionManager.prototype.processPointerMove = function processPointerMove(interactionEvent, displayObject, hit) { - var data = interactionEvent.data; - - var isTouch = data.pointerType === 'touch'; - - var isMouse = data.pointerType === 'mouse' || data.pointerType === 'pen'; - - if (isMouse) { - this.processPointerOverOut(interactionEvent, displayObject, hit); - } - - if (!this.moveWhenInside || hit) { - this.dispatchEvent(displayObject, 'pointermove', interactionEvent); - if (isTouch) this.dispatchEvent(displayObject, 'touchmove', interactionEvent); - if (isMouse) this.dispatchEvent(displayObject, 'mousemove', interactionEvent); - } - }; - - /** - * Is called when the pointer is moved out of the renderer element - * - * @private - * @param {PointerEvent} originalEvent - The DOM event of a pointer being moved out - */ - - - InteractionManager.prototype.onPointerOut = function onPointerOut(originalEvent) { - // if we support touch events, then only use those for touch events, not pointer events - if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') return; - - var events = this.normalizeToPointerData(originalEvent); - - // Only mouse and pointer can call onPointerOut, so events will always be length 1 - var event = events[0]; - - if (event.pointerType === 'mouse') { - this.mouseOverRenderer = false; - this.setCursorMode(null); - } - - var interactionData = this.getInteractionDataForPointerId(event); - - var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); - - interactionEvent.data.originalEvent = event; - - this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerOverOut, false); - - this.emit('pointerout', interactionEvent); - if (event.pointerType === 'mouse' || event.pointerType === 'pen') { - this.emit('mouseout', interactionEvent); - } else { - // we can get touchleave events after touchend, so we want to make sure we don't - // introduce memory leaks - this.releaseInteractionDataForPointerId(interactionData.identifier); - } - }; - - /** - * Processes the result of the pointer over/out check and dispatches the event if need be - * - * @private - * @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event - * @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested - * @param {boolean} hit - the result of the hit test on the display object - */ - - - InteractionManager.prototype.processPointerOverOut = function processPointerOverOut(interactionEvent, displayObject, hit) { - var data = interactionEvent.data; - - var id = interactionEvent.data.identifier; - - var isMouse = data.pointerType === 'mouse' || data.pointerType === 'pen'; - - var trackingData = displayObject.trackedPointers[id]; - - // if we just moused over the display object, then we need to track that state - if (hit && !trackingData) { - trackingData = displayObject.trackedPointers[id] = new _InteractionTrackingData2.default(id); - } - - if (trackingData === undefined) return; - - if (hit && this.mouseOverRenderer) { - if (!trackingData.over) { - trackingData.over = true; - this.dispatchEvent(displayObject, 'pointerover', interactionEvent); - if (isMouse) { - this.dispatchEvent(displayObject, 'mouseover', interactionEvent); - } - } - - // only change the cursor if it has not already been changed (by something deeper in the - // display tree) - if (isMouse && this.cursor === null) { - this.cursor = displayObject.cursor; - } - } else if (trackingData.over) { - trackingData.over = false; - this.dispatchEvent(displayObject, 'pointerout', this.eventData); - if (isMouse) { - this.dispatchEvent(displayObject, 'mouseout', interactionEvent); - } - // if there is no mouse down information for the pointer, then it is safe to delete - if (trackingData.none) { - delete displayObject.trackedPointers[id]; - } - } - }; - - /** - * Is called when the pointer is moved into the renderer element - * - * @private - * @param {PointerEvent} originalEvent - The DOM event of a pointer button being moved into the renderer view - */ - - - InteractionManager.prototype.onPointerOver = function onPointerOver(originalEvent) { - var events = this.normalizeToPointerData(originalEvent); - - // Only mouse and pointer can call onPointerOver, so events will always be length 1 - var event = events[0]; - - var interactionData = this.getInteractionDataForPointerId(event); - - var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData); - - interactionEvent.data.originalEvent = event; - - if (event.pointerType === 'mouse') { - this.mouseOverRenderer = true; - } - - this.emit('pointerover', interactionEvent); - if (event.pointerType === 'mouse' || event.pointerType === 'pen') { - this.emit('mouseover', interactionEvent); - } - }; - - /** - * Get InteractionData for a given pointerId. Store that data as well - * - * @private - * @param {PointerEvent} event - Normalized pointer event, output from normalizeToPointerData - * @return {PIXI.interaction.InteractionData} - Interaction data for the given pointer identifier - */ - - - InteractionManager.prototype.getInteractionDataForPointerId = function getInteractionDataForPointerId(event) { - var pointerId = event.pointerId; - - var interactionData = void 0; - - if (pointerId === MOUSE_POINTER_ID || event.pointerType === 'mouse') { - interactionData = this.mouse; - } else if (this.activeInteractionData[pointerId]) { - interactionData = this.activeInteractionData[pointerId]; - } else { - interactionData = this.interactionDataPool.pop() || new _InteractionData2.default(); - interactionData.identifier = pointerId; - this.activeInteractionData[pointerId] = interactionData; - } - // copy properties from the event, so that we can make sure that touch/pointer specific - // data is available - interactionData.copyEvent(event); - - return interactionData; - }; - - /** - * Return unused InteractionData to the pool, for a given pointerId - * - * @private - * @param {number} pointerId - Identifier from a pointer event - */ - - - InteractionManager.prototype.releaseInteractionDataForPointerId = function releaseInteractionDataForPointerId(pointerId) { - var interactionData = this.activeInteractionData[pointerId]; - - if (interactionData) { - delete this.activeInteractionData[pointerId]; - interactionData.reset(); - this.interactionDataPool.push(interactionData); - } - }; - - /** - * Configure an InteractionEvent to wrap a DOM PointerEvent and InteractionData - * - * @private - * @param {PIXI.interaction.InteractionEvent} interactionEvent - The event to be configured - * @param {PointerEvent} pointerEvent - The DOM event that will be paired with the InteractionEvent - * @param {PIXI.interaction.InteractionData} interactionData - The InteractionData that will be paired - * with the InteractionEvent - * @return {PIXI.interaction.InteractionEvent} the interaction event that was passed in - */ - - - InteractionManager.prototype.configureInteractionEventForDOMEvent = function configureInteractionEventForDOMEvent(interactionEvent, pointerEvent, interactionData) { - interactionEvent.data = interactionData; - - this.mapPositionToPoint(interactionData.global, pointerEvent.clientX, pointerEvent.clientY); - - // This is the way InteractionManager processed touch events before the refactoring, so I've kept - // it here. But it doesn't make that much sense to me, since mapPositionToPoint already factors - // in this.resolution, so this just divides by this.resolution twice for touch events... - if (navigator.isCocoonJS && pointerEvent.pointerType === 'touch') { - interactionData.global.x = interactionData.global.x / this.resolution; - interactionData.global.y = interactionData.global.y / this.resolution; - } - - // Not really sure why this is happening, but it's how a previous version handled things - if (pointerEvent.pointerType === 'touch') { - pointerEvent.globalX = interactionData.global.x; - pointerEvent.globalY = interactionData.global.y; - } - - interactionData.originalEvent = pointerEvent; - interactionEvent.reset(); - - return interactionEvent; - }; - - /** - * Ensures that the original event object contains all data that a regular pointer event would have - * - * @private - * @param {TouchEvent|MouseEvent|PointerEvent} event - The original event data from a touch or mouse event - * @return {PointerEvent[]} An array containing a single normalized pointer event, in the case of a pointer - * or mouse event, or a multiple normalized pointer events if there are multiple changed touches - */ - - - InteractionManager.prototype.normalizeToPointerData = function normalizeToPointerData(event) { - var normalizedEvents = []; - - if (this.supportsTouchEvents && event instanceof TouchEvent) { - for (var i = 0, li = event.changedTouches.length; i < li; i++) { - var touch = event.changedTouches[i]; - - if (typeof touch.button === 'undefined') touch.button = event.touches.length ? 1 : 0; - if (typeof touch.buttons === 'undefined') touch.buttons = event.touches.length ? 1 : 0; - if (typeof touch.isPrimary === 'undefined') { - touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart'; - } - if (typeof touch.width === 'undefined') touch.width = touch.radiusX || 1; - if (typeof touch.height === 'undefined') touch.height = touch.radiusY || 1; - if (typeof touch.tiltX === 'undefined') touch.tiltX = 0; - if (typeof touch.tiltY === 'undefined') touch.tiltY = 0; - if (typeof touch.pointerType === 'undefined') touch.pointerType = 'touch'; - if (typeof touch.pointerId === 'undefined') touch.pointerId = touch.identifier || 0; - if (typeof touch.pressure === 'undefined') touch.pressure = touch.force || 0.5; - if (typeof touch.twist === 'undefined') touch.twist = 0; - if (typeof touch.tangentialPressure === 'undefined') touch.tangentialPressure = 0; - // TODO: Remove these, as layerX/Y is not a standard, is deprecated, has uneven - // support, and the fill ins are not quite the same - // offsetX/Y might be okay, but is not the same as clientX/Y when the canvas's top - // left is not 0,0 on the page - if (typeof touch.layerX === 'undefined') touch.layerX = touch.offsetX = touch.clientX; - if (typeof touch.layerY === 'undefined') touch.layerY = touch.offsetY = touch.clientY; - - // mark the touch as normalized, just so that we know we did it - touch.isNormalized = true; - - normalizedEvents.push(touch); - } - } - // apparently PointerEvent subclasses MouseEvent, so yay - else if (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof window.PointerEvent))) { - if (typeof event.isPrimary === 'undefined') event.isPrimary = true; - if (typeof event.width === 'undefined') event.width = 1; - if (typeof event.height === 'undefined') event.height = 1; - if (typeof event.tiltX === 'undefined') event.tiltX = 0; - if (typeof event.tiltY === 'undefined') event.tiltY = 0; - if (typeof event.pointerType === 'undefined') event.pointerType = 'mouse'; - if (typeof event.pointerId === 'undefined') event.pointerId = MOUSE_POINTER_ID; - if (typeof event.pressure === 'undefined') event.pressure = 0.5; - if (typeof event.twist === 'undefined') event.twist = 0; - if (typeof event.tangentialPressure === 'undefined') event.tangentialPressure = 0; - - // mark the mouse event as normalized, just so that we know we did it - event.isNormalized = true; - - normalizedEvents.push(event); - } else { - normalizedEvents.push(event); - } - - return normalizedEvents; - }; - - /** - * Destroys the interaction manager - * - */ - - - InteractionManager.prototype.destroy = function destroy() { - this.removeEvents(); - - this.removeAllListeners(); - - this.renderer = null; - - this.mouse = null; - - this.eventData = null; - - this.interactionDOMElement = null; - - this.onPointerDown = null; - this.processPointerDown = null; - - this.onPointerUp = null; - this.processPointerUp = null; - - this.onPointerCancel = null; - this.processPointerCancel = null; - - this.onPointerMove = null; - this.processPointerMove = null; - - this.onPointerOut = null; - this.processPointerOverOut = null; - - this.onPointerOver = null; - - this._tempPoint = null; - }; - - return InteractionManager; -}(_eventemitter2.default); - -exports.default = InteractionManager; - - -core.WebGLRenderer.registerPlugin('interaction', InteractionManager); -core.CanvasRenderer.registerPlugin('interaction', InteractionManager); - -},{"../core":65,"./InteractionData":155,"./InteractionEvent":156,"./InteractionTrackingData":158,"./interactiveTarget":160,"eventemitter3":3}],158:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * DisplayObjects with the {@link PIXI.interaction.interactiveTarget} mixin use this class to track interactions - * - * @class - * @private - * @memberof PIXI.interaction - */ -var InteractionTrackingData = function () { - /** - * @param {number} pointerId - Unique pointer id of the event - */ - function InteractionTrackingData(pointerId) { - _classCallCheck(this, InteractionTrackingData); - - this._pointerId = pointerId; - this._flags = InteractionTrackingData.FLAGS.NONE; - } - - /** - * - * @private - * @param {number} flag - The interaction flag to set - * @param {boolean} yn - Should the flag be set or unset - */ - - - InteractionTrackingData.prototype._doSet = function _doSet(flag, yn) { - if (yn) { - this._flags = this._flags | flag; - } else { - this._flags = this._flags & ~flag; - } - }; - - /** - * Unique pointer id of the event - * - * @readonly - * @member {number} - */ - - - _createClass(InteractionTrackingData, [{ - key: "pointerId", - get: function get() { - return this._pointerId; - } - - /** - * State of the tracking data, expressed as bit flags - * - * @member {number} - * @memberof PIXI.interaction.InteractionTrackingData# - */ - - }, { - key: "flags", - get: function get() { - return this._flags; - } - - /** - * Set the flags for the tracking data - * - * @param {number} flags - Flags to set - */ - , - set: function set(flags) { - this._flags = flags; - } - - /** - * Is the tracked event inactive (not over or down)? - * - * @member {number} - * @memberof PIXI.interaction.InteractionTrackingData# - */ - - }, { - key: "none", - get: function get() { - return this._flags === this.constructor.FLAGS.NONE; - } - - /** - * Is the tracked event over the DisplayObject? - * - * @member {boolean} - * @memberof PIXI.interaction.InteractionTrackingData# - */ - - }, { - key: "over", - get: function get() { - return (this._flags & this.constructor.FLAGS.OVER) !== 0; - } - - /** - * Set the over flag - * - * @param {boolean} yn - Is the event over? - */ - , - set: function set(yn) { - this._doSet(this.constructor.FLAGS.OVER, yn); - } - - /** - * Did the right mouse button come down in the DisplayObject? - * - * @member {boolean} - * @memberof PIXI.interaction.InteractionTrackingData# - */ - - }, { - key: "rightDown", - get: function get() { - return (this._flags & this.constructor.FLAGS.RIGHT_DOWN) !== 0; - } - - /** - * Set the right down flag - * - * @param {boolean} yn - Is the right mouse button down? - */ - , - set: function set(yn) { - this._doSet(this.constructor.FLAGS.RIGHT_DOWN, yn); - } - - /** - * Did the left mouse button come down in the DisplayObject? - * - * @member {boolean} - * @memberof PIXI.interaction.InteractionTrackingData# - */ - - }, { - key: "leftDown", - get: function get() { - return (this._flags & this.constructor.FLAGS.LEFT_DOWN) !== 0; - } - - /** - * Set the left down flag - * - * @param {boolean} yn - Is the left mouse button down? - */ - , - set: function set(yn) { - this._doSet(this.constructor.FLAGS.LEFT_DOWN, yn); - } - }]); - - return InteractionTrackingData; -}(); - -exports.default = InteractionTrackingData; - - -InteractionTrackingData.FLAGS = Object.freeze({ - NONE: 0, - OVER: 1 << 0, - LEFT_DOWN: 1 << 1, - RIGHT_DOWN: 1 << 2 -}); - -},{}],159:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _InteractionData = require('./InteractionData'); - -Object.defineProperty(exports, 'InteractionData', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_InteractionData).default; - } -}); - -var _InteractionManager = require('./InteractionManager'); - -Object.defineProperty(exports, 'InteractionManager', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_InteractionManager).default; - } -}); - -var _interactiveTarget = require('./interactiveTarget'); - -Object.defineProperty(exports, 'interactiveTarget', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_interactiveTarget).default; - } -}); - -var _InteractionTrackingData = require('./InteractionTrackingData'); - -Object.defineProperty(exports, 'InteractionTrackingData', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_InteractionTrackingData).default; - } -}); - -var _InteractionEvent = require('./InteractionEvent'); - -Object.defineProperty(exports, 'InteractionEvent', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_InteractionEvent).default; - } -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"./InteractionData":155,"./InteractionEvent":156,"./InteractionManager":157,"./InteractionTrackingData":158,"./interactiveTarget":160}],160:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -/** - * Default property values of interactive objects - * Used by {@link PIXI.interaction.InteractionManager} to automatically give all DisplayObjects these properties - * - * @private - * @name interactiveTarget - * @memberof PIXI.interaction - * @example - * function MyObject() {} - * - * Object.assign( - * core.DisplayObject.prototype, - * PIXI.interaction.interactiveTarget - * ); - */ -exports.default = { - - /** - * Enable interaction events for the DisplayObject. Touch, pointer and mouse - * events will not be emitted unless `interactive` is set to `true`. - * - * @example - * const sprite = new PIXI.Sprite(texture); - * sprite.interactive = true; - * sprite.on('tap', (event) => { - * //handle event - * }); - * @member {boolean} - * @memberof PIXI.DisplayObject# - */ - interactive: false, - - /** - * Determines if the children to the displayObject can be clicked/touched - * Setting this to false allows PixiJS to bypass a recursive `hitTest` function - * - * @member {boolean} - * @memberof PIXI.Container# - */ - interactiveChildren: true, - - /** - * Interaction shape. Children will be hit first, then this shape will be checked. - * Setting this will cause this shape to be checked in hit tests rather than the displayObject's bounds. - * - * @example - * const sprite = new PIXI.Sprite(texture); - * sprite.interactive = true; - * sprite.hitArea = new PIXI.Rectangle(0, 0, 100, 100); - * @member {PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle} - * @memberof PIXI.DisplayObject# - */ - hitArea: null, - - /** - * If enabled, the mouse cursor use the pointer behavior when hovered over the displayObject if it is interactive - * Setting this changes the 'cursor' property to `'pointer'`. - * - * @example - * const sprite = new PIXI.Sprite(texture); - * sprite.interactive = true; - * sprite.buttonMode = true; - * @member {boolean} - * @memberof PIXI.DisplayObject# - */ - get buttonMode() { - return this.cursor === 'pointer'; - }, - set buttonMode(value) { - if (value) { - this.cursor = 'pointer'; - } else if (this.cursor === 'pointer') { - this.cursor = null; - } - }, - - /** - * This defines what cursor mode is used when the mouse cursor - * is hovered over the displayObject. - * - * @example - * const sprite = new PIXI.Sprite(texture); - * sprite.interactive = true; - * sprite.cursor = 'wait'; - * @see https://developer.mozilla.org/en/docs/Web/CSS/cursor - * - * @member {string} - * @memberof PIXI.DisplayObject# - */ - cursor: null, - - /** - * Internal set of all active pointers, by identifier - * - * @member {Map} - * @memberof PIXI.DisplayObject# - * @private - */ - get trackedPointers() { - if (this._trackedPointers === undefined) this._trackedPointers = {}; - - return this._trackedPointers; - }, - - /** - * Map of all tracked pointers, by identifier. Use trackedPointers to access. - * - * @private - * @type {Map} - */ - _trackedPointers: undefined -}; - -},{}],161:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.parse = parse; - -exports.default = function () { - return function bitmapFontParser(resource, next) { - // skip if no data or not xml data - if (!resource.data || resource.type !== _resourceLoader.Resource.TYPE.XML) { - next(); - - return; - } - - // skip if not bitmap font data, using some silly duck-typing - if (resource.data.getElementsByTagName('page').length === 0 || resource.data.getElementsByTagName('info').length === 0 || resource.data.getElementsByTagName('info')[0].getAttribute('face') === null) { - next(); - - return; - } - - var xmlUrl = !resource.isDataUrl ? path.dirname(resource.url) : ''; - - if (resource.isDataUrl) { - if (xmlUrl === '.') { - xmlUrl = ''; - } - - if (this.baseUrl && xmlUrl) { - // if baseurl has a trailing slash then add one to xmlUrl so the replace works below - if (this.baseUrl.charAt(this.baseUrl.length - 1) === '/') { - xmlUrl += '/'; - } - } - } - - // remove baseUrl from xmlUrl - xmlUrl = xmlUrl.replace(this.baseUrl, ''); - - // if there is an xmlUrl now, it needs a trailing slash. Ensure that it does if the string isn't empty. - if (xmlUrl && xmlUrl.charAt(xmlUrl.length - 1) !== '/') { - xmlUrl += '/'; - } - - var pages = resource.data.getElementsByTagName('page'); - var textures = {}; - - // Handle completed, when the number of textures - // load is the same number as references in the fnt file - var completed = function completed(page) { - textures[page.metadata.pageFile] = page.texture; - - if (Object.keys(textures).length === pages.length) { - parse(resource, textures); - next(); - } - }; - - for (var i = 0; i < pages.length; ++i) { - var pageFile = pages[i].getAttribute('file'); - var url = xmlUrl + pageFile; - var exists = false; - - // incase the image is loaded outside - // using the same loader, resource will be available - for (var name in this.resources) { - var bitmapResource = this.resources[name]; - - if (bitmapResource.url === url) { - bitmapResource.metadata.pageFile = pageFile; - if (bitmapResource.texture) { - completed(bitmapResource); - } else { - bitmapResource.onAfterMiddleware.add(completed); - } - exists = true; - break; - } - } - - // texture is not loaded, we'll attempt to add - // it to the load and add the texture to the list - if (!exists) { - // Standard loading options for images - var options = { - crossOrigin: resource.crossOrigin, - loadType: _resourceLoader.Resource.LOAD_TYPE.IMAGE, - metadata: Object.assign({ pageFile: pageFile }, resource.metadata.imageMetadata), - parentResource: resource - }; - - this.add(url, options, completed); - } - } - }; -}; - -var _path = require('path'); - -var path = _interopRequireWildcard(_path); - -var _resourceLoader = require('resource-loader'); - -var _extras = require('../extras'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -/** - * Register a BitmapText font from loader resource. - * - * @function parseBitmapFontData - * @memberof PIXI.loaders - * @param {PIXI.loaders.Resource} resource - Loader resource. - * @param {PIXI.Texture|PIXI.Texture[]} textures - List of textures for each page. - */ -function parse(resource, textures) { - resource.bitmapFont = _extras.BitmapText.registerFont(resource.data, textures); -} - -},{"../extras":141,"path":8,"resource-loader":36}],162:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; -exports.shared = exports.Resource = exports.textureParser = exports.getResourcePath = exports.spritesheetParser = exports.parseBitmapFontData = exports.bitmapFontParser = exports.Loader = undefined; - -var _bitmapFontParser = require('./bitmapFontParser'); - -Object.defineProperty(exports, 'bitmapFontParser', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_bitmapFontParser).default; - } -}); -Object.defineProperty(exports, 'parseBitmapFontData', { - enumerable: true, - get: function get() { - return _bitmapFontParser.parse; - } -}); - -var _spritesheetParser = require('./spritesheetParser'); - -Object.defineProperty(exports, 'spritesheetParser', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_spritesheetParser).default; - } -}); -Object.defineProperty(exports, 'getResourcePath', { - enumerable: true, - get: function get() { - return _spritesheetParser.getResourcePath; - } -}); - -var _textureParser = require('./textureParser'); - -Object.defineProperty(exports, 'textureParser', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_textureParser).default; - } -}); - -var _resourceLoader = require('resource-loader'); - -Object.defineProperty(exports, 'Resource', { - enumerable: true, - get: function get() { - return _resourceLoader.Resource; - } -}); - -var _Application = require('../core/Application'); - -var _Application2 = _interopRequireDefault(_Application); - -var _loader = require('./loader'); - -var _loader2 = _interopRequireDefault(_loader); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * This namespace contains APIs which extends the {@link https://github.com/englercj/resource-loader resource-loader} module - * for loading assets, data, and other resources dynamically. - * @example - * const loader = new PIXI.loaders.Loader(); - * loader.add('bunny', 'data/bunny.png') - * .add('spaceship', 'assets/spritesheet.json'); - * loader.load((loader, resources) => { - * // resources.bunny - * // resources.spaceship - * }); - * @namespace PIXI.loaders - */ -exports.Loader = _loader2.default; - - -/** - * A premade instance of the loader that can be used to load resources. - * @name shared - * @memberof PIXI.loaders - * @type {PIXI.loaders.Loader} - */ -var shared = new _loader2.default(); - -shared.destroy = function () { - // protect destroying shared loader -}; - -exports.shared = shared; - -// Mixin the loader construction - -var AppPrototype = _Application2.default.prototype; - -AppPrototype._loader = null; - -/** - * Loader instance to help with asset loading. - * @name PIXI.Application#loader - * @type {PIXI.loaders.Loader} - */ -Object.defineProperty(AppPrototype, 'loader', { - get: function get() { - if (!this._loader) { - var sharedLoader = this._options.sharedLoader; - - this._loader = sharedLoader ? shared : new _loader2.default(); - } - - return this._loader; - } -}); - -// Override the destroy function -// making sure to destroy the current Loader -AppPrototype._parentDestroy = AppPrototype.destroy; -AppPrototype.destroy = function destroy(removeView, stageOptions) { - if (this._loader) { - this._loader.destroy(); - this._loader = null; - } - this._parentDestroy(removeView, stageOptions); -}; - -},{"../core/Application":43,"./bitmapFontParser":161,"./loader":163,"./spritesheetParser":164,"./textureParser":165,"resource-loader":36}],163:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _resourceLoader = require('resource-loader'); - -var _resourceLoader2 = _interopRequireDefault(_resourceLoader); - -var _blob = require('resource-loader/lib/middlewares/parsing/blob'); - -var _eventemitter = require('eventemitter3'); - -var _eventemitter2 = _interopRequireDefault(_eventemitter); - -var _textureParser = require('./textureParser'); - -var _textureParser2 = _interopRequireDefault(_textureParser); - -var _spritesheetParser = require('./spritesheetParser'); - -var _spritesheetParser2 = _interopRequireDefault(_spritesheetParser); - -var _bitmapFontParser = require('./bitmapFontParser'); - -var _bitmapFontParser2 = _interopRequireDefault(_bitmapFontParser); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * - * The new loader, extends Resource Loader by Chad Engler: https://github.com/englercj/resource-loader - * - * ```js - * const loader = PIXI.loader; // PixiJS exposes a premade instance for you to use. - * //or - * const loader = new PIXI.loaders.Loader(); // you can also create your own if you want - * - * const sprites = {}; - * - * // Chainable `add` to enqueue a resource - * loader.add('bunny', 'data/bunny.png') - * .add('spaceship', 'assets/spritesheet.json'); - * loader.add('scoreFont', 'assets/score.fnt'); - * - * // Chainable `pre` to add a middleware that runs for each resource, *before* loading that resource. - * // This is useful to implement custom caching modules (using filesystem, indexeddb, memory, etc). - * loader.pre(cachingMiddleware); - * - * // Chainable `use` to add a middleware that runs for each resource, *after* loading that resource. - * // This is useful to implement custom parsing modules (like spritesheet parsers, spine parser, etc). - * loader.use(parsingMiddleware); - * - * // The `load` method loads the queue of resources, and calls the passed in callback called once all - * // resources have loaded. - * loader.load((loader, resources) => { - * // resources is an object where the key is the name of the resource loaded and the value is the resource object. - * // They have a couple default properties: - * // - `url`: The URL that the resource was loaded from - * // - `error`: The error that happened when trying to load (if any) - * // - `data`: The raw data that was loaded - * // also may contain other properties based on the middleware that runs. - * sprites.bunny = new PIXI.TilingSprite(resources.bunny.texture); - * sprites.spaceship = new PIXI.TilingSprite(resources.spaceship.texture); - * sprites.scoreFont = new PIXI.TilingSprite(resources.scoreFont.texture); - * }); - * - * // throughout the process multiple signals can be dispatched. - * loader.onProgress.add(() => {}); // called once per loaded/errored file - * loader.onError.add(() => {}); // called once per errored file - * loader.onLoad.add(() => {}); // called once per loaded file - * loader.onComplete.add(() => {}); // called once when the queued resources all load. - * ``` - * - * @see https://github.com/englercj/resource-loader - * - * @class - * @extends module:resource-loader.ResourceLoader - * @memberof PIXI.loaders - */ -var Loader = function (_ResourceLoader) { - _inherits(Loader, _ResourceLoader); - - /** - * @param {string} [baseUrl=''] - The base url for all resources loaded by this loader. - * @param {number} [concurrency=10] - The number of resources to load concurrently. - */ - function Loader(baseUrl, concurrency) { - _classCallCheck(this, Loader); - - var _this = _possibleConstructorReturn(this, _ResourceLoader.call(this, baseUrl, concurrency)); - - _eventemitter2.default.call(_this); - - for (var i = 0; i < Loader._pixiMiddleware.length; ++i) { - _this.use(Loader._pixiMiddleware[i]()); - } - - // Compat layer, translate the new v2 signals into old v1 events. - _this.onStart.add(function (l) { - return _this.emit('start', l); - }); - _this.onProgress.add(function (l, r) { - return _this.emit('progress', l, r); - }); - _this.onError.add(function (e, l, r) { - return _this.emit('error', e, l, r); - }); - _this.onLoad.add(function (l, r) { - return _this.emit('load', l, r); - }); - _this.onComplete.add(function (l, r) { - return _this.emit('complete', l, r); - }); - return _this; - } - - /** - * Adds a default middleware to the PixiJS loader. - * - * @static - * @param {Function} fn - The middleware to add. - */ - - - Loader.addPixiMiddleware = function addPixiMiddleware(fn) { - Loader._pixiMiddleware.push(fn); - }; - - /** - * Destroy the loader, removes references. - */ - - - Loader.prototype.destroy = function destroy() { - this.removeAllListeners(); - this.reset(); - }; - - return Loader; -}(_resourceLoader2.default); - -// Copy EE3 prototype (mixin) - - -exports.default = Loader; -for (var k in _eventemitter2.default.prototype) { - Loader.prototype[k] = _eventemitter2.default.prototype[k]; -} - -Loader._pixiMiddleware = [ -// parse any blob into more usable objects (e.g. Image) -_blob.blobMiddlewareFactory, -// parse any Image objects into textures -_textureParser2.default, -// parse any spritesheet data into multiple textures -_spritesheetParser2.default, -// parse bitmap font data into multiple textures -_bitmapFontParser2.default]; - -// Add custom extentions -var Resource = _resourceLoader2.default.Resource; - -Resource.setExtensionXhrType('fnt', Resource.XHR_RESPONSE_TYPE.DOCUMENT); - -},{"./bitmapFontParser":161,"./spritesheetParser":164,"./textureParser":165,"eventemitter3":3,"resource-loader":36,"resource-loader/lib/middlewares/parsing/blob":37}],164:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -exports.default = function () { - return function spritesheetParser(resource, next) { - var imageResourceName = resource.name + '_image'; - - // skip if no data, its not json, it isn't spritesheet data, or the image resource already exists - if (!resource.data || resource.type !== _resourceLoader.Resource.TYPE.JSON || !resource.data.frames || this.resources[imageResourceName]) { - next(); - - return; - } - - var loadOptions = { - crossOrigin: resource.crossOrigin, - metadata: resource.metadata.imageMetadata, - parentResource: resource - }; - - var resourcePath = getResourcePath(resource, this.baseUrl); - - // load the image for this sheet - this.add(imageResourceName, resourcePath, loadOptions, function onImageLoad(res) { - if (res.error) { - next(res.error); - - return; - } - - var spritesheet = new _core.Spritesheet(res.texture.baseTexture, resource.data, resource.url); - - spritesheet.parse(function () { - resource.spritesheet = spritesheet; - resource.textures = spritesheet.textures; - next(); - }); - }); - }; -}; - -exports.getResourcePath = getResourcePath; - -var _resourceLoader = require('resource-loader'); - -var _url = require('url'); - -var _url2 = _interopRequireDefault(_url); - -var _core = require('../core'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function getResourcePath(resource, baseUrl) { - // Prepend url path unless the resource image is a data url - if (resource.isDataUrl) { - return resource.data.meta.image; - } - - return _url2.default.resolve(resource.url.replace(baseUrl, ''), resource.data.meta.image); -} - -},{"../core":65,"resource-loader":36,"url":38}],165:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -exports.default = function () { - return function textureParser(resource, next) { - // create a new texture if the data is an Image object - if (resource.data && resource.type === _resourceLoader.Resource.TYPE.IMAGE) { - resource.texture = _Texture2.default.fromLoader(resource.data, resource.url, resource.name); - } - next(); - }; -}; - -var _resourceLoader = require('resource-loader'); - -var _Texture = require('../core/textures/Texture'); - -var _Texture2 = _interopRequireDefault(_Texture); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"../core/textures/Texture":115,"resource-loader":36}],166:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -var _Texture = require('../core/textures/Texture'); - -var _Texture2 = _interopRequireDefault(_Texture); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var tempPoint = new core.Point(); -var tempPolygon = new core.Polygon(); - -/** - * Base mesh class - * @class - * @extends PIXI.Container - * @memberof PIXI.mesh - */ - -var Mesh = function (_core$Container) { - _inherits(Mesh, _core$Container); - - /** - * @param {PIXI.Texture} texture - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts - */ - function Mesh(texture, vertices, uvs, indices, drawMode) { - _classCallCheck(this, Mesh); - - /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private - */ - var _this = _possibleConstructorReturn(this, _core$Container.call(this)); - - _this._texture = texture || _Texture2.default.EMPTY; - - /** - * The Uvs of the Mesh - * - * @member {Float32Array} - */ - _this.uvs = uvs || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]); - - /** - * An array of vertices - * - * @member {Float32Array} - */ - _this.vertices = vertices || new Float32Array([0, 0, 100, 0, 100, 100, 0, 100]); - - /** - * An array containing the indices of the vertices - * - * @member {Uint16Array} - */ - // TODO auto generate this based on draw mode! - _this.indices = indices || new Uint16Array([0, 1, 3, 2]); - - /** - * Version of mesh uvs are dirty or not - * - * @member {number} - */ - _this.dirty = 0; - - /** - * Version of mesh indices - * - * @member {number} - */ - _this.indexDirty = 0; - - /** - * Version of mesh verticies array - * - * @member {number} - */ - _this.vertexDirty = 0; - - /** - * For backwards compatibility the default is to re-upload verticies each render call. - * Set this to `false` and increase `vertexDirty` to manually re-upload the buffer. - * - * @member {boolean} - */ - _this.autoUpdate = true; - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove - * any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - _this.blendMode = core.BLEND_MODES.NORMAL; - - /** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. - * - * @member {number} - */ - _this.canvasPadding = core.settings.MESH_CANVAS_PADDING; - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.mesh.Mesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.mesh.Mesh.DRAW_MODES - */ - _this.drawMode = drawMode || Mesh.DRAW_MODES.TRIANGLE_MESH; - - /** - * The default shader that is used if a mesh doesn't have a more specific one. - * - * @member {PIXI.Shader} - */ - _this.shader = null; - - /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. - * - * @member {number} - */ - _this.tintRgb = new Float32Array([1, 1, 1]); - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - _this._glDatas = {}; - - /** - * transform that is applied to UV to get the texture coords - * its updated independently from texture uvTransform - * updates of uvs are tied to that thing - * - * @member {PIXI.TextureMatrix} - * @private - */ - _this._uvTransform = new core.TextureMatrix(_this._texture); - - /** - * whether or not upload uvTransform to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - _this.uploadUvTransform = false; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_renderWebGL' & '_renderCanvas' methods. - * @member {string} - * @default 'mesh' - */ - _this.pluginName = 'mesh'; - return _this; - } - - /** - * Renders the object using the WebGL renderer - * - * @private - * @param {PIXI.WebGLRenderer} renderer - a reference to the WebGL renderer - */ - - - Mesh.prototype._renderWebGL = function _renderWebGL(renderer) { - this.refresh(); - renderer.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - }; - - /** - * Renders the object using the Canvas renderer - * - * @private - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ - - - Mesh.prototype._renderCanvas = function _renderCanvas(renderer) { - this.refresh(); - renderer.plugins[this.pluginName].render(this); - }; - - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - - - Mesh.prototype._onTextureUpdate = function _onTextureUpdate() { - this._uvTransform.texture = this._texture; - this.refresh(); - }; - - /** - * multiplies uvs only if uploadUvTransform is false - * call it after you change uvs manually - * make sure that texture is valid - */ - - - Mesh.prototype.multiplyUvs = function multiplyUvs() { - if (!this.uploadUvTransform) { - this._uvTransform.multiplyUvs(this.uvs); - } - }; - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - - - Mesh.prototype.refresh = function refresh(forceUpdate) { - if (this.autoUpdate) { - this.vertexDirty++; - } - if (this._uvTransform.update(forceUpdate)) { - this._refresh(); - } - }; - - /** - * re-calculates mesh coords - * @protected - */ - - - Mesh.prototype._refresh = function _refresh() {} - /* empty */ - - - /** - * Returns the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * - */ - ; - - Mesh.prototype._calculateBounds = function _calculateBounds() { - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, this.vertices, 0, this.vertices.length); - }; - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point - the point to test - * @return {boolean} the result of the test - */ - - - Mesh.prototype.containsPoint = function containsPoint(point) { - if (!this.getBounds().contains(point.x, point.y)) { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - var vertices = this.vertices; - var points = tempPolygon.points; - var indices = this.indices; - var len = this.indices.length; - var step = this.drawMode === Mesh.DRAW_MODES.TRIANGLES ? 3 : 1; - - for (var i = 0; i + 2 < len; i += step) { - var ind0 = indices[i] * 2; - var ind1 = indices[i + 1] * 2; - var ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - return true; - } - } - - return false; - }; - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - - - /** - * Destroys the Mesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - Mesh.prototype.destroy = function destroy(options) { - // for each webgl data entry, destroy the WebGLGraphicsData - for (var id in this._glDatas) { - var data = this._glDatas[id]; - - if (data.destroy) { - data.destroy(); - } else { - if (data.vertexBuffer) { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - _core$Container.prototype.destroy.call(this, options); - }; - - _createClass(Mesh, [{ - key: 'texture', - get: function get() { - return this._texture; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) { - return; - } - - this._texture = value; - - if (value) { - // wait for the texture to load - if (value.baseTexture.hasLoaded) { - this._onTextureUpdate(); - } else { - value.once('update', this._onTextureUpdate, this); - } - } - } - - /** - * The tint applied to the mesh. This is a hex value. A value of 0xFFFFFF will remove any tint effect. - * - * @member {number} - * @default 0xFFFFFF - */ - - }, { - key: 'tint', - get: function get() { - return core.utils.rgb2hex(this.tintRgb); - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this.tintRgb = core.utils.hex2rgb(value, this.tintRgb); - } - }]); - - return Mesh; -}(core.Container); - -/** - * Different drawing buffer modes supported - * - * @static - * @constant - * @type {object} - * @property {number} TRIANGLE_MESH - * @property {number} TRIANGLES - */ - - -exports.default = Mesh; -Mesh.DRAW_MODES = { - TRIANGLE_MESH: 0, - TRIANGLES: 1 -}; - -},{"../core":65,"../core/textures/Texture":115}],167:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _Plane2 = require('./Plane'); - -var _Plane3 = _interopRequireDefault(_Plane2); - -var _CanvasTinter = require('../core/sprites/canvas/CanvasTinter'); - -var _CanvasTinter2 = _interopRequireDefault(_CanvasTinter); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.fromImage('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.mesh.Plane - * @memberof PIXI.mesh - * - */ - -var NineSlicePlane = function (_Plane) { - _inherits(NineSlicePlane, _Plane); - - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight) { - _classCallCheck(this, NineSlicePlane); - - var _this = _possibleConstructorReturn(this, _Plane.call(this, texture, 4, 4)); - - _this._origWidth = texture.orig.width; - _this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - _this._width = _this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - _this._height = _this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - _this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - _this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - _this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - _this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - /** - * Cached tint value so we can tell when the tint is changed. - * - * @member {number} - * @protected - */ - _this._cachedTint = 0xFFFFFF; - - /** - * Cached tinted texture. - * - * @member {HTMLCanvasElement} - * @protected - */ - _this._tintedTexture = null; - - /** - * Temporary storage for canvas source coords - * - * @member {number[]} - * @private - */ - _this._canvasUvs = null; - - _this.refresh(true); - return _this; - } - - /** - * Updates the horizontal vertices. - * - */ - - - NineSlicePlane.prototype.updateHorizontalVertices = function updateHorizontalVertices() { - var vertices = this.vertices; - - var h = this._topHeight + this._bottomHeight; - var scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - this._bottomHeight * scale; - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - }; - - /** - * Updates the vertical vertices. - * - */ - - - NineSlicePlane.prototype.updateVerticalVertices = function updateVerticalVertices() { - var vertices = this.vertices; - - var w = this._leftWidth + this._rightWidth; - var scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - this._rightWidth * scale; - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - }; - - /** - * Renders the object using the Canvas renderer - * - * @private - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer to render with. - */ - - - NineSlicePlane.prototype._renderCanvas = function _renderCanvas(renderer) { - var context = renderer.context; - var transform = this.worldTransform; - var res = renderer.resolution; - var isTinted = this.tint !== 0xFFFFFF; - var texture = this._texture; - - // Work out tinting - if (isTinted) { - if (this._cachedTint !== this.tint) { - // Tint has changed, need to update the tinted texture and use that instead - - this._cachedTint = this.tint; - - this._tintedTexture = _CanvasTinter2.default.getTintedTexture(this, this.tint); - } - } - - var textureSource = !isTinted ? texture.baseTexture.source : this._tintedTexture; - - if (!this._canvasUvs) { - this._canvasUvs = [0, 0, 0, 0, 0, 0, 0, 0]; - } - - var vertices = this.vertices; - var uvs = this._canvasUvs; - var u0 = isTinted ? 0 : texture.frame.x; - var v0 = isTinted ? 0 : texture.frame.y; - var u1 = u0 + texture.frame.width; - var v1 = v0 + texture.frame.height; - - uvs[0] = u0; - uvs[1] = u0 + this._leftWidth; - uvs[2] = u1 - this._rightWidth; - uvs[3] = u1; - uvs[4] = v0; - uvs[5] = v0 + this._topHeight; - uvs[6] = v1 - this._bottomHeight; - uvs[7] = v1; - - for (var i = 0; i < 8; i++) { - uvs[i] *= texture.baseTexture.resolution; - } - - context.globalAlpha = this.worldAlpha; - renderer.setBlendMode(this.blendMode); - - if (renderer.roundPixels) { - context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res | 0, transform.ty * res | 0); - } else { - context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res, transform.ty * res); - } - - for (var row = 0; row < 3; row++) { - for (var col = 0; col < 3; col++) { - var ind = col * 2 + row * 8; - var sw = Math.max(1, uvs[col + 1] - uvs[col]); - var sh = Math.max(1, uvs[row + 5] - uvs[row + 4]); - var dw = Math.max(1, vertices[ind + 10] - vertices[ind]); - var dh = Math.max(1, vertices[ind + 11] - vertices[ind + 1]); - - context.drawImage(textureSource, uvs[col], uvs[row + 4], sw, sh, vertices[ind], vertices[ind + 1], dw, dh); - } - } - }; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - NineSlicePlane.prototype._refresh = function _refresh() { - _Plane.prototype._refresh.call(this); - - var uvs = this.uvs; - var texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - var _uvw = 1.0 / this._origWidth; - var _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - _uvw * this._rightWidth; - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - _uvh * this._bottomHeight; - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.dirty++; - - this.multiplyUvs(); - }; - - _createClass(NineSlicePlane, [{ - key: 'width', - get: function get() { - return this._width; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - - }, { - key: 'height', - get: function get() { - return this._height; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - - }, { - key: 'leftWidth', - get: function get() { - return this._leftWidth; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - - }, { - key: 'rightWidth', - get: function get() { - return this._rightWidth; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - - }, { - key: 'topHeight', - get: function get() { - return this._topHeight; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - - }, { - key: 'bottomHeight', - get: function get() { - return this._bottomHeight; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - }]); - - return NineSlicePlane; -}(_Plane3.default); - -exports.default = NineSlicePlane; - -},{"../core/sprites/canvas/CanvasTinter":104,"./Plane":168}],168:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Mesh2 = require('./Mesh'); - -var _Mesh3 = _interopRequireDefault(_Mesh2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.fromImage("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.mesh.Mesh - * @memberof PIXI.mesh - * - */ -var Plane = function (_Mesh) { - _inherits(Plane, _Mesh); - - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} [verticesX=10] - The number of vertices in the x-axis - * @param {number} [verticesY=10] - The number of vertices in the y-axis - */ - function Plane(texture, verticesX, verticesY) { - _classCallCheck(this, Plane); - - /** - * Tracker for if the Plane is ready to be drawn. Needed because Mesh ctor can - * call _onTextureUpdated which could call refresh too early. - * - * @member {boolean} - * @private - */ - var _this = _possibleConstructorReturn(this, _Mesh.call(this, texture)); - - _this._ready = true; - - _this.verticesX = verticesX || 10; - _this.verticesY = verticesY || 10; - - _this.drawMode = _Mesh3.default.DRAW_MODES.TRIANGLES; - _this.refresh(); - return _this; - } - - /** - * Refreshes plane coordinates - * - */ - - - Plane.prototype._refresh = function _refresh() { - var texture = this._texture; - var total = this.verticesX * this.verticesY; - var verts = []; - var colors = []; - var uvs = []; - var indices = []; - - var segmentsX = this.verticesX - 1; - var segmentsY = this.verticesY - 1; - - var sizeX = texture.width / segmentsX; - var sizeY = texture.height / segmentsY; - - for (var i = 0; i < total; i++) { - var x = i % this.verticesX; - var y = i / this.verticesX | 0; - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - var totalSub = segmentsX * segmentsY; - - for (var _i = 0; _i < totalSub; _i++) { - var xpos = _i % segmentsX; - var ypos = _i / segmentsX | 0; - - var value = ypos * this.verticesX + xpos; - var value2 = ypos * this.verticesX + xpos + 1; - var value3 = (ypos + 1) * this.verticesX + xpos; - var value4 = (ypos + 1) * this.verticesX + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - // console.log(indices) - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.colors = new Float32Array(colors); - this.indices = new Uint16Array(indices); - - this.dirty++; - this.indexDirty++; - - this.multiplyUvs(); - }; - - /** - * Clear texture UVs when new texture is set - * - * @private - */ - - - Plane.prototype._onTextureUpdate = function _onTextureUpdate() { - _Mesh3.default.prototype._onTextureUpdate.call(this); - - // wait for the Plane ctor to finish before calling refresh - if (this._ready) { - this.refresh(); - } - }; - - return Plane; -}(_Mesh3.default); - -exports.default = Plane; - -},{"./Mesh":166}],169:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Mesh2 = require('./Mesh'); - -var _Mesh3 = _interopRequireDefault(_Mesh2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.fromImage("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.mesh.Mesh - * @memberof PIXI.mesh - * - */ -var Rope = function (_Mesh) { - _inherits(Rope, _Mesh); - - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - function Rope(texture, points) { - _classCallCheck(this, Rope); - - /** - * An array of points that determine the rope - * - * @member {PIXI.Point[]} - */ - var _this = _possibleConstructorReturn(this, _Mesh.call(this, texture)); - - _this.points = points; - - /** - * An array of vertices used to construct this rope. - * - * @member {Float32Array} - */ - _this.vertices = new Float32Array(points.length * 4); - - /** - * The WebGL Uvs of the rope. - * - * @member {Float32Array} - */ - _this.uvs = new Float32Array(points.length * 4); - - /** - * An array containing the color components - * - * @member {Float32Array} - */ - _this.colors = new Float32Array(points.length * 2); - - /** - * An array containing the indices of the vertices - * - * @member {Uint16Array} - */ - _this.indices = new Uint16Array(points.length * 2); - - /** - * refreshes vertices on every updateTransform - * @member {boolean} - * @default true - */ - _this.autoUpdate = true; - - _this.refresh(); - return _this; - } - - /** - * Refreshes - * - */ - - - Rope.prototype._refresh = function _refresh() { - var points = this.points; - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this._texture._uvs) { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (this.vertices.length / 4 !== points.length) { - this.vertices = new Float32Array(points.length * 4); - this.uvs = new Float32Array(points.length * 4); - this.colors = new Float32Array(points.length * 2); - this.indices = new Uint16Array(points.length * 2); - } - - var uvs = this.uvs; - - var indices = this.indices; - var colors = this.colors; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - colors[0] = 1; - colors[1] = 1; - - indices[0] = 0; - indices[1] = 1; - - var total = points.length; - - for (var i = 1; i < total; i++) { - // time to do some smart drawing! - var index = i * 4; - var amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - colors[index] = 1; - colors[index + 1] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - this.dirty++; - this.indexDirty++; - - this.multiplyUvs(); - this.refreshVertices(); - }; - - /** - * refreshes vertices of Rope mesh - */ - - - Rope.prototype.refreshVertices = function refreshVertices() { - var points = this.points; - - if (points.length < 1) { - return; - } - - var lastPoint = points[0]; - var nextPoint = void 0; - var perpX = 0; - var perpY = 0; - - // this.count -= 0.2; - - var vertices = this.vertices; - var total = points.length; - - for (var i = 0; i < total; i++) { - var point = points[i]; - var index = i * 4; - - if (i < points.length - 1) { - nextPoint = points[i + 1]; - } else { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - var ratio = (1 - i / (total - 1)) * 10; - - if (ratio > 1) { - ratio = 1; - } - - var perpLength = Math.sqrt(perpX * perpX + perpY * perpY); - var num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - }; - - /** - * Updates the object transform for rendering - * - * @private - */ - - - Rope.prototype.updateTransform = function updateTransform() { - if (this.autoUpdate) { - this.refreshVertices(); - } - this.containerUpdateTransform(); - }; - - return Rope; -}(_Mesh3.default); - -exports.default = Rope; - -},{"./Mesh":166}],170:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _Mesh = require('../Mesh'); - -var _Mesh2 = _interopRequireDefault(_Mesh); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Renderer dedicated to meshes. - * - * @class - * @private - * @memberof PIXI - */ -var MeshSpriteRenderer = function () { - /** - * @param {PIXI.CanvasRenderer} renderer - The renderer this downport works for - */ - function MeshSpriteRenderer(renderer) { - _classCallCheck(this, MeshSpriteRenderer); - - this.renderer = renderer; - } - - /** - * Renders the Mesh - * - * @param {PIXI.mesh.Mesh} mesh - the Mesh to render - */ - - - MeshSpriteRenderer.prototype.render = function render(mesh) { - var renderer = this.renderer; - var context = renderer.context; - - var transform = mesh.worldTransform; - var res = renderer.resolution; - - if (renderer.roundPixels) { - context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res | 0, transform.ty * res | 0); - } else { - context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res, transform.ty * res); - } - - renderer.context.globalAlpha = mesh.worldAlpha; - renderer.setBlendMode(mesh.blendMode); - - if (mesh.drawMode === _Mesh2.default.DRAW_MODES.TRIANGLE_MESH) { - this._renderTriangleMesh(mesh); - } else { - this._renderTriangles(mesh); - } - }; - - /** - * Draws the object in Triangle Mesh mode - * - * @private - * @param {PIXI.mesh.Mesh} mesh - the Mesh to render - */ - - - MeshSpriteRenderer.prototype._renderTriangleMesh = function _renderTriangleMesh(mesh) { - // draw triangles!! - var length = mesh.vertices.length / 2; - - for (var i = 0; i < length - 2; i++) { - // draw some triangles! - var index = i * 2; - - this._renderDrawTriangle(mesh, index, index + 2, index + 4); - } - }; - - /** - * Draws the object in triangle mode using canvas - * - * @private - * @param {PIXI.mesh.Mesh} mesh - the current mesh - */ - - - MeshSpriteRenderer.prototype._renderTriangles = function _renderTriangles(mesh) { - // draw triangles!! - var indices = mesh.indices; - var length = indices.length; - - for (var i = 0; i < length; i += 3) { - // draw some triangles! - var index0 = indices[i] * 2; - var index1 = indices[i + 1] * 2; - var index2 = indices[i + 2] * 2; - - this._renderDrawTriangle(mesh, index0, index1, index2); - } - }; - - /** - * Draws one of the triangles that from the Mesh - * - * @private - * @param {PIXI.mesh.Mesh} mesh - the current mesh - * @param {number} index0 - the index of the first vertex - * @param {number} index1 - the index of the second vertex - * @param {number} index2 - the index of the third vertex - */ - - - MeshSpriteRenderer.prototype._renderDrawTriangle = function _renderDrawTriangle(mesh, index0, index1, index2) { - var context = this.renderer.context; - var uvs = mesh.uvs; - var vertices = mesh.vertices; - var texture = mesh._texture; - - if (!texture.valid) { - return; - } - - var base = texture.baseTexture; - var textureSource = base.source; - var textureWidth = base.width; - var textureHeight = base.height; - - var u0 = void 0; - var u1 = void 0; - var u2 = void 0; - var v0 = void 0; - var v1 = void 0; - var v2 = void 0; - - if (mesh.uploadUvTransform) { - var ut = mesh._uvTransform.mapCoord; - - u0 = (uvs[index0] * ut.a + uvs[index0 + 1] * ut.c + ut.tx) * base.width; - u1 = (uvs[index1] * ut.a + uvs[index1 + 1] * ut.c + ut.tx) * base.width; - u2 = (uvs[index2] * ut.a + uvs[index2 + 1] * ut.c + ut.tx) * base.width; - v0 = (uvs[index0] * ut.b + uvs[index0 + 1] * ut.d + ut.ty) * base.height; - v1 = (uvs[index1] * ut.b + uvs[index1 + 1] * ut.d + ut.ty) * base.height; - v2 = (uvs[index2] * ut.b + uvs[index2 + 1] * ut.d + ut.ty) * base.height; - } else { - u0 = uvs[index0] * base.width; - u1 = uvs[index1] * base.width; - u2 = uvs[index2] * base.width; - v0 = uvs[index0 + 1] * base.height; - v1 = uvs[index1 + 1] * base.height; - v2 = uvs[index2 + 1] * base.height; - } - - var x0 = vertices[index0]; - var x1 = vertices[index1]; - var x2 = vertices[index2]; - var y0 = vertices[index0 + 1]; - var y1 = vertices[index1 + 1]; - var y2 = vertices[index2 + 1]; - - var canvasPadding = mesh.canvasPadding / this.renderer.resolution; - - if (canvasPadding > 0) { - var paddingX = canvasPadding / Math.abs(mesh.worldTransform.a); - var paddingY = canvasPadding / Math.abs(mesh.worldTransform.d); - var centerX = (x0 + x1 + x2) / 3; - var centerY = (y0 + y1 + y2) / 3; - - var normX = x0 - centerX; - var normY = y0 - centerY; - - var dist = Math.sqrt(normX * normX + normY * normY); - - x0 = centerX + normX / dist * (dist + paddingX); - y0 = centerY + normY / dist * (dist + paddingY); - - // - - normX = x1 - centerX; - normY = y1 - centerY; - - dist = Math.sqrt(normX * normX + normY * normY); - x1 = centerX + normX / dist * (dist + paddingX); - y1 = centerY + normY / dist * (dist + paddingY); - - normX = x2 - centerX; - normY = y2 - centerY; - - dist = Math.sqrt(normX * normX + normY * normY); - x2 = centerX + normX / dist * (dist + paddingX); - y2 = centerY + normY / dist * (dist + paddingY); - } - - context.save(); - context.beginPath(); - - context.moveTo(x0, y0); - context.lineTo(x1, y1); - context.lineTo(x2, y2); - - context.closePath(); - - context.clip(); - - // Compute matrix transform - var delta = u0 * v1 + v0 * u2 + u1 * v2 - v1 * u2 - v0 * u1 - u0 * v2; - var deltaA = x0 * v1 + v0 * x2 + x1 * v2 - v1 * x2 - v0 * x1 - x0 * v2; - var deltaB = u0 * x1 + x0 * u2 + u1 * x2 - x1 * u2 - x0 * u1 - u0 * x2; - var deltaC = u0 * v1 * x2 + v0 * x1 * u2 + x0 * u1 * v2 - x0 * v1 * u2 - v0 * u1 * x2 - u0 * x1 * v2; - var deltaD = y0 * v1 + v0 * y2 + y1 * v2 - v1 * y2 - v0 * y1 - y0 * v2; - var deltaE = u0 * y1 + y0 * u2 + u1 * y2 - y1 * u2 - y0 * u1 - u0 * y2; - var deltaF = u0 * v1 * y2 + v0 * y1 * u2 + y0 * u1 * v2 - y0 * v1 * u2 - v0 * u1 * y2 - u0 * y1 * v2; - - context.transform(deltaA / delta, deltaD / delta, deltaB / delta, deltaE / delta, deltaC / delta, deltaF / delta); - - context.drawImage(textureSource, 0, 0, textureWidth * base.resolution, textureHeight * base.resolution, 0, 0, textureWidth, textureHeight); - - context.restore(); - this.renderer.invalidateBlendMode(); - }; - - /** - * Renders a flat Mesh - * - * @private - * @param {PIXI.mesh.Mesh} mesh - The Mesh to render - */ - - - MeshSpriteRenderer.prototype.renderMeshFlat = function renderMeshFlat(mesh) { - var context = this.renderer.context; - var vertices = mesh.vertices; - var length = vertices.length / 2; - - // this.count++; - - context.beginPath(); - - for (var i = 1; i < length - 2; ++i) { - // draw some triangles! - var index = i * 2; - - var x0 = vertices[index]; - var y0 = vertices[index + 1]; - - var x1 = vertices[index + 2]; - var y1 = vertices[index + 3]; - - var x2 = vertices[index + 4]; - var y2 = vertices[index + 5]; - - context.moveTo(x0, y0); - context.lineTo(x1, y1); - context.lineTo(x2, y2); - } - - context.fillStyle = '#FF0000'; - context.fill(); - context.closePath(); - }; - - /** - * destroy the the renderer. - * - */ - - - MeshSpriteRenderer.prototype.destroy = function destroy() { - this.renderer = null; - }; - - return MeshSpriteRenderer; -}(); - -exports.default = MeshSpriteRenderer; - - -core.CanvasRenderer.registerPlugin('mesh', MeshSpriteRenderer); - -},{"../../core":65,"../Mesh":166}],171:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Mesh = require('./Mesh'); - -Object.defineProperty(exports, 'Mesh', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Mesh).default; - } -}); - -var _MeshRenderer = require('./webgl/MeshRenderer'); - -Object.defineProperty(exports, 'MeshRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_MeshRenderer).default; - } -}); - -var _CanvasMeshRenderer = require('./canvas/CanvasMeshRenderer'); - -Object.defineProperty(exports, 'CanvasMeshRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_CanvasMeshRenderer).default; - } -}); - -var _Plane = require('./Plane'); - -Object.defineProperty(exports, 'Plane', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Plane).default; - } -}); - -var _NineSlicePlane = require('./NineSlicePlane'); - -Object.defineProperty(exports, 'NineSlicePlane', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_NineSlicePlane).default; - } -}); - -var _Rope = require('./Rope'); - -Object.defineProperty(exports, 'Rope', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_Rope).default; - } -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"./Mesh":166,"./NineSlicePlane":167,"./Plane":168,"./Rope":169,"./canvas/CanvasMeshRenderer":170,"./webgl/MeshRenderer":172}],172:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _pixiGlCore = require('pixi-gl-core'); - -var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore); - -var _Mesh = require('../Mesh'); - -var _Mesh2 = _interopRequireDefault(_Mesh); - -var _path = require('path'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var matrixIdentity = core.Matrix.IDENTITY; - -/** - * WebGL renderer plugin for tiling sprites - * - * @class - * @memberof PIXI - * @extends PIXI.ObjectRenderer - */ - -var MeshRenderer = function (_core$ObjectRenderer) { - _inherits(MeshRenderer, _core$ObjectRenderer); - - /** - * constructor for renderer - * - * @param {WebGLRenderer} renderer The renderer this tiling awesomeness works for. - */ - function MeshRenderer(renderer) { - _classCallCheck(this, MeshRenderer); - - var _this = _possibleConstructorReturn(this, _core$ObjectRenderer.call(this, renderer)); - - _this.shader = null; - return _this; - } - - /** - * Sets up the renderer context and necessary buffers. - * - * @private - */ - - - MeshRenderer.prototype.onContextChange = function onContextChange() { - var gl = this.renderer.gl; - - this.shader = new core.Shader(gl, 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n', 'varying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}\n'); - }; - - /** - * renders mesh - * - * @param {PIXI.mesh.Mesh} mesh mesh instance - */ - - - MeshRenderer.prototype.render = function render(mesh) { - var renderer = this.renderer; - var gl = renderer.gl; - var texture = mesh._texture; - - if (!texture.valid) { - return; - } - - var glData = mesh._glDatas[renderer.CONTEXT_UID]; - - if (!glData) { - renderer.bindVao(null); - - glData = { - shader: this.shader, - vertexBuffer: _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, mesh.vertices, gl.STREAM_DRAW), - uvBuffer: _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, mesh.uvs, gl.STREAM_DRAW), - indexBuffer: _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl, mesh.indices, gl.STATIC_DRAW), - // build the vao object that will render.. - vao: null, - dirty: mesh.dirty, - indexDirty: mesh.indexDirty, - vertexDirty: mesh.vertexDirty - }; - - // build the vao object that will render.. - glData.vao = new _pixiGlCore2.default.VertexArrayObject(gl).addIndex(glData.indexBuffer).addAttribute(glData.vertexBuffer, glData.shader.attributes.aVertexPosition, gl.FLOAT, false, 2 * 4, 0).addAttribute(glData.uvBuffer, glData.shader.attributes.aTextureCoord, gl.FLOAT, false, 2 * 4, 0); - - mesh._glDatas[renderer.CONTEXT_UID] = glData; - } - - renderer.bindVao(glData.vao); - - if (mesh.dirty !== glData.dirty) { - glData.dirty = mesh.dirty; - glData.uvBuffer.upload(mesh.uvs); - } - - if (mesh.indexDirty !== glData.indexDirty) { - glData.indexDirty = mesh.indexDirty; - glData.indexBuffer.upload(mesh.indices); - } - - if (mesh.vertexDirty !== glData.vertexDirty) { - glData.vertexDirty = mesh.vertexDirty; - glData.vertexBuffer.upload(mesh.vertices); - } - - renderer.bindShader(glData.shader); - - glData.shader.uniforms.uSampler = renderer.bindTexture(texture); - - renderer.state.setBlendMode(core.utils.correctBlendMode(mesh.blendMode, texture.baseTexture.premultipliedAlpha)); - - if (glData.shader.uniforms.uTransform) { - if (mesh.uploadUvTransform) { - glData.shader.uniforms.uTransform = mesh._uvTransform.mapCoord.toArray(true); - } else { - glData.shader.uniforms.uTransform = matrixIdentity.toArray(true); - } - } - glData.shader.uniforms.translationMatrix = mesh.worldTransform.toArray(true); - - glData.shader.uniforms.uColor = core.utils.premultiplyRgba(mesh.tintRgb, mesh.worldAlpha, glData.shader.uniforms.uColor, texture.baseTexture.premultipliedAlpha); - - var drawMode = mesh.drawMode === _Mesh2.default.DRAW_MODES.TRIANGLE_MESH ? gl.TRIANGLE_STRIP : gl.TRIANGLES; - - glData.vao.draw(drawMode, mesh.indices.length, 0); - }; - - return MeshRenderer; -}(core.ObjectRenderer); - -exports.default = MeshRenderer; - - -core.WebGLRenderer.registerPlugin('mesh', MeshRenderer); - -},{"../../core":65,"../Mesh":166,"path":8,"pixi-gl-core":15}],173:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -var _utils = require('../core/utils'); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The ParticleContainer class is a really fast version of the Container built solely for speed, - * so use when you need a lot of sprites or particles. The tradeoff of the ParticleContainer is that most advanced - * functionality will not work. ParticleContainer implements the basic object transform (position, scale, rotation) - * and some advanced functionality like tint (as of v4.5.6). - * Other more advanced functionality like masking, children, filters, etc will not work on sprites in this batch. - * - * It's extremely easy to use : - * - * ```js - * let container = new ParticleContainer(); - * - * for (let i = 0; i < 100; ++i) - * { - * let sprite = new PIXI.Sprite.fromImage("myImage.png"); - * container.addChild(sprite); - * } - * ``` - * - * And here you have a hundred sprites that will be rendered at the speed of light. - * - * @class - * @extends PIXI.Container - * @memberof PIXI.particles - */ -var ParticleContainer = function (_core$Container) { - _inherits(ParticleContainer, _core$Container); - - /** - * @param {number} [maxSize=1500] - The maximum number of particles that can be rendered by the container. - * Affects size of allocated buffers. - * @param {object} [properties] - The properties of children that should be uploaded to the gpu and applied. - * @param {boolean} [properties.vertices=false] - When true, vertices be uploaded and applied. - * if sprite's ` scale/anchor/trim/frame/orig` is dynamic, please set `true`. - * @param {boolean} [properties.position=true] - When true, position be uploaded and applied. - * @param {boolean} [properties.rotation=false] - When true, rotation be uploaded and applied. - * @param {boolean} [properties.uvs=false] - When true, uvs be uploaded and applied. - * @param {boolean} [properties.tint=false] - When true, alpha and tint be uploaded and applied. - * @param {number} [batchSize=16384] - Number of particles per batch. If less than maxSize, it uses maxSize instead. - * @param {boolean} [autoResize=false] If true, container allocates more batches in case - * there are more than `maxSize` particles. - */ - function ParticleContainer() { - var maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1500; - var properties = arguments[1]; - var batchSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 16384; - var autoResize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - - _classCallCheck(this, ParticleContainer); - - // Making sure the batch size is valid - // 65535 is max vertex index in the index buffer (see ParticleRenderer) - // so max number of particles is 65536 / 4 = 16384 - var _this = _possibleConstructorReturn(this, _core$Container.call(this)); - - var maxBatchSize = 16384; - - if (batchSize > maxBatchSize) { - batchSize = maxBatchSize; - } - - if (batchSize > maxSize) { - batchSize = maxSize; - } - - /** - * Set properties to be dynamic (true) / static (false) - * - * @member {boolean[]} - * @private - */ - _this._properties = [false, true, false, false, false]; - - /** - * @member {number} - * @private - */ - _this._maxSize = maxSize; - - /** - * @member {number} - * @private - */ - _this._batchSize = batchSize; - - /** - * @member {object} - * @private - */ - _this._glBuffers = {}; - - /** - * for every batch stores _updateID corresponding to the last change in that batch - * @member {number[]} - * @private - */ - _this._bufferUpdateIDs = []; - - /** - * when child inserted, removed or changes position this number goes up - * @member {number[]} - * @private - */ - _this._updateID = 0; - - /** - * @member {boolean} - * - */ - _this.interactiveChildren = false; - - /** - * The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL` - * to reset the blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - _this.blendMode = core.BLEND_MODES.NORMAL; - - /** - * If true, container allocates more batches in case there are more than `maxSize` particles. - * @member {boolean} - * @default false - */ - _this.autoResize = autoResize; - - /** - * Used for canvas renderering. If true then the elements will be positioned at the - * nearest pixel. This provides a nice speed boost. - * - * @member {boolean} - * @default true; - */ - _this.roundPixels = true; - - /** - * The texture used to render the children. - * - * @readonly - * @member {BaseTexture} - */ - _this.baseTexture = null; - - _this.setProperties(properties); - - /** - * The tint applied to the container. - * This is a hex value. A value of 0xFFFFFF will remove any tint effect. - * - * @private - * @member {number} - * @default 0xFFFFFF - */ - _this._tint = 0; - _this.tintRgb = new Float32Array(4); - _this.tint = 0xFFFFFF; - return _this; - } - - /** - * Sets the private properties array to dynamic / static based on the passed properties object - * - * @param {object} properties - The properties to be uploaded - */ - - - ParticleContainer.prototype.setProperties = function setProperties(properties) { - if (properties) { - this._properties[0] = 'vertices' in properties || 'scale' in properties ? !!properties.vertices || !!properties.scale : this._properties[0]; - this._properties[1] = 'position' in properties ? !!properties.position : this._properties[1]; - this._properties[2] = 'rotation' in properties ? !!properties.rotation : this._properties[2]; - this._properties[3] = 'uvs' in properties ? !!properties.uvs : this._properties[3]; - this._properties[4] = 'tint' in properties || 'alpha' in properties ? !!properties.tint || !!properties.alpha : this._properties[4]; - } - }; - - /** - * Updates the object transform for rendering - * - * @private - */ - - - ParticleContainer.prototype.updateTransform = function updateTransform() { - // TODO don't need to! - this.displayObjectUpdateTransform(); - // PIXI.Container.prototype.updateTransform.call( this ); - }; - - /** - * The tint applied to the container. This is a hex value. - * A value of 0xFFFFFF will remove any tint effect. - ** IMPORTANT: This is a webGL only feature and will be ignored by the canvas renderer. - * @member {number} - * @default 0xFFFFFF - */ - - - /** - * Renders the container using the WebGL renderer - * - * @private - * @param {PIXI.WebGLRenderer} renderer - The webgl renderer - */ - ParticleContainer.prototype.renderWebGL = function renderWebGL(renderer) { - var _this2 = this; - - if (!this.visible || this.worldAlpha <= 0 || !this.children.length || !this.renderable) { - return; - } - - if (!this.baseTexture) { - this.baseTexture = this.children[0]._texture.baseTexture; - if (!this.baseTexture.hasLoaded) { - this.baseTexture.once('update', function () { - return _this2.onChildrenChange(0); - }); - } - } - - renderer.setObjectRenderer(renderer.plugins.particle); - renderer.plugins.particle.render(this); - }; - - /** - * Set the flag that static data should be updated to true - * - * @private - * @param {number} smallestChildIndex - The smallest child index - */ - - - ParticleContainer.prototype.onChildrenChange = function onChildrenChange(smallestChildIndex) { - var bufferIndex = Math.floor(smallestChildIndex / this._batchSize); - - while (this._bufferUpdateIDs.length < bufferIndex) { - this._bufferUpdateIDs.push(0); - } - this._bufferUpdateIDs[bufferIndex] = ++this._updateID; - }; - - /** - * Renders the object using the Canvas renderer - * - * @private - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer - */ - - - ParticleContainer.prototype.renderCanvas = function renderCanvas(renderer) { - if (!this.visible || this.worldAlpha <= 0 || !this.children.length || !this.renderable) { - return; - } - - var context = renderer.context; - var transform = this.worldTransform; - var isRotated = true; - - var positionX = 0; - var positionY = 0; - - var finalWidth = 0; - var finalHeight = 0; - - renderer.setBlendMode(this.blendMode); - - context.globalAlpha = this.worldAlpha; - - this.displayObjectUpdateTransform(); - - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i]; - - if (!child.visible) { - continue; - } - - var frame = child._texture.frame; - - context.globalAlpha = this.worldAlpha * child.alpha; - - if (child.rotation % (Math.PI * 2) === 0) { - // this is the fastest way to optimise! - if rotation is 0 then we can avoid any kind of setTransform call - if (isRotated) { - context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx * renderer.resolution, transform.ty * renderer.resolution); - - isRotated = false; - } - - positionX = child.anchor.x * (-frame.width * child.scale.x) + child.position.x + 0.5; - positionY = child.anchor.y * (-frame.height * child.scale.y) + child.position.y + 0.5; - - finalWidth = frame.width * child.scale.x; - finalHeight = frame.height * child.scale.y; - } else { - if (!isRotated) { - isRotated = true; - } - - child.displayObjectUpdateTransform(); - - var childTransform = child.worldTransform; - - if (renderer.roundPixels) { - context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx * renderer.resolution | 0, childTransform.ty * renderer.resolution | 0); - } else { - context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx * renderer.resolution, childTransform.ty * renderer.resolution); - } - - positionX = child.anchor.x * -frame.width + 0.5; - positionY = child.anchor.y * -frame.height + 0.5; - - finalWidth = frame.width; - finalHeight = frame.height; - } - - var resolution = child._texture.baseTexture.resolution; - - context.drawImage(child._texture.baseTexture.source, frame.x * resolution, frame.y * resolution, frame.width * resolution, frame.height * resolution, positionX * renderer.resolution, positionY * renderer.resolution, finalWidth * renderer.resolution, finalHeight * renderer.resolution); - } - }; - - /** - * Destroys the container - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options - * have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have their - * destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - - - ParticleContainer.prototype.destroy = function destroy(options) { - _core$Container.prototype.destroy.call(this, options); - - if (this._buffers) { - for (var i = 0; i < this._buffers.length; ++i) { - this._buffers[i].destroy(); - } - } - - this._properties = null; - this._buffers = null; - this._bufferUpdateIDs = null; - }; - - _createClass(ParticleContainer, [{ - key: 'tint', - get: function get() { - return this._tint; - }, - set: function set(value) // eslint-disable-line require-jsdoc - { - this._tint = value; - (0, _utils.hex2rgb)(value, this.tintRgb); - } - }]); - - return ParticleContainer; -}(core.Container); - -exports.default = ParticleContainer; - -},{"../core":65,"../core/utils":125}],174:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _ParticleContainer = require('./ParticleContainer'); - -Object.defineProperty(exports, 'ParticleContainer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_ParticleContainer).default; - } -}); - -var _ParticleRenderer = require('./webgl/ParticleRenderer'); - -Object.defineProperty(exports, 'ParticleRenderer', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_ParticleRenderer).default; - } -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"./ParticleContainer":173,"./webgl/ParticleRenderer":176}],175:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _pixiGlCore = require('pixi-gl-core'); - -var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore); - -var _createIndicesForQuads = require('../../core/utils/createIndicesForQuads'); - -var _createIndicesForQuads2 = _interopRequireDefault(_createIndicesForQuads); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * @author Mat Groves - * - * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/ - * for creating the original PixiJS version! - * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that - * they now share 4 bytes on the vertex buffer - * - * Heavily inspired by LibGDX's ParticleBuffer: - * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleBuffer.java - */ - -/** - * The particle buffer manages the static and dynamic buffers for a particle container. - * - * @class - * @private - * @memberof PIXI - */ -var ParticleBuffer = function () { - /** - * @param {WebGLRenderingContext} gl - The rendering context. - * @param {object} properties - The properties to upload. - * @param {boolean[]} dynamicPropertyFlags - Flags for which properties are dynamic. - * @param {number} size - The size of the batch. - */ - function ParticleBuffer(gl, properties, dynamicPropertyFlags, size) { - _classCallCheck(this, ParticleBuffer); - - /** - * The current WebGL drawing context. - * - * @member {WebGLRenderingContext} - */ - this.gl = gl; - - /** - * The number of particles the buffer can hold - * - * @member {number} - */ - this.size = size; - - /** - * A list of the properties that are dynamic. - * - * @member {object[]} - */ - this.dynamicProperties = []; - - /** - * A list of the properties that are static. - * - * @member {object[]} - */ - this.staticProperties = []; - - for (var i = 0; i < properties.length; ++i) { - var property = properties[i]; - - // Make copy of properties object so that when we edit the offset it doesn't - // change all other instances of the object literal - property = { - attribute: property.attribute, - size: property.size, - uploadFunction: property.uploadFunction, - unsignedByte: property.unsignedByte, - offset: property.offset - }; - - if (dynamicPropertyFlags[i]) { - this.dynamicProperties.push(property); - } else { - this.staticProperties.push(property); - } - } - - this.staticStride = 0; - this.staticBuffer = null; - this.staticData = null; - this.staticDataUint32 = null; - - this.dynamicStride = 0; - this.dynamicBuffer = null; - this.dynamicData = null; - this.dynamicDataUint32 = null; - - this._updateID = 0; - - this.initBuffers(); - } - - /** - * Sets up the renderer context and necessary buffers. - * - * @private - */ - - - ParticleBuffer.prototype.initBuffers = function initBuffers() { - var gl = this.gl; - var dynamicOffset = 0; - - /** - * Holds the indices of the geometry (quads) to draw - * - * @member {Uint16Array} - */ - this.indices = (0, _createIndicesForQuads2.default)(this.size); - this.indexBuffer = _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW); - - this.dynamicStride = 0; - - for (var i = 0; i < this.dynamicProperties.length; ++i) { - var property = this.dynamicProperties[i]; - - property.offset = dynamicOffset; - dynamicOffset += property.size; - this.dynamicStride += property.size; - } - - var dynBuffer = new ArrayBuffer(this.size * this.dynamicStride * 4 * 4); - - this.dynamicData = new Float32Array(dynBuffer); - this.dynamicDataUint32 = new Uint32Array(dynBuffer); - this.dynamicBuffer = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, dynBuffer, gl.STREAM_DRAW); - - // static // - var staticOffset = 0; - - this.staticStride = 0; - - for (var _i = 0; _i < this.staticProperties.length; ++_i) { - var _property = this.staticProperties[_i]; - - _property.offset = staticOffset; - staticOffset += _property.size; - this.staticStride += _property.size; - } - - var statBuffer = new ArrayBuffer(this.size * this.staticStride * 4 * 4); - - this.staticData = new Float32Array(statBuffer); - this.staticDataUint32 = new Uint32Array(statBuffer); - this.staticBuffer = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, statBuffer, gl.STATIC_DRAW); - - this.vao = new _pixiGlCore2.default.VertexArrayObject(gl).addIndex(this.indexBuffer); - - for (var _i2 = 0; _i2 < this.dynamicProperties.length; ++_i2) { - var _property2 = this.dynamicProperties[_i2]; - - if (_property2.unsignedByte) { - this.vao.addAttribute(this.dynamicBuffer, _property2.attribute, gl.UNSIGNED_BYTE, true, this.dynamicStride * 4, _property2.offset * 4); - } else { - this.vao.addAttribute(this.dynamicBuffer, _property2.attribute, gl.FLOAT, false, this.dynamicStride * 4, _property2.offset * 4); - } - } - - for (var _i3 = 0; _i3 < this.staticProperties.length; ++_i3) { - var _property3 = this.staticProperties[_i3]; - - if (_property3.unsignedByte) { - this.vao.addAttribute(this.staticBuffer, _property3.attribute, gl.UNSIGNED_BYTE, true, this.staticStride * 4, _property3.offset * 4); - } else { - this.vao.addAttribute(this.staticBuffer, _property3.attribute, gl.FLOAT, false, this.staticStride * 4, _property3.offset * 4); - } - } - }; - - /** - * Uploads the dynamic properties. - * - * @param {PIXI.DisplayObject[]} children - The children to upload. - * @param {number} startIndex - The index to start at. - * @param {number} amount - The number to upload. - */ - - - ParticleBuffer.prototype.uploadDynamic = function uploadDynamic(children, startIndex, amount) { - for (var i = 0; i < this.dynamicProperties.length; i++) { - var property = this.dynamicProperties[i]; - - property.uploadFunction(children, startIndex, amount, property.unsignedByte ? this.dynamicDataUint32 : this.dynamicData, this.dynamicStride, property.offset); - } - - this.dynamicBuffer.upload(); - }; - - /** - * Uploads the static properties. - * - * @param {PIXI.DisplayObject[]} children - The children to upload. - * @param {number} startIndex - The index to start at. - * @param {number} amount - The number to upload. - */ - - - ParticleBuffer.prototype.uploadStatic = function uploadStatic(children, startIndex, amount) { - for (var i = 0; i < this.staticProperties.length; i++) { - var property = this.staticProperties[i]; - - property.uploadFunction(children, startIndex, amount, property.unsignedByte ? this.staticDataUint32 : this.staticData, this.staticStride, property.offset); - } - - this.staticBuffer.upload(); - }; - - /** - * Destroys the ParticleBuffer. - * - */ - - - ParticleBuffer.prototype.destroy = function destroy() { - this.dynamicProperties = null; - this.dynamicBuffer.destroy(); - this.dynamicBuffer = null; - this.dynamicData = null; - this.dynamicDataUint32 = null; - - this.staticProperties = null; - this.staticBuffer.destroy(); - this.staticBuffer = null; - this.staticData = null; - this.staticDataUint32 = null; - }; - - return ParticleBuffer; -}(); - -exports.default = ParticleBuffer; - -},{"../../core/utils/createIndicesForQuads":123,"pixi-gl-core":15}],176:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _ParticleShader = require('./ParticleShader'); - -var _ParticleShader2 = _interopRequireDefault(_ParticleShader); - -var _ParticleBuffer = require('./ParticleBuffer'); - -var _ParticleBuffer2 = _interopRequireDefault(_ParticleBuffer); - -var _utils = require('../../core/utils'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * @author Mat Groves - * - * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/ - * for creating the original PixiJS version! - * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they now - * share 4 bytes on the vertex buffer - * - * Heavily inspired by LibGDX's ParticleRenderer: - * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleRenderer.java - */ - -/** - * - * @class - * @private - * @memberof PIXI - */ -var ParticleRenderer = function (_core$ObjectRenderer) { - _inherits(ParticleRenderer, _core$ObjectRenderer); - - /** - * @param {PIXI.WebGLRenderer} renderer - The renderer this sprite batch works for. - */ - function ParticleRenderer(renderer) { - _classCallCheck(this, ParticleRenderer); - - // 65535 is max vertex index in the index buffer (see ParticleRenderer) - // so max number of particles is 65536 / 4 = 16384 - // and max number of element in the index buffer is 16384 * 6 = 98304 - // Creating a full index buffer, overhead is 98304 * 2 = 196Ko - // let numIndices = 98304; - - /** - * The default shader that is used if a sprite doesn't have a more specific one. - * - * @member {PIXI.Shader} - */ - var _this = _possibleConstructorReturn(this, _core$ObjectRenderer.call(this, renderer)); - - _this.shader = null; - - _this.indexBuffer = null; - - _this.properties = null; - - _this.tempMatrix = new core.Matrix(); - - _this.CONTEXT_UID = 0; - return _this; - } - - /** - * When there is a WebGL context change - * - * @private - */ - - - ParticleRenderer.prototype.onContextChange = function onContextChange() { - var gl = this.renderer.gl; - - this.CONTEXT_UID = this.renderer.CONTEXT_UID; - - // setup default shader - this.shader = new _ParticleShader2.default(gl); - - this.properties = [ - // verticesData - { - attribute: this.shader.attributes.aVertexPosition, - size: 2, - uploadFunction: this.uploadVertices, - offset: 0 - }, - // positionData - { - attribute: this.shader.attributes.aPositionCoord, - size: 2, - uploadFunction: this.uploadPosition, - offset: 0 - }, - // rotationData - { - attribute: this.shader.attributes.aRotation, - size: 1, - uploadFunction: this.uploadRotation, - offset: 0 - }, - // uvsData - { - attribute: this.shader.attributes.aTextureCoord, - size: 2, - uploadFunction: this.uploadUvs, - offset: 0 - }, - // tintData - { - attribute: this.shader.attributes.aColor, - size: 1, - unsignedByte: true, - uploadFunction: this.uploadTint, - offset: 0 - }]; - }; - - /** - * Starts a new particle batch. - * - */ - - - ParticleRenderer.prototype.start = function start() { - this.renderer.bindShader(this.shader); - }; - - /** - * Renders the particle container object. - * - * @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer - */ - - - ParticleRenderer.prototype.render = function render(container) { - var children = container.children; - var maxSize = container._maxSize; - var batchSize = container._batchSize; - var renderer = this.renderer; - var totalChildren = children.length; - - if (totalChildren === 0) { - return; - } else if (totalChildren > maxSize) { - totalChildren = maxSize; - } - - var buffers = container._glBuffers[renderer.CONTEXT_UID]; - - if (!buffers) { - buffers = container._glBuffers[renderer.CONTEXT_UID] = this.generateBuffers(container); - } - - var baseTexture = children[0]._texture.baseTexture; - - // if the uvs have not updated then no point rendering just yet! - this.renderer.setBlendMode(core.utils.correctBlendMode(container.blendMode, baseTexture.premultipliedAlpha)); - - var gl = renderer.gl; - - var m = container.worldTransform.copy(this.tempMatrix); - - m.prepend(renderer._activeRenderTarget.projectionMatrix); - - this.shader.uniforms.projectionMatrix = m.toArray(true); - - this.shader.uniforms.uColor = core.utils.premultiplyRgba(container.tintRgb, container.worldAlpha, this.shader.uniforms.uColor, baseTexture.premultipliedAlpha); - - // make sure the texture is bound.. - this.shader.uniforms.uSampler = renderer.bindTexture(baseTexture); - - var updateStatic = false; - - // now lets upload and render the buffers.. - for (var i = 0, j = 0; i < totalChildren; i += batchSize, j += 1) { - var amount = totalChildren - i; - - if (amount > batchSize) { - amount = batchSize; - } - - if (j >= buffers.length) { - if (!container.autoResize) { - break; - } - buffers.push(this._generateOneMoreBuffer(container)); - } - - var buffer = buffers[j]; - - // we always upload the dynamic - buffer.uploadDynamic(children, i, amount); - - var bid = container._bufferUpdateIDs[j] || 0; - - updateStatic = updateStatic || buffer._updateID < bid; - // we only upload the static content when we have to! - if (updateStatic) { - buffer._updateID = container._updateID; - buffer.uploadStatic(children, i, amount); - } - - // bind the buffer - renderer.bindVao(buffer.vao); - buffer.vao.draw(gl.TRIANGLES, amount * 6); - } - }; - - /** - * Creates one particle buffer for each child in the container we want to render and updates internal properties - * - * @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer - * @return {PIXI.ParticleBuffer[]} The buffers - */ - - - ParticleRenderer.prototype.generateBuffers = function generateBuffers(container) { - var gl = this.renderer.gl; - var buffers = []; - var size = container._maxSize; - var batchSize = container._batchSize; - var dynamicPropertyFlags = container._properties; - - for (var i = 0; i < size; i += batchSize) { - buffers.push(new _ParticleBuffer2.default(gl, this.properties, dynamicPropertyFlags, batchSize)); - } - - return buffers; - }; - - /** - * Creates one more particle buffer, because container has autoResize feature - * - * @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer - * @return {PIXI.ParticleBuffer} generated buffer - * @private - */ - - - ParticleRenderer.prototype._generateOneMoreBuffer = function _generateOneMoreBuffer(container) { - var gl = this.renderer.gl; - var batchSize = container._batchSize; - var dynamicPropertyFlags = container._properties; - - return new _ParticleBuffer2.default(gl, this.properties, dynamicPropertyFlags, batchSize); - }; - - /** - * Uploads the verticies. - * - * @param {PIXI.DisplayObject[]} children - the array of display objects to render - * @param {number} startIndex - the index to start from in the children array - * @param {number} amount - the amount of children that will have their vertices uploaded - * @param {number[]} array - The vertices to upload. - * @param {number} stride - Stride to use for iteration. - * @param {number} offset - Offset to start at. - */ - - - ParticleRenderer.prototype.uploadVertices = function uploadVertices(children, startIndex, amount, array, stride, offset) { - var w0 = 0; - var w1 = 0; - var h0 = 0; - var h1 = 0; - - for (var i = 0; i < amount; ++i) { - var sprite = children[startIndex + i]; - var texture = sprite._texture; - var sx = sprite.scale.x; - var sy = sprite.scale.y; - var trim = texture.trim; - var orig = texture.orig; - - if (trim) { - // if the sprite is trimmed and is not a tilingsprite then we need to add the - // extra space before transforming the sprite coords.. - w1 = trim.x - sprite.anchor.x * orig.width; - w0 = w1 + trim.width; - - h1 = trim.y - sprite.anchor.y * orig.height; - h0 = h1 + trim.height; - } else { - w0 = orig.width * (1 - sprite.anchor.x); - w1 = orig.width * -sprite.anchor.x; - - h0 = orig.height * (1 - sprite.anchor.y); - h1 = orig.height * -sprite.anchor.y; - } - - array[offset] = w1 * sx; - array[offset + 1] = h1 * sy; - - array[offset + stride] = w0 * sx; - array[offset + stride + 1] = h1 * sy; - - array[offset + stride * 2] = w0 * sx; - array[offset + stride * 2 + 1] = h0 * sy; - - array[offset + stride * 3] = w1 * sx; - array[offset + stride * 3 + 1] = h0 * sy; - - offset += stride * 4; - } - }; - - /** - * - * @param {PIXI.DisplayObject[]} children - the array of display objects to render - * @param {number} startIndex - the index to start from in the children array - * @param {number} amount - the amount of children that will have their positions uploaded - * @param {number[]} array - The vertices to upload. - * @param {number} stride - Stride to use for iteration. - * @param {number} offset - Offset to start at. - */ - - - ParticleRenderer.prototype.uploadPosition = function uploadPosition(children, startIndex, amount, array, stride, offset) { - for (var i = 0; i < amount; i++) { - var spritePosition = children[startIndex + i].position; - - array[offset] = spritePosition.x; - array[offset + 1] = spritePosition.y; - - array[offset + stride] = spritePosition.x; - array[offset + stride + 1] = spritePosition.y; - - array[offset + stride * 2] = spritePosition.x; - array[offset + stride * 2 + 1] = spritePosition.y; - - array[offset + stride * 3] = spritePosition.x; - array[offset + stride * 3 + 1] = spritePosition.y; - - offset += stride * 4; - } - }; - - /** - * - * @param {PIXI.DisplayObject[]} children - the array of display objects to render - * @param {number} startIndex - the index to start from in the children array - * @param {number} amount - the amount of children that will have their rotation uploaded - * @param {number[]} array - The vertices to upload. - * @param {number} stride - Stride to use for iteration. - * @param {number} offset - Offset to start at. - */ - - - ParticleRenderer.prototype.uploadRotation = function uploadRotation(children, startIndex, amount, array, stride, offset) { - for (var i = 0; i < amount; i++) { - var spriteRotation = children[startIndex + i].rotation; - - array[offset] = spriteRotation; - array[offset + stride] = spriteRotation; - array[offset + stride * 2] = spriteRotation; - array[offset + stride * 3] = spriteRotation; - - offset += stride * 4; - } - }; - - /** - * - * @param {PIXI.DisplayObject[]} children - the array of display objects to render - * @param {number} startIndex - the index to start from in the children array - * @param {number} amount - the amount of children that will have their rotation uploaded - * @param {number[]} array - The vertices to upload. - * @param {number} stride - Stride to use for iteration. - * @param {number} offset - Offset to start at. - */ - - - ParticleRenderer.prototype.uploadUvs = function uploadUvs(children, startIndex, amount, array, stride, offset) { - for (var i = 0; i < amount; ++i) { - var textureUvs = children[startIndex + i]._texture._uvs; - - if (textureUvs) { - array[offset] = textureUvs.x0; - array[offset + 1] = textureUvs.y0; - - array[offset + stride] = textureUvs.x1; - array[offset + stride + 1] = textureUvs.y1; - - array[offset + stride * 2] = textureUvs.x2; - array[offset + stride * 2 + 1] = textureUvs.y2; - - array[offset + stride * 3] = textureUvs.x3; - array[offset + stride * 3 + 1] = textureUvs.y3; - - offset += stride * 4; - } else { - // TODO you know this can be easier! - array[offset] = 0; - array[offset + 1] = 0; - - array[offset + stride] = 0; - array[offset + stride + 1] = 0; - - array[offset + stride * 2] = 0; - array[offset + stride * 2 + 1] = 0; - - array[offset + stride * 3] = 0; - array[offset + stride * 3 + 1] = 0; - - offset += stride * 4; - } - } - }; - - /** - * - * @param {PIXI.DisplayObject[]} children - the array of display objects to render - * @param {number} startIndex - the index to start from in the children array - * @param {number} amount - the amount of children that will have their rotation uploaded - * @param {number[]} array - The vertices to upload. - * @param {number} stride - Stride to use for iteration. - * @param {number} offset - Offset to start at. - */ - - - ParticleRenderer.prototype.uploadTint = function uploadTint(children, startIndex, amount, array, stride, offset) { - for (var i = 0; i < amount; ++i) { - var sprite = children[startIndex + i]; - var premultiplied = sprite._texture.baseTexture.premultipliedAlpha; - var alpha = sprite.alpha; - // we dont call extra function if alpha is 1.0, that's faster - var argb = alpha < 1.0 && premultiplied ? (0, _utils.premultiplyTint)(sprite._tintRGB, alpha) : sprite._tintRGB + (alpha * 255 << 24); - - array[offset] = argb; - array[offset + stride] = argb; - array[offset + stride * 2] = argb; - array[offset + stride * 3] = argb; - - offset += stride * 4; - } - }; - - /** - * Destroys the ParticleRenderer. - * - */ - - - ParticleRenderer.prototype.destroy = function destroy() { - if (this.renderer.gl) { - this.renderer.gl.deleteBuffer(this.indexBuffer); - } - - _core$ObjectRenderer.prototype.destroy.call(this); - - this.shader.destroy(); - - this.indices = null; - this.tempMatrix = null; - }; - - return ParticleRenderer; -}(core.ObjectRenderer); - -exports.default = ParticleRenderer; - - -core.WebGLRenderer.registerPlugin('particle', ParticleRenderer); - -},{"../../core":65,"../../core/utils":125,"./ParticleBuffer":175,"./ParticleShader":177}],177:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _Shader2 = require('../../core/Shader'); - -var _Shader3 = _interopRequireDefault(_Shader2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * @class - * @extends PIXI.Shader - * @memberof PIXI - */ -var ParticleShader = function (_Shader) { - _inherits(ParticleShader, _Shader); - - /** - * @param {PIXI.Shader} gl - The webgl shader manager this shader works for. - */ - function ParticleShader(gl) { - _classCallCheck(this, ParticleShader); - - return _possibleConstructorReturn(this, _Shader.call(this, gl, - // vertex shader - ['attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', 'attribute vec4 aColor;', 'attribute vec2 aPositionCoord;', 'attribute float aRotation;', 'uniform mat3 projectionMatrix;', 'uniform vec4 uColor;', 'varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'void main(void){', ' float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);', ' float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);', ' vec2 v = vec2(x, y);', ' v = v + aPositionCoord;', ' gl_Position = vec4((projectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);', ' vTextureCoord = aTextureCoord;', ' vColor = aColor * uColor;', '}'].join('\n'), - // hello - ['varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'uniform sampler2D uSampler;', 'void main(void){', ' vec4 color = texture2D(uSampler, vTextureCoord) * vColor;', ' gl_FragColor = color;', '}'].join('\n'))); - } - - return ParticleShader; -}(_Shader3.default); - -exports.default = ParticleShader; - -},{"../../core/Shader":44}],178:[function(require,module,exports){ -"use strict"; - -// References: -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign - -if (!Math.sign) { - Math.sign = function mathSign(x) { - x = Number(x); - - if (x === 0 || isNaN(x)) { - return x; - } - - return x > 0 ? 1 : -1; - }; -} - -},{}],179:[function(require,module,exports){ -'use strict'; - -// References: -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger - -if (!Number.isInteger) { - Number.isInteger = function numberIsInteger(value) { - return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; - }; -} - -},{}],180:[function(require,module,exports){ -'use strict'; - -var _objectAssign = require('object-assign'); - -var _objectAssign2 = _interopRequireDefault(_objectAssign); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if (!Object.assign) { - Object.assign = _objectAssign2.default; -} // References: -// https://github.com/sindresorhus/object-assign -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign - -},{"object-assign":6}],181:[function(require,module,exports){ -'use strict'; - -require('./Object.assign'); - -require('./requestAnimationFrame'); - -require('./Math.sign'); - -require('./Number.isInteger'); - -if (!window.ArrayBuffer) { - window.ArrayBuffer = Array; -} - -if (!window.Float32Array) { - window.Float32Array = Array; -} - -if (!window.Uint32Array) { - window.Uint32Array = Array; -} - -if (!window.Uint16Array) { - window.Uint16Array = Array; -} - -},{"./Math.sign":178,"./Number.isInteger":179,"./Object.assign":180,"./requestAnimationFrame":182}],182:[function(require,module,exports){ -(function (global){ -'use strict'; - -// References: -// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ -// https://gist.github.com/1579671 -// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision -// https://gist.github.com/timhall/4078614 -// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame - -// Expected to be used with Browserfiy -// Browserify automatically detects the use of `global` and passes the -// correct reference of `global`, `self`, and finally `window` - -var ONE_FRAME_TIME = 16; - -// Date.now -if (!(Date.now && Date.prototype.getTime)) { - Date.now = function now() { - return new Date().getTime(); - }; -} - -// performance.now -if (!(global.performance && global.performance.now)) { - var startTime = Date.now(); - - if (!global.performance) { - global.performance = {}; - } - - global.performance.now = function () { - return Date.now() - startTime; - }; -} - -// requestAnimationFrame -var lastTime = Date.now(); -var vendors = ['ms', 'moz', 'webkit', 'o']; - -for (var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { - var p = vendors[x]; - - global.requestAnimationFrame = global[p + 'RequestAnimationFrame']; - global.cancelAnimationFrame = global[p + 'CancelAnimationFrame'] || global[p + 'CancelRequestAnimationFrame']; -} - -if (!global.requestAnimationFrame) { - global.requestAnimationFrame = function (callback) { - if (typeof callback !== 'function') { - throw new TypeError(callback + 'is not a function'); - } - - var currentTime = Date.now(); - var delay = ONE_FRAME_TIME + lastTime - currentTime; - - if (delay < 0) { - delay = 0; - } - - lastTime = currentTime; - - return setTimeout(function () { - lastTime = Date.now(); - callback(performance.now()); - }, delay); - }; -} - -if (!global.cancelAnimationFrame) { - global.cancelAnimationFrame = function (id) { - return clearTimeout(id); - }; -} - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - -},{}],183:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../core'); - -var core = _interopRequireWildcard(_core); - -var _CountLimiter = require('./limiters/CountLimiter'); - -var _CountLimiter2 = _interopRequireDefault(_CountLimiter); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var SharedTicker = core.ticker.shared; - -/** - * Default number of uploads per frame using prepare plugin. - * - * @static - * @memberof PIXI.settings - * @name UPLOADS_PER_FRAME - * @type {number} - * @default 4 - */ -core.settings.UPLOADS_PER_FRAME = 4; - -/** - * The prepare manager provides functionality to upload content to the GPU. BasePrepare handles - * basic queuing functionality and is extended by {@link PIXI.prepare.WebGLPrepare} and {@link PIXI.prepare.CanvasPrepare} - * to provide preparation capabilities specific to their respective renderers. - * - * @example - * // Create a sprite - * const sprite = new PIXI.Sprite.fromImage('something.png'); - * - * // Load object into GPU - * app.renderer.plugins.prepare.upload(sprite, () => { - * - * //Texture(s) has been uploaded to GPU - * app.stage.addChild(sprite); - * - * }) - * - * @abstract - * @class - * @memberof PIXI.prepare - */ - -var BasePrepare = function () { - /** - * @param {PIXI.SystemRenderer} renderer - A reference to the current renderer - */ - function BasePrepare(renderer) { - var _this = this; - - _classCallCheck(this, BasePrepare); - - /** - * The limiter to be used to control how quickly items are prepared. - * @type {PIXI.prepare.CountLimiter|PIXI.prepare.TimeLimiter} - */ - this.limiter = new _CountLimiter2.default(core.settings.UPLOADS_PER_FRAME); - - /** - * Reference to the renderer. - * @type {PIXI.SystemRenderer} - * @protected - */ - this.renderer = renderer; - - /** - * The only real difference between CanvasPrepare and WebGLPrepare is what they pass - * to upload hooks. That different parameter is stored here. - * @type {PIXI.prepare.CanvasPrepare|PIXI.WebGLRenderer} - * @protected - */ - this.uploadHookHelper = null; - - /** - * Collection of items to uploads at once. - * @type {Array<*>} - * @private - */ - this.queue = []; - - /** - * Collection of additional hooks for finding assets. - * @type {Array} - * @private - */ - this.addHooks = []; - - /** - * Collection of additional hooks for processing assets. - * @type {Array} - * @private - */ - this.uploadHooks = []; - - /** - * Callback to call after completed. - * @type {Array} - * @private - */ - this.completes = []; - - /** - * If prepare is ticking (running). - * @type {boolean} - * @private - */ - this.ticking = false; - - /** - * 'bound' call for prepareItems(). - * @type {Function} - * @private - */ - this.delayedTick = function () { - // unlikely, but in case we were destroyed between tick() and delayedTick() - if (!_this.queue) { - return; - } - _this.prepareItems(); - }; - - // hooks to find the correct texture - this.registerFindHook(findText); - this.registerFindHook(findTextStyle); - this.registerFindHook(findMultipleBaseTextures); - this.registerFindHook(findBaseTexture); - this.registerFindHook(findTexture); - - // upload hooks - this.registerUploadHook(drawText); - this.registerUploadHook(calculateTextStyle); - } - - /** - * Upload all the textures and graphics to the GPU. - * - * @param {Function|PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item - - * Either the container or display object to search for items to upload, the items to upload themselves, - * or the callback function, if items have been added using `prepare.add`. - * @param {Function} [done] - Optional callback when all queued uploads have completed - */ - - - BasePrepare.prototype.upload = function upload(item, done) { - if (typeof item === 'function') { - done = item; - item = null; - } - - // If a display object, search for items - // that we could upload - if (item) { - this.add(item); - } - - // Get the items for upload from the display - if (this.queue.length) { - if (done) { - this.completes.push(done); - } - - if (!this.ticking) { - this.ticking = true; - SharedTicker.addOnce(this.tick, this, core.UPDATE_PRIORITY.UTILITY); - } - } else if (done) { - done(); - } - }; - - /** - * Handle tick update - * - * @private - */ - - - BasePrepare.prototype.tick = function tick() { - setTimeout(this.delayedTick, 0); - }; - - /** - * Actually prepare items. This is handled outside of the tick because it will take a while - * and we do NOT want to block the current animation frame from rendering. - * - * @private - */ - - - BasePrepare.prototype.prepareItems = function prepareItems() { - this.limiter.beginFrame(); - // Upload the graphics - while (this.queue.length && this.limiter.allowedToUpload()) { - var item = this.queue[0]; - var uploaded = false; - - if (item && !item._destroyed) { - for (var i = 0, len = this.uploadHooks.length; i < len; i++) { - if (this.uploadHooks[i](this.uploadHookHelper, item)) { - this.queue.shift(); - uploaded = true; - break; - } - } - } - - if (!uploaded) { - this.queue.shift(); - } - } - - // We're finished - if (!this.queue.length) { - this.ticking = false; - - var completes = this.completes.slice(0); - - this.completes.length = 0; - - for (var _i = 0, _len = completes.length; _i < _len; _i++) { - completes[_i](); - } - } else { - // if we are not finished, on the next rAF do this again - SharedTicker.addOnce(this.tick, this, core.UPDATE_PRIORITY.UTILITY); - } - }; - - /** - * Adds hooks for finding items. - * - * @param {Function} addHook - Function call that takes two parameters: `item:*, queue:Array` - * function must return `true` if it was able to add item to the queue. - * @return {PIXI.BasePrepare} Instance of plugin for chaining. - */ - - - BasePrepare.prototype.registerFindHook = function registerFindHook(addHook) { - if (addHook) { - this.addHooks.push(addHook); - } - - return this; - }; - - /** - * Adds hooks for uploading items. - * - * @param {Function} uploadHook - Function call that takes two parameters: `prepare:CanvasPrepare, item:*` and - * function must return `true` if it was able to handle upload of item. - * @return {PIXI.BasePrepare} Instance of plugin for chaining. - */ - - - BasePrepare.prototype.registerUploadHook = function registerUploadHook(uploadHook) { - if (uploadHook) { - this.uploadHooks.push(uploadHook); - } - - return this; - }; - - /** - * Manually add an item to the uploading queue. - * - * @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text|*} item - Object to - * add to the queue - * @return {PIXI.CanvasPrepare} Instance of plugin for chaining. - */ - - - BasePrepare.prototype.add = function add(item) { - // Add additional hooks for finding elements on special - // types of objects that - for (var i = 0, len = this.addHooks.length; i < len; i++) { - if (this.addHooks[i](item, this.queue)) { - break; - } - } - - // Get childen recursively - if (item instanceof core.Container) { - for (var _i2 = item.children.length - 1; _i2 >= 0; _i2--) { - this.add(item.children[_i2]); - } - } - - return this; - }; - - /** - * Destroys the plugin, don't use after this. - * - */ - - - BasePrepare.prototype.destroy = function destroy() { - if (this.ticking) { - SharedTicker.remove(this.tick, this); - } - this.ticking = false; - this.addHooks = null; - this.uploadHooks = null; - this.renderer = null; - this.completes = null; - this.queue = null; - this.limiter = null; - this.uploadHookHelper = null; - }; - - return BasePrepare; -}(); - -/** - * Built-in hook to find multiple textures from objects like AnimatedSprites. - * - * @private - * @param {PIXI.DisplayObject} item - Display object to check - * @param {Array<*>} queue - Collection of items to upload - * @return {boolean} if a PIXI.Texture object was found. - */ - - -exports.default = BasePrepare; -function findMultipleBaseTextures(item, queue) { - var result = false; - - // Objects with mutliple textures - if (item && item._textures && item._textures.length) { - for (var i = 0; i < item._textures.length; i++) { - if (item._textures[i] instanceof core.Texture) { - var baseTexture = item._textures[i].baseTexture; - - if (queue.indexOf(baseTexture) === -1) { - queue.push(baseTexture); - result = true; - } - } - } - } - - return result; -} - -/** - * Built-in hook to find BaseTextures from Sprites. - * - * @private - * @param {PIXI.DisplayObject} item - Display object to check - * @param {Array<*>} queue - Collection of items to upload - * @return {boolean} if a PIXI.Texture object was found. - */ -function findBaseTexture(item, queue) { - // Objects with textures, like Sprites/Text - if (item instanceof core.BaseTexture) { - if (queue.indexOf(item) === -1) { - queue.push(item); - } - - return true; - } - - return false; -} - -/** - * Built-in hook to find textures from objects. - * - * @private - * @param {PIXI.DisplayObject} item - Display object to check - * @param {Array<*>} queue - Collection of items to upload - * @return {boolean} if a PIXI.Texture object was found. - */ -function findTexture(item, queue) { - if (item._texture && item._texture instanceof core.Texture) { - var texture = item._texture.baseTexture; - - if (queue.indexOf(texture) === -1) { - queue.push(texture); - } - - return true; - } - - return false; -} - -/** - * Built-in hook to draw PIXI.Text to its texture. - * - * @private - * @param {PIXI.WebGLRenderer|PIXI.CanvasPrepare} helper - Not used by this upload handler - * @param {PIXI.DisplayObject} item - Item to check - * @return {boolean} If item was uploaded. - */ -function drawText(helper, item) { - if (item instanceof core.Text) { - // updating text will return early if it is not dirty - item.updateText(true); - - return true; - } - - return false; -} - -/** - * Built-in hook to calculate a text style for a PIXI.Text object. - * - * @private - * @param {PIXI.WebGLRenderer|PIXI.CanvasPrepare} helper - Not used by this upload handler - * @param {PIXI.DisplayObject} item - Item to check - * @return {boolean} If item was uploaded. - */ -function calculateTextStyle(helper, item) { - if (item instanceof core.TextStyle) { - var font = item.toFontString(); - - core.TextMetrics.measureFont(font); - - return true; - } - - return false; -} - -/** - * Built-in hook to find Text objects. - * - * @private - * @param {PIXI.DisplayObject} item - Display object to check - * @param {Array<*>} queue - Collection of items to upload - * @return {boolean} if a PIXI.Text object was found. - */ -function findText(item, queue) { - if (item instanceof core.Text) { - // push the text style to prepare it - this can be really expensive - if (queue.indexOf(item.style) === -1) { - queue.push(item.style); - } - // also push the text object so that we can render it (to canvas/texture) if needed - if (queue.indexOf(item) === -1) { - queue.push(item); - } - // also push the Text's texture for upload to GPU - var texture = item._texture.baseTexture; - - if (queue.indexOf(texture) === -1) { - queue.push(texture); - } - - return true; - } - - return false; -} - -/** - * Built-in hook to find TextStyle objects. - * - * @private - * @param {PIXI.TextStyle} item - Display object to check - * @param {Array<*>} queue - Collection of items to upload - * @return {boolean} if a PIXI.TextStyle object was found. - */ -function findTextStyle(item, queue) { - if (item instanceof core.TextStyle) { - if (queue.indexOf(item) === -1) { - queue.push(item); - } - - return true; - } - - return false; -} - -},{"../core":65,"./limiters/CountLimiter":186}],184:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _BasePrepare2 = require('../BasePrepare'); - -var _BasePrepare3 = _interopRequireDefault(_BasePrepare2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var CANVAS_START_SIZE = 16; - -/** - * The prepare manager provides functionality to upload content to the GPU - * This cannot be done directly for Canvas like in WebGL, but the effect can be achieved by drawing - * textures to an offline canvas. - * This draw call will force the texture to be moved onto the GPU. - * - * An instance of this class is automatically created by default, and can be found at renderer.plugins.prepare - * - * @class - * @extends PIXI.prepare.BasePrepare - * @memberof PIXI.prepare - */ - -var CanvasPrepare = function (_BasePrepare) { - _inherits(CanvasPrepare, _BasePrepare); - - /** - * @param {PIXI.CanvasRenderer} renderer - A reference to the current renderer - */ - function CanvasPrepare(renderer) { - _classCallCheck(this, CanvasPrepare); - - var _this = _possibleConstructorReturn(this, _BasePrepare.call(this, renderer)); - - _this.uploadHookHelper = _this; - - /** - * An offline canvas to render textures to - * @type {HTMLCanvasElement} - * @private - */ - _this.canvas = document.createElement('canvas'); - _this.canvas.width = CANVAS_START_SIZE; - _this.canvas.height = CANVAS_START_SIZE; - - /** - * The context to the canvas - * @type {CanvasRenderingContext2D} - * @private - */ - _this.ctx = _this.canvas.getContext('2d'); - - // Add textures to upload - _this.registerUploadHook(uploadBaseTextures); - return _this; - } - - /** - * Destroys the plugin, don't use after this. - * - */ - - - CanvasPrepare.prototype.destroy = function destroy() { - _BasePrepare.prototype.destroy.call(this); - this.ctx = null; - this.canvas = null; - }; - - return CanvasPrepare; -}(_BasePrepare3.default); - -/** - * Built-in hook to upload PIXI.Texture objects to the GPU. - * - * @private - * @param {*} prepare - Instance of CanvasPrepare - * @param {*} item - Item to check - * @return {boolean} If item was uploaded. - */ - - -exports.default = CanvasPrepare; -function uploadBaseTextures(prepare, item) { - if (item instanceof core.BaseTexture) { - var image = item.source; - - // Sometimes images (like atlas images) report a size of zero, causing errors on windows phone. - // So if the width or height is equal to zero then use the canvas size - // Otherwise use whatever is smaller, the image dimensions or the canvas dimensions. - var imageWidth = image.width === 0 ? prepare.canvas.width : Math.min(prepare.canvas.width, image.width); - var imageHeight = image.height === 0 ? prepare.canvas.height : Math.min(prepare.canvas.height, image.height); - - // Only a small subsections is required to be drawn to have the whole texture uploaded to the GPU - // A smaller draw can be faster. - prepare.ctx.drawImage(image, 0, 0, imageWidth, imageHeight, 0, 0, prepare.canvas.width, prepare.canvas.height); - - return true; - } - - return false; -} - -core.CanvasRenderer.registerPlugin('prepare', CanvasPrepare); - -},{"../../core":65,"../BasePrepare":183}],185:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _WebGLPrepare = require('./webgl/WebGLPrepare'); - -Object.defineProperty(exports, 'webgl', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_WebGLPrepare).default; - } -}); - -var _CanvasPrepare = require('./canvas/CanvasPrepare'); - -Object.defineProperty(exports, 'canvas', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_CanvasPrepare).default; - } -}); - -var _BasePrepare = require('./BasePrepare'); - -Object.defineProperty(exports, 'BasePrepare', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_BasePrepare).default; - } -}); - -var _CountLimiter = require('./limiters/CountLimiter'); - -Object.defineProperty(exports, 'CountLimiter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_CountLimiter).default; - } -}); - -var _TimeLimiter = require('./limiters/TimeLimiter'); - -Object.defineProperty(exports, 'TimeLimiter', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_TimeLimiter).default; - } -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -},{"./BasePrepare":183,"./canvas/CanvasPrepare":184,"./limiters/CountLimiter":186,"./limiters/TimeLimiter":187,"./webgl/WebGLPrepare":188}],186:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * CountLimiter limits the number of items handled by a {@link PIXI.prepare.BasePrepare} to a specified - * number of items per frame. - * - * @class - * @memberof PIXI - */ -var CountLimiter = function () { - /** - * @param {number} maxItemsPerFrame - The maximum number of items that can be prepared each frame. - */ - function CountLimiter(maxItemsPerFrame) { - _classCallCheck(this, CountLimiter); - - /** - * The maximum number of items that can be prepared each frame. - * @private - */ - this.maxItemsPerFrame = maxItemsPerFrame; - /** - * The number of items that can be prepared in the current frame. - * @type {number} - * @private - */ - this.itemsLeft = 0; - } - - /** - * Resets any counting properties to start fresh on a new frame. - */ - - - CountLimiter.prototype.beginFrame = function beginFrame() { - this.itemsLeft = this.maxItemsPerFrame; - }; - - /** - * Checks to see if another item can be uploaded. This should only be called once per item. - * @return {boolean} If the item is allowed to be uploaded. - */ - - - CountLimiter.prototype.allowedToUpload = function allowedToUpload() { - return this.itemsLeft-- > 0; - }; - - return CountLimiter; -}(); - -exports.default = CountLimiter; - -},{}],187:[function(require,module,exports){ -"use strict"; - -exports.__esModule = true; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * TimeLimiter limits the number of items handled by a {@link PIXI.BasePrepare} to a specified - * number of milliseconds per frame. - * - * @class - * @memberof PIXI - */ -var TimeLimiter = function () { - /** - * @param {number} maxMilliseconds - The maximum milliseconds that can be spent preparing items each frame. - */ - function TimeLimiter(maxMilliseconds) { - _classCallCheck(this, TimeLimiter); - - /** - * The maximum milliseconds that can be spent preparing items each frame. - * @private - */ - this.maxMilliseconds = maxMilliseconds; - /** - * The start time of the current frame. - * @type {number} - * @private - */ - this.frameStart = 0; - } - - /** - * Resets any counting properties to start fresh on a new frame. - */ - - - TimeLimiter.prototype.beginFrame = function beginFrame() { - this.frameStart = Date.now(); - }; - - /** - * Checks to see if another item can be uploaded. This should only be called once per item. - * @return {boolean} If the item is allowed to be uploaded. - */ - - - TimeLimiter.prototype.allowedToUpload = function allowedToUpload() { - return Date.now() - this.frameStart < this.maxMilliseconds; - }; - - return TimeLimiter; -}(); - -exports.default = TimeLimiter; - -},{}],188:[function(require,module,exports){ -'use strict'; - -exports.__esModule = true; - -var _core = require('../../core'); - -var core = _interopRequireWildcard(_core); - -var _BasePrepare2 = require('../BasePrepare'); - -var _BasePrepare3 = _interopRequireDefault(_BasePrepare2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * The prepare manager provides functionality to upload content to the GPU. - * - * An instance of this class is automatically created by default, and can be found at renderer.plugins.prepare - * - * @class - * @extends PIXI.prepare.BasePrepare - * @memberof PIXI.prepare - */ -var WebGLPrepare = function (_BasePrepare) { - _inherits(WebGLPrepare, _BasePrepare); - - /** - * @param {PIXI.WebGLRenderer} renderer - A reference to the current renderer - */ - function WebGLPrepare(renderer) { - _classCallCheck(this, WebGLPrepare); - - var _this = _possibleConstructorReturn(this, _BasePrepare.call(this, renderer)); - - _this.uploadHookHelper = _this.renderer; - - // Add textures and graphics to upload - _this.registerFindHook(findGraphics); - _this.registerUploadHook(uploadBaseTextures); - _this.registerUploadHook(uploadGraphics); - return _this; - } - - return WebGLPrepare; -}(_BasePrepare3.default); -/** - * Built-in hook to upload PIXI.Texture objects to the GPU. - * - * @private - * @param {PIXI.WebGLRenderer} renderer - instance of the webgl renderer - * @param {PIXI.DisplayObject} item - Item to check - * @return {boolean} If item was uploaded. - */ - - -exports.default = WebGLPrepare; -function uploadBaseTextures(renderer, item) { - if (item instanceof core.BaseTexture) { - // if the texture already has a GL texture, then the texture has been prepared or rendered - // before now. If the texture changed, then the changer should be calling texture.update() which - // reuploads the texture without need for preparing it again - if (!item._glTextures[renderer.CONTEXT_UID]) { - renderer.textureManager.updateTexture(item); - } - - return true; - } - - return false; -} - -/** - * Built-in hook to upload PIXI.Graphics to the GPU. - * - * @private - * @param {PIXI.WebGLRenderer} renderer - instance of the webgl renderer - * @param {PIXI.DisplayObject} item - Item to check - * @return {boolean} If item was uploaded. - */ -function uploadGraphics(renderer, item) { - if (item instanceof core.Graphics) { - // if the item is not dirty and already has webgl data, then it got prepared or rendered - // before now and we shouldn't waste time updating it again - if (item.dirty || item.clearDirty || !item._webGL[renderer.plugins.graphics.CONTEXT_UID]) { - renderer.plugins.graphics.updateGraphics(item); - } - - return true; - } - - return false; -} - -/** - * Built-in hook to find graphics. - * - * @private - * @param {PIXI.DisplayObject} item - Display object to check - * @param {Array<*>} queue - Collection of items to upload - * @return {boolean} if a PIXI.Graphics object was found. - */ -function findGraphics(item, queue) { - if (item instanceof core.Graphics) { - queue.push(item); - - return true; - } - - return false; -} - -core.WebGLRenderer.registerPlugin('prepare', WebGLPrepare); - -},{"../../core":65,"../BasePrepare":183}],189:[function(require,module,exports){ -(function (global){ -'use strict'; - -exports.__esModule = true; -exports.loader = exports.prepare = exports.particles = exports.mesh = exports.loaders = exports.interaction = exports.filters = exports.extras = exports.extract = exports.accessibility = undefined; - -var _polyfill = require('./polyfill'); - -Object.keys(_polyfill).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _polyfill[key]; - } - }); -}); - -var _core = require('./core'); - -Object.keys(_core).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _core[key]; - } - }); -}); - -var _deprecation = require('./deprecation'); - -var _deprecation2 = _interopRequireDefault(_deprecation); - -var _accessibility = require('./accessibility'); - -var accessibility = _interopRequireWildcard(_accessibility); - -var _extract = require('./extract'); - -var extract = _interopRequireWildcard(_extract); - -var _extras = require('./extras'); - -var extras = _interopRequireWildcard(_extras); - -var _filters = require('./filters'); - -var filters = _interopRequireWildcard(_filters); - -var _interaction = require('./interaction'); - -var interaction = _interopRequireWildcard(_interaction); - -var _loaders = require('./loaders'); - -var loaders = _interopRequireWildcard(_loaders); - -var _mesh = require('./mesh'); - -var mesh = _interopRequireWildcard(_mesh); - -var _particles = require('./particles'); - -var particles = _interopRequireWildcard(_particles); - -var _prepare = require('./prepare'); - -var prepare = _interopRequireWildcard(_prepare); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// export core -_core.utils.mixins.performMixins(); - -/** - * Alias for {@link PIXI.loaders.shared}. - * @name loader - * @memberof PIXI - * @type {PIXI.loader.Loader} - */ - - -// handle mixins now, after all code has been added, including deprecation - - -// export libs -// import polyfills. Done as an export to make sure polyfills are imported first -var loader = loaders.shared || null; - -exports.accessibility = accessibility; -exports.extract = extract; -exports.extras = extras; -exports.filters = filters; -exports.interaction = interaction; -exports.loaders = loaders; -exports.mesh = mesh; -exports.particles = particles; -exports.prepare = prepare; -exports.loader = loader; - -// Apply the deprecations - -if (typeof _deprecation2.default === 'function') { - (0, _deprecation2.default)(exports); -} - -// Always export PixiJS globally. -global.PIXI = exports; // eslint-disable-line - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - -},{"./accessibility":42,"./core":65,"./deprecation":131,"./extract":133,"./extras":141,"./filters":153,"./interaction":159,"./loaders":162,"./mesh":171,"./particles":174,"./polyfill":181,"./prepare":185}]},{},[189])(189) -}); + Resource.prototype._onError = function _onError(event) { + this.abort('Failed to load element using: ' + event.target.nodeName); + }; + + /** + * Called if a load progress event fires for an element or xhr/xdr. + * + * @private + * @param {XMLHttpRequestProgressEvent|Event} event - Progress event. + */ + + + Resource.prototype._onProgress = function _onProgress(event) { + if (event && event.lengthComputable) { + this.onProgress.dispatch(this, event.loaded / event.total); + } + }; + + /** + * Called if a timeout event fires for an element. + * + * @private + */ + + + Resource.prototype._onTimeout = function _onTimeout() { + this.abort('Load timed out.'); + }; + + /** + * Called if an error event fires for xhr/xdr. + * + * @private + */ + + + Resource.prototype._xhrOnError = function _xhrOnError() { + var xhr = this.xhr; + + this.abort(reqType(xhr) + ' Request failed. Status: ' + xhr.status + ', text: "' + xhr.statusText + '"'); + }; + + /** + * Called if an error event fires for xhr/xdr. + * + * @private + */ + + + Resource.prototype._xhrOnTimeout = function _xhrOnTimeout() { + var xhr = this.xhr; + + this.abort(reqType(xhr) + ' Request timed out.'); + }; + + /** + * Called if an abort event fires for xhr/xdr. + * + * @private + */ + + + Resource.prototype._xhrOnAbort = function _xhrOnAbort() { + var xhr = this.xhr; + + this.abort(reqType(xhr) + ' Request was aborted by the user.'); + }; + + /** + * Called when data successfully loads from an xhr/xdr request. + * + * @private + * @param {XMLHttpRequestLoadEvent|Event} event - Load event + */ + + + Resource.prototype._xhrOnLoad = function _xhrOnLoad() { + var xhr = this.xhr; + var text = ''; + var status = typeof xhr.status === 'undefined' ? STATUS_OK : xhr.status; // XDR has no `.status`, assume 200. + + // responseText is accessible only if responseType is '' or 'text' and on older browsers + if (xhr.responseType === '' || xhr.responseType === 'text' || typeof xhr.responseType === 'undefined') { + text = xhr.responseText; + } + + // status can be 0 when using the `file://` protocol so we also check if a response is set. + // If it has a response, we assume 200; otherwise a 0 status code with no contents is an aborted request. + if (status === STATUS_NONE && (text.length > 0 || xhr.responseType === Resource.XHR_RESPONSE_TYPE.BUFFER)) { + status = STATUS_OK; + } + // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request + else if (status === STATUS_IE_BUG_EMPTY) { + status = STATUS_EMPTY; + } + + var statusType = status / 100 | 0; + + if (statusType === STATUS_TYPE_OK) { + // if text, just return it + if (this.xhrType === Resource.XHR_RESPONSE_TYPE.TEXT) { + this.data = text; + this.type = Resource.TYPE.TEXT; + } + // if json, parse into json object + else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON) { + try { + this.data = JSON.parse(text); + this.type = Resource.TYPE.JSON; + } catch (e) { + this.abort('Error trying to parse loaded json: ' + e); + + return; + } + } + // if xml, parse into an xml document or div element + else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) { + try { + if (window.DOMParser) { + var domparser = new DOMParser(); + + this.data = domparser.parseFromString(text, 'text/xml'); + } else { + var div = document.createElement('div'); + + div.innerHTML = text; + + this.data = div; + } + + this.type = Resource.TYPE.XML; + } catch (e) { + this.abort('Error trying to parse loaded xml: ' + e); + + return; + } + } + // other types just return the response + else { + this.data = xhr.response || text; + } + } else { + this.abort('[' + xhr.status + '] ' + xhr.statusText + ': ' + xhr.responseURL); + + return; + } + + this.complete(); + }; + + /** + * Sets the `crossOrigin` property for this resource based on if the url + * for this resource is cross-origin. If crossOrigin was manually set, this + * function does nothing. + * + * @private + * @param {string} url - The url to test. + * @param {object} [loc=window.location] - The location object to test against. + * @return {string} The crossOrigin value to use (or empty string for none). + */ + + + Resource.prototype._determineCrossOrigin = function _determineCrossOrigin(url, loc) { + // data: and javascript: urls are considered same-origin + if (url.indexOf('data:') === 0) { + return ''; + } + + // A sandboxed iframe without the 'allow-same-origin' attribute will have a special + // origin designed not to match window.location.origin, and will always require + // crossOrigin requests regardless of whether the location matches. + if (window.origin !== window.location.origin) { + return 'anonymous'; + } + + // default is window.location + loc = loc || window.location; + + if (!tempAnchor) { + tempAnchor = document.createElement('a'); + } + + // let the browser determine the full href for the url of this resource and then + // parse with the node url lib, we can't use the properties of the anchor element + // because they don't work in IE9 :( + tempAnchor.href = url; + url = (0, _parseUri2.default)(tempAnchor.href, { strictMode: true }); + + var samePort = !url.port && loc.port === '' || url.port === loc.port; + var protocol = url.protocol ? url.protocol + ':' : ''; + + // if cross origin + if (url.host !== loc.hostname || !samePort || protocol !== loc.protocol) { + return 'anonymous'; + } + + return ''; + }; + + /** + * Determines the responseType of an XHR request based on the extension of the + * resource being loaded. + * + * @private + * @return {Resource.XHR_RESPONSE_TYPE} The responseType to use. + */ + + + Resource.prototype._determineXhrType = function _determineXhrType() { + return Resource._xhrTypeMap[this.extension] || Resource.XHR_RESPONSE_TYPE.TEXT; + }; + + /** + * Determines the loadType of a resource based on the extension of the + * resource being loaded. + * + * @private + * @return {Resource.LOAD_TYPE} The loadType to use. + */ + + + Resource.prototype._determineLoadType = function _determineLoadType() { + return Resource._loadTypeMap[this.extension] || Resource.LOAD_TYPE.XHR; + }; + + /** + * Extracts the extension (sans '.') of the file being loaded by the resource. + * + * @private + * @return {string} The extension. + */ + + + Resource.prototype._getExtension = function _getExtension() { + var url = this.url; + var ext = ''; + + if (this.isDataUrl) { + var slashIndex = url.indexOf('/'); + + ext = url.substring(slashIndex + 1, url.indexOf(';', slashIndex)); + } else { + var queryStart = url.indexOf('?'); + var hashStart = url.indexOf('#'); + var index = Math.min(queryStart > -1 ? queryStart : url.length, hashStart > -1 ? hashStart : url.length); + + url = url.substring(0, index); + ext = url.substring(url.lastIndexOf('.') + 1); + } + + return ext.toLowerCase(); + }; + + /** + * Determines the mime type of an XHR request based on the responseType of + * resource being loaded. + * + * @private + * @param {Resource.XHR_RESPONSE_TYPE} type - The type to get a mime type for. + * @return {string} The mime type to use. + */ + + + Resource.prototype._getMimeFromXhrType = function _getMimeFromXhrType(type) { + switch (type) { + case Resource.XHR_RESPONSE_TYPE.BUFFER: + return 'application/octet-binary'; + + case Resource.XHR_RESPONSE_TYPE.BLOB: + return 'application/blob'; + + case Resource.XHR_RESPONSE_TYPE.DOCUMENT: + return 'application/xml'; + + case Resource.XHR_RESPONSE_TYPE.JSON: + return 'application/json'; + + case Resource.XHR_RESPONSE_TYPE.DEFAULT: + case Resource.XHR_RESPONSE_TYPE.TEXT: + /* falls through */ + default: + return 'text/plain'; + } + }; + + _createClass(Resource, [{ + key: 'isDataUrl', + get: function get() { + return this._hasFlag(Resource.STATUS_FLAGS.DATA_URL); + } + + /** + * Describes if this resource has finished loading. Is true when the resource has completely + * loaded. + * + * @readonly + * @member {boolean} + */ + + }, { + key: 'isComplete', + get: function get() { + return this._hasFlag(Resource.STATUS_FLAGS.COMPLETE); + } + + /** + * Describes if this resource is currently loading. Is true when the resource starts loading, + * and is false again when complete. + * + * @readonly + * @member {boolean} + */ + + }, { + key: 'isLoading', + get: function get() { + return this._hasFlag(Resource.STATUS_FLAGS.LOADING); + } + }]); + + return Resource; + }(); + + /** + * The types of resources a resource could represent. + * + * @static + * @readonly + * @enum {number} + */ + + + Resource.STATUS_FLAGS = { + NONE: 0, + DATA_URL: 1 << 0, + COMPLETE: 1 << 1, + LOADING: 1 << 2 + }; + + /** + * The types of resources a resource could represent. + * + * @static + * @readonly + * @enum {number} + */ + Resource.TYPE = { + UNKNOWN: 0, + JSON: 1, + XML: 2, + IMAGE: 3, + AUDIO: 4, + VIDEO: 5, + TEXT: 6 + }; + + /** + * The types of loading a resource can use. + * + * @static + * @readonly + * @enum {number} + */ + Resource.LOAD_TYPE = { + /** Uses XMLHttpRequest to load the resource. */ + XHR: 1, + /** Uses an `Image` object to load the resource. */ + IMAGE: 2, + /** Uses an `Audio` object to load the resource. */ + AUDIO: 3, + /** Uses a `Video` object to load the resource. */ + VIDEO: 4 + }; + + /** + * The XHR ready states, used internally. + * + * @static + * @readonly + * @enum {string} + */ + Resource.XHR_RESPONSE_TYPE = { + /** string */ + DEFAULT: 'text', + /** ArrayBuffer */ + BUFFER: 'arraybuffer', + /** Blob */ + BLOB: 'blob', + /** Document */ + DOCUMENT: 'document', + /** Object */ + JSON: 'json', + /** String */ + TEXT: 'text' + }; + + Resource._loadTypeMap = { + // images + gif: Resource.LOAD_TYPE.IMAGE, + png: Resource.LOAD_TYPE.IMAGE, + bmp: Resource.LOAD_TYPE.IMAGE, + jpg: Resource.LOAD_TYPE.IMAGE, + jpeg: Resource.LOAD_TYPE.IMAGE, + tif: Resource.LOAD_TYPE.IMAGE, + tiff: Resource.LOAD_TYPE.IMAGE, + webp: Resource.LOAD_TYPE.IMAGE, + tga: Resource.LOAD_TYPE.IMAGE, + svg: Resource.LOAD_TYPE.IMAGE, + 'svg+xml': Resource.LOAD_TYPE.IMAGE, // for SVG data urls + + // audio + mp3: Resource.LOAD_TYPE.AUDIO, + ogg: Resource.LOAD_TYPE.AUDIO, + wav: Resource.LOAD_TYPE.AUDIO, + + // videos + mp4: Resource.LOAD_TYPE.VIDEO, + webm: Resource.LOAD_TYPE.VIDEO + }; + + Resource._xhrTypeMap = { + // xml + xhtml: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + html: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + htm: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + xml: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + tmx: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + svg: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + + // This was added to handle Tiled Tileset XML, but .tsx is also a TypeScript React Component. + // Since it is way less likely for people to be loading TypeScript files instead of Tiled files, + // this should probably be fine. + tsx: Resource.XHR_RESPONSE_TYPE.DOCUMENT, + + // images + gif: Resource.XHR_RESPONSE_TYPE.BLOB, + png: Resource.XHR_RESPONSE_TYPE.BLOB, + bmp: Resource.XHR_RESPONSE_TYPE.BLOB, + jpg: Resource.XHR_RESPONSE_TYPE.BLOB, + jpeg: Resource.XHR_RESPONSE_TYPE.BLOB, + tif: Resource.XHR_RESPONSE_TYPE.BLOB, + tiff: Resource.XHR_RESPONSE_TYPE.BLOB, + webp: Resource.XHR_RESPONSE_TYPE.BLOB, + tga: Resource.XHR_RESPONSE_TYPE.BLOB, + + // json + json: Resource.XHR_RESPONSE_TYPE.JSON, + + // text + text: Resource.XHR_RESPONSE_TYPE.TEXT, + txt: Resource.XHR_RESPONSE_TYPE.TEXT, + + // fonts + ttf: Resource.XHR_RESPONSE_TYPE.BUFFER, + otf: Resource.XHR_RESPONSE_TYPE.BUFFER + }; + + // We can't set the `src` attribute to empty string, so on abort we set it to this 1px transparent gif + Resource.EMPTY_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; + + /** + * Quick helper to set a value on one of the extension maps. Ensures there is no + * dot at the start of the extension. + * + * @ignore + * @param {object} map - The map to set on. + * @param {string} extname - The extension (or key) to set. + * @param {number} val - The value to set. + */ + function setExtMap(map, extname, val) { + if (extname && extname.indexOf('.') === 0) { + extname = extname.substring(1); + } + + if (!extname) { + return; + } + + map[extname] = val; + } + + /** + * Quick helper to get string xhr type. + * + * @ignore + * @param {XMLHttpRequest|XDomainRequest} xhr - The request to check. + * @return {string} The type. + */ + function reqType(xhr) { + return xhr.toString().replace('object ', ''); + } + + // Backwards compat + { + module.exports.default = Resource; // eslint-disable-line no-undef + } + + }); + + unwrapExports$1(Resource_1$1); + var Resource_2$1 = Resource_1$1.Resource; + + var b64$2 = createCommonjsModule$1(function (module, exports) { + + exports.__esModule = true; + exports.encodeBinary = encodeBinary; + var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + /** + * Encodes binary into base64. + * + * @param {string} input The input data to encode. + * @returns {string} The encoded base64 string + */ + function encodeBinary(input) { + var output = ''; + var inx = 0; + + while (inx < input.length) { + // Fill byte buffer array + var bytebuffer = [0, 0, 0]; + var encodedCharIndexes = [0, 0, 0, 0]; + + for (var jnx = 0; jnx < bytebuffer.length; ++jnx) { + if (inx < input.length) { + // throw away high-order byte, as documented at: + // https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data + bytebuffer[jnx] = input.charCodeAt(inx++) & 0xff; + } else { + bytebuffer[jnx] = 0; + } + } + + // Get each encoded character, 6 bits at a time + // index 1: first 6 bits + encodedCharIndexes[0] = bytebuffer[0] >> 2; + + // index 2: second 6 bits (2 least significant bits from input byte 1 + 4 most significant bits from byte 2) + encodedCharIndexes[1] = (bytebuffer[0] & 0x3) << 4 | bytebuffer[1] >> 4; + + // index 3: third 6 bits (4 least significant bits from input byte 2 + 2 most significant bits from byte 3) + encodedCharIndexes[2] = (bytebuffer[1] & 0x0f) << 2 | bytebuffer[2] >> 6; + + // index 3: forth 6 bits (6 least significant bits from input byte 3) + encodedCharIndexes[3] = bytebuffer[2] & 0x3f; + + // Determine whether padding happened, and adjust accordingly + var paddingBytes = inx - (input.length - 1); + + switch (paddingBytes) { + case 2: + // Set last 2 characters to padding char + encodedCharIndexes[3] = 64; + encodedCharIndexes[2] = 64; + break; + + case 1: + // Set last character to padding char + encodedCharIndexes[3] = 64; + break; + + default: + break; // No padding - proceed + } + + // Now we will grab each appropriate character out of our keystring + // based on our index array and append it to the output string + for (var _jnx = 0; _jnx < encodedCharIndexes.length; ++_jnx) { + output += _keyStr.charAt(encodedCharIndexes[_jnx]); + } + } + + return output; + } + + // Backwards compat + { + module.exports.default = encodeBinary; // eslint-disable-line no-undef + } + + }); + + unwrapExports$1(b64$2); + var b64_1$1 = b64$2.encodeBinary; + + var blob = createCommonjsModule$1(function (module, exports) { + + exports.__esModule = true; + exports.blobMiddlewareFactory = blobMiddlewareFactory; + + + + + + var Url = window.URL || window.webkitURL; + + // a middleware for transforming XHR loaded Blobs into more useful objects + function blobMiddlewareFactory() { + return function blobMiddleware(resource, next) { + if (!resource.data) { + next(); + + return; + } + + // if this was an XHR load of a blob + if (resource.xhr && resource.xhrType === Resource_1$1.Resource.XHR_RESPONSE_TYPE.BLOB) { + // if there is no blob support we probably got a binary string back + if (!window.Blob || typeof resource.data === 'string') { + var type = resource.xhr.getResponseHeader('content-type'); + + // this is an image, convert the binary string into a data url + if (type && type.indexOf('image') === 0) { + resource.data = new Image(); + resource.data.src = 'data:' + type + ';base64,' + (0, b64$2.encodeBinary)(resource.xhr.responseText); + + resource.type = Resource_1$1.Resource.TYPE.IMAGE; + + // wait until the image loads and then callback + resource.data.onload = function () { + resource.data.onload = null; + + next(); + }; + + // next will be called on load + return; + } + } + // if content type says this is an image, then we should transform the blob into an Image object + else if (resource.data.type.indexOf('image') === 0) { + var src = Url.createObjectURL(resource.data); + + resource.blob = resource.data; + resource.data = new Image(); + resource.data.src = src; + + resource.type = Resource_1$1.Resource.TYPE.IMAGE; + + // cleanup the no longer used blob after the image loads + // TODO: Is this correct? Will the image be invalid after revoking? + resource.data.onload = function () { + Url.revokeObjectURL(src); + resource.data.onload = null; + + next(); + }; + + // next will be called on load. + return; + } + } + + next(); + }; + } + + }); + + unwrapExports$1(blob); + var blob_1 = blob.blobMiddlewareFactory; + + /** + * Loader plugin for handling Texture resources. + * @class + * @memberof PIXI + * @implements PIXI.ILoaderPlugin + */ + var TextureLoader = function TextureLoader () {}; + + TextureLoader.use = function use (resource, next) + { + // create a new texture if the data is an Image object + if (resource.data && resource.type === lib_1.TYPE.IMAGE) + { + resource.texture = Texture.fromLoader( + resource.data, + resource.url, + resource.name + ); + } + next(); + }; + + /** + * The new loader, extends Resource Loader by Chad Engler: https://github.com/englercj/resource-loader + * + * ```js + * const loader = PIXI.Loader.shared; // PixiJS exposes a premade instance for you to use. + * //or + * const loader = new PIXI.Loader(); // you can also create your own if you want + * + * const sprites = {}; + * + * // Chainable `add` to enqueue a resource + * loader.add('bunny', 'data/bunny.png') + * .add('spaceship', 'assets/spritesheet.json'); + * loader.add('scoreFont', 'assets/score.fnt'); + * + * // Chainable `pre` to add a middleware that runs for each resource, *before* loading that resource. + * // This is useful to implement custom caching modules (using filesystem, indexeddb, memory, etc). + * loader.pre(cachingMiddleware); + * + * // Chainable `use` to add a middleware that runs for each resource, *after* loading that resource. + * // This is useful to implement custom parsing modules (like spritesheet parsers, spine parser, etc). + * loader.use(parsingMiddleware); + * + * // The `load` method loads the queue of resources, and calls the passed in callback called once all + * // resources have loaded. + * loader.load((loader, resources) => { + * // resources is an object where the key is the name of the resource loaded and the value is the resource object. + * // They have a couple default properties: + * // - `url`: The URL that the resource was loaded from + * // - `error`: The error that happened when trying to load (if any) + * // - `data`: The raw data that was loaded + * // also may contain other properties based on the middleware that runs. + * sprites.bunny = new PIXI.TilingSprite(resources.bunny.texture); + * sprites.spaceship = new PIXI.TilingSprite(resources.spaceship.texture); + * sprites.scoreFont = new PIXI.TilingSprite(resources.scoreFont.texture); + * }); + * + * // throughout the process multiple signals can be dispatched. + * loader.onProgress.add(() => {}); // called once per loaded/errored file + * loader.onError.add(() => {}); // called once per errored file + * loader.onLoad.add(() => {}); // called once per loaded file + * loader.onComplete.add(() => {}); // called once when the queued resources all load. + * ``` + * + * @see https://github.com/englercj/resource-loader + * + * @class Loader + * @memberof PIXI + * @param {string} [baseUrl=''] - The base url for all resources loaded by this loader. + * @param {number} [concurrency=10] - The number of resources to load concurrently. + */ + var Loader$2 = /*@__PURE__*/(function (ResourceLoader) { + function Loader(baseUrl, concurrency) + { + var this$1 = this; + + ResourceLoader.call(this, baseUrl, concurrency); + eventemitter3.call(this); + + for (var i = 0; i < Loader._plugins.length; ++i) + { + var plugin = Loader._plugins[i]; + var pre = plugin.pre; + var use = plugin.use; + + if (pre) + { + this.pre(pre); + } + + if (use) + { + this.use(use); + } + } + + // Compat layer, translate the new v2 signals into old v1 events. + this.onStart.add(function (l) { return this$1.emit('start', l); }); + this.onProgress.add(function (l, r) { return this$1.emit('progress', l, r); }); + this.onError.add(function (e, l, r) { return this$1.emit('error', e, l, r); }); + this.onLoad.add(function (l, r) { return this$1.emit('load', l, r); }); + this.onComplete.add(function (l, r) { return this$1.emit('complete', l, r); }); + + /** + * If this loader cannot be destroyed. + * @member {boolean} + * @default false + * @private + */ + this._protected = false; + } + + if ( ResourceLoader ) { Loader.__proto__ = ResourceLoader; } + Loader.prototype = Object.create( ResourceLoader && ResourceLoader.prototype ); + Loader.prototype.constructor = Loader; + + var staticAccessors = { shared: { configurable: true } }; + + /** + * Destroy the loader, removes references. + * @private + */ + Loader.prototype.destroy = function destroy () + { + if (!this._protected) + { + this.removeAllListeners(); + this.reset(); + } + }; + + /** + * A premade instance of the loader that can be used to load resources. + * @name shared + * @type {PIXI.Loader} + * @static + * @memberof PIXI.Loader + */ + staticAccessors.shared.get = function () + { + var shared = Loader._shared; + + if (!shared) + { + shared = new Loader(); + shared._protected = true; + Loader._shared = shared; + } + + return shared; + }; + + Object.defineProperties( Loader, staticAccessors ); + + return Loader; + }(lib)); + + // Copy EE3 prototype (mixin) + Object.assign(Loader$2.prototype, eventemitter3.prototype); + + /** + * Collection of all installed `use` middleware for Loader. + * + * @static + * @member {Array} _plugins + * @memberof PIXI.Loader + * @private + */ + Loader$2._plugins = []; + + /** + * Adds a Loader plugin for the global shared loader and all + * new Loader instances created. + * + * @static + * @method registerPlugin + * @memberof PIXI.Loader + * @param {PIXI.ILoaderPlugin} plugin - The plugin to add + * @return {PIXI.Loader} Reference to PIXI.Loader for chaining + */ + Loader$2.registerPlugin = function registerPlugin(plugin) + { + Loader$2._plugins.push(plugin); + + if (plugin.add) + { + plugin.add(); + } + + return Loader$2; + }; + + // parse any blob into more usable objects (e.g. Image) + Loader$2.registerPlugin({ use: blob_1() }); + + // parse any Image objects into textures + Loader$2.registerPlugin(TextureLoader); + + /** + * Plugin to be installed for handling specific Loader resources. + * + * @memberof PIXI + * @typedef ILoaderPlugin + * @property {function} [add] - Function to call immediate after registering plugin. + * @property {PIXI.Loader.loaderMiddleware} [pre] - Middleware function to run before load, the + * arguments for this are `(resource, next)` + * @property {PIXI.Loader.loaderMiddleware} [use] - Middleware function to run after load, the + * arguments for this are `(resource, next)` + */ + + /** + * @memberof PIXI.Loader + * @callback loaderMiddleware + * @param {PIXI.LoaderResource} resource + * @param {function} next + */ + + /** + * Application plugin for supporting loader option. Installing the LoaderPlugin + * is not necessary if using **pixi.js** or **pixi.js-legacy**. + * @example + * import {AppLoaderPlugin} from '@pixi/loaders'; + * import {Application} from '@pixi/app'; + * Application.registerPlugin(AppLoaderPlugin); + * @class + * @memberof PIXI + */ + var AppLoaderPlugin = function AppLoaderPlugin () {}; + + AppLoaderPlugin.init = function init (options) + { + options = Object.assign({ + sharedLoader: false, + }, options); + + /** + * Loader instance to help with asset loading. + * @name PIXI.Application#loader + * @type {PIXI.Loader} + * @readonly + */ + this.loader = options.sharedLoader ? Loader$2.shared : new Loader$2(); + }; + + /** + * Called when application destroyed + * @private + */ + AppLoaderPlugin.destroy = function destroy () + { + if (this.loader) + { + this.loader.destroy(); + this.loader = null; + } + }; + + /** + * Reference to **{@link https://github.com/englercj/resource-loader + * resource-loader}**'s Resource class. + * @see http://englercj.github.io/resource-loader/Resource.html + * @class LoaderResource + * @memberof PIXI + */ + var LoaderResource = lib_1; + + /*! + * @pixi/particles - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/particles is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * The ParticleContainer class is a really fast version of the Container built solely for speed, + * so use when you need a lot of sprites or particles. + * + * The tradeoff of the ParticleContainer is that most advanced functionality will not work. + * ParticleContainer implements the basic object transform (position, scale, rotation) + * and some advanced functionality like tint (as of v4.5.6). + * + * Other more advanced functionality like masking, children, filters, etc will not work on sprites in this batch. + * + * It's extremely easy to use: + * ```js + * let container = new ParticleContainer(); + * + * for (let i = 0; i < 100; ++i) + * { + * let sprite = new PIXI.Sprite.from("myImage.png"); + * container.addChild(sprite); + * } + * ``` + * + * And here you have a hundred sprites that will be rendered at the speed of light. + * + * @class + * @extends PIXI.Container + * @memberof PIXI + */ + var ParticleContainer = /*@__PURE__*/(function (Container) { + function ParticleContainer(maxSize, properties, batchSize, autoResize) + { + if ( maxSize === void 0 ) { maxSize = 1500; } + if ( batchSize === void 0 ) { batchSize = 16384; } + if ( autoResize === void 0 ) { autoResize = false; } + + Container.call(this); + + // Making sure the batch size is valid + // 65535 is max vertex index in the index buffer (see ParticleRenderer) + // so max number of particles is 65536 / 4 = 16384 + var maxBatchSize = 16384; + + if (batchSize > maxBatchSize) + { + batchSize = maxBatchSize; + } + + if (batchSize > maxSize) + { + batchSize = maxSize; + } + + /** + * Set properties to be dynamic (true) / static (false) + * + * @member {boolean[]} + * @private + */ + this._properties = [false, true, false, false, false]; + + /** + * @member {number} + * @private + */ + this._maxSize = maxSize; + + /** + * @member {number} + * @private + */ + this._batchSize = batchSize; + + /** + * @member {Array} + * @private + */ + this._buffers = null; + + /** + * for every batch stores _updateID corresponding to the last change in that batch + * @member {number[]} + * @private + */ + this._bufferUpdateIDs = []; + + /** + * when child inserted, removed or changes position this number goes up + * @member {number[]} + * @private + */ + this._updateID = 0; + + /** + * @member {boolean} + * + */ + this.interactiveChildren = false; + + /** + * The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL` + * to reset the blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + this.blendMode = BLEND_MODES.NORMAL; + + /** + * If true, container allocates more batches in case there are more than `maxSize` particles. + * @member {boolean} + * @default false + */ + this.autoResize = autoResize; + + /** + * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. + * Advantages can include sharper image quality (like text) and faster rendering on canvas. + * The main disadvantage is movement of objects may appear less smooth. + * Default to true here as performance is usually the priority for particles. + * + * @member {boolean} + * @default true + */ + this.roundPixels = true; + + /** + * The texture used to render the children. + * + * @readonly + * @member {BaseTexture} + */ + this.baseTexture = null; + + this.setProperties(properties); + + /** + * The tint applied to the container. + * This is a hex value. A value of 0xFFFFFF will remove any tint effect. + * + * @private + * @member {number} + * @default 0xFFFFFF + */ + this._tint = 0; + this.tintRgb = new Float32Array(4); + this.tint = 0xFFFFFF; + } + + if ( Container ) { ParticleContainer.__proto__ = Container; } + ParticleContainer.prototype = Object.create( Container && Container.prototype ); + ParticleContainer.prototype.constructor = ParticleContainer; + + var prototypeAccessors = { tint: { configurable: true } }; + + /** + * Sets the private properties array to dynamic / static based on the passed properties object + * + * @param {object} properties - The properties to be uploaded + */ + ParticleContainer.prototype.setProperties = function setProperties (properties) + { + if (properties) + { + this._properties[0] = 'vertices' in properties || 'scale' in properties + ? !!properties.vertices || !!properties.scale : this._properties[0]; + this._properties[1] = 'position' in properties ? !!properties.position : this._properties[1]; + this._properties[2] = 'rotation' in properties ? !!properties.rotation : this._properties[2]; + this._properties[3] = 'uvs' in properties ? !!properties.uvs : this._properties[3]; + this._properties[4] = 'tint' in properties || 'alpha' in properties + ? !!properties.tint || !!properties.alpha : this._properties[4]; + } + }; + + /** + * Updates the object transform for rendering + * + * @private + */ + ParticleContainer.prototype.updateTransform = function updateTransform () + { + // TODO don't need to! + this.displayObjectUpdateTransform(); + // PIXI.Container.prototype.updateTransform.call( this ); + }; + + /** + * The tint applied to the container. This is a hex value. + * A value of 0xFFFFFF will remove any tint effect. + ** IMPORTANT: This is a WebGL only feature and will be ignored by the canvas renderer. + * @member {number} + * @default 0xFFFFFF + */ + prototypeAccessors.tint.get = function () + { + return this._tint; + }; + + prototypeAccessors.tint.set = function (value) // eslint-disable-line require-jsdoc + { + this._tint = value; + hex2rgb(value, this.tintRgb); + }; + + /** + * Renders the container using the WebGL renderer + * + * @private + * @param {PIXI.Renderer} renderer - The webgl renderer + */ + ParticleContainer.prototype.render = function render (renderer) + { + var this$1 = this; + + if (!this.visible || this.worldAlpha <= 0 || !this.children.length || !this.renderable) + { + return; + } + + if (!this.baseTexture) + { + this.baseTexture = this.children[0]._texture.baseTexture; + if (!this.baseTexture.valid) + { + this.baseTexture.once('update', function () { return this$1.onChildrenChange(0); }); + } + } + + renderer.batch.setObjectRenderer(renderer.plugins.particle); + renderer.plugins.particle.render(this); + }; + + /** + * Set the flag that static data should be updated to true + * + * @private + * @param {number} smallestChildIndex - The smallest child index + */ + ParticleContainer.prototype.onChildrenChange = function onChildrenChange (smallestChildIndex) + { + var bufferIndex = Math.floor(smallestChildIndex / this._batchSize); + + while (this._bufferUpdateIDs.length < bufferIndex) + { + this._bufferUpdateIDs.push(0); + } + this._bufferUpdateIDs[bufferIndex] = ++this._updateID; + }; + + ParticleContainer.prototype.dispose = function dispose () + { + if (this._buffers) + { + for (var i = 0; i < this._buffers.length; ++i) + { + this._buffers[i].destroy(); + } + + this._buffers = null; + } + }; + + /** + * Destroys the container + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options + * have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have their + * destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + ParticleContainer.prototype.destroy = function destroy (options) + { + Container.prototype.destroy.call(this, options); + + this.dispose(); + + this._properties = null; + this._buffers = null; + this._bufferUpdateIDs = null; + }; + + Object.defineProperties( ParticleContainer.prototype, prototypeAccessors ); + + return ParticleContainer; + }(Container)); + + /** + * @author Mat Groves + * + * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/ + * for creating the original PixiJS version! + * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that + * they now share 4 bytes on the vertex buffer + * + * Heavily inspired by LibGDX's ParticleBuffer: + * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleBuffer.java + */ + + /** + * The particle buffer manages the static and dynamic buffers for a particle container. + * + * @class + * @private + * @memberof PIXI + */ + var ParticleBuffer = function ParticleBuffer(properties, dynamicPropertyFlags, size) + { + this.geometry = new Geometry(); + + this.indexBuffer = null; + + /** + * The number of particles the buffer can hold + * + * @private + * @member {number} + */ + this.size = size; + + /** + * A list of the properties that are dynamic. + * + * @private + * @member {object[]} + */ + this.dynamicProperties = []; + + /** + * A list of the properties that are static. + * + * @private + * @member {object[]} + */ + this.staticProperties = []; + + for (var i = 0; i < properties.length; ++i) + { + var property = properties[i]; + + // Make copy of properties object so that when we edit the offset it doesn't + // change all other instances of the object literal + property = { + attributeName: property.attributeName, + size: property.size, + uploadFunction: property.uploadFunction, + type: property.type || TYPES.FLOAT, + offset: property.offset, + }; + + if (dynamicPropertyFlags[i]) + { + this.dynamicProperties.push(property); + } + else + { + this.staticProperties.push(property); + } + } + + this.staticStride = 0; + this.staticBuffer = null; + this.staticData = null; + this.staticDataUint32 = null; + + this.dynamicStride = 0; + this.dynamicBuffer = null; + this.dynamicData = null; + this.dynamicDataUint32 = null; + + this._updateID = 0; + + this.initBuffers(); + }; + + /** + * Sets up the renderer context and necessary buffers. + * + * @private + */ + ParticleBuffer.prototype.initBuffers = function initBuffers () + { + var geometry = this.geometry; + + var dynamicOffset = 0; + + /** + * Holds the indices of the geometry (quads) to draw + * + * @member {Uint16Array} + * @private + */ + this.indexBuffer = new Buffer(createIndicesForQuads(this.size), true, true); + geometry.addIndex(this.indexBuffer); + + this.dynamicStride = 0; + + for (var i = 0; i < this.dynamicProperties.length; ++i) + { + var property = this.dynamicProperties[i]; + + property.offset = dynamicOffset; + dynamicOffset += property.size; + this.dynamicStride += property.size; + } + + var dynBuffer = new ArrayBuffer(this.size * this.dynamicStride * 4 * 4); + + this.dynamicData = new Float32Array(dynBuffer); + this.dynamicDataUint32 = new Uint32Array(dynBuffer); + this.dynamicBuffer = new Buffer(this.dynamicData, false, false); + + // static // + var staticOffset = 0; + + this.staticStride = 0; + + for (var i$1 = 0; i$1 < this.staticProperties.length; ++i$1) + { + var property$1 = this.staticProperties[i$1]; + + property$1.offset = staticOffset; + staticOffset += property$1.size; + this.staticStride += property$1.size; + } + + var statBuffer = new ArrayBuffer(this.size * this.staticStride * 4 * 4); + + this.staticData = new Float32Array(statBuffer); + this.staticDataUint32 = new Uint32Array(statBuffer); + this.staticBuffer = new Buffer(this.staticData, true, false); + + for (var i$2 = 0; i$2 < this.dynamicProperties.length; ++i$2) + { + var property$2 = this.dynamicProperties[i$2]; + + geometry.addAttribute( + property$2.attributeName, + this.dynamicBuffer, + 0, + property$2.type === TYPES.UNSIGNED_BYTE, + property$2.type, + this.dynamicStride * 4, + property$2.offset * 4 + ); + } + + for (var i$3 = 0; i$3 < this.staticProperties.length; ++i$3) + { + var property$3 = this.staticProperties[i$3]; + + geometry.addAttribute( + property$3.attributeName, + this.staticBuffer, + 0, + property$3.type === TYPES.UNSIGNED_BYTE, + property$3.type, + this.staticStride * 4, + property$3.offset * 4 + ); + } + }; + + /** + * Uploads the dynamic properties. + * + * @private + * @param {PIXI.DisplayObject[]} children - The children to upload. + * @param {number} startIndex - The index to start at. + * @param {number} amount - The number to upload. + */ + ParticleBuffer.prototype.uploadDynamic = function uploadDynamic (children, startIndex, amount) + { + for (var i = 0; i < this.dynamicProperties.length; i++) + { + var property = this.dynamicProperties[i]; + + property.uploadFunction(children, startIndex, amount, + property.type === TYPES.UNSIGNED_BYTE ? this.dynamicDataUint32 : this.dynamicData, + this.dynamicStride, property.offset); + } + + this.dynamicBuffer._updateID++; + }; + + /** + * Uploads the static properties. + * + * @private + * @param {PIXI.DisplayObject[]} children - The children to upload. + * @param {number} startIndex - The index to start at. + * @param {number} amount - The number to upload. + */ + ParticleBuffer.prototype.uploadStatic = function uploadStatic (children, startIndex, amount) + { + for (var i = 0; i < this.staticProperties.length; i++) + { + var property = this.staticProperties[i]; + + property.uploadFunction(children, startIndex, amount, + property.type === TYPES.UNSIGNED_BYTE ? this.staticDataUint32 : this.staticData, + this.staticStride, property.offset); + } + + this.staticBuffer._updateID++; + }; + + /** + * Destroys the ParticleBuffer. + * + * @private + */ + ParticleBuffer.prototype.destroy = function destroy () + { + this.indexBuffer = null; + + this.dynamicProperties = null; + // this.dynamicBuffer.destroy(); + this.dynamicBuffer = null; + this.dynamicData = null; + this.dynamicDataUint32 = null; + + this.staticProperties = null; + // this.staticBuffer.destroy(); + this.staticBuffer = null; + this.staticData = null; + this.staticDataUint32 = null; + // all buffers are destroyed inside geometry + this.geometry.destroy(); + }; + + var vertex$2 = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nattribute vec2 aPositionCoord;\nattribute float aRotation;\n\nuniform mat3 translationMatrix;\nuniform vec4 uColor;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void){\n float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);\n float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);\n\n vec2 v = vec2(x, y);\n v = v + aPositionCoord;\n\n gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vColor = aColor * uColor;\n}\n"; + + var fragment$1 = "varying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n vec4 color = texture2D(uSampler, vTextureCoord) * vColor;\n gl_FragColor = color;\n}"; + + /** + * @author Mat Groves + * + * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/ + * for creating the original PixiJS version! + * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they now + * share 4 bytes on the vertex buffer + * + * Heavily inspired by LibGDX's ParticleRenderer: + * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleRenderer.java + */ + + /** + * Renderer for Particles that is designer for speed over feature set. + * + * @class + * @memberof PIXI + */ + var ParticleRenderer = /*@__PURE__*/(function (ObjectRenderer) { + function ParticleRenderer(renderer) + { + ObjectRenderer.call(this, renderer); + + // 65535 is max vertex index in the index buffer (see ParticleRenderer) + // so max number of particles is 65536 / 4 = 16384 + // and max number of element in the index buffer is 16384 * 6 = 98304 + // Creating a full index buffer, overhead is 98304 * 2 = 196Ko + // let numIndices = 98304; + + /** + * The default shader that is used if a sprite doesn't have a more specific one. + * + * @member {PIXI.Shader} + */ + this.shader = null; + + this.properties = null; + + this.tempMatrix = new Matrix(); + + this.properties = [ + // verticesData + { + attributeName: 'aVertexPosition', + size: 2, + uploadFunction: this.uploadVertices, + offset: 0, + }, + // positionData + { + attributeName: 'aPositionCoord', + size: 2, + uploadFunction: this.uploadPosition, + offset: 0, + }, + // rotationData + { + attributeName: 'aRotation', + size: 1, + uploadFunction: this.uploadRotation, + offset: 0, + }, + // uvsData + { + attributeName: 'aTextureCoord', + size: 2, + uploadFunction: this.uploadUvs, + offset: 0, + }, + // tintData + { + attributeName: 'aColor', + size: 1, + type: TYPES.UNSIGNED_BYTE, + uploadFunction: this.uploadTint, + offset: 0, + } ]; + + this.shader = Shader.from(vertex$2, fragment$1, {}); + } + + if ( ObjectRenderer ) { ParticleRenderer.__proto__ = ObjectRenderer; } + ParticleRenderer.prototype = Object.create( ObjectRenderer && ObjectRenderer.prototype ); + ParticleRenderer.prototype.constructor = ParticleRenderer; + + /** + * Renders the particle container object. + * + * @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer + */ + ParticleRenderer.prototype.render = function render (container) + { + var children = container.children; + var maxSize = container._maxSize; + var batchSize = container._batchSize; + var renderer = this.renderer; + var totalChildren = children.length; + + if (totalChildren === 0) + { + return; + } + else if (totalChildren > maxSize) + { + totalChildren = maxSize; + } + + var buffers = container._buffers; + + if (!buffers) + { + buffers = container._buffers = this.generateBuffers(container); + } + + var baseTexture = children[0]._texture.baseTexture; + + // if the uvs have not updated then no point rendering just yet! + this.renderer.state.setBlendMode(correctBlendMode(container.blendMode, baseTexture.premultiplyAlpha)); + + var gl = renderer.gl; + + var m = container.worldTransform.copyTo(this.tempMatrix); + + m.prepend(renderer.globalUniforms.uniforms.projectionMatrix); + + this.shader.uniforms.translationMatrix = m.toArray(true); + + this.shader.uniforms.uColor = premultiplyRgba(container.tintRgb, + container.worldAlpha, this.shader.uniforms.uColor, baseTexture.premultiplyAlpha); + + this.shader.uniforms.uSampler = baseTexture; + + this.renderer.shader.bind(this.shader); + + var updateStatic = false; + + // now lets upload and render the buffers.. + for (var i = 0, j = 0; i < totalChildren; i += batchSize, j += 1) + { + var amount = (totalChildren - i); + + if (amount > batchSize) + { + amount = batchSize; + } + + if (j >= buffers.length) + { + if (!container.autoResize) + { + break; + } + buffers.push(this._generateOneMoreBuffer(container)); + } + + var buffer = buffers[j]; + + // we always upload the dynamic + buffer.uploadDynamic(children, i, amount); + + var bid = container._bufferUpdateIDs[j] || 0; + + updateStatic = updateStatic || (buffer._updateID < bid); + // we only upload the static content when we have to! + if (updateStatic) + { + buffer._updateID = container._updateID; + buffer.uploadStatic(children, i, amount); + } + + // bind the buffer + renderer.geometry.bind(buffer.geometry); + gl.drawElements(gl.TRIANGLES, amount * 6, gl.UNSIGNED_SHORT, 0); + } + }; + + /** + * Creates one particle buffer for each child in the container we want to render and updates internal properties + * + * @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer + * @return {PIXI.ParticleBuffer[]} The buffers + * @private + */ + ParticleRenderer.prototype.generateBuffers = function generateBuffers (container) + { + var buffers = []; + var size = container._maxSize; + var batchSize = container._batchSize; + var dynamicPropertyFlags = container._properties; + + for (var i = 0; i < size; i += batchSize) + { + buffers.push(new ParticleBuffer(this.properties, dynamicPropertyFlags, batchSize)); + } + + return buffers; + }; + + /** + * Creates one more particle buffer, because container has autoResize feature + * + * @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer + * @return {PIXI.ParticleBuffer} generated buffer + * @private + */ + ParticleRenderer.prototype._generateOneMoreBuffer = function _generateOneMoreBuffer (container) + { + var batchSize = container._batchSize; + var dynamicPropertyFlags = container._properties; + + return new ParticleBuffer(this.properties, dynamicPropertyFlags, batchSize); + }; + + /** + * Uploads the vertices. + * + * @param {PIXI.DisplayObject[]} children - the array of display objects to render + * @param {number} startIndex - the index to start from in the children array + * @param {number} amount - the amount of children that will have their vertices uploaded + * @param {number[]} array - The vertices to upload. + * @param {number} stride - Stride to use for iteration. + * @param {number} offset - Offset to start at. + */ + ParticleRenderer.prototype.uploadVertices = function uploadVertices (children, startIndex, amount, array, stride, offset) + { + var w0 = 0; + var w1 = 0; + var h0 = 0; + var h1 = 0; + + for (var i = 0; i < amount; ++i) + { + var sprite = children[startIndex + i]; + var texture = sprite._texture; + var sx = sprite.scale.x; + var sy = sprite.scale.y; + var trim = texture.trim; + var orig = texture.orig; + + if (trim) + { + // if the sprite is trimmed and is not a tilingsprite then we need to add the + // extra space before transforming the sprite coords.. + w1 = trim.x - (sprite.anchor.x * orig.width); + w0 = w1 + trim.width; + + h1 = trim.y - (sprite.anchor.y * orig.height); + h0 = h1 + trim.height; + } + else + { + w0 = (orig.width) * (1 - sprite.anchor.x); + w1 = (orig.width) * -sprite.anchor.x; + + h0 = orig.height * (1 - sprite.anchor.y); + h1 = orig.height * -sprite.anchor.y; + } + + array[offset] = w1 * sx; + array[offset + 1] = h1 * sy; + + array[offset + stride] = w0 * sx; + array[offset + stride + 1] = h1 * sy; + + array[offset + (stride * 2)] = w0 * sx; + array[offset + (stride * 2) + 1] = h0 * sy; + + array[offset + (stride * 3)] = w1 * sx; + array[offset + (stride * 3) + 1] = h0 * sy; + + offset += stride * 4; + } + }; + + /** + * Uploads the position. + * + * @param {PIXI.DisplayObject[]} children - the array of display objects to render + * @param {number} startIndex - the index to start from in the children array + * @param {number} amount - the amount of children that will have their positions uploaded + * @param {number[]} array - The vertices to upload. + * @param {number} stride - Stride to use for iteration. + * @param {number} offset - Offset to start at. + */ + ParticleRenderer.prototype.uploadPosition = function uploadPosition (children, startIndex, amount, array, stride, offset) + { + for (var i = 0; i < amount; i++) + { + var spritePosition = children[startIndex + i].position; + + array[offset] = spritePosition.x; + array[offset + 1] = spritePosition.y; + + array[offset + stride] = spritePosition.x; + array[offset + stride + 1] = spritePosition.y; + + array[offset + (stride * 2)] = spritePosition.x; + array[offset + (stride * 2) + 1] = spritePosition.y; + + array[offset + (stride * 3)] = spritePosition.x; + array[offset + (stride * 3) + 1] = spritePosition.y; + + offset += stride * 4; + } + }; + + /** + * Uploads the rotiation. + * + * @param {PIXI.DisplayObject[]} children - the array of display objects to render + * @param {number} startIndex - the index to start from in the children array + * @param {number} amount - the amount of children that will have their rotation uploaded + * @param {number[]} array - The vertices to upload. + * @param {number} stride - Stride to use for iteration. + * @param {number} offset - Offset to start at. + */ + ParticleRenderer.prototype.uploadRotation = function uploadRotation (children, startIndex, amount, array, stride, offset) + { + for (var i = 0; i < amount; i++) + { + var spriteRotation = children[startIndex + i].rotation; + + array[offset] = spriteRotation; + array[offset + stride] = spriteRotation; + array[offset + (stride * 2)] = spriteRotation; + array[offset + (stride * 3)] = spriteRotation; + + offset += stride * 4; + } + }; + + /** + * Uploads the Uvs + * + * @param {PIXI.DisplayObject[]} children - the array of display objects to render + * @param {number} startIndex - the index to start from in the children array + * @param {number} amount - the amount of children that will have their rotation uploaded + * @param {number[]} array - The vertices to upload. + * @param {number} stride - Stride to use for iteration. + * @param {number} offset - Offset to start at. + */ + ParticleRenderer.prototype.uploadUvs = function uploadUvs (children, startIndex, amount, array, stride, offset) + { + for (var i = 0; i < amount; ++i) + { + var textureUvs = children[startIndex + i]._texture._uvs; + + if (textureUvs) + { + array[offset] = textureUvs.x0; + array[offset + 1] = textureUvs.y0; + + array[offset + stride] = textureUvs.x1; + array[offset + stride + 1] = textureUvs.y1; + + array[offset + (stride * 2)] = textureUvs.x2; + array[offset + (stride * 2) + 1] = textureUvs.y2; + + array[offset + (stride * 3)] = textureUvs.x3; + array[offset + (stride * 3) + 1] = textureUvs.y3; + + offset += stride * 4; + } + else + { + // TODO you know this can be easier! + array[offset] = 0; + array[offset + 1] = 0; + + array[offset + stride] = 0; + array[offset + stride + 1] = 0; + + array[offset + (stride * 2)] = 0; + array[offset + (stride * 2) + 1] = 0; + + array[offset + (stride * 3)] = 0; + array[offset + (stride * 3) + 1] = 0; + + offset += stride * 4; + } + } + }; + + /** + * Uploads the tint. + * + * @param {PIXI.DisplayObject[]} children - the array of display objects to render + * @param {number} startIndex - the index to start from in the children array + * @param {number} amount - the amount of children that will have their rotation uploaded + * @param {number[]} array - The vertices to upload. + * @param {number} stride - Stride to use for iteration. + * @param {number} offset - Offset to start at. + */ + ParticleRenderer.prototype.uploadTint = function uploadTint (children, startIndex, amount, array, stride, offset) + { + for (var i = 0; i < amount; ++i) + { + var sprite = children[startIndex + i]; + var premultiplied = sprite._texture.baseTexture.premultiplyAlpha; + var alpha = sprite.alpha; + // we dont call extra function if alpha is 1.0, that's faster + var argb = alpha < 1.0 && premultiplied ? premultiplyTint(sprite._tintRGB, alpha) + : sprite._tintRGB + (alpha * 255 << 24); + + array[offset] = argb; + array[offset + stride] = argb; + array[offset + (stride * 2)] = argb; + array[offset + (stride * 3)] = argb; + + offset += stride * 4; + } + }; + + /** + * Destroys the ParticleRenderer. + */ + ParticleRenderer.prototype.destroy = function destroy () + { + ObjectRenderer.prototype.destroy.call(this); + + if (this.shader) + { + this.shader.destroy(); + this.shader = null; + } + + this.tempMatrix = null; + }; + + return ParticleRenderer; + }(ObjectRenderer)); + + /*! + * @pixi/spritesheet - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/spritesheet is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Utility class for maintaining reference to a collection + * of Textures on a single Spritesheet. + * + * To access a sprite sheet from your code pass its JSON data file to Pixi's loader: + * + * ```js + * PIXI.Loader.shared.add("images/spritesheet.json").load(setup); + * + * function setup() { + * let sheet = PIXI.Loader.shared.resources["images/spritesheet.json"].spritesheet; + * ... + * } + * ``` + * With the `sheet.textures` you can create Sprite objects,`sheet.animations` can be used to create an AnimatedSprite. + * + * Sprite sheets can be packed using tools like {@link https://codeandweb.com/texturepacker|TexturePacker}, + * {@link https://renderhjs.net/shoebox/|Shoebox} or {@link https://github.com/krzysztof-o/spritesheet.js|Spritesheet.js}. + * Default anchor points (see {@link PIXI.Texture#defaultAnchor}) and grouping of animation sprites are currently only + * supported by TexturePacker. + * + * @class + * @memberof PIXI + */ + var Spritesheet = function Spritesheet(baseTexture, data, resolutionFilename) + { + if ( resolutionFilename === void 0 ) { resolutionFilename = null; } + + /** + * Reference to ths source texture + * @type {PIXI.BaseTexture} + */ + this.baseTexture = baseTexture; + + /** + * A map containing all textures of the sprite sheet. + * Can be used to create a {@link PIXI.Sprite|Sprite}: + * ```js + * new PIXI.Sprite(sheet.textures["image.png"]); + * ``` + * @member {Object} + */ + this.textures = {}; + + /** + * A map containing the textures for each animation. + * Can be used to create an {@link PIXI.AnimatedSprite|AnimatedSprite}: + * ```js + * new PIXI.AnimatedSprite(sheet.animations["anim_name"]) + * ``` + * @member {Object} + */ + this.animations = {}; + + /** + * Reference to the original JSON data. + * @type {Object} + */ + this.data = data; + + /** + * The resolution of the spritesheet. + * @type {number} + */ + this.resolution = this._updateResolution( + resolutionFilename + || (this.baseTexture.resource ? this.baseTexture.resource.url : null) + ); + + /** + * Map of spritesheet frames. + * @type {Object} + * @private + */ + this._frames = this.data.frames; + + /** + * Collection of frame names. + * @type {string[]} + * @private + */ + this._frameKeys = Object.keys(this._frames); + + /** + * Current batch index being processed. + * @type {number} + * @private + */ + this._batchIndex = 0; + + /** + * Callback when parse is completed. + * @type {Function} + * @private + */ + this._callback = null; + }; + + var staticAccessors$4 = { BATCH_SIZE: { configurable: true } }; + + /** + * Generate the resolution from the filename or fallback + * to the meta.scale field of the JSON data. + * + * @private + * @param {string} resolutionFilename - The filename to use for resolving + * the default resolution. + * @return {number} Resolution to use for spritesheet. + */ + staticAccessors$4.BATCH_SIZE.get = function () + { + return 1000; + }; + + Spritesheet.prototype._updateResolution = function _updateResolution (resolutionFilename) + { + var scale = this.data.meta.scale; + + // Use a defaultValue of `null` to check if a url-based resolution is set + var resolution = getResolutionOfUrl(resolutionFilename, null); + + // No resolution found via URL + if (resolution === null) + { + // Use the scale value or default to 1 + resolution = scale !== undefined ? parseFloat(scale) : 1; + } + + // For non-1 resolutions, update baseTexture + if (resolution !== 1) + { + this.baseTexture.setResolution(resolution); + } + + return resolution; + }; + + /** + * Parser spritesheet from loaded data. This is done asynchronously + * to prevent creating too many Texture within a single process. + * + * @param {Function} callback - Callback when complete returns + * a map of the Textures for this spritesheet. + */ + Spritesheet.prototype.parse = function parse (callback) + { + this._batchIndex = 0; + this._callback = callback; + + if (this._frameKeys.length <= Spritesheet.BATCH_SIZE) + { + this._processFrames(0); + this._processAnimations(); + this._parseComplete(); + } + else + { + this._nextBatch(); + } + }; + + /** + * Process a batch of frames + * + * @private + * @param {number} initialFrameIndex - The index of frame to start. + */ + Spritesheet.prototype._processFrames = function _processFrames (initialFrameIndex) + { + var frameIndex = initialFrameIndex; + var maxFrames = Spritesheet.BATCH_SIZE; + + while (frameIndex - initialFrameIndex < maxFrames && frameIndex < this._frameKeys.length) + { + var i = this._frameKeys[frameIndex]; + var data = this._frames[i]; + var rect = data.frame; + + if (rect) + { + var frame = null; + var trim = null; + var sourceSize = data.trimmed !== false && data.sourceSize + ? data.sourceSize : data.frame; + + var orig = new Rectangle( + 0, + 0, + Math.floor(sourceSize.w) / this.resolution, + Math.floor(sourceSize.h) / this.resolution + ); + + if (data.rotated) + { + frame = new Rectangle( + Math.floor(rect.x) / this.resolution, + Math.floor(rect.y) / this.resolution, + Math.floor(rect.h) / this.resolution, + Math.floor(rect.w) / this.resolution + ); + } + else + { + frame = new Rectangle( + Math.floor(rect.x) / this.resolution, + Math.floor(rect.y) / this.resolution, + Math.floor(rect.w) / this.resolution, + Math.floor(rect.h) / this.resolution + ); + } + + // Check to see if the sprite is trimmed + if (data.trimmed !== false && data.spriteSourceSize) + { + trim = new Rectangle( + Math.floor(data.spriteSourceSize.x) / this.resolution, + Math.floor(data.spriteSourceSize.y) / this.resolution, + Math.floor(rect.w) / this.resolution, + Math.floor(rect.h) / this.resolution + ); + } + + this.textures[i] = new Texture( + this.baseTexture, + frame, + orig, + trim, + data.rotated ? 2 : 0, + data.anchor + ); + + // lets also add the frame to pixi's global cache for 'from' and 'fromLoader' functions + Texture.addToCache(this.textures[i], i); + } + + frameIndex++; + } + }; + + /** + * Parse animations config + * + * @private + */ + Spritesheet.prototype._processAnimations = function _processAnimations () + { + var animations = this.data.animations || {}; + + for (var animName in animations) + { + this.animations[animName] = []; + for (var i = 0; i < animations[animName].length; i++) + { + var frameName = animations[animName][i]; + + this.animations[animName].push(this.textures[frameName]); + } + } + }; + + /** + * The parse has completed. + * + * @private + */ + Spritesheet.prototype._parseComplete = function _parseComplete () + { + var callback = this._callback; + + this._callback = null; + this._batchIndex = 0; + callback.call(this, this.textures); + }; + + /** + * Begin the next batch of textures. + * + * @private + */ + Spritesheet.prototype._nextBatch = function _nextBatch () + { + var this$1 = this; + + this._processFrames(this._batchIndex * Spritesheet.BATCH_SIZE); + this._batchIndex++; + setTimeout(function () { + if (this$1._batchIndex * Spritesheet.BATCH_SIZE < this$1._frameKeys.length) + { + this$1._nextBatch(); + } + else + { + this$1._processAnimations(); + this$1._parseComplete(); + } + }, 0); + }; + + /** + * Destroy Spritesheet and don't use after this. + * + * @param {boolean} [destroyBase=false] Whether to destroy the base texture as well + */ + Spritesheet.prototype.destroy = function destroy (destroyBase) + { + if ( destroyBase === void 0 ) { destroyBase = false; } + + for (var i in this.textures) + { + this.textures[i].destroy(); + } + this._frames = null; + this._frameKeys = null; + this.data = null; + this.textures = null; + if (destroyBase) + { + this.baseTexture.destroy(); + } + this.baseTexture = null; + }; + + Object.defineProperties( Spritesheet, staticAccessors$4 ); + + /** + * {@link PIXI.Loader Loader} middleware for loading texture atlases that have been created with + * TexturePacker or similar JSON-based spritesheet. + * + * This middleware automatically generates Texture resources. + * + * @class + * @memberof PIXI + * @implements PIXI.ILoaderPlugin + */ + var SpritesheetLoader = function SpritesheetLoader () {}; + + SpritesheetLoader.use = function use (resource, next) + { + var imageResourceName = (resource.name) + "_image"; + + // skip if no data, its not json, it isn't spritesheet data, or the image resource already exists + if (!resource.data + || resource.type !== LoaderResource.TYPE.JSON + || !resource.data.frames + || this.resources[imageResourceName] + ) + { + next(); + + return; + } + + var loadOptions = { + crossOrigin: resource.crossOrigin, + metadata: resource.metadata.imageMetadata, + parentResource: resource, + }; + + var resourcePath = SpritesheetLoader.getResourcePath(resource, this.baseUrl); + + // load the image for this sheet + this.add(imageResourceName, resourcePath, loadOptions, function onImageLoad(res) + { + if (res.error) + { + next(res.error); + + return; + } + + var spritesheet = new Spritesheet( + res.texture.baseTexture, + resource.data, + resource.url + ); + + spritesheet.parse(function () { + resource.spritesheet = spritesheet; + resource.textures = spritesheet.textures; + next(); + }); + }); + }; + + /** + * Get the spritesheets root path + * @param {PIXI.LoaderResource} resource - Resource to check path + * @param {string} baseUrl - Base root url + */ + SpritesheetLoader.getResourcePath = function getResourcePath (resource, baseUrl) + { + // Prepend url path unless the resource image is a data url + if (resource.isDataUrl) + { + return resource.data.meta.image; + } + + return url.resolve(resource.url.replace(baseUrl, ''), resource.data.meta.image); + }; + + /*! + * @pixi/sprite-tiling - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/sprite-tiling is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var tempPoint$1 = new Point(); + + /** + * A tiling sprite is a fast way of rendering a tiling image + * + * @class + * @extends PIXI.Sprite + * @memberof PIXI + */ + var TilingSprite = /*@__PURE__*/(function (Sprite) { + function TilingSprite(texture, width, height) + { + if ( width === void 0 ) { width = 100; } + if ( height === void 0 ) { height = 100; } + + Sprite.call(this, texture); + + /** + * Tile transform + * + * @member {PIXI.Transform} + */ + this.tileTransform = new Transform(); + + // /// private + + /** + * The with of the tiling sprite + * + * @member {number} + * @private + */ + this._width = width; + + /** + * The height of the tiling sprite + * + * @member {number} + * @private + */ + this._height = height; + + /** + * Canvas pattern + * + * @type {CanvasPattern} + * @private + */ + this._canvasPattern = null; + + /** + * matrix that is applied to UV to get the coords in Texture normalized space to coords in BaseTexture space + * + * @member {PIXI.TextureMatrix} + */ + this.uvMatrix = texture.uvMatrix || new TextureMatrix(texture); + + /** + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' method. + * + * @member {string} + * @default 'tilingSprite' + */ + this.pluginName = 'tilingSprite'; + + /** + * Whether or not anchor affects uvs + * + * @member {boolean} + * @default false + */ + this.uvRespectAnchor = false; + } + + if ( Sprite ) { TilingSprite.__proto__ = Sprite; } + TilingSprite.prototype = Object.create( Sprite && Sprite.prototype ); + TilingSprite.prototype.constructor = TilingSprite; + + var prototypeAccessors = { clampMargin: { configurable: true },tileScale: { configurable: true },tilePosition: { configurable: true },width: { configurable: true },height: { configurable: true } }; + /** + * Changes frame clamping in corresponding textureTransform, shortcut + * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas + * + * @default 0.5 + * @member {number} + */ + prototypeAccessors.clampMargin.get = function () + { + return this.uvMatrix.clampMargin; + }; + + prototypeAccessors.clampMargin.set = function (value) // eslint-disable-line require-jsdoc + { + this.uvMatrix.clampMargin = value; + this.uvMatrix.update(true); + }; + + /** + * The scaling of the image that is being tiled + * + * @member {PIXI.ObservablePoint} + */ + prototypeAccessors.tileScale.get = function () + { + return this.tileTransform.scale; + }; + + prototypeAccessors.tileScale.set = function (value) // eslint-disable-line require-jsdoc + { + this.tileTransform.scale.copyFrom(value); + }; + + /** + * The offset of the image that is being tiled + * + * @member {PIXI.ObservablePoint} + */ + prototypeAccessors.tilePosition.get = function () + { + return this.tileTransform.position; + }; + + prototypeAccessors.tilePosition.set = function (value) // eslint-disable-line require-jsdoc + { + this.tileTransform.position.copyFrom(value); + }; + + /** + * @private + */ + TilingSprite.prototype._onTextureUpdate = function _onTextureUpdate () + { + if (this.uvMatrix) + { + this.uvMatrix.texture = this._texture; + } + this.cachedTint = 0xFFFFFF; + }; + + /** + * Renders the object using the WebGL renderer + * + * @protected + * @param {PIXI.Renderer} renderer - The renderer + */ + TilingSprite.prototype._render = function _render (renderer) + { + // tweak our texture temporarily.. + var texture = this._texture; + + if (!texture || !texture.valid) + { + return; + } + + this.tileTransform.updateLocalTransform(); + this.uvMatrix.update(); + + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); + }; + + /** + * Updates the bounds of the tiling sprite. + * + * @protected + */ + TilingSprite.prototype._calculateBounds = function _calculateBounds () + { + var minX = this._width * -this._anchor._x; + var minY = this._height * -this._anchor._y; + var maxX = this._width * (1 - this._anchor._x); + var maxY = this._height * (1 - this._anchor._y); + + this._bounds.addFrame(this.transform, minX, minY, maxX, maxY); + }; + + /** + * Gets the local bounds of the sprite object. + * + * @param {PIXI.Rectangle} rect - The output rectangle. + * @return {PIXI.Rectangle} The bounds. + */ + TilingSprite.prototype.getLocalBounds = function getLocalBounds (rect) + { + // we can do a fast local bounds if the sprite has no children! + if (this.children.length === 0) + { + this._bounds.minX = this._width * -this._anchor._x; + this._bounds.minY = this._height * -this._anchor._y; + this._bounds.maxX = this._width * (1 - this._anchor._x); + this._bounds.maxY = this._height * (1 - this._anchor._y); + + if (!rect) + { + if (!this._localBoundsRect) + { + this._localBoundsRect = new Rectangle(); + } + + rect = this._localBoundsRect; + } + + return this._bounds.getRectangle(rect); + } + + return Sprite.prototype.getLocalBounds.call(this, rect); + }; + + /** + * Checks if a point is inside this tiling sprite. + * + * @param {PIXI.Point} point - the point to check + * @return {boolean} Whether or not the sprite contains the point. + */ + TilingSprite.prototype.containsPoint = function containsPoint (point) + { + this.worldTransform.applyInverse(point, tempPoint$1); + + var width = this._width; + var height = this._height; + var x1 = -width * this.anchor._x; + + if (tempPoint$1.x >= x1 && tempPoint$1.x < x1 + width) + { + var y1 = -height * this.anchor._y; + + if (tempPoint$1.y >= y1 && tempPoint$1.y < y1 + height) + { + return true; + } + } + + return false; + }; + + /** + * Destroys this sprite and optionally its texture and children + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options + * have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy + * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well + * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well + */ + TilingSprite.prototype.destroy = function destroy (options) + { + Sprite.prototype.destroy.call(this, options); + + this.tileTransform = null; + this.uvMatrix = null; + }; + + /** + * Helper function that creates a new tiling sprite based on the source you provide. + * The source can be - frame id, image url, video url, canvas element, video element, base texture + * + * @static + * @param {number|string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source - Source to create texture from + * @param {number} width - the width of the tiling sprite + * @param {number} height - the height of the tiling sprite + * @return {PIXI.TilingSprite} The newly created texture + */ + TilingSprite.from = function from (source, width, height) + { + return new TilingSprite(Texture.from(source), width, height); + }; + + /** + * Helper function that creates a tiling sprite that will use a texture from the TextureCache based on the frameId + * The frame ids are created when a Texture packer file has been loaded + * + * @static + * @param {string} frameId - The frame Id of the texture in the cache + * @param {number} width - the width of the tiling sprite + * @param {number} height - the height of the tiling sprite + * @return {PIXI.TilingSprite} A new TilingSprite using a texture from the texture cache matching the frameId + */ + TilingSprite.fromFrame = function fromFrame (frameId, width, height) + { + var texture = TextureCache[frameId]; + + if (!texture) + { + throw new Error(("The frameId \"" + frameId + "\" does not exist in the texture cache " + (this))); + } + + return new TilingSprite(texture, width, height); + }; + + /** + * Helper function that creates a sprite that will contain a texture based on an image url + * If the image is not in the texture cache it will be loaded + * + * @static + * @param {string} imageId - The image url of the texture + * @param {number} width - the width of the tiling sprite + * @param {number} height - the height of the tiling sprite + * @param {Object} [options] - See {@link PIXI.BaseTexture}'s constructor for options. + * @return {PIXI.TilingSprite} A new TilingSprite using a texture from the texture cache matching the image id + */ + TilingSprite.fromImage = function fromImage (imageId, width, height, options) + { + // Fallback support for crossorigin, scaleMode parameters + if (options && typeof options !== 'object') + { + options = { + scaleMode: arguments[4], + resourceOptions: { + crossorigin: arguments[3], + }, + }; + } + + return new TilingSprite(Texture.from(imageId, options), width, height); + }; + + /** + * The width of the sprite, setting this will actually modify the scale to achieve the value set + * + * @member {number} + */ + prototypeAccessors.width.get = function () + { + return this._width; + }; + + prototypeAccessors.width.set = function (value) // eslint-disable-line require-jsdoc + { + this._width = value; + }; + + /** + * The height of the TilingSprite, setting this will actually modify the scale to achieve the value set + * + * @member {number} + */ + prototypeAccessors.height.get = function () + { + return this._height; + }; + + prototypeAccessors.height.set = function (value) // eslint-disable-line require-jsdoc + { + this._height = value; + }; + + Object.defineProperties( TilingSprite.prototype, prototypeAccessors ); + + return TilingSprite; + }(Sprite)); + + var vertex$3 = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n"; + + var fragment$2 = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = mod(vTextureCoord - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 sample = texture2D(uSampler, coord);\n gl_FragColor = sample * uColor;\n}\n"; + + var fragmentSimple = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 sample = texture2D(uSampler, vTextureCoord);\n gl_FragColor = sample * uColor;\n}\n"; + + var tempMat$1 = new Matrix(); + + /** + * WebGL renderer plugin for tiling sprites + * + * @class + * @memberof PIXI + * @extends PIXI.ObjectRenderer + */ + var TilingSpriteRenderer = /*@__PURE__*/(function (ObjectRenderer) { + function TilingSpriteRenderer(renderer) + { + ObjectRenderer.call(this, renderer); + + var uniforms = { globals: this.renderer.globalUniforms }; + + this.shader = Shader.from(vertex$3, fragment$2, uniforms); + + this.simpleShader = Shader.from(vertex$3, fragmentSimple, uniforms); + + this.quad = new QuadUv(); + } + + if ( ObjectRenderer ) { TilingSpriteRenderer.__proto__ = ObjectRenderer; } + TilingSpriteRenderer.prototype = Object.create( ObjectRenderer && ObjectRenderer.prototype ); + TilingSpriteRenderer.prototype.constructor = TilingSpriteRenderer; + + /** + * + * @param {PIXI.TilingSprite} ts tilingSprite to be rendered + */ + TilingSpriteRenderer.prototype.render = function render (ts) + { + var renderer = this.renderer; + var quad = this.quad; + + var vertices = quad.vertices; + + vertices[0] = vertices[6] = (ts._width) * -ts.anchor.x; + vertices[1] = vertices[3] = ts._height * -ts.anchor.y; + + vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); + vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); + + if (ts.uvRespectAnchor) + { + vertices = quad.uvs; + + vertices[0] = vertices[6] = -ts.anchor.x; + vertices[1] = vertices[3] = -ts.anchor.y; + + vertices[2] = vertices[4] = 1.0 - ts.anchor.x; + vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + } + + quad.invalidate(); + + var tex = ts._texture; + var baseTex = tex.baseTexture; + var lt = ts.tileTransform.localTransform; + var uv = ts.uvMatrix; + var isSimple = baseTex.isPowerOfTwo + && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height; + + // auto, force repeat wrapMode for big tiling textures + if (isSimple) + { + if (!baseTex._glTextures[renderer.CONTEXT_UID]) + { + if (baseTex.wrapMode === WRAP_MODES.CLAMP) + { + baseTex.wrapMode = WRAP_MODES.REPEAT; + } + } + else + { + isSimple = baseTex.wrapMode !== WRAP_MODES.CLAMP; + } + } + + var shader = isSimple ? this.simpleShader : this.shader; + + var w = tex.width; + var h = tex.height; + var W = ts._width; + var H = ts._height; + + tempMat$1.set(lt.a * w / W, + lt.b * w / H, + lt.c * h / W, + lt.d * h / H, + lt.tx / W, + lt.ty / H); + + // that part is the same as above: + // tempMat.identity(); + // tempMat.scale(tex.width, tex.height); + // tempMat.prepend(lt); + // tempMat.scale(1.0 / ts._width, 1.0 / ts._height); + + tempMat$1.invert(); + if (isSimple) + { + tempMat$1.prepend(uv.mapCoord); + } + else + { + shader.uniforms.uMapCoord = uv.mapCoord.toArray(true); + shader.uniforms.uClampFrame = uv.uClampFrame; + shader.uniforms.uClampOffset = uv.uClampOffset; + } + + shader.uniforms.uTransform = tempMat$1.toArray(true); + shader.uniforms.uColor = premultiplyTintToRgba(ts.tint, ts.worldAlpha, + shader.uniforms.uColor, baseTex.premultiplyAlpha); + shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true); + shader.uniforms.uSampler = tex; + + renderer.shader.bind(shader); + renderer.geometry.bind(quad);// , renderer.shader.getGLShader()); + + renderer.state.setBlendMode(correctBlendMode(ts.blendMode, baseTex.premultiplyAlpha)); + renderer.geometry.draw(this.renderer.gl.TRIANGLES, 6, 0); + }; + + return TilingSpriteRenderer; + }(ObjectRenderer)); + + /*! + * @pixi/text-bitmap - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/text-bitmap is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * A BitmapText object will create a line or multiple lines of text using bitmap font. + * + * The primary advantage of this class over Text is that all of your textures are pre-generated and loading, + * meaning that rendering is fast, and changing text has no performance implications. + * + * The primary disadvantage is that you need to preload the bitmap font assets, and thus the styling is set in stone. + * Supporting character sets other than latin, such as CJK languages, may be impractical due to the number of characters. + * + * To split a line you can use '\n', '\r' or '\r\n' in your string. + * + * You can generate the fnt files using + * http://www.angelcode.com/products/bmfont/ for Windows or + * http://www.bmglyph.com/ for Mac. + * + * A BitmapText can only be created when the font is loaded. + * + * ```js + * // in this case the font is in a file called 'desyrel.fnt' + * let bitmapText = new PIXI.BitmapText("text using a fancy font!", {font: "35px Desyrel", align: "right"}); + * ``` + * + * @class + * @extends PIXI.Container + * @memberof PIXI + */ + var BitmapText = /*@__PURE__*/(function (Container) { + function BitmapText(text, style) + { + var this$1 = this; + if ( style === void 0 ) { style = {}; } + + Container.call(this); + + /** + * Private tracker for the width of the overall text + * + * @member {number} + * @private + */ + this._textWidth = 0; + + /** + * Private tracker for the height of the overall text + * + * @member {number} + * @private + */ + this._textHeight = 0; + + /** + * Private tracker for the letter sprite pool. + * + * @member {PIXI.Sprite[]} + * @private + */ + this._glyphs = []; + + /** + * Private tracker for the current style. + * + * @member {object} + * @private + */ + this._font = { + tint: style.tint !== undefined ? style.tint : 0xFFFFFF, + align: style.align || 'left', + name: null, + size: 0, + }; + + /** + * Private tracker for the current font. + * + * @member {object} + * @private + */ + this.font = style.font; // run font setter + + /** + * Private tracker for the current text. + * + * @member {string} + * @private + */ + this._text = text; + + /** + * The max width of this bitmap text in pixels. If the text provided is longer than the + * value provided, line breaks will be automatically inserted in the last whitespace. + * Disable by setting value to 0 + * + * @member {number} + * @private + */ + this._maxWidth = 0; + + /** + * The max line height. This is useful when trying to use the total height of the Text, + * ie: when trying to vertically align. + * + * @member {number} + * @private + */ + this._maxLineHeight = 0; + + /** + * Letter spacing. This is useful for setting the space between characters. + * @member {number} + * @private + */ + this._letterSpacing = 0; + + /** + * Text anchor. read-only + * + * @member {PIXI.ObservablePoint} + * @private + */ + this._anchor = new ObservablePoint(function () { this$1.dirty = true; }, this, 0, 0); + + /** + * The dirty state of this object. + * + * @member {boolean} + */ + this.dirty = false; + + /** + * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. + * Advantages can include sharper image quality (like text) and faster rendering on canvas. + * The main disadvantage is movement of objects may appear less smooth. + * To set the global default, change {@link PIXI.settings.ROUND_PIXELS} + * + * @member {boolean} + * @default false + */ + this.roundPixels = settings.ROUND_PIXELS; + + this.updateText(); + } + + if ( Container ) { BitmapText.__proto__ = Container; } + BitmapText.prototype = Object.create( Container && Container.prototype ); + BitmapText.prototype.constructor = BitmapText; + + var prototypeAccessors = { tint: { configurable: true },align: { configurable: true },anchor: { configurable: true },font: { configurable: true },text: { configurable: true },maxWidth: { configurable: true },maxLineHeight: { configurable: true },textWidth: { configurable: true },letterSpacing: { configurable: true },textHeight: { configurable: true } }; + + /** + * Renders text and updates it when needed + * + * @private + */ + BitmapText.prototype.updateText = function updateText () + { + var data = BitmapText.fonts[this._font.name]; + var scale = this._font.size / data.size; + var pos = new Point(); + var chars = []; + var lineWidths = []; + var text = this._text.replace(/(?:\r\n|\r)/g, '\n') || ' '; + var textLength = text.length; + var maxWidth = this._maxWidth * data.size / this._font.size; + + var prevCharCode = null; + var lastLineWidth = 0; + var maxLineWidth = 0; + var line = 0; + var lastBreakPos = -1; + var lastBreakWidth = 0; + var spacesRemoved = 0; + var maxLineHeight = 0; + + for (var i = 0; i < textLength; i++) + { + var charCode = text.charCodeAt(i); + var char = text.charAt(i); + + if ((/(?:\s)/).test(char)) + { + lastBreakPos = i; + lastBreakWidth = lastLineWidth; + } + + if (char === '\r' || char === '\n') + { + lineWidths.push(lastLineWidth); + maxLineWidth = Math.max(maxLineWidth, lastLineWidth); + ++line; + ++spacesRemoved; + + pos.x = 0; + pos.y += data.lineHeight; + prevCharCode = null; + continue; + } + + var charData = data.chars[charCode]; + + if (!charData) + { + continue; + } + + if (prevCharCode && charData.kerning[prevCharCode]) + { + pos.x += charData.kerning[prevCharCode]; + } + + chars.push({ + texture: charData.texture, + line: line, + charCode: charCode, + position: new Point(pos.x + charData.xOffset + (this._letterSpacing / 2), pos.y + charData.yOffset), + }); + pos.x += charData.xAdvance + this._letterSpacing; + lastLineWidth = pos.x; + maxLineHeight = Math.max(maxLineHeight, (charData.yOffset + charData.texture.height)); + prevCharCode = charCode; + + if (lastBreakPos !== -1 && maxWidth > 0 && pos.x > maxWidth) + { + ++spacesRemoved; + removeItems(chars, 1 + lastBreakPos - spacesRemoved, 1 + i - lastBreakPos); + i = lastBreakPos; + lastBreakPos = -1; + + lineWidths.push(lastBreakWidth); + maxLineWidth = Math.max(maxLineWidth, lastBreakWidth); + line++; + + pos.x = 0; + pos.y += data.lineHeight; + prevCharCode = null; + } + } + + var lastChar = text.charAt(text.length - 1); + + if (lastChar !== '\r' && lastChar !== '\n') + { + if ((/(?:\s)/).test(lastChar)) + { + lastLineWidth = lastBreakWidth; + } + + lineWidths.push(lastLineWidth); + maxLineWidth = Math.max(maxLineWidth, lastLineWidth); + } + + var lineAlignOffsets = []; + + for (var i$1 = 0; i$1 <= line; i$1++) + { + var alignOffset = 0; + + if (this._font.align === 'right') + { + alignOffset = maxLineWidth - lineWidths[i$1]; + } + else if (this._font.align === 'center') + { + alignOffset = (maxLineWidth - lineWidths[i$1]) / 2; + } + + lineAlignOffsets.push(alignOffset); + } + + var lenChars = chars.length; + var tint = this.tint; + + for (var i$2 = 0; i$2 < lenChars; i$2++) + { + var c = this._glyphs[i$2]; // get the next glyph sprite + + if (c) + { + c.texture = chars[i$2].texture; + } + else + { + c = new Sprite(chars[i$2].texture); + c.roundPixels = this.roundPixels; + this._glyphs.push(c); + } + + c.position.x = (chars[i$2].position.x + lineAlignOffsets[chars[i$2].line]) * scale; + c.position.y = chars[i$2].position.y * scale; + c.scale.x = c.scale.y = scale; + c.tint = tint; + + if (!c.parent) + { + this.addChild(c); + } + } + + // remove unnecessary children. + for (var i$3 = lenChars; i$3 < this._glyphs.length; ++i$3) + { + this.removeChild(this._glyphs[i$3]); + } + + this._textWidth = maxLineWidth * scale; + this._textHeight = (pos.y + data.lineHeight) * scale; + + // apply anchor + if (this.anchor.x !== 0 || this.anchor.y !== 0) + { + for (var i$4 = 0; i$4 < lenChars; i$4++) + { + this._glyphs[i$4].x -= this._textWidth * this.anchor.x; + this._glyphs[i$4].y -= this._textHeight * this.anchor.y; + } + } + this._maxLineHeight = maxLineHeight * scale; + }; + + /** + * Updates the transform of this object + * + * @private + */ + BitmapText.prototype.updateTransform = function updateTransform () + { + this.validate(); + this.containerUpdateTransform(); + }; + + /** + * Validates text before calling parent's getLocalBounds + * + * @return {PIXI.Rectangle} The rectangular bounding area + */ + BitmapText.prototype.getLocalBounds = function getLocalBounds () + { + this.validate(); + + return Container.prototype.getLocalBounds.call(this); + }; + + /** + * Updates text when needed + * + * @private + */ + BitmapText.prototype.validate = function validate () + { + if (this.dirty) + { + this.updateText(); + this.dirty = false; + } + }; + + /** + * The tint of the BitmapText object. + * + * @member {number} + */ + prototypeAccessors.tint.get = function () + { + return this._font.tint; + }; + + prototypeAccessors.tint.set = function (value) // eslint-disable-line require-jsdoc + { + this._font.tint = (typeof value === 'number' && value >= 0) ? value : 0xFFFFFF; + + this.dirty = true; + }; + + /** + * The alignment of the BitmapText object. + * + * @member {string} + * @default 'left' + */ + prototypeAccessors.align.get = function () + { + return this._font.align; + }; + + prototypeAccessors.align.set = function (value) // eslint-disable-line require-jsdoc + { + this._font.align = value || 'left'; + + this.dirty = true; + }; + + /** + * The anchor sets the origin point of the text. + * + * The default is `(0,0)`, this means the text's origin is the top left. + * + * Setting the anchor to `(0.5,0.5)` means the text's origin is centered. + * + * Setting the anchor to `(1,1)` would mean the text's origin point will be the bottom right corner. + * + * @member {PIXI.Point | number} + */ + prototypeAccessors.anchor.get = function () + { + return this._anchor; + }; + + prototypeAccessors.anchor.set = function (value) // eslint-disable-line require-jsdoc + { + if (typeof value === 'number') + { + this._anchor.set(value); + } + else + { + this._anchor.copyFrom(value); + } + }; + + /** + * The font descriptor of the BitmapText object. + * + * @member {object} + */ + prototypeAccessors.font.get = function () + { + return this._font; + }; + + prototypeAccessors.font.set = function (value) // eslint-disable-line require-jsdoc + { + if (!value) + { + return; + } + + if (typeof value === 'string') + { + value = value.split(' '); + + this._font.name = value.length === 1 ? value[0] : value.slice(1).join(' '); + this._font.size = value.length >= 2 ? parseInt(value[0], 10) : BitmapText.fonts[this._font.name].size; + } + else + { + this._font.name = value.name; + this._font.size = typeof value.size === 'number' ? value.size : parseInt(value.size, 10); + } + + this.dirty = true; + }; + + /** + * The text of the BitmapText object. + * + * @member {string} + */ + prototypeAccessors.text.get = function () + { + return this._text; + }; + + prototypeAccessors.text.set = function (text) // eslint-disable-line require-jsdoc + { + text = String(text === null || text === undefined ? '' : text); + + if (this._text === text) + { + return; + } + this._text = text; + this.dirty = true; + }; + + /** + * The max width of this bitmap text in pixels. If the text provided is longer than the + * value provided, line breaks will be automatically inserted in the last whitespace. + * Disable by setting the value to 0. + * + * @member {number} + */ + prototypeAccessors.maxWidth.get = function () + { + return this._maxWidth; + }; + + prototypeAccessors.maxWidth.set = function (value) // eslint-disable-line require-jsdoc + { + if (this._maxWidth === value) + { + return; + } + this._maxWidth = value; + this.dirty = true; + }; + + /** + * The max line height. This is useful when trying to use the total height of the Text, + * i.e. when trying to vertically align. + * + * @member {number} + * @readonly + */ + prototypeAccessors.maxLineHeight.get = function () + { + this.validate(); + + return this._maxLineHeight; + }; + + /** + * The width of the overall text, different from fontSize, + * which is defined in the style object. + * + * @member {number} + * @readonly + */ + prototypeAccessors.textWidth.get = function () + { + this.validate(); + + return this._textWidth; + }; + + /** + * Additional space between characters. + * + * @member {number} + */ + prototypeAccessors.letterSpacing.get = function () + { + return this._letterSpacing; + }; + + prototypeAccessors.letterSpacing.set = function (value) // eslint-disable-line require-jsdoc + { + if (this._letterSpacing !== value) + { + this._letterSpacing = value; + this.dirty = true; + } + }; + + /** + * The height of the overall text, different from fontSize, + * which is defined in the style object. + * + * @member {number} + * @readonly + */ + prototypeAccessors.textHeight.get = function () + { + this.validate(); + + return this._textHeight; + }; + + /** + * Register a bitmap font with data and a texture. + * + * @static + * @param {XMLDocument} xml - The XML document data. + * @param {Object.|PIXI.Texture|PIXI.Texture[]} textures - List of textures for each page. + * If providing an object, the key is the `` element's `file` attribute in the FNT file. + * @return {Object} Result font object with font, size, lineHeight and char fields. + */ + BitmapText.registerFont = function registerFont (xml, textures) + { + var data = {}; + var info = xml.getElementsByTagName('info')[0]; + var common = xml.getElementsByTagName('common')[0]; + var pages = xml.getElementsByTagName('page'); + var res = getResolutionOfUrl(pages[0].getAttribute('file'), settings.RESOLUTION); + var pagesTextures = {}; + + data.font = info.getAttribute('face'); + data.size = parseInt(info.getAttribute('size'), 10); + data.lineHeight = parseInt(common.getAttribute('lineHeight'), 10) / res; + data.chars = {}; + + // Single texture, convert to list + if (textures instanceof Texture) + { + textures = [textures]; + } + + // Convert the input Texture, Textures or object + // into a page Texture lookup by "id" + for (var i = 0; i < pages.length; i++) + { + var id = pages[i].getAttribute('id'); + var file = pages[i].getAttribute('file'); + + pagesTextures[id] = textures instanceof Array ? textures[i] : textures[file]; + } + + // parse letters + var letters = xml.getElementsByTagName('char'); + + for (var i$1 = 0; i$1 < letters.length; i$1++) + { + var letter = letters[i$1]; + var charCode = parseInt(letter.getAttribute('id'), 10); + var page = letter.getAttribute('page') || 0; + var textureRect = new Rectangle( + (parseInt(letter.getAttribute('x'), 10) / res) + (pagesTextures[page].frame.x / res), + (parseInt(letter.getAttribute('y'), 10) / res) + (pagesTextures[page].frame.y / res), + parseInt(letter.getAttribute('width'), 10) / res, + parseInt(letter.getAttribute('height'), 10) / res + ); + + data.chars[charCode] = { + xOffset: parseInt(letter.getAttribute('xoffset'), 10) / res, + yOffset: parseInt(letter.getAttribute('yoffset'), 10) / res, + xAdvance: parseInt(letter.getAttribute('xadvance'), 10) / res, + kerning: {}, + texture: new Texture(pagesTextures[page].baseTexture, textureRect), + page: page, + }; + } + + // parse kernings + var kernings = xml.getElementsByTagName('kerning'); + + for (var i$2 = 0; i$2 < kernings.length; i$2++) + { + var kerning = kernings[i$2]; + var first = parseInt(kerning.getAttribute('first'), 10) / res; + var second = parseInt(kerning.getAttribute('second'), 10) / res; + var amount = parseInt(kerning.getAttribute('amount'), 10) / res; + + if (data.chars[second]) + { + data.chars[second].kerning[first] = amount; + } + } + + // I'm leaving this as a temporary fix so we can test the bitmap fonts in v3 + // but it's very likely to change + BitmapText.fonts[data.font] = data; + + return data; + }; + + Object.defineProperties( BitmapText.prototype, prototypeAccessors ); + + return BitmapText; + }(Container)); + + BitmapText.fonts = {}; + + /** + * {@link PIXI.Loader Loader} middleware for loading + * bitmap-based fonts suitable for using with {@link PIXI.BitmapText}. + * @class + * @memberof PIXI + * @implements PIXI.ILoaderPlugin + */ + var BitmapFontLoader = function BitmapFontLoader () {}; + + BitmapFontLoader.parse = function parse (resource, texture) + { + resource.bitmapFont = BitmapText.registerFont(resource.data, texture); + }; + + /** + * Called when the plugin is installed. + * + * @see PIXI.Loader.registerPlugin + */ + BitmapFontLoader.add = function add () + { + LoaderResource.setExtensionXhrType('fnt', LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT); + }; + + /** + * Replacement for NodeJS's path.dirname + * @private + * @param {string} url Path to get directory for + */ + BitmapFontLoader.dirname = function dirname (url) + { + var dir = url + .replace(/\/$/, '') // replace trailing slash + .replace(/\/[^\/]*$/, ''); // remove everything after the last + + // File request is relative, use current directory + if (dir === url) + { + return '.'; + } + // Started with a slash + else if (dir === '') + { + return '/'; + } + + return dir; + }; + + /** + * Called after a resource is loaded. + * @see PIXI.Loader.loaderMiddleware + * @param {PIXI.LoaderResource} resource + * @param {function} next + */ + BitmapFontLoader.use = function use (resource, next) + { + // skip if no data or not xml data + if (!resource.data || resource.type !== LoaderResource.TYPE.XML) + { + next(); + + return; + } + + // skip if not bitmap font data, using some silly duck-typing + if (resource.data.getElementsByTagName('page').length === 0 + || resource.data.getElementsByTagName('info').length === 0 + || resource.data.getElementsByTagName('info')[0].getAttribute('face') === null + ) + { + next(); + + return; + } + + var xmlUrl = !resource.isDataUrl ? BitmapFontLoader.dirname(resource.url) : ''; + + if (resource.isDataUrl) + { + if (xmlUrl === '.') + { + xmlUrl = ''; + } + + if (this.baseUrl && xmlUrl) + { + // if baseurl has a trailing slash then add one to xmlUrl so the replace works below + if (this.baseUrl.charAt(this.baseUrl.length - 1) === '/') + { + xmlUrl += '/'; + } + } + } + + // remove baseUrl from xmlUrl + xmlUrl = xmlUrl.replace(this.baseUrl, ''); + + // if there is an xmlUrl now, it needs a trailing slash. Ensure that it does if the string isn't empty. + if (xmlUrl && xmlUrl.charAt(xmlUrl.length - 1) !== '/') + { + xmlUrl += '/'; + } + + var pages = resource.data.getElementsByTagName('page'); + var textures = {}; + + // Handle completed, when the number of textures + // load is the same number as references in the fnt file + var completed = function (page) { + textures[page.metadata.pageFile] = page.texture; + + if (Object.keys(textures).length === pages.length) + { + BitmapFontLoader.parse(resource, textures); + next(); + } + }; + + for (var i = 0; i < pages.length; ++i) + { + var pageFile = pages[i].getAttribute('file'); + var url = xmlUrl + pageFile; + var exists = false; + + // incase the image is loaded outside + // using the same loader, resource will be available + for (var name in this.resources) + { + var bitmapResource = this.resources[name]; + + if (bitmapResource.url === url) + { + bitmapResource.metadata.pageFile = pageFile; + if (bitmapResource.texture) + { + completed(bitmapResource); + } + else + { + bitmapResource.onAfterMiddleware.add(completed); + } + exists = true; + break; + } + } + + // texture is not loaded, we'll attempt to add + // it to the load and add the texture to the list + if (!exists) + { + // Standard loading options for images + var options = { + crossOrigin: resource.crossOrigin, + loadType: LoaderResource.LOAD_TYPE.IMAGE, + metadata: Object.assign( + { pageFile: pageFile }, + resource.metadata.imageMetadata + ), + parentResource: resource, + }; + + this.add(url, options, completed); + } + } + }; + + /*! + * @pixi/filter-alpha - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/filter-alpha is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var fragment$3 = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float uAlpha;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;\n}\n"; + + /** + * Simplest filter - applies alpha. + * + * Use this instead of Container's alpha property to avoid visual layering of individual elements. + * AlphaFilter applies alpha evenly across the entire display object and any opaque elements it contains. + * If elements are not opaque, they will blend with each other anyway. + * + * Very handy if you want to use common features of all filters: + * + * 1. Assign a blendMode to this filter, blend all elements inside display object with background. + * + * 2. To use clipping in display coordinates, assign a filterArea to the same container that has this filter. + * + * @class + * @extends PIXI.Filter + * @memberof PIXI.filters + */ + var AlphaFilter = /*@__PURE__*/(function (Filter) { + function AlphaFilter(alpha) + { + if ( alpha === void 0 ) { alpha = 1.0; } + + Filter.call(this, _default, fragment$3, { uAlpha: 1 }); + + this.alpha = alpha; + } + + if ( Filter ) { AlphaFilter.__proto__ = Filter; } + AlphaFilter.prototype = Object.create( Filter && Filter.prototype ); + AlphaFilter.prototype.constructor = AlphaFilter; + + var prototypeAccessors = { alpha: { configurable: true } }; + + /** + * Coefficient for alpha multiplication + * + * @member {number} + * @default 1 + */ + prototypeAccessors.alpha.get = function () + { + return this.uniforms.uAlpha; + }; + + prototypeAccessors.alpha.set = function (value) // eslint-disable-line require-jsdoc + { + this.uniforms.uAlpha = value; + }; + + Object.defineProperties( AlphaFilter.prototype, prototypeAccessors ); + + return AlphaFilter; + }(Filter)); + + /*! + * @pixi/filter-blur - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/filter-blur is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var vertTemplate = "\n attribute vec2 aVertexPosition;\n\n uniform mat3 projectionMatrix;\n\n uniform float strength;\n\n varying vec2 vBlurTexCoords[%size%];\n\n uniform vec4 inputSize;\n uniform vec4 outputFrame;\n \n vec4 filterVertexPosition( void )\n {\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n \n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n }\n \n vec2 filterTextureCoord( void )\n {\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n }\n\n void main(void)\n {\n gl_Position = filterVertexPosition();\n\n vec2 textureCoord = filterTextureCoord();\n %blur%\n }"; + + function generateBlurVertSource(kernelSize, x) + { + var halfLength = Math.ceil(kernelSize / 2); + + var vertSource = vertTemplate; + + var blurLoop = ''; + var template; + // let value; + + if (x) + { + template = 'vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);'; + } + else + { + template = 'vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);'; + } + + for (var i = 0; i < kernelSize; i++) + { + var blur = template.replace('%index%', i); + + // value = i; + + // if(i >= halfLength) + // { + // value = kernelSize - i - 1; + // } + + blur = blur.replace('%sampleIndex%', ((i - (halfLength - 1)) + ".0")); + + blurLoop += blur; + blurLoop += '\n'; + } + + vertSource = vertSource.replace('%blur%', blurLoop); + vertSource = vertSource.replace('%size%', kernelSize); + + return vertSource; + } + + var GAUSSIAN_VALUES = { + 5: [0.153388, 0.221461, 0.250301], + 7: [0.071303, 0.131514, 0.189879, 0.214607], + 9: [0.028532, 0.067234, 0.124009, 0.179044, 0.20236], + 11: [0.0093, 0.028002, 0.065984, 0.121703, 0.175713, 0.198596], + 13: [0.002406, 0.009255, 0.027867, 0.065666, 0.121117, 0.174868, 0.197641], + 15: [0.000489, 0.002403, 0.009246, 0.02784, 0.065602, 0.120999, 0.174697, 0.197448], + }; + + var fragTemplate$2 = [ + 'varying vec2 vBlurTexCoords[%size%];', + 'uniform sampler2D uSampler;', + + 'void main(void)', + '{', + ' gl_FragColor = vec4(0.0);', + ' %blur%', + '}' ].join('\n'); + + function generateBlurFragSource(kernelSize) + { + var kernel = GAUSSIAN_VALUES[kernelSize]; + var halfLength = kernel.length; + + var fragSource = fragTemplate$2; + + var blurLoop = ''; + var template = 'gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;'; + var value; + + for (var i = 0; i < kernelSize; i++) + { + var blur = template.replace('%index%', i); + + value = i; + + if (i >= halfLength) + { + value = kernelSize - i - 1; + } + + blur = blur.replace('%value%', kernel[value]); + + blurLoop += blur; + blurLoop += '\n'; + } + + fragSource = fragSource.replace('%blur%', blurLoop); + fragSource = fragSource.replace('%size%', kernelSize); + + return fragSource; + } + + /** + * The BlurFilterPass applies a horizontal or vertical Gaussian blur to an object. + * + * @class + * @extends PIXI.Filter + * @memberof PIXI.filters + */ + var BlurFilterPass = /*@__PURE__*/(function (Filter) { + function BlurFilterPass(horizontal, strength, quality, resolution, kernelSize) + { + kernelSize = kernelSize || 5; + var vertSrc = generateBlurVertSource(kernelSize, horizontal); + var fragSrc = generateBlurFragSource(kernelSize); + + Filter.call( + // vertex shader + this, vertSrc, + // fragment shader + fragSrc + ); + + this.horizontal = horizontal; + + this.resolution = resolution || settings.RESOLUTION; + + this._quality = 0; + + this.quality = quality || 4; + + this.blur = strength || 8; + } + + if ( Filter ) { BlurFilterPass.__proto__ = Filter; } + BlurFilterPass.prototype = Object.create( Filter && Filter.prototype ); + BlurFilterPass.prototype.constructor = BlurFilterPass; + + var prototypeAccessors = { blur: { configurable: true },quality: { configurable: true } }; + + BlurFilterPass.prototype.apply = function apply (filterManager, input, output, clear) + { + if (output) + { + if (this.horizontal) + { + this.uniforms.strength = (1 / output.width) * (output.width / input.width); + } + else + { + this.uniforms.strength = (1 / output.height) * (output.height / input.height); + } + } + else + { + if (this.horizontal) // eslint-disable-line + { + this.uniforms.strength = (1 / filterManager.renderer.width) * (filterManager.renderer.width / input.width); + } + else + { + this.uniforms.strength = (1 / filterManager.renderer.height) * (filterManager.renderer.height / input.height); // eslint-disable-line + } + } + + // screen space! + this.uniforms.strength *= this.strength; + this.uniforms.strength /= this.passes; + + if (this.passes === 1) + { + filterManager.applyFilter(this, input, output, clear); + } + else + { + var renderTarget = filterManager.getFilterTexture(); + var renderer = filterManager.renderer; + + var flip = input; + var flop = renderTarget; + + this.state.blend = false; + filterManager.applyFilter(this, flip, flop, false); + + for (var i = 1; i < this.passes - 1; i++) + { + renderer.renderTexture.bind(flip, flip.filterFrame); + + this.uniforms.uSampler = flop; + + var temp = flop; + + flop = flip; + flip = temp; + + renderer.shader.bind(this); + renderer.geometry.draw(5); + } + + this.state.blend = true; + filterManager.applyFilter(this, flop, output, clear); + filterManager.returnFilterTexture(renderTarget); + } + }; + /** + * Sets the strength of both the blur. + * + * @member {number} + * @default 16 + */ + prototypeAccessors.blur.get = function () + { + return this.strength; + }; + + prototypeAccessors.blur.set = function (value) // eslint-disable-line require-jsdoc + { + this.padding = 1 + (Math.abs(value) * 2); + this.strength = value; + }; + + /** + * Sets the quality of the blur by modifying the number of passes. More passes means higher + * quaility bluring but the lower the performance. + * + * @member {number} + * @default 4 + */ + prototypeAccessors.quality.get = function () + { + return this._quality; + }; + + prototypeAccessors.quality.set = function (value) // eslint-disable-line require-jsdoc + { + this._quality = value; + this.passes = value; + }; + + Object.defineProperties( BlurFilterPass.prototype, prototypeAccessors ); + + return BlurFilterPass; + }(Filter)); + + /** + * The BlurFilter applies a Gaussian blur to an object. + * + * The strength of the blur can be set for the x-axis and y-axis separately. + * + * @class + * @extends PIXI.Filter + * @memberof PIXI.filters + */ + var BlurFilter = /*@__PURE__*/(function (Filter) { + function BlurFilter(strength, quality, resolution, kernelSize) + { + Filter.call(this); + + this.blurXFilter = new BlurFilterPass(true, strength, quality, resolution, kernelSize); + this.blurYFilter = new BlurFilterPass(false, strength, quality, resolution, kernelSize); + + this.resolution = resolution || settings.RESOLUTION; + this.quality = quality || 4; + this.blur = strength || 8; + + this.repeatEdgePixels = false; + } + + if ( Filter ) { BlurFilter.__proto__ = Filter; } + BlurFilter.prototype = Object.create( Filter && Filter.prototype ); + BlurFilter.prototype.constructor = BlurFilter; + + var prototypeAccessors = { blur: { configurable: true },quality: { configurable: true },blurX: { configurable: true },blurY: { configurable: true },blendMode: { configurable: true },repeatEdgePixels: { configurable: true } }; + + /** + * Applies the filter. + * + * @param {PIXI.systems.FilterSystem} filterManager - The manager. + * @param {PIXI.RenderTexture} input - The input target. + * @param {PIXI.RenderTexture} output - The output target. + */ + BlurFilter.prototype.apply = function apply (filterManager, input, output, clear) + { + var xStrength = Math.abs(this.blurXFilter.strength); + var yStrength = Math.abs(this.blurYFilter.strength); + + if (xStrength && yStrength) + { + var renderTarget = filterManager.getFilterTexture(); + + this.blurXFilter.apply(filterManager, input, renderTarget, true); + this.blurYFilter.apply(filterManager, renderTarget, output, clear); + + filterManager.returnFilterTexture(renderTarget); + } + else if (yStrength) + { + this.blurYFilter.apply(filterManager, input, output, clear); + } + else + { + this.blurXFilter.apply(filterManager, input, output, clear); + } + }; + + BlurFilter.prototype.updatePadding = function updatePadding () + { + if (this._repeatEdgePixels) + { + this.padding = 0; + } + else + { + this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2; + } + }; + + /** + * Sets the strength of both the blurX and blurY properties simultaneously + * + * @member {number} + * @default 2 + */ + prototypeAccessors.blur.get = function () + { + return this.blurXFilter.blur; + }; + + prototypeAccessors.blur.set = function (value) // eslint-disable-line require-jsdoc + { + this.blurXFilter.blur = this.blurYFilter.blur = value; + this.updatePadding(); + }; + + /** + * Sets the number of passes for blur. More passes means higher quaility bluring. + * + * @member {number} + * @default 1 + */ + prototypeAccessors.quality.get = function () + { + return this.blurXFilter.quality; + }; + + prototypeAccessors.quality.set = function (value) // eslint-disable-line require-jsdoc + { + this.blurXFilter.quality = this.blurYFilter.quality = value; + }; + + /** + * Sets the strength of the blurX property + * + * @member {number} + * @default 2 + */ + prototypeAccessors.blurX.get = function () + { + return this.blurXFilter.blur; + }; + + prototypeAccessors.blurX.set = function (value) // eslint-disable-line require-jsdoc + { + this.blurXFilter.blur = value; + this.updatePadding(); + }; + + /** + * Sets the strength of the blurY property + * + * @member {number} + * @default 2 + */ + prototypeAccessors.blurY.get = function () + { + return this.blurYFilter.blur; + }; + + prototypeAccessors.blurY.set = function (value) // eslint-disable-line require-jsdoc + { + this.blurYFilter.blur = value; + this.updatePadding(); + }; + + /** + * Sets the blendmode of the filter + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + */ + prototypeAccessors.blendMode.get = function () + { + return this.blurYFilter.blendMode; + }; + + prototypeAccessors.blendMode.set = function (value) // eslint-disable-line require-jsdoc + { + this.blurYFilter.blendMode = value; + }; + + /** + * If set to true the edge of the target will be clamped + * + * @member {bool} + * @default false + */ + prototypeAccessors.repeatEdgePixels.get = function () + { + return this._repeatEdgePixels; + }; + + prototypeAccessors.repeatEdgePixels.set = function (value) + { + this._repeatEdgePixels = value; + this.updatePadding(); + }; + + Object.defineProperties( BlurFilter.prototype, prototypeAccessors ); + + return BlurFilter; + }(Filter)); + + /*! + * @pixi/filter-color-matrix - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/filter-color-matrix is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var fragment$4 = "varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\nuniform float uAlpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (uAlpha == 0.0) {\n gl_FragColor = c;\n return;\n }\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (c.a > 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n"; + + /** + * The ColorMatrixFilter class lets you apply a 5x4 matrix transformation on the RGBA + * color and alpha values of every pixel on your displayObject to produce a result + * with a new set of RGBA color and alpha values. It's pretty powerful! + * + * ```js + * let colorMatrix = new PIXI.filters.ColorMatrixFilter(); + * container.filters = [colorMatrix]; + * colorMatrix.contrast(2); + * ``` + * @author Clément Chenebault + * @class + * @extends PIXI.Filter + * @memberof PIXI.filters + */ + var ColorMatrixFilter = /*@__PURE__*/(function (Filter) { + function ColorMatrixFilter() + { + var uniforms = { + m: new Float32Array([1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0]), + uAlpha: 1, + }; + + Filter.call(this, defaultFilter, fragment$4, uniforms); + + this.alpha = 1; + } + + if ( Filter ) { ColorMatrixFilter.__proto__ = Filter; } + ColorMatrixFilter.prototype = Object.create( Filter && Filter.prototype ); + ColorMatrixFilter.prototype.constructor = ColorMatrixFilter; + + var prototypeAccessors = { matrix: { configurable: true },alpha: { configurable: true } }; + + /** + * Transforms current matrix and set the new one + * + * @param {number[]} matrix - 5x4 matrix + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype._loadMatrix = function _loadMatrix (matrix, multiply) + { + if ( multiply === void 0 ) { multiply = false; } + + var newMatrix = matrix; + + if (multiply) + { + this._multiply(newMatrix, this.uniforms.m, matrix); + newMatrix = this._colorMatrix(newMatrix); + } + + // set the new matrix + this.uniforms.m = newMatrix; + }; + + /** + * Multiplies two mat5's + * + * @private + * @param {number[]} out - 5x4 matrix the receiving matrix + * @param {number[]} a - 5x4 matrix the first operand + * @param {number[]} b - 5x4 matrix the second operand + * @returns {number[]} 5x4 matrix + */ + ColorMatrixFilter.prototype._multiply = function _multiply (out, a, b) + { + // Red Channel + out[0] = (a[0] * b[0]) + (a[1] * b[5]) + (a[2] * b[10]) + (a[3] * b[15]); + out[1] = (a[0] * b[1]) + (a[1] * b[6]) + (a[2] * b[11]) + (a[3] * b[16]); + out[2] = (a[0] * b[2]) + (a[1] * b[7]) + (a[2] * b[12]) + (a[3] * b[17]); + out[3] = (a[0] * b[3]) + (a[1] * b[8]) + (a[2] * b[13]) + (a[3] * b[18]); + out[4] = (a[0] * b[4]) + (a[1] * b[9]) + (a[2] * b[14]) + (a[3] * b[19]) + a[4]; + + // Green Channel + out[5] = (a[5] * b[0]) + (a[6] * b[5]) + (a[7] * b[10]) + (a[8] * b[15]); + out[6] = (a[5] * b[1]) + (a[6] * b[6]) + (a[7] * b[11]) + (a[8] * b[16]); + out[7] = (a[5] * b[2]) + (a[6] * b[7]) + (a[7] * b[12]) + (a[8] * b[17]); + out[8] = (a[5] * b[3]) + (a[6] * b[8]) + (a[7] * b[13]) + (a[8] * b[18]); + out[9] = (a[5] * b[4]) + (a[6] * b[9]) + (a[7] * b[14]) + (a[8] * b[19]) + a[9]; + + // Blue Channel + out[10] = (a[10] * b[0]) + (a[11] * b[5]) + (a[12] * b[10]) + (a[13] * b[15]); + out[11] = (a[10] * b[1]) + (a[11] * b[6]) + (a[12] * b[11]) + (a[13] * b[16]); + out[12] = (a[10] * b[2]) + (a[11] * b[7]) + (a[12] * b[12]) + (a[13] * b[17]); + out[13] = (a[10] * b[3]) + (a[11] * b[8]) + (a[12] * b[13]) + (a[13] * b[18]); + out[14] = (a[10] * b[4]) + (a[11] * b[9]) + (a[12] * b[14]) + (a[13] * b[19]) + a[14]; + + // Alpha Channel + out[15] = (a[15] * b[0]) + (a[16] * b[5]) + (a[17] * b[10]) + (a[18] * b[15]); + out[16] = (a[15] * b[1]) + (a[16] * b[6]) + (a[17] * b[11]) + (a[18] * b[16]); + out[17] = (a[15] * b[2]) + (a[16] * b[7]) + (a[17] * b[12]) + (a[18] * b[17]); + out[18] = (a[15] * b[3]) + (a[16] * b[8]) + (a[17] * b[13]) + (a[18] * b[18]); + out[19] = (a[15] * b[4]) + (a[16] * b[9]) + (a[17] * b[14]) + (a[18] * b[19]) + a[19]; + + return out; + }; + + /** + * Create a Float32 Array and normalize the offset component to 0-1 + * + * @private + * @param {number[]} matrix - 5x4 matrix + * @return {number[]} 5x4 matrix with all values between 0-1 + */ + ColorMatrixFilter.prototype._colorMatrix = function _colorMatrix (matrix) + { + // Create a Float32 Array and normalize the offset component to 0-1 + var m = new Float32Array(matrix); + + m[4] /= 255; + m[9] /= 255; + m[14] /= 255; + m[19] /= 255; + + return m; + }; + + /** + * Adjusts brightness + * + * @param {number} b - value of the brigthness (0-1, where 0 is black) + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.brightness = function brightness (b, multiply) + { + var matrix = [ + b, 0, 0, 0, 0, + 0, b, 0, 0, 0, + 0, 0, b, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Set the matrices in grey scales + * + * @param {number} scale - value of the grey (0-1, where 0 is black) + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.greyscale = function greyscale (scale, multiply) + { + var matrix = [ + scale, scale, scale, 0, 0, + scale, scale, scale, 0, 0, + scale, scale, scale, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Set the black and white matrice. + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.blackAndWhite = function blackAndWhite (multiply) + { + var matrix = [ + 0.3, 0.6, 0.1, 0, 0, + 0.3, 0.6, 0.1, 0, 0, + 0.3, 0.6, 0.1, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Set the hue property of the color + * + * @param {number} rotation - in degrees + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.hue = function hue (rotation, multiply) + { + rotation = (rotation || 0) / 180 * Math.PI; + + var cosR = Math.cos(rotation); + var sinR = Math.sin(rotation); + var sqrt = Math.sqrt; + + /* a good approximation for hue rotation + This matrix is far better than the versions with magic luminance constants + formerly used here, but also used in the starling framework (flash) and known from this + old part of the internet: quasimondo.com/archives/000565.php + + This new matrix is based on rgb cube rotation in space. Look here for a more descriptive + implementation as a shader not a general matrix: + https://github.com/evanw/glfx.js/blob/58841c23919bd59787effc0333a4897b43835412/src/filters/adjust/huesaturation.js + + This is the source for the code: + see http://stackoverflow.com/questions/8507885/shift-hue-of-an-rgb-color/8510751#8510751 + */ + + var w = 1 / 3; + var sqrW = sqrt(w); // weight is + + var a00 = cosR + ((1.0 - cosR) * w); + var a01 = (w * (1.0 - cosR)) - (sqrW * sinR); + var a02 = (w * (1.0 - cosR)) + (sqrW * sinR); + + var a10 = (w * (1.0 - cosR)) + (sqrW * sinR); + var a11 = cosR + (w * (1.0 - cosR)); + var a12 = (w * (1.0 - cosR)) - (sqrW * sinR); + + var a20 = (w * (1.0 - cosR)) - (sqrW * sinR); + var a21 = (w * (1.0 - cosR)) + (sqrW * sinR); + var a22 = cosR + (w * (1.0 - cosR)); + + var matrix = [ + a00, a01, a02, 0, 0, + a10, a11, a12, 0, 0, + a20, a21, a22, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Set the contrast matrix, increase the separation between dark and bright + * Increase contrast : shadows darker and highlights brighter + * Decrease contrast : bring the shadows up and the highlights down + * + * @param {number} amount - value of the contrast (0-1) + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.contrast = function contrast (amount, multiply) + { + var v = (amount || 0) + 1; + var o = -0.5 * (v - 1); + + var matrix = [ + v, 0, 0, 0, o, + 0, v, 0, 0, o, + 0, 0, v, 0, o, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Set the saturation matrix, increase the separation between colors + * Increase saturation : increase contrast, brightness, and sharpness + * + * @param {number} amount - The saturation amount (0-1) + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.saturate = function saturate (amount, multiply) + { + if ( amount === void 0 ) { amount = 0; } + + var x = (amount * 2 / 3) + 1; + var y = ((x - 1) * -0.5); + + var matrix = [ + x, y, y, 0, 0, + y, x, y, 0, 0, + y, y, x, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Desaturate image (remove color) + * + * Call the saturate function + * + */ + ColorMatrixFilter.prototype.desaturate = function desaturate () // eslint-disable-line no-unused-vars + { + this.saturate(-1); + }; + + /** + * Negative image (inverse of classic rgb matrix) + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.negative = function negative (multiply) + { + var matrix = [ + -1, 0, 0, 1, 0, + 0, -1, 0, 1, 0, + 0, 0, -1, 1, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Sepia image + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.sepia = function sepia (multiply) + { + var matrix = [ + 0.393, 0.7689999, 0.18899999, 0, 0, + 0.349, 0.6859999, 0.16799999, 0, 0, + 0.272, 0.5339999, 0.13099999, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Color motion picture process invented in 1916 (thanks Dominic Szablewski) + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.technicolor = function technicolor (multiply) + { + var matrix = [ + 1.9125277891456083, -0.8545344976951645, -0.09155508482755585, 0, 11.793603434377337, + -0.3087833385928097, 1.7658908555458428, -0.10601743074722245, 0, -70.35205161461398, + -0.231103377548616, -0.7501899197440212, 1.847597816108189, 0, 30.950940869491138, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Polaroid filter + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.polaroid = function polaroid (multiply) + { + var matrix = [ + 1.438, -0.062, -0.062, 0, 0, + -0.122, 1.378, -0.122, 0, 0, + -0.016, -0.016, 1.483, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Filter who transforms : Red -> Blue and Blue -> Red + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.toBGR = function toBGR (multiply) + { + var matrix = [ + 0, 0, 1, 0, 0, + 0, 1, 0, 0, 0, + 1, 0, 0, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Color reversal film introduced by Eastman Kodak in 1935. (thanks Dominic Szablewski) + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.kodachrome = function kodachrome (multiply) + { + var matrix = [ + 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502, + -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203, + -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Brown delicious browni filter (thanks Dominic Szablewski) + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.browni = function browni (multiply) + { + var matrix = [ + 0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, 47.43192855600873, + -0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, -36.96841498319127, + 0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, -7.562075277591283, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Vintage filter (thanks Dominic Szablewski) + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.vintage = function vintage (multiply) + { + var matrix = [ + 0.6279345635605994, 0.3202183420819367, -0.03965408211312453, 0, 9.651285835294123, + 0.02578397704808868, 0.6441188644374771, 0.03259127616149294, 0, 7.462829176470591, + 0.0466055556782719, -0.0851232987247891, 0.5241648018700465, 0, 5.159190588235296, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * We don't know exactly what it does, kind of gradient map, but funny to play with! + * + * @param {number} desaturation - Tone values. + * @param {number} toned - Tone values. + * @param {string} lightColor - Tone values, example: `0xFFE580` + * @param {string} darkColor - Tone values, example: `0xFFE580` + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.colorTone = function colorTone (desaturation, toned, lightColor, darkColor, multiply) + { + desaturation = desaturation || 0.2; + toned = toned || 0.15; + lightColor = lightColor || 0xFFE580; + darkColor = darkColor || 0x338000; + + var lR = ((lightColor >> 16) & 0xFF) / 255; + var lG = ((lightColor >> 8) & 0xFF) / 255; + var lB = (lightColor & 0xFF) / 255; + + var dR = ((darkColor >> 16) & 0xFF) / 255; + var dG = ((darkColor >> 8) & 0xFF) / 255; + var dB = (darkColor & 0xFF) / 255; + + var matrix = [ + 0.3, 0.59, 0.11, 0, 0, + lR, lG, lB, desaturation, 0, + dR, dG, dB, toned, 0, + lR - dR, lG - dG, lB - dB, 0, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Night effect + * + * @param {number} intensity - The intensity of the night effect. + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.night = function night (intensity, multiply) + { + intensity = intensity || 0.1; + var matrix = [ + intensity * (-2.0), -intensity, 0, 0, 0, + -intensity, 0, intensity, 0, 0, + 0, intensity, intensity * 2.0, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Predator effect + * + * Erase the current matrix by setting a new indepent one + * + * @param {number} amount - how much the predator feels his future victim + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.predator = function predator (amount, multiply) + { + var matrix = [ + // row 1 + 11.224130630493164 * amount, + -4.794486999511719 * amount, + -2.8746118545532227 * amount, + 0 * amount, + 0.40342438220977783 * amount, + // row 2 + -3.6330697536468506 * amount, + 9.193157196044922 * amount, + -2.951810836791992 * amount, + 0 * amount, + -1.316135048866272 * amount, + // row 3 + -3.2184197902679443 * amount, + -4.2375030517578125 * amount, + 7.476448059082031 * amount, + 0 * amount, + 0.8044459223747253 * amount, + // row 4 + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * LSD effect + * + * Multiply the current matrix + * + * @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false, + * just set the current matrix with @param matrix + */ + ColorMatrixFilter.prototype.lsd = function lsd (multiply) + { + var matrix = [ + 2, -0.4, 0.5, 0, 0, + -0.5, 2, -0.4, 0, 0, + -0.4, -0.5, 3, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, multiply); + }; + + /** + * Erase the current matrix by setting the default one + * + */ + ColorMatrixFilter.prototype.reset = function reset () + { + var matrix = [ + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0 ]; + + this._loadMatrix(matrix, false); + }; + + /** + * The matrix of the color matrix filter + * + * @member {number[]} + * @default [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0] + */ + prototypeAccessors.matrix.get = function () + { + return this.uniforms.m; + }; + + prototypeAccessors.matrix.set = function (value) // eslint-disable-line require-jsdoc + { + this.uniforms.m = value; + }; + + /** + * The opacity value to use when mixing the original and resultant colors. + * + * When the value is 0, the original color is used without modification. + * When the value is 1, the result color is used. + * When in the range (0, 1) the color is interpolated between the original and result by this amount. + * + * @member {number} + * @default 1 + */ + prototypeAccessors.alpha.get = function () + { + return this.uniforms.uAlpha; + }; + + prototypeAccessors.alpha.set = function (value) // eslint-disable-line require-jsdoc + { + this.uniforms.uAlpha = value; + }; + + Object.defineProperties( ColorMatrixFilter.prototype, prototypeAccessors ); + + return ColorMatrixFilter; + }(Filter)); + + // Americanized alias + ColorMatrixFilter.prototype.grayscale = ColorMatrixFilter.prototype.greyscale; + + /*! + * @pixi/filter-displacement - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/filter-displacement is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var vertex$4 = "attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\nuniform mat3 filterMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vFilterCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n\tgl_Position = filterVertexPosition();\n\tvTextureCoord = filterTextureCoord();\n\tvFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;\n}\n"; + + var fragment$5 = "varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\nuniform mat2 rotation;\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform highp vec4 inputSize;\nuniform vec4 inputClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy = scale * inputSize.zw * (rotation * map.xy);\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));\n}\n"; + + /** + * The DisplacementFilter class uses the pixel values from the specified texture + * (called the displacement map) to perform a displacement of an object. + * + * You can use this filter to apply all manor of crazy warping effects. + * Currently the `r` property of the texture is used to offset the `x` + * and the `g` property of the texture is used to offset the `y`. + * + * The way it works is it uses the values of the displacement map to look up the + * correct pixels to output. This means it's not technically moving the original. + * Instead, it's starting at the output and asking "which pixel from the original goes here". + * For example, if a displacement map pixel has `red = 1` and the filter scale is `20`, + * this filter will output the pixel approximately 20 pixels to the right of the original. + * + * @class + * @extends PIXI.Filter + * @memberof PIXI.filters + */ + var DisplacementFilter = /*@__PURE__*/(function (Filter) { + function DisplacementFilter(sprite, scale) + { + var maskMatrix = new Matrix(); + + sprite.renderable = false; + + Filter.call(this, vertex$4, fragment$5, { + mapSampler: sprite._texture, + filterMatrix: maskMatrix, + scale: { x: 1, y: 1 }, + rotation: new Float32Array([1, 0, 0, 1]), + }); + + this.maskSprite = sprite; + this.maskMatrix = maskMatrix; + + if (scale === null || scale === undefined) + { + scale = 20; + } + + /** + * scaleX, scaleY for displacements + * @member {PIXI.Point} + */ + this.scale = new Point(scale, scale); + } + + if ( Filter ) { DisplacementFilter.__proto__ = Filter; } + DisplacementFilter.prototype = Object.create( Filter && Filter.prototype ); + DisplacementFilter.prototype.constructor = DisplacementFilter; + + var prototypeAccessors = { map: { configurable: true } }; + + /** + * Applies the filter. + * + * @param {PIXI.systems.FilterSystem} filterManager - The manager. + * @param {PIXI.RenderTexture} input - The input target. + * @param {PIXI.RenderTexture} output - The output target. + * @param {boolean} clear - Should the output be cleared before rendering to it. + */ + DisplacementFilter.prototype.apply = function apply (filterManager, input, output, clear) + { + // fill maskMatrix with _normalized sprite texture coords_ + this.uniforms.filterMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, this.maskSprite); + this.uniforms.scale.x = this.scale.x; + this.uniforms.scale.y = this.scale.y; + + // Extract rotation from world transform + var wt = this.maskSprite.transform.worldTransform; + var lenX = Math.sqrt((wt.a * wt.a) + (wt.b * wt.b)); + var lenY = Math.sqrt((wt.c * wt.c) + (wt.d * wt.d)); + + if (lenX !== 0 && lenY !== 0) + { + this.uniforms.rotation[0] = wt.a / lenX; + this.uniforms.rotation[1] = wt.b / lenX; + this.uniforms.rotation[2] = wt.c / lenY; + this.uniforms.rotation[3] = wt.d / lenY; + } + + // draw the filter... + filterManager.applyFilter(this, input, output, clear); + }; + + /** + * The texture used for the displacement map. Must be power of 2 sized texture. + * + * @member {PIXI.Texture} + */ + prototypeAccessors.map.get = function () + { + return this.uniforms.mapSampler; + }; + + prototypeAccessors.map.set = function (value) // eslint-disable-line require-jsdoc + { + this.uniforms.mapSampler = value; + }; + + Object.defineProperties( DisplacementFilter.prototype, prototypeAccessors ); + + return DisplacementFilter; + }(Filter)); + + /*! + * @pixi/filter-fxaa - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/filter-fxaa is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var vertex$5 = "\nattribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vFragCoord;\n\nuniform vec4 inputPixel;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvoid texcoords(vec2 fragCoord, vec2 inverseVP,\n out vec2 v_rgbNW, out vec2 v_rgbNE,\n out vec2 v_rgbSW, out vec2 v_rgbSE,\n out vec2 v_rgbM) {\n v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\n v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\n v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\n v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\n v_rgbM = vec2(fragCoord * inverseVP);\n}\n\nvoid main(void) {\n\n gl_Position = filterVertexPosition();\n\n vFragCoord = aVertexPosition * outputFrame.zw;\n\n texcoords(vFragCoord, inputPixel.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}\n"; + + var fragment$6 = "varying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vFragCoord;\nuniform sampler2D uSampler;\nuniform highp vec4 inputPixel;\n\n\n/**\n Basic FXAA implementation based on the code on geeks3d.com with the\n modification that the texture2DLod stuff was removed since it's\n unsupported by WebGL.\n\n --\n\n From:\n https://github.com/mitsuhiko/webgl-meincraft\n\n Copyright (c) 2011 by Armin Ronacher.\n\n Some rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are\n met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n\n * The names of the contributors may not be used to endorse or\n promote products derived from this software without specific\n prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef FXAA_REDUCE_MIN\n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n#define FXAA_SPAN_MAX 8.0\n#endif\n\n//optimized version for mobile, where dependent\n//texture reads can be a bottleneck\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,\n vec2 v_rgbNW, vec2 v_rgbNE,\n vec2 v_rgbSW, vec2 v_rgbSE,\n vec2 v_rgbM) {\n vec4 color;\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n\n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\nvoid main() {\n\n vec4 color;\n\n color = fxaa(uSampler, vFragCoord, inputPixel.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n gl_FragColor = color;\n}\n"; + + /** + * Basic FXAA (Fast Approximate Anti-Aliasing) implementation based on the code on geeks3d.com + * with the modification that the texture2DLod stuff was removed since it is unsupported by WebGL. + * + * @see https://github.com/mitsuhiko/webgl-meincraft + * + * @class + * @extends PIXI.Filter + * @memberof PIXI.filters + * + */ + var FXAAFilter = /*@__PURE__*/(function (Filter) { + function FXAAFilter() + { + // TODO - needs work + Filter.call(this, vertex$5, fragment$6); + } + + if ( Filter ) { FXAAFilter.__proto__ = Filter; } + FXAAFilter.prototype = Object.create( Filter && Filter.prototype ); + FXAAFilter.prototype.constructor = FXAAFilter; + + return FXAAFilter; + }(Filter)); + + /*! + * @pixi/filter-noise - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/filter-noise is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var fragment$7 = "precision highp float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform float uNoise;\nuniform float uSeed;\nuniform sampler2D uSampler;\n\nfloat rand(vec2 co)\n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float randomValue = rand(gl_FragCoord.xy * uSeed);\n float diff = (randomValue - 0.5) * uNoise;\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (color.a > 0.0) {\n color.rgb /= color.a;\n }\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n // Premultiply alpha again.\n color.rgb *= color.a;\n\n gl_FragColor = color;\n}\n"; + + /** + * @author Vico @vicocotea + * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/noise.js + */ + + /** + * A Noise effect filter. + * + * @class + * @extends PIXI.Filter + * @memberof PIXI.filters + */ + var NoiseFilter = /*@__PURE__*/(function (Filter) { + function NoiseFilter(noise, seed) + { + if ( noise === void 0 ) { noise = 0.5; } + if ( seed === void 0 ) { seed = Math.random(); } + + Filter.call(this, defaultFilter, fragment$7, { + uNoise: 0, + uSeed: 0, + }); + + this.noise = noise; + this.seed = seed; + } + + if ( Filter ) { NoiseFilter.__proto__ = Filter; } + NoiseFilter.prototype = Object.create( Filter && Filter.prototype ); + NoiseFilter.prototype.constructor = NoiseFilter; + + var prototypeAccessors = { noise: { configurable: true },seed: { configurable: true } }; + + /** + * The amount of noise to apply, this value should be in the range (0, 1]. + * + * @member {number} + * @default 0.5 + */ + prototypeAccessors.noise.get = function () + { + return this.uniforms.uNoise; + }; + + prototypeAccessors.noise.set = function (value) // eslint-disable-line require-jsdoc + { + this.uniforms.uNoise = value; + }; + + /** + * A seed value to apply to the random noise generation. `Math.random()` is a good value to use. + * + * @member {number} + */ + prototypeAccessors.seed.get = function () + { + return this.uniforms.uSeed; + }; + + prototypeAccessors.seed.set = function (value) // eslint-disable-line require-jsdoc + { + this.uniforms.uSeed = value; + }; + + Object.defineProperties( NoiseFilter.prototype, prototypeAccessors ); + + return NoiseFilter; + }(Filter)); + + /*! + * @pixi/mixin-cache-as-bitmap - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/mixin-cache-as-bitmap is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var _tempMatrix = new Matrix(); + + DisplayObject.prototype._cacheAsBitmap = false; + DisplayObject.prototype._cacheData = false; + + // figured theres no point adding ALL the extra variables to prototype. + // this model can hold the information needed. This can also be generated on demand as + // most objects are not cached as bitmaps. + /** + * @class + * @ignore + */ + var CacheData = function CacheData() + { + this.textureCacheId = null; + + this.originalRender = null; + this.originalRenderCanvas = null; + this.originalCalculateBounds = null; + this.originalGetLocalBounds = null; + + this.originalUpdateTransform = null; + this.originalHitTest = null; + this.originalDestroy = null; + this.originalMask = null; + this.originalFilterArea = null; + this.sprite = null; + }; + + Object.defineProperties(DisplayObject.prototype, { + /** + * Set this to true if you want this display object to be cached as a bitmap. + * This basically takes a snap shot of the display object as it is at that moment. It can + * provide a performance benefit for complex static displayObjects. + * To remove simply set this property to `false` + * + * IMPORTANT GOTCHA - Make sure that all your textures are preloaded BEFORE setting this property to true + * as it will take a snapshot of what is currently there. If the textures have not loaded then they will not appear. + * + * @member {boolean} + * @memberof PIXI.DisplayObject# + */ + cacheAsBitmap: { + get: function get() + { + return this._cacheAsBitmap; + }, + set: function set(value) + { + if (this._cacheAsBitmap === value) + { + return; + } + + this._cacheAsBitmap = value; + + var data; + + if (value) + { + if (!this._cacheData) + { + this._cacheData = new CacheData(); + } + + data = this._cacheData; + + data.originalRender = this.render; + data.originalRenderCanvas = this.renderCanvas; + + data.originalUpdateTransform = this.updateTransform; + data.originalCalculateBounds = this.calculateBounds; + data.originalGetLocalBounds = this.getLocalBounds; + + data.originalDestroy = this.destroy; + + data.originalContainsPoint = this.containsPoint; + + data.originalMask = this._mask; + data.originalFilterArea = this.filterArea; + + this.render = this._renderCached; + this.renderCanvas = this._renderCachedCanvas; + + this.destroy = this._cacheAsBitmapDestroy; + } + else + { + data = this._cacheData; + + if (data.sprite) + { + this._destroyCachedDisplayObject(); + } + + this.render = data.originalRender; + this.renderCanvas = data.originalRenderCanvas; + this.calculateBounds = data.originalCalculateBounds; + this.getLocalBounds = data.originalGetLocalBounds; + + this.destroy = data.originalDestroy; + + this.updateTransform = data.originalUpdateTransform; + this.containsPoint = data.originalContainsPoint; + + this._mask = data.originalMask; + this.filterArea = data.originalFilterArea; + } + }, + }, + }); + + /** + * Renders a cached version of the sprite with WebGL + * + * @private + * @function _renderCached + * @memberof PIXI.DisplayObject# + * @param {PIXI.Renderer} renderer - the WebGL renderer + */ + DisplayObject.prototype._renderCached = function _renderCached(renderer) + { + if (!this.visible || this.worldAlpha <= 0 || !this.renderable) + { + return; + } + + this._initCachedDisplayObject(renderer); + + this._cacheData.sprite.transform._worldID = this.transform._worldID; + this._cacheData.sprite.worldAlpha = this.worldAlpha; + this._cacheData.sprite._render(renderer); + }; + + /** + * Prepares the WebGL renderer to cache the sprite + * + * @private + * @function _initCachedDisplayObject + * @memberof PIXI.DisplayObject# + * @param {PIXI.Renderer} renderer - the WebGL renderer + */ + DisplayObject.prototype._initCachedDisplayObject = function _initCachedDisplayObject(renderer) + { + if (this._cacheData && this._cacheData.sprite) + { + return; + } + + // make sure alpha is set to 1 otherwise it will get rendered as invisible! + var cacheAlpha = this.alpha; + + this.alpha = 1; + + // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) + renderer.batch.flush(); + // this.filters= []; + + // next we find the dimensions of the untransformed object + // this function also calls updatetransform on all its children as part of the measuring. + // This means we don't need to update the transform again in this function + // TODO pass an object to clone too? saves having to create a new one each time! + var bounds = this.getLocalBounds().clone(); + + // add some padding! + if (this.filters) + { + var padding = this.filters[0].padding; + + bounds.pad(padding); + } + + bounds.ceil(settings.RESOLUTION); + + // for now we cache the current renderTarget that the WebGL renderer is currently using. + // this could be more elegant.. + var cachedRenderTarget = renderer._activeRenderTarget; + // We also store the filter stack - I will definitely look to change how this works a little later down the line. + // const stack = renderer.filterManager.filterStack; + + // this renderTexture will be used to store the cached DisplayObject + var renderTexture = RenderTexture.create(bounds.width, bounds.height); + + var textureCacheId = "cacheAsBitmap_" + (uid()); + + this._cacheData.textureCacheId = textureCacheId; + + BaseTexture.addToCache(renderTexture.baseTexture, textureCacheId); + Texture.addToCache(renderTexture, textureCacheId); + + // need to set // + var m = _tempMatrix; + + m.tx = -bounds.x; + m.ty = -bounds.y; + + // reset + this.transform.worldTransform.identity(); + + // set all properties to there original so we can render to a texture + this.render = this._cacheData.originalRender; + + renderer.render(this, renderTexture, true, m, true); + // now restore the state be setting the new properties + + renderer.renderTexture.bind(cachedRenderTarget); + + // renderer.filterManager.filterStack = stack; + + this.render = this._renderCached; + // the rest is the same as for Canvas + this.updateTransform = this.displayObjectUpdateTransform; + this.calculateBounds = this._calculateCachedBounds; + this.getLocalBounds = this._getCachedLocalBounds; + + this._mask = null; + this.filterArea = null; + + // create our cached sprite + var cachedSprite = new Sprite(renderTexture); + + cachedSprite.transform.worldTransform = this.transform.worldTransform; + cachedSprite.anchor.x = -(bounds.x / bounds.width); + cachedSprite.anchor.y = -(bounds.y / bounds.height); + cachedSprite.alpha = cacheAlpha; + cachedSprite._bounds = this._bounds; + + this._cacheData.sprite = cachedSprite; + + this.transform._parentID = -1; + // restore the transform of the cached sprite to avoid the nasty flicker.. + if (!this.parent) + { + this.parent = renderer._tempDisplayObjectParent; + this.updateTransform(); + this.parent = null; + } + else + { + this.updateTransform(); + } + // map the hit test.. + this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite); + }; + /** + * Renders a cached version of the sprite with canvas + * + * @private + * @function _renderCachedCanvas + * @memberof PIXI.DisplayObject# + * @param {PIXI.Renderer} renderer - the WebGL renderer + */ + DisplayObject.prototype._renderCachedCanvas = function _renderCachedCanvas(renderer) + { + if (!this.visible || this.worldAlpha <= 0 || !this.renderable) + { + return; + } + + this._initCachedDisplayObjectCanvas(renderer); + + this._cacheData.sprite.worldAlpha = this.worldAlpha; + this._cacheData.sprite._renderCanvas(renderer); + }; + + // TODO this can be the same as the WebGL version.. will need to do a little tweaking first though.. + /** + * Prepares the Canvas renderer to cache the sprite + * + * @private + * @function _initCachedDisplayObjectCanvas + * @memberof PIXI.DisplayObject# + * @param {PIXI.Renderer} renderer - the WebGL renderer + */ + DisplayObject.prototype._initCachedDisplayObjectCanvas = function _initCachedDisplayObjectCanvas(renderer) + { + if (this._cacheData && this._cacheData.sprite) + { + return; + } + + // get bounds actually transforms the object for us already! + var bounds = this.getLocalBounds(); + + var cacheAlpha = this.alpha; + + this.alpha = 1; + + var cachedRenderTarget = renderer.context; + + bounds.ceil(settings.RESOLUTION); + + var renderTexture = RenderTexture.create(bounds.width, bounds.height); + + var textureCacheId = "cacheAsBitmap_" + (uid()); + + this._cacheData.textureCacheId = textureCacheId; + + BaseTexture.addToCache(renderTexture.baseTexture, textureCacheId); + Texture.addToCache(renderTexture, textureCacheId); + + // need to set // + var m = _tempMatrix; + + this.transform.localTransform.copyTo(m); + m.invert(); + + m.tx -= bounds.x; + m.ty -= bounds.y; + + // m.append(this.transform.worldTransform.) + // set all properties to there original so we can render to a texture + this.renderCanvas = this._cacheData.originalRenderCanvas; + + // renderTexture.render(this, m, true); + renderer.render(this, renderTexture, true, m, false); + + // now restore the state be setting the new properties + renderer.context = cachedRenderTarget; + + this.renderCanvas = this._renderCachedCanvas; + // the rest is the same as for WebGL + this.updateTransform = this.displayObjectUpdateTransform; + this.calculateBounds = this._calculateCachedBounds; + this.getLocalBounds = this._getCachedLocalBounds; + + this._mask = null; + this.filterArea = null; + + // create our cached sprite + var cachedSprite = new Sprite(renderTexture); + + cachedSprite.transform.worldTransform = this.transform.worldTransform; + cachedSprite.anchor.x = -(bounds.x / bounds.width); + cachedSprite.anchor.y = -(bounds.y / bounds.height); + cachedSprite.alpha = cacheAlpha; + cachedSprite._bounds = this._bounds; + + this._cacheData.sprite = cachedSprite; + + this.transform._parentID = -1; + // restore the transform of the cached sprite to avoid the nasty flicker.. + if (!this.parent) + { + this.parent = renderer._tempDisplayObjectParent; + this.updateTransform(); + this.parent = null; + } + else + { + this.updateTransform(); + } + + // map the hit test.. + this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite); + }; + + /** + * Calculates the bounds of the cached sprite + * + * @private + */ + DisplayObject.prototype._calculateCachedBounds = function _calculateCachedBounds() + { + this._bounds.clear(); + this._cacheData.sprite.transform._worldID = this.transform._worldID; + this._cacheData.sprite._calculateBounds(); + this._lastBoundsID = this._boundsID; + }; + + /** + * Gets the bounds of the cached sprite. + * + * @private + * @return {Rectangle} The local bounds. + */ + DisplayObject.prototype._getCachedLocalBounds = function _getCachedLocalBounds() + { + return this._cacheData.sprite.getLocalBounds(); + }; + + /** + * Destroys the cached sprite. + * + * @private + */ + DisplayObject.prototype._destroyCachedDisplayObject = function _destroyCachedDisplayObject() + { + this._cacheData.sprite._texture.destroy(true); + this._cacheData.sprite = null; + + BaseTexture.removeFromCache(this._cacheData.textureCacheId); + Texture.removeFromCache(this._cacheData.textureCacheId); + + this._cacheData.textureCacheId = null; + }; + + /** + * Destroys the cached object. + * + * @private + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options + * have been set to that value. + * Used when destroying containers, see the Container.destroy method. + */ + DisplayObject.prototype._cacheAsBitmapDestroy = function _cacheAsBitmapDestroy(options) + { + this.cacheAsBitmap = false; + this.destroy(options); + }; + + /*! + * @pixi/mixin-get-child-by-name - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/mixin-get-child-by-name is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * The instance name of the object. + * + * @memberof PIXI.DisplayObject# + * @member {string} name + */ + DisplayObject.prototype.name = null; + + /** + * Returns the display object in the container. + * + * @method getChildByName + * @memberof PIXI.Container# + * @param {string} name - Instance name. + * @return {PIXI.DisplayObject} The child with the specified name. + */ + Container.prototype.getChildByName = function getChildByName(name) + { + for (var i = 0; i < this.children.length; i++) + { + if (this.children[i].name === name) + { + return this.children[i]; + } + } + + return null; + }; + + /*! + * @pixi/mixin-get-global-position - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/mixin-get-global-position is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Returns the global position of the displayObject. Does not depend on object scale, rotation and pivot. + * + * @method getGlobalPosition + * @memberof PIXI.DisplayObject# + * @param {Point} point - The point to write the global value to. If null a new point will be returned + * @param {boolean} skipUpdate - Setting to true will stop the transforms of the scene graph from + * being updated. This means the calculation returned MAY be out of date BUT will give you a + * nice performance boost. + * @return {Point} The updated point. + */ + DisplayObject.prototype.getGlobalPosition = function getGlobalPosition(point, skipUpdate) + { + if ( point === void 0 ) { point = new Point(); } + if ( skipUpdate === void 0 ) { skipUpdate = false; } + + if (this.parent) + { + this.parent.toGlobal(this.position, point, skipUpdate); + } + else + { + point.x = this.position.x; + point.y = this.position.y; + } + + return point; + }; + + var v5 = '5.0.0'; + + /** + * Deprecations (backward compatibilities) are automatically applied for browser bundles + * in the UMD module format. If using Webpack or Rollup, you'll need to apply these + * deprecations manually by doing something like this: + * @example + * import * as PIXI from 'pixi.js'; + * PIXI.useDeprecated(); // MUST be bound to namespace + * @memberof PIXI + * @function useDeprecated + */ + function useDeprecated() + { + var PIXI = this; + + Object.defineProperties(PIXI, { + /** + * @constant {RegExp|string} SVG_SIZE + * @memberof PIXI + * @see PIXI.resources.SVGResource.SVG_SIZE + * @deprecated since 5.0.0 + */ + SVG_SIZE: { + get: function get() + { + deprecation(v5, 'PIXI.utils.SVG_SIZE property has moved to PIXI.resources.SVGResource.SVG_SIZE'); + + return PIXI.SVGResource.SVG_SIZE; + }, + }, + + /** + * @class PIXI.TransformStatic + * @deprecated since 5.0.0 + * @see PIXI.Transform + */ + TransformStatic: { + get: function get() + { + deprecation(v5, 'PIXI.TransformStatic class has been removed, use PIXI.Transform'); + + return PIXI.Transform; + }, + }, + + /** + * @class PIXI.TransformBase + * @deprecated since 5.0.0 + * @see PIXI.Transform + */ + TransformBase: { + get: function get() + { + deprecation(v5, 'PIXI.TransformBase class has been removed, use PIXI.Transform'); + + return PIXI.Transform; + }, + }, + + /** + * Constants that specify the transform type. + * + * @static + * @constant + * @name TRANSFORM_MODE + * @memberof PIXI + * @enum {number} + * @deprecated since 5.0.0 + * @property {number} STATIC + * @property {number} DYNAMIC + */ + TRANSFORM_MODE: { + get: function get() + { + deprecation(v5, 'PIXI.TRANSFORM_MODE property has been removed'); + + return { STATIC: 0, DYNAMIC: 1 }; + }, + }, + + /** + * @class PIXI.WebGLRenderer + * @see PIXI.Renderer + * @deprecated since 5.0.0 + */ + WebGLRenderer: { + get: function get() + { + deprecation(v5, 'PIXI.WebGLRenderer class has moved to PIXI.Renderer'); + + return PIXI.Renderer; + }, + }, + + /** + * @class PIXI.CanvasRenderTarget + * @see PIXI.utils.CanvasRenderTarget + * @deprecated since 5.0.0 + */ + CanvasRenderTarget: { + get: function get() + { + deprecation(v5, 'PIXI.CanvasRenderTarget class has moved to PIXI.utils.CanvasRenderTarget'); + + return PIXI.utils.CanvasRenderTarget; + }, + }, + + /** + * @memberof PIXI + * @name loader + * @type {PIXI.Loader} + * @see PIXI.Loader.shared + * @deprecated since 5.0.0 + */ + loader: { + get: function get() + { + deprecation(v5, 'PIXI.loader instance has moved to PIXI.Loader.shared'); + + return PIXI.Loader.shared; + }, + }, + + /** + * @class PIXI.FilterManager + * @see PIXI.systems.FilterSystem + * @deprecated since 5.0.0 + */ + FilterManager: { + get: function get() + { + deprecation(v5, 'PIXI.FilterManager class has moved to PIXI.systems.FilterSystem'); + + return PIXI.systems.FilterSystem; + }, + }, + }); + + /** + * This namespace has been removed. All classes previous nested + * under this namespace have been moved to the top-level `PIXI` object. + * @namespace PIXI.extras + * @deprecated since 5.0.0 + */ + PIXI.extras = {}; + + Object.defineProperties(PIXI.extras, { + /** + * @class PIXI.extras.TilingSprite + * @see PIXI.TilingSprite + * @deprecated since 5.0.0 + */ + TilingSprite: { + get: function get() + { + deprecation(v5, 'PIXI.extras.TilingSprite class has moved to PIXI.TilingSprite'); + + return PIXI.TilingSprite; + }, + }, + /** + * @class PIXI.extras.TilingSpriteRenderer + * @see PIXI.TilingSpriteRenderer + * @deprecated since 5.0.0 + */ + TilingSpriteRenderer: { + get: function get() + { + deprecation(v5, 'PIXI.extras.TilingSpriteRenderer class has moved to PIXI.TilingSpriteRenderer'); + + return PIXI.TilingSpriteRenderer; + }, + }, + /** + * @class PIXI.extras.AnimatedSprite + * @see PIXI.AnimatedSprite + * @deprecated since 5.0.0 + */ + AnimatedSprite: { + get: function get() + { + deprecation(v5, 'PIXI.extras.AnimatedSprite class has moved to PIXI.AnimatedSprite'); + + return PIXI.AnimatedSprite; + }, + }, + /** + * @class PIXI.extras.BitmapText + * @see PIXI.BitmapText + * @deprecated since 5.0.0 + */ + BitmapText: { + get: function get() + { + deprecation(v5, 'PIXI.extras.BitmapText class has moved to PIXI.BitmapText'); + + return PIXI.BitmapText; + }, + }, + }); + + Object.defineProperties(PIXI.utils, { + /** + * @function PIXI.utils.getSvgSize + * @see PIXI.resources.SVGResource.getSize + * @deprecated since 5.0.0 + */ + getSvgSize: { + get: function get() + { + deprecation(v5, 'PIXI.utils.getSvgSize function has moved to PIXI.resources.SVGResource.getSize'); + + return PIXI.SVGResource.getSize; + }, + }, + }); + + /** + * All classes on this namespace have moved to the high-level `PIXI` object. + * @namespace PIXI.mesh + * @deprecated since 5.0.0 + */ + PIXI.mesh = {}; + + Object.defineProperties(PIXI.mesh, { + /** + * @class PIXI.mesh.Mesh + * @see PIXI.SimpleMesh + * @deprecated since 5.0.0 + */ + Mesh: { + get: function get() + { + deprecation(v5, 'PIXI.mesh.Mesh class has moved to PIXI.SimpleMesh'); + + return PIXI.SimpleMesh; + }, + }, + /** + * @class PIXI.mesh.NineSlicePlane + * @see PIXI.NineSlicePlane + * @deprecated since 5.0.0 + */ + NineSlicePlane: { + get: function get() + { + deprecation(v5, 'PIXI.mesh.NineSlicePlane class has moved to PIXI.NineSlicePlane'); + + return PIXI.NineSlicePlane; + }, + }, + /** + * @class PIXI.mesh.Plane + * @see PIXI.SimplePlane + * @deprecated since 5.0.0 + */ + Plane: { + get: function get() + { + deprecation(v5, 'PIXI.mesh.Plane class has moved to PIXI.SimplePlane'); + + return PIXI.SimplePlane; + }, + }, + /** + * @class PIXI.mesh.Rope + * @see PIXI.SimpleRope + * @deprecated since 5.0.0 + */ + Rope: { + get: function get() + { + deprecation(v5, 'PIXI.mesh.Rope class has moved to PIXI.SimpleRope'); + + return PIXI.SimpleRope; + }, + }, + /** + * @class PIXI.mesh.RawMesh + * @see PIXI.Mesh + * @deprecated since 5.0.0 + */ + RawMesh: { + get: function get() + { + deprecation(v5, 'PIXI.mesh.RawMesh class has moved to PIXI.Mesh'); + + return PIXI.Mesh; + }, + }, + /** + * @class PIXI.mesh.CanvasMeshRenderer + * @see PIXI.CanvasMeshRenderer + * @deprecated since 5.0.0 + */ + CanvasMeshRenderer: { + get: function get() + { + deprecation(v5, 'PIXI.mesh.CanvasMeshRenderer class has moved to PIXI.CanvasMeshRenderer'); + + return PIXI.CanvasMeshRenderer; + }, + }, + /** + * @class PIXI.mesh.MeshRenderer + * @see PIXI.MeshRenderer + * @deprecated since 5.0.0 + */ + MeshRenderer: { + get: function get() + { + deprecation(v5, 'PIXI.mesh.MeshRenderer class has moved to PIXI.MeshRenderer'); + + return PIXI.MeshRenderer; + }, + }, + }); + + /** + * This namespace has been removed and items have been moved to + * the top-level `PIXI` object. + * @namespace PIXI.particles + * @deprecated since 5.0.0 + */ + PIXI.particles = {}; + + Object.defineProperties(PIXI.particles, { + /** + * @class PIXI.particles.ParticleContainer + * @deprecated since 5.0.0 + * @see PIXI.ParticleContainer + */ + ParticleContainer: { + get: function get() + { + deprecation(v5, 'PIXI.particles.ParticleContainer class has moved to PIXI.ParticleContainer'); + + return PIXI.ParticleContainer; + }, + }, + /** + * @class PIXI.particles.ParticleRenderer + * @deprecated since 5.0.0 + * @see PIXI.ParticleRenderer + */ + ParticleRenderer: { + get: function get() + { + deprecation(v5, 'PIXI.particles.ParticleRenderer class has moved to PIXI.ParticleRenderer'); + + return PIXI.ParticleRenderer; + }, + }, + }); + + /** + * This namespace has been removed and items have been moved to + * the top-level `PIXI` object. + * @namespace PIXI.ticker + * @deprecated since 5.0.0 + */ + PIXI.ticker = {}; + + Object.defineProperties(PIXI.ticker, { + /** + * @class PIXI.ticker.Ticker + * @deprecated since 5.0.0 + * @see PIXI.Ticker + */ + Ticker: { + get: function get() + { + deprecation(v5, 'PIXI.ticker.Ticker class has moved to PIXI.Ticker'); + + return PIXI.Ticker; + }, + }, + /** + * @name PIXI.ticker.shared + * @type {PIXI.Ticker} + * @deprecated since 5.0.0 + * @see PIXI.Ticker.shared + */ + shared: { + get: function get() + { + deprecation(v5, 'PIXI.ticker.shared instance has moved to PIXI.Ticker.shared'); + + return PIXI.Ticker.shared; + }, + }, + }); + + /** + * All classes on this namespace have moved to the high-level `PIXI` object. + * @namespace PIXI.loaders + * @deprecated since 5.0.0 + */ + PIXI.loaders = {}; + + Object.defineProperties(PIXI.loaders, { + /** + * @class PIXI.loaders.Loader + * @see PIXI.Loader + * @deprecated since 5.0.0 + */ + Loader: { + get: function get() + { + deprecation(v5, 'PIXI.loaders.Loader class has moved to PIXI.Loader'); + + return PIXI.Loader; + }, + }, + /** + * @class PIXI.loaders.Resource + * @see PIXI.LoaderResource + * @deprecated since 5.0.0 + */ + Resource: { + get: function get() + { + deprecation(v5, 'PIXI.loaders.Resource class has moved to PIXI.LoaderResource'); + + return PIXI.LoaderResource; + }, + }, + /** + * @function PIXI.loaders.bitmapFontParser + * @see PIXI.BitmapFontLoader.use + * @deprecated since 5.0.0 + */ + bitmapFontParser: { + get: function get() + { + deprecation(v5, 'PIXI.loaders.bitmapFontParser function has moved to PIXI.BitmapFontLoader.use'); + + return PIXI.BitmapFontLoader.use; + }, + }, + /** + * @function PIXI.loaders.parseBitmapFontData + * @see PIXI.BitmapFontLoader.parse + * @deprecated since 5.0.0 + */ + parseBitmapFontData: { + get: function get() + { + deprecation(v5, 'PIXI.loaders.parseBitmapFontData function has moved to PIXI.BitmapFontLoader.parse'); + + return PIXI.BitmapFontLoader.parse; + }, + }, + /** + * @function PIXI.loaders.spritesheetParser + * @see PIXI.SpritesheetLoader.use + * @deprecated since 5.0.0 + */ + spritesheetParser: { + get: function get() + { + deprecation(v5, 'PIXI.loaders.spritesheetParser function has moved to PIXI.SpritesheetLoader.use'); + + return PIXI.SpritesheetLoader.use; + }, + }, + /** + * @function PIXI.loaders.getResourcePath + * @see PIXI.SpritesheetLoader.getResourcePath + * @deprecated since 5.0.0 + */ + getResourcePath: { + get: function get() + { + deprecation(v5, 'PIXI.loaders.getResourcePath property has moved to PIXI.SpritesheetLoader.getResourcePath'); + + return PIXI.SpritesheetLoader.getResourcePath; + }, + }, + }); + + /** + * @function PIXI.loaders.Loader.addPixiMiddleware + * @see PIXI.Loader.registerPlugin + * @deprecated since 5.0.0 + * @param {function} middleware + */ + PIXI.Loader.addPixiMiddleware = function addPixiMiddleware(middleware) + { + deprecation(v5, + 'PIXI.loaders.Loader.addPixiMiddleware function is deprecated, use PIXI.loaders.Loader.registerPlugin' + ); + + return PIXI.loaders.Loader.registerPlugin({ use: middleware() }); + }; + + /** + * @class PIXI.extract.WebGLExtract + * @deprecated since 5.0.0 + * @see PIXI.extract.Extract + */ + Object.defineProperty(PIXI.extract, 'WebGLExtract', { + get: function get() + { + deprecation(v5, 'PIXI.extract.WebGLExtract method has moved to PIXI.extract.Extract'); + + return PIXI.extract.Extract; + }, + }); + + /** + * @class PIXI.prepare.WebGLPrepare + * @deprecated since 5.0.0 + * @see PIXI.prepare.Prepare + */ + Object.defineProperty(PIXI.prepare, 'WebGLPrepare', { + get: function get() + { + deprecation(v5, 'PIXI.prepare.WebGLPrepare class has moved to PIXI.prepare.Prepare'); + + return PIXI.prepare.Prepare; + }, + }); + + /** + * @method PIXI.Container#_renderWebGL + * @private + * @deprecated since 5.0.0 + * @see PIXI.Container#render + * @param {PIXI.Renderer} renderer Instance of renderer + */ + PIXI.Container.prototype._renderWebGL = function _renderWebGL(renderer) + { + deprecation(v5, 'PIXI.Container._renderWebGL method has moved to PIXI.Container._render'); + + this._render(renderer); + }; + + /** + * @method PIXI.Container#renderWebGL + * @deprecated since 5.0.0 + * @see PIXI.Container#render + * @param {PIXI.Renderer} renderer Instance of renderer + */ + PIXI.Container.prototype.renderWebGL = function renderWebGL(renderer) + { + deprecation(v5, 'PIXI.Container.renderWebGL method has moved to PIXI.Container.render'); + + this.render(renderer); + }; + + /** + * @method PIXI.DisplayObject#renderWebGL + * @deprecated since 5.0.0 + * @see PIXI.DisplayObject#render + * @param {PIXI.Renderer} renderer Instance of renderer + */ + PIXI.DisplayObject.prototype.renderWebGL = function renderWebGL(renderer) + { + deprecation(v5, 'PIXI.DisplayObject.renderWebGL method has moved to PIXI.DisplayObject.render'); + + this.render(renderer); + }; + + /** + * @method PIXI.Container#renderAdvancedWebGL + * @deprecated since 5.0.0 + * @see PIXI.Container#renderAdvanced + * @param {PIXI.Renderer} renderer Instance of renderer + */ + PIXI.Container.prototype.renderAdvancedWebGL = function renderAdvancedWebGL(renderer) + { + deprecation(v5, 'PIXI.Container.renderAdvancedWebGL method has moved to PIXI.Container.renderAdvanced'); + + this.renderAdvanced(renderer); + }; + + Object.defineProperties(PIXI.settings, { + /** + * Default transform type. + * + * @static + * @deprecated since 5.0.0 + * @memberof PIXI.settings + * @type {PIXI.TRANSFORM_MODE} + * @default PIXI.TRANSFORM_MODE.STATIC + */ + TRANSFORM_MODE: { + get: function get() + { + deprecation(v5, 'PIXI.settings.TRANSFORM_MODE property has been removed'); + + return 0; + }, + set: function set() + { + deprecation(v5, 'PIXI.settings.TRANSFORM_MODE property has been removed'); + }, + }, + }); + + var BaseTexture = PIXI.BaseTexture; + + /** + * @method loadSource + * @memberof PIXI.BaseTexture# + * @deprecated since 5.0.0 + */ + BaseTexture.prototype.loadSource = function loadSource(image) + { + deprecation(v5, 'PIXI.BaseTexture.loadSource method has been deprecated'); + + var resource = PIXI.resources.autoDetectResource(image); + + resource.internal = true; + + this.setResource(resource); + this.update(); + }; + + Object.defineProperties(BaseTexture.prototype, { + /** + * @name PIXI.BaseTexture#hasLoaded + * @type {boolean} + * @deprecated since 5.0.0 + * @readonly + * @see PIXI.BaseTexture#valid + */ + hasLoaded: { + get: function get() + { + deprecation(v5, 'PIXI.BaseTexture.hasLoaded property has been removed, use PIXI.BaseTexture.valid'); + + return this.valid; + }, + }, + /** + * @name PIXI.BaseTexture#imageUrl + * @type {string} + * @deprecated since 5.0.0 + * @readonly + * @see PIXI.resource.ImageResource#url + */ + imageUrl: { + get: function get() + { + deprecation(v5, 'PIXI.BaseTexture.imageUrl property has been removed, use resource.url'); + + return this.resource && this.resource.url; + }, + }, + }); + + /** + * @method fromImage + * @static + * @memberof PIXI.BaseTexture + * @deprecated since 5.0.0 + * @see PIXI.BaseTexture.from + */ + BaseTexture.fromImage = function fromImage(canvas, crossorigin, scaleMode, scale) + { + deprecation(v5, 'PIXI.BaseTexture.fromImage method has been replaced with PIXI.BaseTexture.from'); + + var resourceOptions = { scale: scale, crossorigin: crossorigin }; + + return BaseTexture.from(canvas, { scaleMode: scaleMode, resourceOptions: resourceOptions }); + }; + + /** + * @method fromCanvas + * @static + * @memberof PIXI.BaseTexture + * @deprecated since 5.0.0 + * @see PIXI.BaseTexture.from + */ + BaseTexture.fromCanvas = function fromCanvas(canvas, scaleMode) + { + deprecation(v5, 'PIXI.BaseTexture.fromCanvas method has been replaced with PIXI.BaseTexture.from'); + + return BaseTexture.from(canvas, { scaleMode: scaleMode }); + }; + + /** + * @method fromSVG + * @static + * @memberof PIXI.BaseTexture + * @deprecated since 5.0.0 + * @see PIXI.BaseTexture.from + */ + BaseTexture.fromSVG = function fromSVG(canvas, crossorigin, scaleMode, scale) + { + deprecation(v5, 'PIXI.BaseTexture.fromSVG method has been replaced with PIXI.BaseTexture.from'); + + var resourceOptions = { scale: scale, crossorigin: crossorigin }; + + return BaseTexture.from(canvas, { scaleMode: scaleMode, resourceOptions: resourceOptions }); + }; + + /** + * @method PIXI.Point#copy + * @deprecated since 5.0.0 + * @see PIXI.Point#copyFrom + */ + PIXI.Point.prototype.copy = function copy(p) + { + deprecation(v5, 'PIXI.Point.copy method has been replaced with PIXI.Point.copyFrom'); + + return this.copyFrom(p); + }; + + /** + * @method PIXI.ObservablePoint#copy + * @deprecated since 5.0.0 + * @see PIXI.ObservablePoint#copyFrom + */ + PIXI.ObservablePoint.prototype.copy = function copy(p) + { + deprecation(v5, 'PIXI.ObservablePoint.copy method has been replaced with PIXI.ObservablePoint.copyFrom'); + + return this.copyFrom(p); + }; + + /** + * @method PIXI.Rectangle#copy + * @deprecated since 5.0.0 + * @see PIXI.Rectangle#copyFrom + */ + PIXI.Rectangle.prototype.copy = function copy(p) + { + deprecation(v5, 'PIXI.Rectangle.copy method has been replaced with PIXI.Rectangle.copyFrom'); + + return this.copyFrom(p); + }; + + /** + * @method PIXI.Matrix#copy + * @deprecated since 5.0.0 + * @see PIXI.Matrix#copyTo + */ + PIXI.Matrix.prototype.copy = function copy(p) + { + deprecation(v5, 'PIXI.Matrix.copy method has been replaced with PIXI.Matrix.copyTo'); + + return this.copyTo(p); + }; + + Object.assign(PIXI.systems.FilterSystem.prototype, { + /** + * @method PIXI.FilterManager#getRenderTarget + * @deprecated since 5.0.0 + * @see PIXI.systems.FilterSystem#getFilterTexture + */ + getRenderTarget: function getRenderTarget(clear, resolution) + { + deprecation(v5, + 'PIXI.FilterManager.getRenderTarget method has been replaced with PIXI.systems.FilterSystem#getFilterTexture' + ); + + return this.getFilterTexture(resolution); + }, + + /** + * @method PIXI.FilterManager#returnRenderTarget + * @deprecated since 5.0.0 + * @see PIXI.systems.FilterSystem#returnFilterTexture + */ + returnRenderTarget: function returnRenderTarget(renderTexture) + { + deprecation(v5, + 'PIXI.FilterManager.returnRenderTarget method has been replaced with ' + + 'PIXI.systems.FilterSystem.returnFilterTexture' + ); + + this.returnFilterTexture(renderTexture); + }, + + /** + * @method PIXI.systems.FilterSystem#calculateScreenSpaceMatrix + * @deprecated since 5.0.0 + * @param {PIXI.Matrix} outputMatrix - the matrix to output to. + * @return {PIXI.Matrix} The mapped matrix. + */ + calculateScreenSpaceMatrix: function calculateScreenSpaceMatrix(outputMatrix) + { + deprecation(v5, 'PIXI.systems.FilterSystem.calculateScreenSpaceMatrix method is removed, ' + + 'use `(vTextureCoord * inputSize.xy) + outputFrame.xy` instead'); + + var mappedMatrix = outputMatrix.identity(); + var ref = this.activeState; + var sourceFrame = ref.sourceFrame; + var destinationFrame = ref.destinationFrame; + + mappedMatrix.translate(sourceFrame.x / destinationFrame.width, sourceFrame.y / destinationFrame.height); + mappedMatrix.scale(destinationFrame.width, destinationFrame.height); + + return mappedMatrix; + }, + + /** + * @method PIXI.systems.FilterSystem#calculateNormalizedScreenSpaceMatrix + * @deprecated since 5.0.0 + * @param {PIXI.Matrix} outputMatrix - The matrix to output to. + * @return {PIXI.Matrix} The mapped matrix. + */ + calculateNormalizedScreenSpaceMatrix: function calculateNormalizedScreenSpaceMatrix(outputMatrix) + { + deprecation(v5, 'PIXI.systems.FilterManager.calculateNormalizedScreenSpaceMatrix method is removed, ' + + 'use `((vTextureCoord * inputSize.xy) + outputFrame.xy) / outputFrame.zw` instead.'); + + var ref = this.activeState; + var sourceFrame = ref.sourceFrame; + var destinationFrame = ref.destinationFrame; + var mappedMatrix = outputMatrix.identity(); + + mappedMatrix.translate(sourceFrame.x / destinationFrame.width, sourceFrame.y / destinationFrame.height); + + var translateScaleX = (destinationFrame.width / sourceFrame.width); + var translateScaleY = (destinationFrame.height / sourceFrame.height); + + mappedMatrix.scale(translateScaleX, translateScaleY); + + return mappedMatrix; + }, + }); + + Object.defineProperties(PIXI.RenderTexture.prototype, { + /** + * @name PIXI.RenderTexture#sourceFrame + * @type {PIXI.Rectangle} + * @deprecated since 5.0.0 + * @readonly + */ + sourceFrame: { + get: function get() + { + deprecation(v5, 'PIXI.RenderTexture.sourceFrame property has been removed'); + + return this.filterFrame; + }, + }, + /** + * @name PIXI.RenderTexture#size + * @type {PIXI.Rectangle} + * @deprecated since 5.0.0 + * @readonly + */ + size: { + get: function get() + { + deprecation(v5, 'PIXI.RenderTexture.size property has been removed'); + + return this._frame; + }, + }, + }); + + /** + * @class BlurXFilter + * @memberof PIXI.filters + * @deprecated since 5.0.0 + * @see PIXI.filters.BlurFilterPass + */ + var BlurXFilter = /*@__PURE__*/(function (superclass) { + function BlurXFilter(strength, quality, resolution, kernelSize) + { + deprecation(v5, 'PIXI.filters.BlurXFilter class is deprecated, use PIXI.filters.BlurFilterPass'); + + superclass.call(this, true, strength, quality, resolution, kernelSize); + } + + if ( superclass ) BlurXFilter.__proto__ = superclass; + BlurXFilter.prototype = Object.create( superclass && superclass.prototype ); + BlurXFilter.prototype.constructor = BlurXFilter; + + return BlurXFilter; + }(PIXI.filters.BlurFilterPass)); + + /** + * @class BlurYFilter + * @memberof PIXI.filters + * @deprecated since 5.0.0 + * @see PIXI.filters.BlurFilterPass + */ + var BlurYFilter = /*@__PURE__*/(function (superclass) { + function BlurYFilter(strength, quality, resolution, kernelSize) + { + deprecation(v5, 'PIXI.filters.BlurYFilter class is deprecated, use PIXI.filters.BlurFilterPass'); + + superclass.call(this, false, strength, quality, resolution, kernelSize); + } + + if ( superclass ) BlurYFilter.__proto__ = superclass; + BlurYFilter.prototype = Object.create( superclass && superclass.prototype ); + BlurYFilter.prototype.constructor = BlurYFilter; + + return BlurYFilter; + }(PIXI.filters.BlurFilterPass)); + + Object.assign(PIXI.filters, { + BlurXFilter: BlurXFilter, + BlurYFilter: BlurYFilter, + }); + + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + var Graphics = PIXI.Graphics; + + // Support for pixi.js-legacy bifurcation + // give users a friendly assist to use legacy + if (!Graphics.prototype.generateCanvasTexture) + { + Graphics.prototype.generateCanvasTexture = function generateCanvasTexture() + { + deprecation(v5, 'PIXI.Graphics.generateCanvasTexture method is only available in "pixi.js-legacy"'); + }; + } + + // Use these to deprecate all the Sprite from* methods + function spriteFrom(name, source, crossorigin, scaleMode) + { + deprecation(v5, ("PIXI.Sprite." + name + " method is deprecated, use PIXI.Sprite.from")); + + return Sprite.from(source, { + resourceOptions: { + scale: scaleMode, + crossorigin: crossorigin, + }, + }); + } + + /** + * @deprecated since 5.0.0 + * @see PIXI.Sprite.from + * @method PIXI.Sprite.fromImage + * @return {PIXI.Sprite} + */ + Sprite.fromImage = spriteFrom.bind(null, 'fromImage'); + + /** + * @deprecated since 5.0.0 + * @method PIXI.Sprite.fromSVG + * @see PIXI.Sprite.from + * @return {PIXI.Sprite} + */ + Sprite.fromSVG = spriteFrom.bind(null, 'fromSVG'); + + /** + * @deprecated since 5.0.0 + * @method PIXI.Sprite.fromCanvas + * @see PIXI.Sprite.from + * @return {PIXI.Sprite} + */ + Sprite.fromCanvas = spriteFrom.bind(null, 'fromCanvas'); + + /** + * @deprecated since 5.0.0 + * @method PIXI.Sprite.fromVideo + * @see PIXI.Sprite.from + * @return {PIXI.Sprite} + */ + Sprite.fromVideo = spriteFrom.bind(null, 'fromVideo'); + + /** + * @deprecated since 5.0.0 + * @method PIXI.Sprite.fromFrame + * @see PIXI.Sprite.from + * @return {PIXI.Sprite} + */ + Sprite.fromFrame = spriteFrom.bind(null, 'fromFrame'); + + // Use these to deprecate all the Texture from* methods + function textureFrom(name, source, crossorigin, scaleMode) + { + deprecation(v5, ("PIXI.Texture." + name + " method is deprecated, use PIXI.Texture.from")); + + return Texture.from(source, { + resourceOptions: { + scale: scaleMode, + crossorigin: crossorigin, + }, + }); + } + + /** + * @deprecated since 5.0.0 + * @method PIXI.Texture.fromImage + * @see PIXI.Texture.from + * @return {PIXI.Texture} + */ + Texture.fromImage = textureFrom.bind(null, 'fromImage'); + + /** + * @deprecated since 5.0.0 + * @method PIXI.Texture.fromSVG + * @see PIXI.Texture.from + * @return {PIXI.Texture} + */ + Texture.fromSVG = textureFrom.bind(null, 'fromSVG'); + + /** + * @deprecated since 5.0.0 + * @method PIXI.Texture.fromCanvas + * @see PIXI.Texture.from + * @return {PIXI.Texture} + */ + Texture.fromCanvas = textureFrom.bind(null, 'fromCanvas'); + + /** + * @deprecated since 5.0.0 + * @method PIXI.Texture.fromVideo + * @see PIXI.Texture.from + * @return {PIXI.Texture} + */ + Texture.fromVideo = textureFrom.bind(null, 'fromVideo'); + + /** + * @deprecated since 5.0.0 + * @method PIXI.Texture.fromFrame + * @see PIXI.Texture.from + * @return {PIXI.Texture} + */ + Texture.fromFrame = textureFrom.bind(null, 'fromFrame'); + + /** + * @deprecated since 5.0.0 + * @member {boolean} PIXI.AbstractRenderer#autoResize + * @see PIXI.AbstractRenderer#autoDensity + */ + Object.defineProperty(PIXI.AbstractRenderer.prototype, 'autoResize', { + get: function get() + { + deprecation(v5, 'PIXI.AbstractRenderer.autoResize property is deprecated, use autoDensity'); + + return this.autoDensity; + }, + set: function set(value) + { + deprecation(v5, 'PIXI.AbstractRenderer.autoResize property is deprecated, use autoDensity'); + + this.autoDensity = value; + }, + }); + + /** + * @namespace PIXI.utils.mixins + * @deprecated since 5.0.0 + */ + PIXI.utils.mixins = { + /** + * @memberof PIXI.utils.mixins + * @function mixin + * @deprecated since 5.0.0 + */ + mixin: function mixin() + { + deprecation(v5, 'PIXI.utils.mixins.mixin function is no longer available'); + }, + /** + * @memberof PIXI.utils.mixins + * @function delayMixin + * @deprecated since 5.0.0 + */ + delayMixin: function delayMixin() + { + deprecation(v5, 'PIXI.utils.mixins.delayMixin function is no longer available'); + }, + /** + * @memberof PIXI.utils.mixins + * @function performMixins + * @deprecated since 5.0.0 + */ + performMixins: function performMixins() + { + deprecation(v5, 'PIXI.utils.mixins.performMixins function is no longer available'); + }, + }; + } + + /*! + * @pixi/mesh - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/mesh is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * Class controls cache for UV mapping from Texture normal space to BaseTexture normal space. + * + * @class + * @memberof PIXI + */ + var MeshBatchUvs = function MeshBatchUvs(uvBuffer, uvMatrix) + { + /** + * Buffer with normalized UV's + * @member {PIXI.Buffer} + */ + this.uvBuffer = uvBuffer; + + /** + * Material UV matrix + * @member {PIXI.TextureMatrix} + */ + this.uvMatrix = uvMatrix; + + /** + * UV Buffer data + * @member {Float32Array} + * @readonly + */ + this.data = null; + + this._bufferUpdateId = -1; + + this._textureUpdateId = -1; + + this._updateID = 0; + }; + + /** + * updates + * + * @param {boolean} forceUpdate - force the update + */ + MeshBatchUvs.prototype.update = function update (forceUpdate) + { + if (!forceUpdate + && this._bufferUpdateId === this.uvBuffer._updateID + && this._textureUpdateId === this.uvMatrix._updateID) + { + return; + } + + this._bufferUpdateId = this.uvBuffer._updateID; + this._textureUpdateId = this.uvMatrix._updateID; + + var data = this.uvBuffer.data; + + if (!this.data || this.data.length !== data.length) + { + this.data = new Float32Array(data.length); + } + + this.uvMatrix.multiplyUvs(data, this.data); + + this._updateID++; + }; + + var tempPoint$2 = new Point(); + var tempPolygon = new Polygon(); + + /** + * Base mesh class. + * + * This class empowers you to have maximum flexibility to render any kind of WebGL visuals you can think of. + * This class assumes a certain level of WebGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * + * Pretty much ALL WebGL can be broken down into the following: + * - Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * - Shader - This is the shader that PixiJS will render the geometry with (attributes in the shader must match the geometry) + * - State - This is the state of WebGL required to render the mesh. + * + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * + * @class + * @extends PIXI.Container + * @memberof PIXI + */ + var Mesh = /*@__PURE__*/(function (Container) { + function Mesh(geometry, shader, state, drawMode)// vertices, uvs, indices, drawMode) + { + if ( drawMode === void 0 ) { drawMode = DRAW_MODES.TRIANGLES; } + + Container.call(this); + + /** + * Includes vertex positions, face indices, normals, colors, UVs, and + * custom attributes within buffers, reducing the cost of passing all + * this data to the GPU. Can be shared between multiple Mesh objects. + * @member {PIXI.Geometry} + * @readonly + */ + this.geometry = geometry; + + geometry.refCount++; + + /** + * Represents the vertex and fragment shaders that processes the geometry and runs on the GPU. + * Can be shared between multiple Mesh objects. + * @member {PIXI.Shader|PIXI.MeshMaterial} + */ + this.shader = shader; + + /** + * Represents the WebGL state the Mesh required to render, excludes shader and geometry. E.g., + * blend mode, culling, depth testing, direction of rendering triangles, backface, etc. + * @member {PIXI.State} + */ + this.state = state || State.for2d(); + + /** + * The way the Mesh should be drawn, can be any of the {@link PIXI.DRAW_MODES} constants. + * + * @member {number} + * @see PIXI.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * Typically the index of the IndexBuffer where to start drawing. + * @member {number} + * @default 0 + */ + this.start = 0; + + /** + * How much of the geometry to draw, by default `0` renders everything. + * @member {number} + * @default 0 + */ + this.size = 0; + + /** + * thease are used as easy access for batching + * @member {Float32Array} + * @private + */ + this.uvs = null; + + /** + * thease are used as easy access for batching + * @member {Uint16Array} + * @private + */ + this.indices = null; + + /** + * this is the caching layer used by the batcher + * @member {Float32Array} + * @private + */ + this.vertexData = new Float32Array(1); + + /** + * If geometry is changed used to decide to re-transform + * the vertexData. + * @member {number} + * @private + */ + this.vertexDirty = 0; + + this._transformID = -1; + + // Inherited from DisplayMode, set defaults + this.tint = 0xFFFFFF; + this.blendMode = BLEND_MODES.NORMAL; + + /** + * Internal roundPixels field + * + * @member {boolean} + * @private + */ + this._roundPixels = settings.ROUND_PIXELS; + + /** + * Batched UV's are cached for atlas textures + * @member {PIXI.MeshBatchUvs} + * @private + */ + this.batchUvs = null; + } + + if ( Container ) { Mesh.__proto__ = Container; } + Mesh.prototype = Object.create( Container && Container.prototype ); + Mesh.prototype.constructor = Mesh; + + var prototypeAccessors = { uvBuffer: { configurable: true },verticesBuffer: { configurable: true },material: { configurable: true },blendMode: { configurable: true },roundPixels: { configurable: true },tint: { configurable: true },texture: { configurable: true } }; + + /** + * To change mesh uv's, change its uvBuffer data and increment its _updateID. + * @member {PIXI.Buffer} + * @readonly + */ + prototypeAccessors.uvBuffer.get = function () + { + return this.geometry.buffers[1]; + }; + + /** + * To change mesh vertices, change its uvBuffer data and increment its _updateID. + * Incrementing _updateID is optional because most of Mesh objects do it anyway. + * @member {PIXI.Buffer} + * @readonly + */ + prototypeAccessors.verticesBuffer.get = function () + { + return this.geometry.buffers[0]; + }; + + /** + * Alias for {@link PIXI.Mesh#shader}. + * @member {PIXI.Shader|PIXI.MeshMaterial} + */ + prototypeAccessors.material.set = function (value) + { + this.shader = value; + }; + + prototypeAccessors.material.get = function () + { + return this.shader; + }; + + /** + * The blend mode to be applied to the Mesh. Apply a value of + * `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL; + * @see PIXI.BLEND_MODES + */ + prototypeAccessors.blendMode.set = function (value) + { + this.state.blendMode = value; + }; + + prototypeAccessors.blendMode.get = function () + { + return this.state.blendMode; + }; + + /** + * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. + * Advantages can include sharper image quality (like text) and faster rendering on canvas. + * The main disadvantage is movement of objects may appear less smooth. + * To set the global default, change {@link PIXI.settings.ROUND_PIXELS} + * + * @member {boolean} + * @default false + */ + prototypeAccessors.roundPixels.set = function (value) + { + if (this._roundPixels !== value) + { + this._transformID = -1; + } + this._roundPixels = value; + }; + + prototypeAccessors.roundPixels.get = function () + { + return this._roundPixels; + }; + + /** + * The multiply tint applied to the Mesh. This is a hex value. A value of + * `0xFFFFFF` will remove any tint effect. + * + * @member {number} + * @default 0xFFFFFF + */ + prototypeAccessors.tint.get = function () + { + return this.shader.tint; + }; + + prototypeAccessors.tint.set = function (value) + { + this.shader.tint = value; + }; + + /** + * The texture that the Mesh uses. + * + * @member {PIXI.Texture} + */ + prototypeAccessors.texture.get = function () + { + return this.shader.texture; + }; + + prototypeAccessors.texture.set = function (value) + { + this.shader.texture = value; + }; + + /** + * Standard renderer draw. + * @protected + */ + Mesh.prototype._render = function _render (renderer) + { + // set properties for batching.. + // TODO could use a different way to grab verts? + var vertices = this.geometry.buffers[0].data; + + // TODO benchmark check for attribute size.. + if (this.shader.batchable && this.drawMode === DRAW_MODES.TRIANGLES && vertices.length < Mesh.BATCHABLE_SIZE * 2) + { + this._renderToBatch(renderer); + } + else + { + this._renderDefault(renderer); + } + }; + + /** + * Standard non-batching way of rendering. + * @protected + * @param {PIXI.Renderer} renderer - Instance to renderer. + */ + Mesh.prototype._renderDefault = function _renderDefault (renderer) + { + var shader = this.shader; + + shader.alpha = this.worldAlpha; + if (shader.update) + { + shader.update(); + } + + renderer.batch.flush(); + + if (shader.program.uniformData.translationMatrix) + { + shader.uniforms.translationMatrix = this.transform.worldTransform.toArray(true); + } + + // bind and sync uniforms.. + renderer.shader.bind(shader); + + // set state.. + renderer.state.setState(this.state); + + // bind the geometry... + renderer.geometry.bind(this.geometry, shader); + + // then render it + renderer.geometry.draw(this.drawMode, this.size, this.start, this.geometry.instanceCount); + }; + + /** + * Rendering by using the Batch system. + * @protected + * @param {PIXI.Renderer} renderer - Instance to renderer. + */ + Mesh.prototype._renderToBatch = function _renderToBatch (renderer) + { + var geometry = this.geometry; + + if (this.shader.uvMatrix) + { + this.shader.uvMatrix.update(); + this.calculateUvs(); + } + + // set properties for batching.. + this.calculateVertices(); + this.indices = geometry.indexBuffer.data; + this._tintRGB = this.shader._tintRGB; + this._texture = this.shader.texture; + + var pluginName = this.material.pluginName; + + renderer.batch.setObjectRenderer(renderer.plugins[pluginName]); + renderer.plugins[pluginName].render(this); + }; + + /** + * Updates vertexData field based on transform and vertices + */ + Mesh.prototype.calculateVertices = function calculateVertices () + { + var geometry = this.geometry; + var vertices = geometry.buffers[0].data; + + if (geometry.vertexDirtyId === this.vertexDirty && this._transformID === this.transform._worldID) + { + return; + } + + this._transformID = this.transform._worldID; + + if (this.vertexData.length !== vertices.length) + { + this.vertexData = new Float32Array(vertices.length); + } + + var wt = this.transform.worldTransform; + var a = wt.a; + var b = wt.b; + var c = wt.c; + var d = wt.d; + var tx = wt.tx; + var ty = wt.ty; + + var vertexData = this.vertexData; + + for (var i = 0; i < vertexData.length / 2; i++) + { + var x = vertices[(i * 2)]; + var y = vertices[(i * 2) + 1]; + + vertexData[(i * 2)] = (a * x) + (c * y) + tx; + vertexData[(i * 2) + 1] = (b * x) + (d * y) + ty; + } + + if (this._roundPixels) + { + for (var i$1 = 0; i$1 < vertexData.length; i$1++) + { + vertexData[i$1] = Math.round(vertexData[i$1]); + } + } + + this.vertexDirty = geometry.vertexDirtyId; + }; + + /** + * Updates uv field based on from geometry uv's or batchUvs + */ + Mesh.prototype.calculateUvs = function calculateUvs () + { + var geomUvs = this.geometry.buffers[1]; + + if (!this.shader.uvMatrix.isSimple) + { + if (!this.batchUvs) + { + this.batchUvs = new MeshBatchUvs(geomUvs, this.shader.uvMatrix); + } + this.batchUvs.update(); + this.uvs = this.batchUvs.data; + } + else + { + this.uvs = geomUvs.data; + } + }; + + /** + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. + * + * @protected + */ + Mesh.prototype._calculateBounds = function _calculateBounds () + { + this.calculateVertices(); + + this._bounds.addVertexData(this.vertexData, 0, this.vertexData.length); + }; + + /** + * Tests if a point is inside this mesh. Works only for PIXI.DRAW_MODES.TRIANGLES. + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + Mesh.prototype.containsPoint = function containsPoint (point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; + } + + this.worldTransform.applyInverse(point, tempPoint$2); + + var vertices = this.geometry.getBuffer('aVertexPosition').data; + + var points = tempPolygon.points; + var indices = this.geometry.getIndex().data; + var len = indices.length; + var step = this.drawMode === 4 ? 3 : 1; + + for (var i = 0; i + 2 < len; i += step) + { + var ind0 = indices[i] * 2; + var ind1 = indices[i + 1] * 2; + var ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint$2.x, tempPoint$2.y)) + { + return true; + } + } + + return false; + }; + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + */ + Mesh.prototype.destroy = function destroy (options) + { + Container.prototype.destroy.call(this, options); + + this.geometry.refCount--; + if (this.geometry.refCount === 0) + { + this.geometry.dispose(); + } + + this.geometry = null; + this.shader = null; + this.state = null; + this.uvs = null; + this.indices = null; + this.vertexData = null; + }; + + Object.defineProperties( Mesh.prototype, prototypeAccessors ); + + return Mesh; + }(Container)); + + /** + * The maximum number of vertices to consider batchable. Generally, the complexity + * of the geometry. + * @memberof PIXI.Mesh + * @static + * @member {number} BATCHABLE_SIZE + */ + Mesh.BATCHABLE_SIZE = 100; + + var vertex$6 = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTextureMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\n}\n"; + + var fragment$8 = "varying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}\n"; + + /** + * Slightly opinionated default shader for PixiJS 2D objects. + * @class + * @memberof PIXI + * @extends PIXI.Shader + */ + var MeshMaterial = /*@__PURE__*/(function (Shader) { + function MeshMaterial(uSampler, options) + { + var uniforms = { + uSampler: uSampler, + alpha: 1, + uTextureMatrix: Matrix.IDENTITY, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + // Set defaults + options = Object.assign({ + tint: 0xFFFFFF, + alpha: 1, + pluginName: 'batch', + }, options); + + if (options.uniforms) + { + Object.assign(uniforms, options.uniforms); + } + + Shader.call(this, options.program || Program.from(vertex$6, fragment$8), uniforms); + + /** + * Only do update if tint or alpha changes. + * @member {boolean} + * @private + * @default false + */ + this._colorDirty = false; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(uSampler); + + /** + * `true` if shader can be batch with the renderer's batch system. + * @member {boolean} + * @default true + */ + this.batchable = options.program === undefined; + + /** + * Renderer plugin for batching + * + * @member {string} + * @default 'batch' + */ + this.pluginName = options.pluginName; + + this.tint = options.tint; + this.alpha = options.alpha; + } + + if ( Shader ) { MeshMaterial.__proto__ = Shader; } + MeshMaterial.prototype = Object.create( Shader && Shader.prototype ); + MeshMaterial.prototype.constructor = MeshMaterial; + + var prototypeAccessors = { texture: { configurable: true },alpha: { configurable: true },tint: { configurable: true } }; + + /** + * Reference to the texture being rendered. + * @member {PIXI.Texture} + */ + prototypeAccessors.texture.get = function () + { + return this.uniforms.uSampler; + }; + prototypeAccessors.texture.set = function (value) + { + if (this.uniforms.uSampler !== value) + { + this.uniforms.uSampler = value; + this.uvMatrix.texture = value; + } + }; + + /** + * This gets automatically set by the object using this. + * + * @default 1 + * @member {number} + */ + prototypeAccessors.alpha.set = function (value) + { + if (value === this._alpha) { return; } + + this._alpha = value; + this._colorDirty = true; + }; + prototypeAccessors.alpha.get = function () + { + return this._alpha; + }; + + /** + * Multiply tint for the material. + * @member {number} + * @default 0xFFFFFF + */ + prototypeAccessors.tint.set = function (value) + { + if (value === this._tint) { return; } + + this._tint = value; + this._tintRGB = (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); + this._colorDirty = true; + }; + prototypeAccessors.tint.get = function () + { + return this._tint; + }; + + /** + * Gets called automatically by the Mesh. Intended to be overridden for custom + * MeshMaterial objects. + */ + MeshMaterial.prototype.update = function update () + { + if (this._colorDirty) + { + this._colorDirty = false; + var baseTexture = this.texture.baseTexture; + + premultiplyTintToRgba(this._tint, this._alpha, this.uniforms.uColor, baseTexture.premultiplyAlpha); + } + if (this.uvMatrix.update()) + { + this.uniforms.uTextureMatrix = this.uvMatrix.mapCoord; + } + }; + + Object.defineProperties( MeshMaterial.prototype, prototypeAccessors ); + + return MeshMaterial; + }(Shader)); + + /** + * Standard 2D geometry used in PixiJS. + * + * Geometry can be defined without passing in a style or data if required. + * + * ```js + * const geometry = new PIXI.Geometry(); + * + * geometry.addAttribute('positions', [0, 0, 100, 0, 100, 100, 0, 100], 2); + * geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1], 2); + * geometry.addIndex([0,1,2,1,3,2]); + * + * ``` + * @class + * @memberof PIXI + * @extends PIXI.Geometry + */ + var MeshGeometry = /*@__PURE__*/(function (Geometry) { + function MeshGeometry(vertices, uvs, index) + { + Geometry.call(this); + + var verticesBuffer = new Buffer(vertices); + var uvsBuffer = new Buffer(uvs, true); + var indexBuffer = new Buffer(index, true, true); + + this.addAttribute('aVertexPosition', verticesBuffer, 2, false, TYPES.FLOAT) + .addAttribute('aTextureCoord', uvsBuffer, 2, false, TYPES.FLOAT) + .addIndex(indexBuffer); + + /** + * Dirty flag to limit update calls on Mesh. For example, + * limiting updates on a single Mesh instance with a shared Geometry + * within the render loop. + * @private + * @member {number} + * @default -1 + */ + this._updateId = -1; + } + + if ( Geometry ) { MeshGeometry.__proto__ = Geometry; } + MeshGeometry.prototype = Object.create( Geometry && Geometry.prototype ); + MeshGeometry.prototype.constructor = MeshGeometry; + + var prototypeAccessors = { vertexDirtyId: { configurable: true } }; + + /** + * If the vertex position is updated. + * @member {number} + * @readonly + * @private + */ + prototypeAccessors.vertexDirtyId.get = function () + { + return this.buffers[0]._updateID; + }; + + Object.defineProperties( MeshGeometry.prototype, prototypeAccessors ); + + return MeshGeometry; + }(Geometry)); + + /*! + * @pixi/mesh-extras - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/mesh-extras is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + var PlaneGeometry = /*@__PURE__*/(function (MeshGeometry) { + function PlaneGeometry(width, height, segWidth, segHeight) + { + if ( width === void 0 ) { width = 100; } + if ( height === void 0 ) { height = 100; } + if ( segWidth === void 0 ) { segWidth = 10; } + if ( segHeight === void 0 ) { segHeight = 10; } + + MeshGeometry.call(this); + + this.segWidth = segWidth; + this.segHeight = segHeight; + + this.width = width; + this.height = height; + + this.build(); + } + + if ( MeshGeometry ) { PlaneGeometry.__proto__ = MeshGeometry; } + PlaneGeometry.prototype = Object.create( MeshGeometry && MeshGeometry.prototype ); + PlaneGeometry.prototype.constructor = PlaneGeometry; + + /** + * Refreshes plane coordinates + * @private + */ + PlaneGeometry.prototype.build = function build () + { + var total = this.segWidth * this.segHeight; + var verts = []; + var uvs = []; + var indices = []; + + var segmentsX = this.segWidth - 1; + var segmentsY = this.segHeight - 1; + + var sizeX = (this.width) / segmentsX; + var sizeY = (this.height) / segmentsY; + + for (var i = 0; i < total; i++) + { + var x = (i % this.segWidth); + var y = ((i / this.segWidth) | 0); + + verts.push(x * sizeX, y * sizeY); + uvs.push(x / segmentsX, y / segmentsY); + } + + var totalSub = segmentsX * segmentsY; + + for (var i$1 = 0; i$1 < totalSub; i$1++) + { + var xpos = i$1 % segmentsX; + var ypos = (i$1 / segmentsX) | 0; + + var value = (ypos * this.segWidth) + xpos; + var value2 = (ypos * this.segWidth) + xpos + 1; + var value3 = ((ypos + 1) * this.segWidth) + xpos; + var value4 = ((ypos + 1) * this.segWidth) + xpos + 1; + + indices.push(value, value2, value3, + value2, value4, value3); + } + + this.buffers[0].data = new Float32Array(verts); + this.buffers[1].data = new Float32Array(uvs); + this.indexBuffer.data = new Uint16Array(indices); + + // ensure that the changes are uploaded + this.buffers[0].update(); + this.buffers[1].update(); + this.indexBuffer.update(); + }; + + return PlaneGeometry; + }(MeshGeometry)); + + /** + * RopeGeometry allows you to draw a geometry across several points and then manipulate these points. + * + * ```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * const rope = new PIXI.RopeGeometry(100, points); + * ``` + * + * @class + * @extends PIXI.MeshGeometry + * @memberof PIXI + * + */ + var RopeGeometry = /*@__PURE__*/(function (MeshGeometry) { + function RopeGeometry(width, points) + { + if ( width === void 0 ) { width = 200; } + + MeshGeometry.call(this, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array((points.length - 1) * 6)); + + /** + * An array of points that determine the rope + * @member {PIXI.Point[]} + */ + this.points = points; + + /** + * The width (i.e., thickness) of the rope. + * @member {number} + * @readOnly + */ + this.width = width; + + this.build(); + } + + if ( MeshGeometry ) { RopeGeometry.__proto__ = MeshGeometry; } + RopeGeometry.prototype = Object.create( MeshGeometry && MeshGeometry.prototype ); + RopeGeometry.prototype.constructor = RopeGeometry; + /** + * Refreshes Rope indices and uvs + * @private + */ + RopeGeometry.prototype.build = function build () + { + var points = this.points; + + if (!points) { return; } + + var vertexBuffer = this.getBuffer('aVertexPosition'); + var uvBuffer = this.getBuffer('aTextureCoord'); + var indexBuffer = this.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array((points.length - 1) * 6); + } + + var uvs = uvBuffer.data; + var indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + // indices[0] = 0; + // indices[1] = 1; + + var total = points.length; // - 1; + + for (var i = 0; i < total; i++) + { + // time to do some smart drawing! + var index = i * 4; + var amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + } + + var indexCount = 0; + + for (var i$1 = 0; i$1 < total - 1; i$1++) + { + var index$1 = i$1 * 2; + + indices[indexCount++] = index$1; + indices[indexCount++] = index$1 + 1; + indices[indexCount++] = index$1 + 2; + + indices[indexCount++] = index$1 + 2; + indices[indexCount++] = index$1 + 1; + indices[indexCount++] = index$1 + 3; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.updateVertices(); + }; + + /** + * refreshes vertices of Rope mesh + */ + RopeGeometry.prototype.updateVertices = function updateVertices () + { + var points = this.points; + + if (points.length < 1) + { + return; + } + + var lastPoint = points[0]; + var nextPoint; + var perpX = 0; + var perpY = 0; + + // this.count -= 0.2; + + var vertices = this.buffers[0].data; + var total = points.length; + + for (var i = 0; i < total; i++) + { + var point = points[i]; + var index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + var perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + var num = this.width / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.buffers[0].update(); + }; + + RopeGeometry.prototype.update = function update () + { + this.updateVertices(); + }; + + return RopeGeometry; + }(MeshGeometry)); + + /** + * The rope allows you to draw a texture across several points and then manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ + var SimpleRope = /*@__PURE__*/(function (Mesh) { + function SimpleRope(texture, points) + { + var ropeGeometry = new RopeGeometry(texture.height, points); + var meshMaterial = new MeshMaterial(texture); + + Mesh.call(this, ropeGeometry, meshMaterial); + + /** + * re-calculate vertices by rope points each frame + * + * @member {boolean} + */ + this.autoUpdate = true; + } + + if ( Mesh ) { SimpleRope.__proto__ = Mesh; } + SimpleRope.prototype = Object.create( Mesh && Mesh.prototype ); + SimpleRope.prototype.constructor = SimpleRope; + + SimpleRope.prototype._render = function _render (renderer) + { + if (this.autoUpdate + || this.geometry.width !== this.shader.texture.height) + { + this.geometry.width = this.shader.texture.height; + this.geometry.update(); + } + + Mesh.prototype._render.call(this, renderer); + }; + + return SimpleRope; + }(Mesh)); + + /** + * The SimplePlane allows you to draw a texture across several points and then manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let SimplePlane = new PIXI.SimplePlane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ + var SimplePlane = /*@__PURE__*/(function (Mesh) { + function SimplePlane(texture, verticesX, verticesY) + { + var planeGeometry = new PlaneGeometry(texture.width, texture.height, verticesX, verticesY); + var meshMaterial = new MeshMaterial(Texture.WHITE); + + Mesh.call(this, planeGeometry, meshMaterial); + + // lets call the setter to ensure all necessary updates are performed + this.texture = texture; + } + + if ( Mesh ) { SimplePlane.__proto__ = Mesh; } + SimplePlane.prototype = Object.create( Mesh && Mesh.prototype ); + SimplePlane.prototype.constructor = SimplePlane; + + var prototypeAccessors = { texture: { configurable: true } }; + + /** + * Method used for overrides, to do something in case texture frame was changed. + * Meshes based on plane can override it and change more details based on texture. + */ + SimplePlane.prototype.textureUpdated = function textureUpdated () + { + this._textureID = this.shader.texture._updateID; + + this.geometry.width = this.shader.texture.width; + this.geometry.height = this.shader.texture.height; + + this.geometry.build(); + }; + + prototypeAccessors.texture.set = function (value) + { + // Track texture same way sprite does. + // For generated meshes like NineSlicePlane it can change the geometry. + // Unfortunately, this method might not work if you directly change texture in material. + + if (this.shader.texture === value) + { + return; + } + + this.shader.texture = value; + this._textureID = -1; + + if (value.baseTexture.valid) + { + this.textureUpdated(); + } + else + { + value.once('update', this.textureUpdated, this); + } + }; + + prototypeAccessors.texture.get = function () + { + return this.shader.texture; + }; + + SimplePlane.prototype._render = function _render (renderer) + { + if (this._textureID !== this.shader.texture._updateID) + { + this.textureUpdated(); + } + + Mesh.prototype._render.call(this, renderer); + }; + + Object.defineProperties( SimplePlane.prototype, prototypeAccessors ); + + return SimplePlane; + }(Mesh)); + + /** + * The Simple Mesh class mimics Mesh in PixiJS v4, providing easy-to-use constructor arguments. + * For more robust customization, use {@link PIXI.Mesh}. + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + */ + var SimpleMesh = /*@__PURE__*/(function (Mesh) { + function SimpleMesh(texture, vertices, uvs, indices, drawMode) + { + if ( texture === void 0 ) { texture = Texture.EMPTY; } + + var geometry = new MeshGeometry(vertices, uvs, indices); + + geometry.getBuffer('aVertexPosition').static = false; + + var meshMaterial = new MeshMaterial(texture); + + Mesh.call(this, geometry, meshMaterial, null, drawMode); + + /** + * upload vertices buffer each frame + * @member {boolean} + */ + this.autoUpdate = true; + } + + if ( Mesh ) { SimpleMesh.__proto__ = Mesh; } + SimpleMesh.prototype = Object.create( Mesh && Mesh.prototype ); + SimpleMesh.prototype.constructor = SimpleMesh; + + var prototypeAccessors = { vertices: { configurable: true } }; + + /** + * Collection of vertices data. + * @member {Float32Array} + */ + prototypeAccessors.vertices.get = function () + { + return this.geometry.getBuffer('aVertexPosition').data; + }; + prototypeAccessors.vertices.set = function (value) + { + this.geometry.getBuffer('aVertexPosition').data = value; + }; + + SimpleMesh.prototype._render = function _render (renderer) + { + if (this.autoUpdate) + { + this.geometry.getBuffer('aVertexPosition').update(); + } + + Mesh.prototype._render.call(this, renderer); + }; + + Object.defineProperties( SimpleMesh.prototype, prototypeAccessors ); + + return SimpleMesh; + }(Mesh)); + + var DEFAULT_BORDER_SIZE = 10; + + /** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+	 *      A                          B
+	 *    +---+----------------------+---+
+	 *  C | 1 |          2           | 3 |
+	 *    +---+----------------------+---+
+	 *    |   |                      |   |
+	 *    | 4 |          5           | 6 |
+	 *    |   |                      |   |
+	 *    +---+----------------------+---+
+	 *  D | 7 |          8           | 9 |
+	 *    +---+----------------------+---+
+
+	 *  When changing this objects width and/or height:
+	 *     areas 1 3 7 and 9 will remain unscaled.
+	 *     areas 2 and 8 will be stretched horizontally
+	 *     areas 4 and 6 will be stretched vertically
+	 *     area 5 will be stretched both horizontally and vertically
+	 * 
+ * + * @class + * @extends PIXI.SimplePlane + * @memberof PIXI + * + */ + var NineSlicePlane = /*@__PURE__*/(function (SimplePlane) { + function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + SimplePlane.call(this, Texture.WHITE, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @private + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @private + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @private + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @private + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + // lets call the setter to ensure all necessary updates are performed + this.texture = texture; + } + + if ( SimplePlane ) { NineSlicePlane.__proto__ = SimplePlane; } + NineSlicePlane.prototype = Object.create( SimplePlane && SimplePlane.prototype ); + NineSlicePlane.prototype.constructor = NineSlicePlane; + + var prototypeAccessors = { vertices: { configurable: true },width: { configurable: true },height: { configurable: true },leftWidth: { configurable: true },rightWidth: { configurable: true },topHeight: { configurable: true },bottomHeight: { configurable: true } }; + + NineSlicePlane.prototype.textureUpdated = function textureUpdated () + { + this._textureID = this.shader.texture._updateID; + this._refresh(); + }; + + prototypeAccessors.vertices.get = function () + { + return this.geometry.getBuffer('aVertexPosition').data; + }; + + prototypeAccessors.vertices.set = function (value) + { + this.geometry.getBuffer('aVertexPosition').data = value; + }; + + /** + * Updates the horizontal vertices. + * + */ + NineSlicePlane.prototype.updateHorizontalVertices = function updateHorizontalVertices () + { + var vertices = this.vertices; + + var h = this._topHeight + this._bottomHeight; + var scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + }; + + /** + * Updates the vertical vertices. + * + */ + NineSlicePlane.prototype.updateVerticalVertices = function updateVerticalVertices () + { + var vertices = this.vertices; + + var w = this._leftWidth + this._rightWidth; + var scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + }; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + prototypeAccessors.width.get = function () + { + return this._width; + }; + + prototypeAccessors.width.set = function (value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + }; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + prototypeAccessors.height.get = function () + { + return this._height; + }; + + prototypeAccessors.height.set = function (value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + }; + + /** + * The width of the left column + * + * @member {number} + */ + prototypeAccessors.leftWidth.get = function () + { + return this._leftWidth; + }; + + prototypeAccessors.leftWidth.set = function (value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + }; + + /** + * The width of the right column + * + * @member {number} + */ + prototypeAccessors.rightWidth.get = function () + { + return this._rightWidth; + }; + + prototypeAccessors.rightWidth.set = function (value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + }; + + /** + * The height of the top row + * + * @member {number} + */ + prototypeAccessors.topHeight.get = function () + { + return this._topHeight; + }; + + prototypeAccessors.topHeight.set = function (value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + }; + + /** + * The height of the bottom row + * + * @member {number} + */ + prototypeAccessors.bottomHeight.get = function () + { + return this._bottomHeight; + }; + + prototypeAccessors.bottomHeight.set = function (value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + }; + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + NineSlicePlane.prototype._refresh = function _refresh () + { + var texture = this.texture; + + var uvs = this.geometry.buffers[1].data; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + var _uvw = 1.0 / this._origWidth; + var _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + }; + + Object.defineProperties( NineSlicePlane.prototype, prototypeAccessors ); + + return NineSlicePlane; + }(SimplePlane)); + + /*! + * @pixi/sprite-animated - v5.0.0-rc.3 + * Compiled Tue, 30 Apr 2019 02:21:00 UTC + * + * @pixi/sprite-animated is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */ + + /** + * An AnimatedSprite is a simple way to display an animation depicted by a list of textures. + * + * ```js + * let alienImages = ["image_sequence_01.png","image_sequence_02.png","image_sequence_03.png","image_sequence_04.png"]; + * let textureArray = []; + * + * for (let i=0; i < 4; i++) + * { + * let texture = PIXI.Texture.from(alienImages[i]); + * textureArray.push(texture); + * }; + * + * let animatedSprite = new PIXI.AnimatedSprite(textureArray); + * ``` + * + * The more efficient and simpler way to create an animated sprite is using a {@link PIXI.Spritesheet} + * containing the animation definitions: + * + * ```js + * PIXI.Loader.shared.add("assets/spritesheet.json").load(setup); + * + * function setup() { + * let sheet = PIXI.Loader.shared.resources["assets/spritesheet.json"].spritesheet; + * animatedSprite = new PIXI.AnimatedSprite(sheet.animations["image_sequence"]); + * ... + * } + * ``` + * + * @class + * @extends PIXI.Sprite + * @memberof PIXI + */ + var AnimatedSprite = /*@__PURE__*/(function (Sprite) { + function AnimatedSprite(textures, autoUpdate) + { + Sprite.call(this, textures[0] instanceof Texture ? textures[0] : textures[0].texture); + + /** + * @type {PIXI.Texture[]} + * @private + */ + this._textures = null; + + /** + * @type {number[]} + * @private + */ + this._durations = null; + + this.textures = textures; + + /** + * `true` uses PIXI.Ticker.shared to auto update animation time. + * @type {boolean} + * @default true + * @private + */ + this._autoUpdate = autoUpdate !== false; + + /** + * The speed that the AnimatedSprite will play at. Higher is faster, lower is slower. + * + * @member {number} + * @default 1 + */ + this.animationSpeed = 1; + + /** + * Whether or not the animate sprite repeats after playing. + * + * @member {boolean} + * @default true + */ + this.loop = true; + + /** + * Update anchor to [Texture's defaultAnchor]{@link PIXI.Texture#defaultAnchor} when frame changes. + * + * Useful with [sprite sheet animations]{@link PIXI.Spritesheet#animations} created with tools. + * Changing anchor for each frame allows to pin sprite origin to certain moving feature + * of the frame (e.g. left foot). + * + * Note: Enabling this will override any previously set `anchor` on each frame change. + * + * @member {boolean} + * @default false + */ + this.updateAnchor = false; + + /** + * Function to call when an AnimatedSprite finishes playing. + * + * @member {Function} + */ + this.onComplete = null; + + /** + * Function to call when an AnimatedSprite changes which texture is being rendered. + * + * @member {Function} + */ + this.onFrameChange = null; + + /** + * Function to call when `loop` is true, and an AnimatedSprite is played and loops around to start again. + * + * @member {Function} + */ + this.onLoop = null; + + /** + * Elapsed time since animation has been started, used internally to display current texture. + * + * @member {number} + * @private + */ + this._currentTime = 0; + + /** + * Indicates if the AnimatedSprite is currently playing. + * + * @member {boolean} + * @readonly + */ + this.playing = false; + } + + if ( Sprite ) { AnimatedSprite.__proto__ = Sprite; } + AnimatedSprite.prototype = Object.create( Sprite && Sprite.prototype ); + AnimatedSprite.prototype.constructor = AnimatedSprite; + + var prototypeAccessors = { totalFrames: { configurable: true },textures: { configurable: true },currentFrame: { configurable: true } }; + + /** + * Stops the AnimatedSprite. + * + */ + AnimatedSprite.prototype.stop = function stop () + { + if (!this.playing) + { + return; + } + + this.playing = false; + if (this._autoUpdate) + { + Ticker.shared.remove(this.update, this); + } + }; + + /** + * Plays the AnimatedSprite. + * + */ + AnimatedSprite.prototype.play = function play () + { + if (this.playing) + { + return; + } + + this.playing = true; + if (this._autoUpdate) + { + Ticker.shared.add(this.update, this, UPDATE_PRIORITY.HIGH); + } + }; + + /** + * Stops the AnimatedSprite and goes to a specific frame. + * + * @param {number} frameNumber - Frame index to stop at. + */ + AnimatedSprite.prototype.gotoAndStop = function gotoAndStop (frameNumber) + { + this.stop(); + + var previousFrame = this.currentFrame; + + this._currentTime = frameNumber; + + if (previousFrame !== this.currentFrame) + { + this.updateTexture(); + } + }; + + /** + * Goes to a specific frame and begins playing the AnimatedSprite. + * + * @param {number} frameNumber - Frame index to start at. + */ + AnimatedSprite.prototype.gotoAndPlay = function gotoAndPlay (frameNumber) + { + var previousFrame = this.currentFrame; + + this._currentTime = frameNumber; + + if (previousFrame !== this.currentFrame) + { + this.updateTexture(); + } + + this.play(); + }; + + /** + * Updates the object transform for rendering. + * + * @private + * @param {number} deltaTime - Time since last tick. + */ + AnimatedSprite.prototype.update = function update (deltaTime) + { + var elapsed = this.animationSpeed * deltaTime; + var previousFrame = this.currentFrame; + + if (this._durations !== null) + { + var lag = this._currentTime % 1 * this._durations[this.currentFrame]; + + lag += elapsed / 60 * 1000; + + while (lag < 0) + { + this._currentTime--; + lag += this._durations[this.currentFrame]; + } + + var sign = Math.sign(this.animationSpeed * deltaTime); + + this._currentTime = Math.floor(this._currentTime); + + while (lag >= this._durations[this.currentFrame]) + { + lag -= this._durations[this.currentFrame] * sign; + this._currentTime += sign; + } + + this._currentTime += lag / this._durations[this.currentFrame]; + } + else + { + this._currentTime += elapsed; + } + + if (this._currentTime < 0 && !this.loop) + { + this.gotoAndStop(0); + + if (this.onComplete) + { + this.onComplete(); + } + } + else if (this._currentTime >= this._textures.length && !this.loop) + { + this.gotoAndStop(this._textures.length - 1); + + if (this.onComplete) + { + this.onComplete(); + } + } + else if (previousFrame !== this.currentFrame) + { + if (this.loop && this.onLoop) + { + if (this.animationSpeed > 0 && this.currentFrame < previousFrame) + { + this.onLoop(); + } + else if (this.animationSpeed < 0 && this.currentFrame > previousFrame) + { + this.onLoop(); + } + } + + this.updateTexture(); + } + }; + + /** + * Updates the displayed texture to match the current frame index. + * + * @private + */ + AnimatedSprite.prototype.updateTexture = function updateTexture () + { + this._texture = this._textures[this.currentFrame]; + this._textureID = -1; + this._textureTrimmedID = -1; + this.cachedTint = 0xFFFFFF; + this.uvs = this._texture._uvs.uvsFloat32; + + if (this.updateAnchor) + { + this._anchor.copy(this._texture.defaultAnchor); + } + + if (this.onFrameChange) + { + this.onFrameChange(this.currentFrame); + } + }; + + /** + * Stops the AnimatedSprite and destroys it. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options + * have been set to that value. + * @param {boolean} [options.children=false] - If set to true, all the children will have their destroy + * method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well. + * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well. + */ + AnimatedSprite.prototype.destroy = function destroy (options) + { + this.stop(); + Sprite.prototype.destroy.call(this, options); + + this.onComplete = null; + this.onFrameChange = null; + this.onLoop = null; + }; + + /** + * A short hand way of creating an AnimatedSprite from an array of frame ids. + * + * @static + * @param {string[]} frames - The array of frames ids the AnimatedSprite will use as its texture frames. + * @return {AnimatedSprite} The new animated sprite with the specified frames. + */ + AnimatedSprite.fromFrames = function fromFrames (frames) + { + var textures = []; + + for (var i = 0; i < frames.length; ++i) + { + textures.push(Texture.from(frames[i])); + } + + return new AnimatedSprite(textures); + }; + + /** + * A short hand way of creating an AnimatedSprite from an array of image ids. + * + * @static + * @param {string[]} images - The array of image urls the AnimatedSprite will use as its texture frames. + * @return {AnimatedSprite} The new animate sprite with the specified images as frames. + */ + AnimatedSprite.fromImages = function fromImages (images) + { + var textures = []; + + for (var i = 0; i < images.length; ++i) + { + textures.push(Texture.from(images[i])); + } + + return new AnimatedSprite(textures); + }; + + /** + * The total number of frames in the AnimatedSprite. This is the same as number of textures + * assigned to the AnimatedSprite. + * + * @readonly + * @member {number} + * @default 0 + */ + prototypeAccessors.totalFrames.get = function () + { + return this._textures.length; + }; + + /** + * The array of textures used for this AnimatedSprite. + * + * @member {PIXI.Texture[]} + */ + prototypeAccessors.textures.get = function () + { + return this._textures; + }; + + prototypeAccessors.textures.set = function (value) // eslint-disable-line require-jsdoc + { + if (value[0] instanceof Texture) + { + this._textures = value; + this._durations = null; + } + else + { + this._textures = []; + this._durations = []; + + for (var i = 0; i < value.length; i++) + { + this._textures.push(value[i].texture); + this._durations.push(value[i].time); + } + } + this.gotoAndStop(0); + this.updateTexture(); + }; + + /** + * The AnimatedSprites current frame index. + * + * @member {number} + * @readonly + */ + prototypeAccessors.currentFrame.get = function () + { + var currentFrame = Math.floor(this._currentTime) % this._textures.length; + + if (currentFrame < 0) + { + currentFrame += this._textures.length; + } + + return currentFrame; + }; + + Object.defineProperties( AnimatedSprite.prototype, prototypeAccessors ); + + return AnimatedSprite; + }(Sprite)); + + // Install renderer plugins + Renderer.registerPlugin('accessibility', AccessibilityManager); + Renderer.registerPlugin('extract', Extract); + Renderer.registerPlugin('interaction', InteractionManager); + Renderer.registerPlugin('particle', ParticleRenderer); + Renderer.registerPlugin('prepare', Prepare); + Renderer.registerPlugin('batch', BatchRenderer); + Renderer.registerPlugin('tilingSprite', TilingSpriteRenderer); + + Loader$2.registerPlugin(BitmapFontLoader); + Loader$2.registerPlugin(SpritesheetLoader); + + Application.registerPlugin(TickerPlugin); + Application.registerPlugin(AppLoaderPlugin); + + /** + * String of the current PIXI version. + * + * @static + * @constant + * @memberof PIXI + * @name VERSION + * @type {string} + */ + var VERSION$1 = '5.0.0-rc.3'; + + /** + * @namespace PIXI + */ + + /** + * This namespace contains WebGL-only display filters that can be applied + * to DisplayObjects using the {@link PIXI.DisplayObject#filters filters} property. + * + * Since PixiJS only had a handful of built-in filters, additional filters + * can be downloaded {@link https://github.com/pixijs/pixi-filters here} from the + * PixiJS Filters repository. + * + * All filters must extend {@link PIXI.Filter}. + * + * @example + * // Create a new application + * const app = new PIXI.Application(); + * + * // Draw a green rectangle + * const rect = new PIXI.Graphics() + * .beginFill(0x00ff00) + * .drawRect(40, 40, 200, 200); + * + * // Add a blur filter + * rect.filters = [new PIXI.filters.BlurFilter()]; + * + * // Display rectangle + * app.stage.addChild(rect); + * document.body.appendChild(app.view); + * @namespace PIXI.filters + */ + var filters = { + AlphaFilter: AlphaFilter, + BlurFilter: BlurFilter, + BlurFilterPass: BlurFilterPass, + ColorMatrixFilter: ColorMatrixFilter, + DisplacementFilter: DisplacementFilter, + FXAAFilter: FXAAFilter, + NoiseFilter: NoiseFilter, + }; + + exports.AbstractRenderer = AbstractRenderer; + exports.AnimatedSprite = AnimatedSprite; + exports.AppLoaderPlugin = AppLoaderPlugin; + exports.Application = Application; + exports.Attribute = Attribute; + exports.BLEND_MODES = BLEND_MODES; + exports.BaseRenderTexture = BaseRenderTexture; + exports.BaseTexture = BaseTexture; + exports.BatchDrawCall = BatchDrawCall; + exports.BatchGeometry = BatchGeometry; + exports.BatchRenderer = BatchRenderer; + exports.BitmapFontLoader = BitmapFontLoader; + exports.BitmapText = BitmapText; + exports.Bounds = Bounds; + exports.Buffer = Buffer; + exports.Circle = Circle; + exports.Container = Container; + exports.CubeTexture = CubeTexture; + exports.DEG_TO_RAD = DEG_TO_RAD; + exports.DRAW_MODES = DRAW_MODES; + exports.DisplayObject = DisplayObject; + exports.ENV = ENV; + exports.Ellipse = Ellipse; + exports.FORMATS = FORMATS; + exports.FillStyle = FillStyle; + exports.Filter = Filter; + exports.Framebuffer = Framebuffer; + exports.GC_MODES = GC_MODES; + exports.GLProgram = GLProgram; + exports.GLTexture = BaseTexture; + exports.GRAPHICS_CURVES = GRAPHICS_CURVES; + exports.Geometry = Geometry; + exports.Graphics = Graphics; + exports.GraphicsData = GraphicsData; + exports.GraphicsGeometry = GraphicsGeometry; + exports.GroupD8 = GroupD8; + exports.LineStyle = LineStyle; + exports.Loader = Loader$2; + exports.LoaderResource = LoaderResource; + exports.MIPMAP_MODES = MIPMAP_MODES; + exports.Matrix = Matrix; + exports.Mesh = Mesh; + exports.MeshBatchUvs = MeshBatchUvs; + exports.MeshGeometry = MeshGeometry; + exports.MeshMaterial = MeshMaterial; + exports.NineSlicePlane = NineSlicePlane; + exports.ObjectRenderer = ObjectRenderer; + exports.ObservablePoint = ObservablePoint; + exports.PI_2 = PI_2; + exports.PRECISION = PRECISION; + exports.ParticleContainer = ParticleContainer; + exports.ParticleRenderer = ParticleRenderer; + exports.PlaneGeometry = PlaneGeometry; + exports.Point = Point; + exports.Polygon = Polygon; + exports.Program = Program; + exports.Quad = Quad; + exports.QuadUv = QuadUv; + exports.RAD_TO_DEG = RAD_TO_DEG; + exports.RENDERER_TYPE = RENDERER_TYPE; + exports.Rectangle = Rectangle; + exports.RenderTexture = RenderTexture; + exports.Renderer = Renderer; + exports.RopeGeometry = RopeGeometry; + exports.RoundedRectangle = RoundedRectangle; + exports.Runner = Runner; + exports.SCALE_MODES = SCALE_MODES; + exports.SHAPES = SHAPES; + exports.Shader = Shader; + exports.SimpleMesh = SimpleMesh; + exports.SimplePlane = SimplePlane; + exports.SimpleRope = SimpleRope; + exports.Sprite = Sprite; + exports.SpriteMaskFilter = SpriteMaskFilter; + exports.Spritesheet = Spritesheet; + exports.SpritesheetLoader = SpritesheetLoader; + exports.State = State; + exports.System = System; + exports.TARGETS = TARGETS; + exports.TEXT_GRADIENT = TEXT_GRADIENT; + exports.TYPES = TYPES; + exports.Text = Text; + exports.TextMetrics = TextMetrics; + exports.TextStyle = TextStyle; + exports.Texture = Texture; + exports.TextureLoader = TextureLoader; + exports.TextureMatrix = TextureMatrix; + exports.TextureUvs = TextureUvs; + exports.Ticker = Ticker; + exports.TickerPlugin = TickerPlugin; + exports.TilingSprite = TilingSprite; + exports.TilingSpriteRenderer = TilingSpriteRenderer; + exports.Transform = Transform; + exports.UPDATE_PRIORITY = UPDATE_PRIORITY; + exports.UniformGroup = UniformGroup; + exports.VERSION = VERSION$1; + exports.WRAP_MODES = WRAP_MODES; + exports.accessibility = accessibility_es; + exports.autoDetectRenderer = autoDetectRenderer; + exports.checkMaxIfStatementsInShader = checkMaxIfStatementsInShader; + exports.defaultFilterVertex = defaultFilter; + exports.defaultVertex = _default; + exports.extract = extract_es; + exports.filters = filters; + exports.generateMultiTextureShader = generateMultiTextureShader; + exports.interaction = interaction_es; + exports.isMobile = isMobile_min; + exports.prepare = prepare_es; + exports.resources = index; + exports.settings = settings; + exports.systems = systems; + exports.useDeprecated = useDeprecated; + exports.utils = utils_es; + + return exports; + +}({})); +PIXI.useDeprecated(); var e;e||(e=eval("(function() { try { return Module || {} } catch(e) { return {} } })()"));var aa={},k;for(k in e)e.hasOwnProperty(k)&&(aa[k]=e[k]);var ba="object"===typeof window,ca="function"===typeof importScripts,da="object"===typeof process&&"function"===typeof require&&!ba&&!ca,ea=!ba&&!da&&!ca; diff --git a/dist/iwmlib.3rdparty.min.js b/dist/iwmlib.3rdparty.min.js index a6928c2..cfe5891 100644 --- a/dist/iwmlib.3rdparty.min.js +++ b/dist/iwmlib.3rdparty.min.js @@ -1 +1 @@ -var e;!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.OptimalSelect=t():e.OptimalSelect=t()}(this,function(){return function(r){var i={};function n(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,n),t.l=!0,t.exports}return n.m=r,n.c=i,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertNodeList=function(e){for(var t=e.length,r=new Array(t),i=0;i@~]/g,"\\$&").replace(/\n/g,"A")}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getCommonAncestor=function(e){var t=(1 /g,">").split(/\s+(?=(?:(?:[^"]*"){2})*[^"]*$)/);if(i.length<2)return h("",e,"",t);var n=[i.pop()];for(;1/g,"> ").trim()};var i,n=r(3),f=(i=n)&&i.__esModule?i:{default:i},l=r(0);function h(r,i,n,o){if(r.length&&(r+=" "),n.length&&(n=" "+n),/\[*\]/.test(i)){var e=i.replace(/=.*$/,"]"),a=""+r+e+n;if(m(document.querySelectorAll(a),o))i=e;else for(var s=document.querySelectorAll(""+r+e),t=function(){var t=s[u];if(o.some(function(e){return t.contains(e)})){var e=t.tagName.toLowerCase();return a=""+r+e+n,m(document.querySelectorAll(a),o)&&(i=e),"break"}},u=0,c=s.length;u/.test(i)){var f=i.replace(/>/,"");a=""+r+f+n;m(document.querySelectorAll(a),o)&&(i=f)}if(/:nth-child/.test(i)){var l=i.replace(/nth-child/g,"nth-of-type");a=""+r+l+n;m(document.querySelectorAll(a),o)&&(i=l)}if(/\.\S+\.\S+/.test(i)){for(var h=i.trim().split(".").slice(1).map(function(e){return"."+e}).sort(function(e,t){return e.length-t.length});h.length;){var d=i.replace(h.shift(),"").trim();if(!(a=(""+r+d+n).trim()).length||">"===a.charAt(0)||">"===a.charAt(a.length-1))break;m(document.querySelectorAll(a),o)&&(i=d)}if((h=i&&i.match(/\./g))&&2/.test(s):c=function(t){return function(e){return e(t.parent)&&t.parent}};break;case/^\./.test(s):var r=s.substr(1).split(".");u=function(e){var t=e.attribs.class;return t&&r.every(function(e){return-1)(\S)/g,"$1 $2").trim()),t=i.shift(),n=i.length;return t(this).filter(function(e){for(var t=0;t\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=o.console&&(o.console.warn||o.console.log);return r&&r.call(o.console,n,t),i.apply(this,arguments)}}a="function"!=typeof Object.assign?function(e){if(e===l||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;rt[r]}):i.sort()),i}function A(e,t){for(var r,i,n=t[0].toUpperCase()+t.slice(1),o=0;oh(c.y)?c.x:c.y,t.scale=a?function(e,t){return ie(t[0],t[1],J)/ie(e[0],e[1],J)}(a.pointers,i):1,t.rotation=a?function(e,t){return ne(t[1],t[0],J)+ne(e[1],e[0],J)}(a.pointers,i):0,t.maxPointers=r.prevInput?t.pointers.length>r.prevInput.maxPointers?t.pointers.length:r.prevInput.maxPointers:t.pointers.length,function(e,t){var r,i,n,o,a=e.lastInterval||t,s=t.timeStamp-a.timeStamp;if(t.eventType!=U&&(Fh(f.y)?f.x:f.y,o=re(u,c),e.lastInterval=t}else r=a.velocity,i=a.velocityX,n=a.velocityY,o=a.direction;t.velocity=r,t.velocityX=i,t.velocityY=n,t.direction=o}(r,t);var f=e.element;T(t.srcEvent.target,f)&&(f=t.srcEvent.target);t.target=f}(e,r),e.emit("hammer.input",r),e.recognize(r),e.session.prevInput=r}function $(e){for(var t=[],r=0;r=h(t)?e<0?X:q:t<0?G:H}function ie(e,t,r){r||(r=K);var i=t[r[0]]-e[r[0]],n=t[r[1]]-e[r[1]];return Math.sqrt(i*i+n*n)}function ne(e,t,r){r||(r=K);var i=t[r[0]]-e[r[0]],n=t[r[1]]-e[r[1]];return 180*Math.atan2(n,i)/Math.PI}Z.prototype={handler:function(){},init:function(){this.evEl&&w(this.element,this.evEl,this.domHandler),this.evTarget&&w(this.target,this.evTarget,this.domHandler),this.evWin&&w(I(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(I(this.element),this.evWin,this.domHandler)}};var oe={mousedown:B,mousemove:2,mouseup:N},ae="mousedown",se="mousemove mouseup";function ue(){this.evEl=ae,this.evWin=se,this.pressed=!1,Z.apply(this,arguments)}b(ue,Z,{handler:function(e){var t=oe[e.type];t&B&&0===e.button&&(this.pressed=!0),2&t&&1!==e.which&&(t=N),this.pressed&&(t&N&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:j,srcEvent:e}))}});var ce={pointerdown:B,pointermove:2,pointerup:N,pointercancel:U,pointerout:U},fe={2:L,3:"pen",4:j,5:"kinect"},le="pointerdown",he="pointermove pointerup pointercancel";function de(){this.evEl=le,this.evWin=he,Z.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}o.MSPointerEvent&&!o.PointerEvent&&(le="MSPointerDown",he="MSPointerMove MSPointerUp MSPointerCancel"),b(de,Z,{handler:function(e){var t=this.store,r=!1,i=e.type.toLowerCase().replace("ms",""),n=ce[i],o=fe[e.pointerType]||e.pointerType,a=o==L,s=M(t,e.pointerId,"pointerId");n&B&&(0===e.button||a)?s<0&&(t.push(e),s=t.length-1):n&(N|U)&&(r=!0),s<0||(t[s]=e,this.callback(this.manager,n,{pointers:t,changedPointers:[e],pointerType:o,srcEvent:e}),r&&t.splice(s,1))}});var pe={touchstart:B,touchmove:2,touchend:N,touchcancel:U};function ve(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Z.apply(this,arguments)}b(ve,Z,{handler:function(e){var t=pe[e.type];if(t===B&&(this.started=!0),this.started){var r=function(e,t){var r=C(e.touches),i=C(e.changedTouches);t&(N|U)&&(r=P(r.concat(i),"identifier",!0));return[r,i]}.call(this,e,t);t&(N|U)&&r[0].length-r[1].length==0&&(this.started=!1),this.callback(this.manager,t,{pointers:r[0],changedPointers:r[1],pointerType:L,srcEvent:e})}}});var me={touchstart:B,touchmove:2,touchend:N,touchcancel:U},be="touchstart touchmove touchend touchcancel";function ge(){this.evTarget=be,this.targetIds={},Z.apply(this,arguments)}b(ge,Z,{handler:function(e){var t=me[e.type],r=function(e,t){var r=C(e.touches),i=this.targetIds;if(t&(2|B)&&1===r.length)return i[r[0].identifier]=!0,[r,r];var n,o,a=C(e.changedTouches),s=[],u=this.target;if(o=r.filter(function(e){return T(e.target,u)}),t===B)for(n=0;nt.threshold&&n&t.direction},attrTest:function(e){return je.prototype.attrTest.call(this,e)&&(2&this.state||!(2&this.state)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=De(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}}),b(Be,je,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Me]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||2&this.state)},emit:function(e){if(1!==e.scale){var t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}}),b(Ne,Re,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return["auto"]},process:function(e){var t=this.options,r=e.pointers.length===t.pointers,i=e.distancet.time;if(this._input=e,!i||!r||e.eventType&(N|U)&&!n)this.reset();else if(e.eventType&B)this.reset(),this._timer=c(function(){this.state=8,this.tryEmit()},t.time,this);else if(e.eventType&N)return 8;return 32},reset:function(){clearTimeout(this._timer)},emit:function(e){8===this.state&&(e&&e.eventType&N?this.manager.emit(this.options.event+"up",e):(this._input.timeStamp=d(),this.manager.emit(this.options.event,this._input)))}}),b(Ue,je,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Me]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||2&this.state)}}),b(ze,je,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:V|W,pointers:1},getTouchAction:function(){return Fe.prototype.getTouchAction.call(this)},attrTest:function(e){var t,r=this.options.direction;return r&(V|W)?t=e.overallVelocity:r&V?t=e.overallVelocityX:r&W&&(t=e.overallVelocityY),this._super.attrTest.call(this,e)&&r&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&h(t)>this.options.velocity&&e.eventType&N},emit:function(e){var t=De(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}}),b(Xe,Re,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Ee]},process:function(e){var t=this.options,r=e.pointers.length===t.pointers,i=e.distance]+>|\t|)+|(?:\n)))/gm,y="",_={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};function w(e){return e.replace(/&/g,"&").replace(//g,">")}function h(e){return e.nodeName.toLowerCase()}function x(e,t){var r=e&&e.exec(t);return r&&0===r.index}function f(e){return t.test(e)}function d(e){var t,r={},i=Array.prototype.slice.call(arguments,1);for(t in e)r[t]=e[t];return i.forEach(function(e){for(t in e)r[t]=e[t]}),r}function p(e){var n=[];return function e(t,r){for(var i=t.firstChild;i;i=i.nextSibling)3===i.nodeType?r+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:r,node:i}),r=e(i,r),h(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:r,node:i}));return r}(e,0),n}function o(e){if(r&&!e.langApiRestored){for(var t in e.langApiRestored=!0,r)e[t]&&(e[r[t]]=e[t]);(e.contains||[]).concat(e.variants||[]).forEach(o)}}function T(a){function c(e){return e&&e.source||e}function s(e,t){return new RegExp(c(e),"m"+(a.case_insensitive?"i":"")+(t?"g":""))}!function t(r,e){if(!r.compiled){if(r.compiled=!0,r.keywords=r.keywords||r.beginKeywords,r.keywords){var i={},n=function(r,e){a.case_insensitive&&(e=e.toLowerCase()),e.split(" ").forEach(function(e){var t=e.split("|");i[t[0]]=[r,t[1]?Number(t[1]):1]})};"string"==typeof r.keywords?n("keyword",r.keywords):u(r.keywords).forEach(function(e){n(e,r.keywords[e])}),r.keywords=i}r.lexemesRe=s(r.lexemes||/\w+/,!0),e&&(r.beginKeywords&&(r.begin="\\b("+r.beginKeywords.split(" ").join("|")+")\\b"),r.begin||(r.begin=/\B|\b/),r.beginRe=s(r.begin),r.endSameAsBegin&&(r.end=r.begin),r.end||r.endsWithParent||(r.end=/\B|\b/),r.end&&(r.endRe=s(r.end)),r.terminator_end=c(r.end)||"",r.endsWithParent&&e.terminator_end&&(r.terminator_end+=(r.end?"|":"")+e.terminator_end)),r.illegal&&(r.illegalRe=s(r.illegal)),null==r.relevance&&(r.relevance=1),r.contains||(r.contains=[]),r.contains=Array.prototype.concat.apply([],r.contains.map(function(e){return function(t){return t.variants&&!t.cached_variants&&(t.cached_variants=t.variants.map(function(e){return d(t,{variants:null},e)})),t.cached_variants||t.endsWithParent&&[d(t)]||[t]}("self"===e?r:e)})),r.contains.forEach(function(e){t(e,r)}),r.starts&&t(r.starts,e);var o=r.contains.map(function(e){return e.beginKeywords?"\\.?(?:"+e.begin+")\\.?":e.begin}).concat([r.terminator_end,r.illegal]).map(c).filter(Boolean);r.terminators=o.length?s(function(e,t){for(var r=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,i=0,n="",o=0;o')+t+(r?"":y)}function a(){h+=null!=f.subLanguage?function(){var e="string"==typeof f.subLanguage;if(e&&!g[f.subLanguage])return w(d);var t=e?S(f.subLanguage,d,!0,l[f.subLanguage]):E(d,f.subLanguage.length?f.subLanguage:void 0);return 0")+'"');return d+=t,t.length||1}var c=M(e);if(!c)throw new Error('Unknown language: "'+e+'"');T(c);var n,f=r||c,l={},h="";for(n=f;n!==c;n=n.parent)n.className&&(h=s(n.className,"",!0)+h);var d="",p=0;try{for(var v,m,b=0;f.terminators.lastIndex=b,v=f.terminators.exec(t);)m=i(t.substring(b,v.index),v[0]),b=v.index+m;for(i(t.substr(b)),n=f;n.parent;n=n.parent)n.className&&(h+=y);return{relevance:p,value:h,language:e,top:f}}catch(e){if(e.message&&-1!==e.message.indexOf("Illegal"))return{relevance:0,value:w(t)};throw e}}function E(r,e){e=e||_.languages||u(g);var i={relevance:0,value:w(r)},n=i;return e.filter(M).filter(b).forEach(function(e){var t=S(e,r,!1);t.language=e,t.relevance>n.relevance&&(n=t),t.relevance>i.relevance&&(n=i,i=t)}),n.language&&(i.second_best=n),i}function v(e){return _.tabReplace||_.useBR?e.replace(i,function(e,t){return _.useBR&&"\n"===e?"
":_.tabReplace?t.replace(/\t/g,_.tabReplace):""}):e}function a(e){var t,r,i,n,o,a=function(e){var t,r,i,n,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",r=c.exec(o))return M(r[1])?r[1]:"no-highlight";for(t=0,i=(o=o.split(/\s+/)).length;t/g,"\n"):t=e,o=t.textContent,i=a?S(a,o,!0):E(o),(r=p(t)).length&&((n=document.createElementNS("http://www.w3.org/1999/xhtml","div")).innerHTML=i.value,i.value=function(e,t,r){var i=0,n="",o=[];function a(){return e.length&&t.length?e[0].offset!==t[0].offset?e[0].offset"}function u(e){n+=""}function c(e){("start"===e.event?s:u)(e.node)}for(;e.length||t.length;){var f=a();if(n+=w(r.substring(i,f[0].offset)),i=f[0].offset,f===e){for(o.reverse().forEach(u);c(f.splice(0,1)[0]),(f=a())===e&&f.length&&f[0].offset===i;);o.reverse().forEach(s)}else"start"===f[0].event?o.push(f[0].node):o.pop(),c(f.splice(0,1)[0])}return n+w(r.substr(i))}(r,p(n),o)),i.value=v(i.value),e.innerHTML=i.value,e.className=function(e,t,r){var i=t?s[t]:r,n=[e.trim()];return e.match(/\bhljs\b/)||n.push("hljs"),-1===e.indexOf(i)&&n.push(i),n.join(" ").trim()}(e.className,a,i.language),e.result={language:i.language,re:i.relevance},i.second_best&&(e.second_best={language:i.second_best.language,re:i.second_best.relevance}))}function m(){if(!m.called){m.called=!0;var e=document.querySelectorAll("pre code");l.forEach.call(e,a)}}function M(e){return e=(e||"").toLowerCase(),g[e]||g[s[e]]}function b(e){var t=M(e);return t&&!t.disableAutodetect}return n.highlight=S,n.highlightAuto=E,n.fixMarkup=v,n.highlightBlock=a,n.configure=function(e){_=d(_,e)},n.initHighlighting=m,n.initHighlightingOnLoad=function(){addEventListener("DOMContentLoaded",m,!1),addEventListener("load",m,!1)},n.registerLanguage=function(t,e){var r=g[t]=e(n);o(r),r.aliases&&r.aliases.forEach(function(e){s[e]=t})},n.listLanguages=function(){return u(g)},n.getLanguage=M,n.autoDetection=b,n.inherit=d,n.IDENT_RE="[a-zA-Z]\\w*",n.UNDERSCORE_IDENT_RE="[a-zA-Z_]\\w*",n.NUMBER_RE="\\b\\d+(\\.\\d+)?",n.C_NUMBER_RE="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",n.BINARY_NUMBER_RE="\\b(0b[01]+)",n.RE_STARTERS_RE="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",n.BACKSLASH_ESCAPE={begin:"\\\\[\\s\\S]",relevance:0},n.APOS_STRING_MODE={className:"string",begin:"'",end:"'",illegal:"\\n",contains:[n.BACKSLASH_ESCAPE]},n.QUOTE_STRING_MODE={className:"string",begin:'"',end:'"',illegal:"\\n",contains:[n.BACKSLASH_ESCAPE]},n.PHRASAL_WORDS_MODE={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},n.COMMENT=function(e,t,r){var i=n.inherit({className:"comment",begin:e,end:t,contains:[]},r||{});return i.contains.push(n.PHRASAL_WORDS_MODE),i.contains.push({className:"doctag",begin:"(?:TODO|FIXME|NOTE|BUG|XXX):",relevance:0}),i},n.C_LINE_COMMENT_MODE=n.COMMENT("//","$"),n.C_BLOCK_COMMENT_MODE=n.COMMENT("/\\*","\\*/"),n.HASH_COMMENT_MODE=n.COMMENT("#","$"),n.NUMBER_MODE={className:"number",begin:n.NUMBER_RE,relevance:0},n.C_NUMBER_MODE={className:"number",begin:n.C_NUMBER_RE,relevance:0},n.BINARY_NUMBER_MODE={className:"number",begin:n.BINARY_NUMBER_RE,relevance:0},n.CSS_NUMBER_MODE={className:"number",begin:n.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},n.REGEXP_MODE={className:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[n.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[n.BACKSLASH_ESCAPE]}]},n.TITLE_MODE={className:"title",begin:n.IDENT_RE,relevance:0},n.UNDERSCORE_TITLE_MODE={className:"title",begin:n.UNDERSCORE_IDENT_RE,relevance:0},n.METHOD_GUARD={begin:"\\.\\s*"+n.UNDERSCORE_IDENT_RE,relevance:0},n}),function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).PIXI=e()}}(function(){return function o(a,s,u){function c(r,e){if(!s[r]){if(!a[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(f)return f(r,!0);var i=new Error("Cannot find module '"+r+"'");throw i.code="MODULE_NOT_FOUND",i}var n=s[r]={exports:{}};a[r][0].call(n.exports,function(e){var t=a[r][1][e];return c(t||e)},n,n.exports,o,a,s,u)}return s[r].exports}for(var f="function"==typeof require&&require,e=0;e>31;return(e^t)-t},r.min=function(e,t){return t^(e^t)&-(e>>=t))<<3,t|=r=(15<(e>>>=r))<<2,(t|=r=(3<(e>>>=r))<<1)|(e>>>=r)>>1},r.log10=function(e){return 1e9<=e?9:1e8<=e?8:1e7<=e?7:1e6<=e?6:1e5<=e?5:1e4<=e?4:1e3<=e?3:100<=e?2:10<=e?1:0},r.popCount=function(e){return 16843009*((e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24},r.countTrailingZeros=i,r.nextPow2=function(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)+1},r.prevPow2=function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)-(e>>>1)},r.parity=function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,27030>>>(e&=15)&1};var n=new Array(256);!function(e){for(var t=0;t<256;++t){var r=t,i=t,n=7;for(r>>>=1;r;r>>>=1)i<<=1,i|=1&r,--n;e[t]=i<>>8&255]<<16|n[e>>>16&255]<<8|n[e>>>24&255]},r.interleave2=function(e,t){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))<<1},r.deinterleave2=function(e,t){return(e=65535&((e=16711935&((e=252645135&((e=858993459&((e=e>>>t&1431655765)|e>>>1))|e>>>2))|e>>>4))|e>>>16))<<16>>16},r.interleave3=function(e,t,r){return e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2),(e|=(t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(e,t){return(e=1023&((e=4278190335&((e=251719695&((e=3272356035&((e=e>>>t&1227133513)|e>>>2))|e>>>4))|e>>>8))|e>>>16))<<22>>22},r.nextCombination=function(e){var t=e|e-1;return 1+t|(~t&-~t)-1>>>i(e)+1}},{}],2:[function(e,t,r){"use strict";function i(e,t,r){r=r||2;var i,n,o,a,s,u,c,f=t&&t.length,l=f?t[0]*r:e.length,h=v(e,0,l,r,!0),d=[];if(!h||h.next===h.prev)return d;if(f&&(h=function(e,t,r,i){var n,o,a,s,u,c=[];for(n=0,o=t.length;n80*r){i=o=e[0],n=a=e[1];for(var p=r;po.x?n.x>a.x?n.x:a.x:o.x>a.x?o.x:a.x,f=n.y>o.y?n.y>a.y?n.y:a.y:o.y>a.y?o.y:a.y,l=_(s,u,t,r,i),h=_(c,f,t,r,i),d=e.prevZ,p=e.nextZ;d&&d.z>=l&&p&&p.z<=h;){if(d!==e.prev&&d!==e.next&&x(n.x,n.y,o.x,o.y,a.x,a.y,d.x,d.y)&&0<=T(d.prev,d,d.next))return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&&x(n.x,n.y,o.x,o.y,a.x,a.y,p.x,p.y)&&0<=T(p.prev,p,p.next))return!1;p=p.nextZ}for(;d&&d.z>=l;){if(d!==e.prev&&d!==e.next&&x(n.x,n.y,o.x,o.y,a.x,a.y,d.x,d.y)&&0<=T(d.prev,d,d.next))return!1;d=d.prevZ}for(;p&&p.z<=h;){if(p!==e.prev&&p!==e.next&&x(n.x,n.y,o.x,o.y,a.x,a.y,p.x,p.y)&&0<=T(p.prev,p,p.next))return!1;p=p.nextZ}return!0}function h(e,t,r){var i=e;do{var n=i.prev,o=i.next.next;!s(n,o)&&p(n,i,i.next,o)&&S(n,o)&&S(o,n)&&(t.push(n.i/r),t.push(i.i/r),t.push(o.i/r),M(i),M(i.next),i=e=o),i=i.next}while(i!==e);return i}function d(e,t,r,i,n,o){var a,s,u=e;do{for(var c=u.next.next;c!==u.prev;){if(u.i!==c.i&&(s=c,(a=u).next.i!==s.i&&a.prev.i!==s.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&p(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(a,s)&&S(a,s)&&S(s,a)&&function(e,t){var r=e,i=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;for(;r.y>o!=r.next.y>o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next,r!==e;);return i}(a,s))){var f=E(u,c);return u=m(u,u.next),f=m(f,f.next),b(u,t,r,i,n,o),void b(f,t,r,i,n,o)}c=c.next}u=u.next}while(u!==e)}function g(e,t){return e.x-t.x}function y(e,t){if(t=function(e,t){var r,i=t,n=e.x,o=e.y,a=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var s=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=n&&a=i.x&&i.x>=f&&n!==i.x&&x(or.x)&&S(i,e)&&(r=i,h=u),i=i.next;return r}(e,t)){var r=E(t,e);m(r,r.next)}}function _(e,t,r,i,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function w(e){for(var t=e,r=e;t.x=e.byteLength?i.bufferSubData(this.type,t,e):i.bufferData(this.type,e,this.drawType),this.data=e},o.prototype.bind=function(){this.gl.bindBuffer(this.type,this.buffer)},o.createVertexBuffer=function(e,t,r){return new o(e,e.ARRAY_BUFFER,t,r)},o.createIndexBuffer=function(e,t,r){return new o(e,e.ELEMENT_ARRAY_BUFFER,t,r)},o.create=function(e,t,r,i){return new o(e,t,r,i)},o.prototype.destroy=function(){this.gl.deleteBuffer(this.buffer)},t.exports=o},{}],10:[function(e,t,r){var a=e("./GLTexture"),s=function(e,t,r){this.gl=e,this.framebuffer=e.createFramebuffer(),this.stencil=null,this.texture=null,this.width=t||100,this.height=r||100};s.prototype.enableTexture=function(e){var t=this.gl;this.texture=e||new a(t),this.texture.bind(),this.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture.texture,0)},s.prototype.enableStencil=function(){if(!this.stencil){var e=this.gl;this.stencil=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this.stencil),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,this.stencil),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,this.width,this.height)}},s.prototype.clear=function(e,t,r,i){this.bind();var n=this.gl;n.clearColor(e,t,r,i),n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT)},s.prototype.bind=function(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer)},s.prototype.unbind=function(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null)},s.prototype.resize=function(e,t){var r=this.gl;this.width=e,this.height=t,this.texture&&this.texture.uploadData(null,e,t),this.stencil&&(r.bindRenderbuffer(r.RENDERBUFFER,this.stencil),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,e,t))},s.prototype.destroy=function(){var e=this.gl;this.texture&&this.texture.destroy(),e.deleteFramebuffer(this.framebuffer),this.gl=null,this.stencil=null,this.texture=null},s.createRGBA=function(e,t,r,i){var n=a.fromData(e,null,t,r);n.enableNearestScaling(),n.enableWrapClamp();var o=new s(e,t,r);return o.enableTexture(n),o.unbind(),o},s.createFloat32=function(e,t,r,i){var n=new a.fromData(e,i,t,r);n.enableNearestScaling(),n.enableWrapClamp();var o=new s(e,t,r);return o.enableTexture(n),o.unbind(),o},t.exports=s},{"./GLTexture":12}],11:[function(e,t,r){var o=e("./shader/compileProgram"),a=e("./shader/extractAttributes"),s=e("./shader/extractUniforms"),u=e("./shader/setPrecision"),c=e("./shader/generateUniformAccessObject"),i=function(e,t,r,i,n){this.gl=e,i&&(t=u(t,i),r=u(r,i)),this.program=o(e,t,r,n),this.attributes=a(e,this.program),this.uniformData=s(e,this.program),this.uniforms=c(e,this.uniformData)};i.prototype.bind=function(){return this.gl.useProgram(this.program),this},i.prototype.destroy=function(){this.attributes=null,this.uniformData=null,this.uniforms=null,this.gl.deleteProgram(this.program)},t.exports=i},{"./shader/compileProgram":17,"./shader/extractAttributes":19,"./shader/extractUniforms":20,"./shader/generateUniformAccessObject":21,"./shader/setPrecision":25}],12:[function(e,t,r){var o=function(e,t,r,i,n){this.gl=e,this.texture=e.createTexture(),this.mipmap=!1,this.premultiplyAlpha=!1,this.width=t||-1,this.height=r||-1,this.format=i||e.RGBA,this.type=n||e.UNSIGNED_BYTE},n=!(o.prototype.upload=function(e){this.bind();var t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);var r=e.videoWidth||e.width,i=e.videoHeight||e.height;i!==this.height||r!==this.width?t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,this.type,e):t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.format,this.type,e),this.width=r,this.height=i});o.prototype.uploadData=function(e,t,r){this.bind();var i=this.gl;if(e instanceof Float32Array){if(!n){if(!i.getExtension("OES_texture_float"))throw new Error("floating point textures not available");n=!0}this.type=i.FLOAT}else this.type=this.type||i.UNSIGNED_BYTE;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t!==this.width||r!==this.height?i.texImage2D(i.TEXTURE_2D,0,this.format,t,r,0,this.format,this.type,e||null):i.texSubImage2D(i.TEXTURE_2D,0,0,0,t,r,this.format,this.type,e||null),this.width=t,this.height=r},o.prototype.bind=function(e){var t=this.gl;void 0!==e&&t.activeTexture(t.TEXTURE0+e),t.bindTexture(t.TEXTURE_2D,this.texture)},o.prototype.unbind=function(){var e=this.gl;e.bindTexture(e.TEXTURE_2D,null)},o.prototype.minFilter=function(e){var t=this.gl;this.bind(),this.mipmap?t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.NEAREST_MIPMAP_NEAREST):t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e?t.LINEAR:t.NEAREST)},o.prototype.magFilter=function(e){var t=this.gl;this.bind(),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,e?t.LINEAR:t.NEAREST)},o.prototype.enableMipmap=function(){var e=this.gl;this.bind(),this.mipmap=!0,e.generateMipmap(e.TEXTURE_2D)},o.prototype.enableLinearScaling=function(){this.minFilter(!0),this.magFilter(!0)},o.prototype.enableNearestScaling=function(){this.minFilter(!1),this.magFilter(!1)},o.prototype.enableWrapClamp=function(){var e=this.gl;this.bind(),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)},o.prototype.enableWrapRepeat=function(){var e=this.gl;this.bind(),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)},o.prototype.enableWrapMirrorRepeat=function(){var e=this.gl;this.bind(),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.MIRRORED_REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.MIRRORED_REPEAT)},o.prototype.destroy=function(){this.gl.deleteTexture(this.texture)},o.fromSource=function(e,t,r){var i=new o(e);return i.premultiplyAlpha=r||!1,i.upload(t),i},o.fromData=function(e,t,r,i){var n=new o(e);return n.uploadData(t,r,i),n},t.exports=o},{}],13:[function(e,t,r){var n=e("./setVertexAttribArrays");function i(e,t){if(this.nativeVaoExtension=null,i.FORCE_NATIVE||(this.nativeVaoExtension=e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object")),this.nativeState=t,this.nativeVaoExtension){this.nativeVao=this.nativeVaoExtension.createVertexArrayOES();var r=e.getParameter(e.MAX_VERTEX_ATTRIBS);this.nativeState={tempAttribState:new Array(r),attribState:new Array(r)}}this.gl=e,this.attributes=[],this.indexBuffer=null,this.dirty=!1}i.prototype.constructor=i,(t.exports=i).FORCE_NATIVE=!1,i.prototype.bind=function(){if(this.nativeVao){if(this.nativeVaoExtension.bindVertexArrayOES(this.nativeVao),this.dirty)return this.dirty=!1,this.activate(),this;this.indexBuffer&&this.indexBuffer.bind()}else this.activate();return this},i.prototype.unbind=function(){return this.nativeVao&&this.nativeVaoExtension.bindVertexArrayOES(null),this},i.prototype.activate=function(){for(var e=this.gl,t=null,r=0;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=g-y,S=Math.floor,E=String.fromCharCode;function M(e){throw new RangeError(l[e])}function d(e,t){for(var r=e.length,i=[];r--;)i[r]=t(e[r]);return i}function p(e,t){var r=e.split("@"),i="";return 1>>10&1023|55296),e=56320|1023&e),t+=E(e)}).join("")}function A(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function k(e,t,r){var i=0;for(e=r?S(e/s):e>>1,e+=S(e/t);h*_>>1S((b-p)/a))&&M("overflow"),p+=u*a,!(u<(c=s<=m?y:m+_<=s?_:s-m));s+=g)a>S(b/(f=g-c))&&M("overflow"),a*=f;m=k(p-o,t=h.length+1,0==o),S(p/t)>b-v&&M("overflow"),v+=S(p/t),p%=t,h.splice(p++,0,v)}return P(h)}function m(e){var t,r,i,n,o,a,s,u,c,f,l,h,d,p,v,m=[];for(h=(e=C(e)).length,t=x,o=w,a=r=0;aS((b-r)/(d=i+1))&&M("overflow"),r+=(s-t)*d,t=s,a=0;ab&&M("overflow"),l==t){for(u=r,c=g;!(u<(f=c<=o?y:o+_<=c?_:c-o));c+=g)v=u-f,p=g-f,m.push(E(A(f+v%p,0))),u=S(v/p);m.push(E(A(u,0))),o=k(r,d,i==n),r=0,++i}++r,++t}return m.join("")}if(n={version:"1.4.1",ucs2:{decode:C,encode:P},decode:v,encode:m,toASCII:function(e){return p(e,function(e){return c.test(e)?"xn--"+m(e):e})},toUnicode:function(e){return p(e,function(e){return u.test(e)?v(e.slice(4).toLowerCase()):e})}},t&&r)if(R.exports==t)r.exports=n;else for(o in n)n.hasOwnProperty(o)&&(t[o]=n[o]);else e.punycode=n}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],28:[function(e,t,r){"use strict";t.exports=function(e,t,r,i){t=t||"&",r=r||"=";var n={};if("string"!=typeof e||0===e.length)return n;var o=/\+/g;e=e.split(t);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var s,u,c=e.length;0>2,n[1]=(3&i[0])<<4|i[1]>>4,n[2]=(15&i[1])<<2|i[2]>>6,n[3]=63&i[2],r-(e.length-1)){case 2:n[3]=64,n[2]=64;break;case 1:n[3]=64}for(var a=0;a",'"',"`"," ","\r","\n","\t"]),F=["'"].concat(n),B=["%","/","?",";","#"].concat(F),N=["/","?","#"],U=/^[+a-z0-9A-Z_-]{0,63}$/,z=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,X={javascript:!0,"javascript:":!0},q={javascript:!0,"javascript:":!0},G={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},H=e("querystring");function o(e,t,r){if(e&&D.isObject(e)&&e instanceof C)return e;var i=new C;return i.parse(e,t,r),i}C.prototype.parse=function(e,t,r){if(!D.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),n=-1!==i&&ithis.renderer.width&&(e.width=this.renderer.width-e.x),e.y+e.height>this.renderer.height&&(e.height=this.renderer.height-e.y)},r.prototype.addChild=function(e){var t=this.pool.pop();t||((t=document.createElement("button")).style.width="100px",t.style.height="100px",t.style.backgroundColor=this.debug?"rgba(255,0,0,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=2,t.style.borderStyle="none",-1]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i,r.SHAPES={POLY:0,RECT:1,CIRC:2,ELIP:3,RREC:4},r.PRECISION={LOW:"lowp",MEDIUM:"mediump",HIGH:"highp"},r.TRANSFORM_MODE={STATIC:0,DYNAMIC:1},r.TEXT_GRADIENT={LINEAR_VERTICAL:0,LINEAR_HORIZONTAL:1},r.UPDATE_PRIORITY={INTERACTION:50,HIGH:25,NORMAL:0,LOW:-25,UTILITY:-50}},{}],47:[function(e,t,r){"use strict";r.__esModule=!0;var i=e("../math");var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null}return e.prototype.isEmpty=function(){return this.minX>this.maxX||this.minY>this.maxY},e.prototype.clear=function(){this.updateID++,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0},e.prototype.getRectangle=function(e){return this.minX>this.maxX||this.minY>this.maxY?i.Rectangle.EMPTY:((e=e||new i.Rectangle(0,0,1,1)).x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)},e.prototype.addPoint=function(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)},e.prototype.addQuad=function(e){var t=this.minX,r=this.minY,i=this.maxX,n=this.maxY,o=e[0],a=e[1];t=oi?e.maxX:i,this.maxY=e.maxY>n?e.maxY:n},e.prototype.addBoundsMask=function(e,t){var r=e.minX>t.minX?e.minX:t.minX,i=e.minY>t.minY?e.minY:t.minY,n=e.maxXt.x?e.minX:t.x,i=e.minY>t.y?e.minY:t.y,n=e.maxXthis.children.length)throw new Error(e+"addChildAt: The index "+t+" supplied is out of bounds "+this.children.length);return e.parent&&e.parent.removeChild(e),e.parent=this,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit("added",this),e},t.prototype.swapChildren=function(e,t){if(e!==t){var r=this.getChildIndex(e),i=this.getChildIndex(t);this.children[r]=t,this.children[i]=e,this.onChildrenChange(r=this.children.length)throw new Error("The index "+t+" supplied is out of bounds "+this.children.length);var r=this.getChildIndex(e);(0,a.removeItems)(this.children,r,1),this.children.splice(t,0,e),this.onChildrenChange(t)},t.prototype.getChildAt=function(e){if(e<0||e>=this.children.length)throw new Error("getChildAt: Index ("+e+") does not exist.");return this.children[e]},t.prototype.removeChild=function(e){var t=arguments.length;if(1T.CURVES.maxSegments&&(t=T.CURVES.maxSegments),t},T.prototype.lineStyle=function(){var e=0>16&255)/255,r=(e.tint>>8&255)/255,i=(255&e.tint)/255,n=0;n>16&255)/255*t*255<<16)+((a>>8&255)/255*r*255<<8)+(255&a)/255*i*255,o._lineTint=((s>>16&255)/255*t*255<<16)+((s>>8&255)/255*r*255<<8)+(255&s)/255*i*255}},t.prototype.renderPolygon=function(e,t,r){r.moveTo(e[0],e[1]);for(var i=1;i=this.x&&e=this.y&&t=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){if(t>=this.y+this.radius&&t<=this.y+this.height-this.radius||e>=this.x+this.radius&&e<=this.x+this.width-this.radius)return!0;var r=e-(this.x+this.radius),i=t-(this.y+this.radius),n=this.radius*this.radius;if(r*r+i*i<=n)return!0;if((r=e-(this.x+this.width-this.radius))*r+i*i<=n)return!0;if(r*r+(i=t-(this.y+this.height-this.radius))*i<=n)return!0;if((r=e-(this.x+this.radius))*r+i*i<=n)return!0}return!1},o}();r.default=i},{"../../const":46}],76:[function(e,t,r){"use strict";r.__esModule=!0;var i=function(){function i(e,t){for(var r=0;rthis.checkCountMax&&(this.checkCount=0,this.run()))},t.prototype.run=function(){for(var e=this.renderer.textureManager,t=e._managedTextures,r=!1,i=0;ithis.maxIdle&&(e.destroyTexture(n,!0),r=!(t[i]=null))}if(r){for(var o=0,a=0;a 0.5)"," {"," color = vec4(1.0, 0.0, 0.0, 1.0);"," }"," else"," {"," color = vec4(0.0, 1.0, 0.0, 1.0);"," }"," gl_FragColor = mix(sample, masky, 0.5);"," gl_FragColor *= sample.a;","}"].join("\n")}}]),n}();r.default=f},{"../../../const":46,"../../../settings":101,"../../../utils":125,"./extractUniformsFromSrc":87}],87:[function(e,t,r){"use strict";r.__esModule=!0,r.default=function(e,t,r){var i=o(e),n=o(t);return Object.assign(i,n)};var i,n=e("pixi-gl-core");var l=((i=n)&&i.__esModule?i:{default:i}).default.shader.defaultValue;function o(e){for(var t=new RegExp("^(projectionMatrix|uSampler|filterArea|filterClamp)$"),r={},i=void 0,n=e.replace(/\s+/g," ").split(/\s*;\s*/),o=0;o=i&&f.x=n&&f.y>16)+(65280&e)+((255&e)<<16)}},{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e||u.default.EMPTY,this.cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,e&&(e.baseTexture.hasLoaded?this._onTextureUpdate():e.once("update",this._onTextureUpdate,this)))}}]),i}(i.default);r.default=l},{"../const":46,"../display/Container":48,"../math":70,"../textures/Texture":115,"../utils":125}],103:[function(e,t,r){"use strict";r.__esModule=!0;var i=n(e("../../renderers/canvas/CanvasRenderer")),f=e("../../const"),l=e("../../math"),h=n(e("./CanvasTinter"));function n(e){return e&&e.__esModule?e:{default:e}}var d=new l.Matrix,o=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.renderer=e}return t.prototype.render=function(e){var t=e._texture,r=this.renderer,i=t._frame.width,n=t._frame.height,o=e.transform.worldTransform,a=0,s=0;if(!(t.orig.width<=0||t.orig.height<=0)&&t.baseTexture.source&&(r.setBlendMode(e.blendMode),t.valid)){r.context.globalAlpha=e.worldAlpha;var u=t.baseTexture.scaleMode===f.SCALE_MODES.LINEAR;r.smoothProperty&&r.context[r.smoothProperty]!==u&&(r.context[r.smoothProperty]=u),s=t.trim?(a=t.trim.width/2+t.trim.x-e.anchor.x*t.orig.width,t.trim.height/2+t.trim.y-e.anchor.y*t.orig.height):(a=(.5-e.anchor.x)*t.orig.width,(.5-e.anchor.y)*t.orig.height),t.rotate&&(o.copy(d),o=d,l.GroupD8.matrixAppendRotationInv(o,t.rotate,a,s),s=a=0),a-=i/2,s-=n/2,r.roundPixels?(r.context.setTransform(o.a,o.b,o.c,o.d,o.tx*r.resolution|0,o.ty*r.resolution|0),a|=0,s|=0):r.context.setTransform(o.a,o.b,o.c,o.d,o.tx*r.resolution,o.ty*r.resolution);var c=t.baseTexture.resolution;16777215!==e.tint?(e.cachedTint===e.tint&&e.tintedTexture.tintId===e._texture._updateID||(e.cachedTint=e.tint,e.tintedTexture=h.default.getTintedTexture(e,e.tint)),r.context.drawImage(e.tintedTexture,0,0,i*c,n*c,a*r.resolution,s*r.resolution,i*r.resolution,n*r.resolution)):r.context.drawImage(t.baseTexture.source,t._frame.x*c,t._frame.y*c,i*c,n*c,a*r.resolution,s*r.resolution,i*r.resolution,n*r.resolution)}},t.prototype.destroy=function(){this.renderer=null},t}();r.default=o,i.default.registerPlugin("sprite",o)},{"../../const":46,"../../math":70,"../../renderers/canvas/CanvasRenderer":77,"./CanvasTinter":104}],104:[function(e,t,r){"use strict";r.__esModule=!0;var i,d=e("../../utils"),n=e("../../renderers/canvas/utils/canUseNewCanvasBlendModes");var s={getTintedTexture:function(e,t){var r=e._texture,i="#"+("00000"+(0|(t=s.roundColor(t))).toString(16)).substr(-6);r.tintCache=r.tintCache||{};var n=r.tintCache[i],o=void 0;if(n){if(n.tintId===r._updateID)return r.tintCache[i];o=r.tintCache[i]}else o=s.canvas||document.createElement("canvas");if(s.tintMethod(r,t,o),o.tintId=r._updateID,s.convertTintToImage){var a=new Image;a.src=o.toDataURL(),r.tintCache[i]=a}else r.tintCache[i]=o,s.canvas=null;return o},tintWithMultiply:function(e,t,r){var i=r.getContext("2d"),n=e._frame.clone(),o=e.baseTexture.resolution;n.x*=o,n.y*=o,n.width*=o,n.height*=o,r.width=Math.ceil(n.width),r.height=Math.ceil(n.height),i.save(),i.fillStyle="#"+("00000"+(0|t).toString(16)).substr(-6),i.fillRect(0,0,n.width,n.height),i.globalCompositeOperation="multiply",i.drawImage(e.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.globalCompositeOperation="destination-atop",i.drawImage(e.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.restore()},tintWithOverlay:function(e,t,r){var i=r.getContext("2d"),n=e._frame.clone(),o=e.baseTexture.resolution;n.x*=o,n.y*=o,n.width*=o,n.height*=o,r.width=Math.ceil(n.width),r.height=Math.ceil(n.height),i.save(),i.globalCompositeOperation="copy",i.fillStyle="#"+("00000"+(0|t).toString(16)).substr(-6),i.fillRect(0,0,n.width,n.height),i.globalCompositeOperation="destination-atop",i.drawImage(e.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.restore()},tintWithPerPixel:function(e,t,r){var i=r.getContext("2d"),n=e._frame.clone(),o=e.baseTexture.resolution;n.x*=o,n.y*=o,n.width*=o,n.height*=o,r.width=Math.ceil(n.width),r.height=Math.ceil(n.height),i.save(),i.globalCompositeOperation="copy",i.drawImage(e.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.restore();for(var a=(0,d.hex2rgb)(t),s=a[0],u=a[1],c=a[2],f=i.getImageData(0,0,n.width,n.height),l=f.data,h=0;h=this.size&&this.flush(),e._texture._uvs&&(this.sprites[this.currentIndex++]=e)},o.prototype.flush=function(){if(0!==this.currentIndex){var e=this.renderer.gl,t=this.MAX_TEXTURES,r=U.default.nextPow2(this.currentIndex),i=U.default.log2(r),n=this.buffers[i],o=this.sprites,a=this.groups,s=n.float32View,u=n.uint32View,c=this.boundTextures,f=this.renderer.boundTextures,l=this.renderer.textureGC.count,h=0,d=void 0,p=void 0,v=1,m=0,b=a[0],g=void 0,y=void 0,_=B.premultiplyBlendMode[o[0]._texture.baseTexture.premultipliedAlpha?1:0][o[0].blendMode];b.textureCount=0,b.start=0,b.blend=_,z++;var w=void 0;for(w=0;w=r.length)break;o=r[n++]}else{if((n=r.next()).done)break;o=n.value}var a=o;this.animations[t].push(this.textures[a])}}},l.prototype._parseComplete=function(){var e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)},l.prototype._nextBatch=function(){var e=this;this._processFrames(this._batchIndex*l.BATCH_SIZE),this._batchIndex++,setTimeout(function(){e._batchIndex*l.BATCH_SIZEthis.baseTexture.width,a=r+n>this.baseTexture.height;if(o||a){var s=o&&a?"and":"or",u="X: "+t+" + "+i+" = "+(t+i)+" > "+this.baseTexture.width,c="Y: "+r+" + "+n+" = "+(r+n)+" > "+this.baseTexture.height;throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: "+u+" "+s+" "+c)}this.valid=i&&n&&this.baseTexture.hasLoaded,this.trim||this.rotate||(this.orig=e),this.valid&&this._updateUvs()}},{key:"rotate",get:function(){return this._rotate},set:function(e){this._rotate=e,this.valid&&this._updateUvs()}},{key:"width",get:function(){return this.orig.width}},{key:"height",get:function(){return this.orig.height}}]),u}(s.default);function d(e){e.destroy=function(){},e.on=function(){},e.once=function(){},e.emit=function(){}}(r.default=h).EMPTY=new h(new o.default),d(h.EMPTY),d(h.EMPTY.baseTexture),h.WHITE=function(){var e=document.createElement("canvas");e.width=10,e.height=10;var t=e.getContext("2d");return t.fillStyle="white",t.fillRect(0,0,10,10),new h(new o.default(e))}(),d(h.WHITE),d(h.WHITE.baseTexture)},{"../math":70,"../settings":101,"../utils":125,"./BaseTexture":112,"./TextureUvs":117,"./VideoBaseTexture":118,eventemitter3:3}],116:[function(e,t,r){"use strict";r.__esModule=!0;var i,n=function(){function i(e,t){for(var r=0;rt.priority){e.connect(r);break}t=(r=t).next}e.previous||e.connect(r)}else e.connect(r);return this._startIfPossible(),this},e.prototype.remove=function(e,t){for(var r=this._head.next;r;)r=r.match(e,t)?r.destroy():r.next;return this._head.next||this._cancelIfNeeded(),this},e.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},e.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},e.prototype.destroy=function(){this.stop();for(var e=this._head.next;e;)e=e.destroy(!0);this._head.destroy(),this._head=null},e.prototype.update=function(){var e=0this.lastTime){(t=this.elapsedMS=e-this.lastTime)>this._maxElapsedMS&&(t=this._maxElapsedMS),this.deltaTime=t*n.default.TARGET_FPMS*this.speed;for(var r=this._head,i=r.next;i;)i=i.emit(this.deltaTime);r.next||this._cancelIfNeeded()}else this.deltaTime=this.elapsedMS=0;this.lastTime=e},i(e,[{key:"FPS",get:function(){return 1e3/this.elapsedMS}},{key:"minFPS",get:function(){return 1e3/this._maxElapsedMS},set:function(e){var t=Math.min(Math.max(0,e)/1e3,n.default.TARGET_FPMS);this._maxElapsedMS=1/t}}]),e}();r.default=u},{"../const":46,"../settings":101,"./TickerListener":120}],120:[function(e,t,r){"use strict";r.__esModule=!0;var i=function(){function n(e){var t=1>16&255)/255,t[1]=(e>>8&255)/255,t[2]=(255&e)/255,t},r.hex2string=function(e){return e=e.toString(16),"#"+(e="000000".substr(0,6-e.length)+e)},r.rgb2hex=function(e){return(255*e[0]<<16)+(255*e[1]<<8)+(255*e[2]|0)},r.getResolutionOfUrl=function(e,t){var r=n.default.RETINA_PREFIX.exec(e);if(r)return parseFloat(r[1]);return void 0!==t?t:1},r.decomposeDataUri=function(e){var t=i.DATA_URI.exec(e);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]};return},r.getUrlFileExtension=function(e){var t=i.URL_FILE_EXTENSION.exec(e);if(t)return t[1].toLowerCase();return},r.getSvgSize=function(e){var t=i.SVG_SIZE.exec(e),r={};t&&(r[t[1]]=Math.round(parseFloat(t[3])),r[t[5]]=Math.round(parseFloat(t[7])));return r},r.skipHello=function(){v=!0},r.sayHello=function(e){if(v)return;if(-1>16&255,i=e>>8&255,n=255&e;return(255*t<<24)+((r=r*t+.5|0)<<16)+((i=i*t+.5|0)<<8)+(n=n*t+.5|0)},r.premultiplyRgba=function(e,t,r,i){r=r||new Float32Array(4),i||void 0===i?(r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t):(r[0]=e[0],r[1]=e[1],r[2]=e[2]);return r[3]=t,r},r.premultiplyTintToRgba=function(e,t,r,i){(r=r||new Float32Array(4))[0]=(e>>16&255)/255,r[1]=(e>>8&255)/255,r[2]=(255&e)/255,(i||void 0===i)&&(r[0]*=t,r[1]*=t,r[2]*=t);return r[3]=t,r};var i=e("../const"),n=d(e("../settings")),o=d(e("eventemitter3")),a=d(e("./pluginTarget")),s=h(e("./mixin")),u=h(e("ismobilejs")),c=d(e("remove-array-items")),f=d(e("./mapPremultipliedBlendModes")),l=d(e("earcut"));function h(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function d(e){return e&&e.__esModule?e:{default:e}}var p=0,v=!1;r.isMobile=u,r.removeItems=c.default,r.EventEmitter=o.default,r.pluginTarget=a.default,r.mixins=s,r.earcut=l.default;var m=r.TextureCache=Object.create(null),b=r.BaseTextureCache=Object.create(null);var g=r.premultiplyBlendMode=(0,f.default)()},{"../const":46,"../settings":101,"./mapPremultipliedBlendModes":126,"./mixin":128,"./pluginTarget":129,earcut:2,eventemitter3:3,ismobilejs:4,"remove-array-items":31}],126:[function(e,t,r){"use strict";r.__esModule=!0,r.default=function(){for(var e=[],t=[],r=0;r<32;r++)e[r]=r,t[r]=r;e[n.BLEND_MODES.NORMAL_NPM]=n.BLEND_MODES.NORMAL,e[n.BLEND_MODES.ADD_NPM]=n.BLEND_MODES.ADD,e[n.BLEND_MODES.SCREEN_NPM]=n.BLEND_MODES.SCREEN,t[n.BLEND_MODES.NORMAL]=n.BLEND_MODES.NORMAL_NPM,t[n.BLEND_MODES.ADD]=n.BLEND_MODES.ADD_NPM,t[n.BLEND_MODES.SCREEN]=n.BLEND_MODES.SCREEN_NPM;var i=[];return i.push(t),i.push(e),i};var n=e("../const")},{"../const":46}],127:[function(e,t,r){"use strict";r.__esModule=!0,r.default=function(e){if(o.default.tablet||o.default.phone)return 4;return e};var i,n=e("ismobilejs"),o=(i=n)&&i.__esModule?i:{default:i}},{ismobilejs:4}],128:[function(e,t,r){"use strict";function i(e,t){if(e&&t)for(var r=Object.keys(t),i=0;i=this._durations[this.currentFrame];)i-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=i/this._durations[this.currentFrame]}else this._currentTime+=t;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):r!==this.currentFrame&&(this.loop&&this.onLoop&&(0r&&this.onLoop()),this.updateTexture())},n.prototype.updateTexture=function(){this._texture=this._textures[this.currentFrame],this._textureID=-1,this.cachedTint=16777215,this.updateAnchor&&this._anchor.copy(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame)},n.prototype.destroy=function(e){this.stop(),i.prototype.destroy.call(this,e)},n.fromFrames=function(e){for(var t=[],r=0;rs&&(++p,I.utils.removeItems(i,1+h-p,1+m-h),m=h,h=-1,n.push(d),f=Math.max(f,d),l++,r.x=0,r.y+=e.lineHeight,u=null))}else n.push(c),f=Math.max(f,c),++l,++p,r.x=0,r.y+=e.lineHeight,u=null}var _=o.charAt(o.length-1);"\r"!==_&&"\n"!==_&&(/(?:\s)/.test(_)&&(c=d),n.push(c),f=Math.max(f,c));for(var w=[],x=0;x<=l;x++){var T=0;"right"===this._font.align?T=f-n[x]:"center"===this._font.align&&(T=(f-n[x])/2),w.push(T)}for(var S=i.length,E=this.tint,M=0;M=i&&s.x=n&&s.y 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n"));return e.uniforms.m=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],e.alpha=1,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,t),r.prototype._loadMatrix=function(e){var t=e;1>16&255)/255,a=(r>>8&255)/255,s=(255&r)/255,u=((i=i||3375104)>>16&255)/255,c=(i>>8&255)/255,f=(255&i)/255,l=[.3,.59,.11,0,0,o,a,s,e=e||.2,0,u,c,f,t=t||.15,0,o-u,a-c,s-f,0,0];this._loadMatrix(l,n)},r.prototype.night=function(e,t){var r=[-2*(e=e||.1),-e,0,0,0,-e,0,e,0,0,0,e,2*e,0,0,0,0,0,1,0];this._loadMatrix(r,t)},r.prototype.predator=function(e,t){var r=[11.224130630493164*e,-4.794486999511719*e,-2.8746118545532227*e,0*e,.40342438220977783*e,-3.6330697536468506*e,9.193157196044922*e,-2.951810836791992*e,0*e,-1.316135048866272*e,-3.2184197902679443*e,-4.2375030517578125*e,7.476448059082031*e,0*e,.8044459223747253*e,0,0,0,1,0];this._loadMatrix(r,t)},r.prototype.lsd=function(e){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],e)},r.prototype.reset=function(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!1)},i(r,[{key:"matrix",get:function(){return this.uniforms.m},set:function(e){this.uniforms.m=e}},{key:"alpha",get:function(){return this.uniforms.uAlpha},set:function(e){this.uniforms.uAlpha=e}}]),r}(n.Filter);(r.default=o).prototype.grayscale=o.prototype.greyscale},{"../../core":65,path:8}],151:[function(e,t,r){"use strict";r.__esModule=!0;var i=function(){function i(e,t){for(var r=0;r lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\nvoid main() {\n\n vec2 fragCoord = vTextureCoord * filterArea.xy;\n\n vec4 color;\n\n color = fxaa(uSampler, fragCoord, filterArea.xy, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n gl_FragColor = color;\n}\n'))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t}(i.Filter);r.default=n},{"../../core":65,path:8}],153:[function(e,t,r){"use strict";r.__esModule=!0;var i=e("./fxaa/FXAAFilter");Object.defineProperty(r,"FXAAFilter",{enumerable:!0,get:function(){return l(i).default}});var n=e("./noise/NoiseFilter");Object.defineProperty(r,"NoiseFilter",{enumerable:!0,get:function(){return l(n).default}});var o=e("./displacement/DisplacementFilter");Object.defineProperty(r,"DisplacementFilter",{enumerable:!0,get:function(){return l(o).default}});var a=e("./blur/BlurFilter");Object.defineProperty(r,"BlurFilter",{enumerable:!0,get:function(){return l(a).default}});var s=e("./blur/BlurXFilter");Object.defineProperty(r,"BlurXFilter",{enumerable:!0,get:function(){return l(s).default}});var u=e("./blur/BlurYFilter");Object.defineProperty(r,"BlurYFilter",{enumerable:!0,get:function(){return l(u).default}});var c=e("./colormatrix/ColorMatrixFilter");Object.defineProperty(r,"ColorMatrixFilter",{enumerable:!0,get:function(){return l(c).default}});var f=e("./alpha/AlphaFilter");function l(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(r,"AlphaFilter",{enumerable:!0,get:function(){return l(f).default}})},{"./alpha/AlphaFilter":143,"./blur/BlurFilter":144,"./blur/BlurXFilter":145,"./blur/BlurYFilter":146,"./colormatrix/ColorMatrixFilter":150,"./displacement/DisplacementFilter":151,"./fxaa/FXAAFilter":152,"./noise/NoiseFilter":154}],154:[function(e,t,r){"use strict";r.__esModule=!0;var o=function(){function i(e,t){for(var r=0;r 0.0) {\n color.rgb /= color.a;\n }\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n // Premultiply alpha again.\n color.rgb *= color.a;\n\n gl_FragColor = color;\n}\n"));return r.noise=e,r.seed=t,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(n,i),o(n,[{key:"noise",get:function(){return this.uniforms.uNoise},set:function(e){this.uniforms.uNoise=e}},{key:"seed",get:function(){return this.uniforms.uSeed},set:function(e){this.uniforms.uSeed=e}}]),n}(i.Filter);r.default=n},{"../../core":65,path:8}],155:[function(e,t,r){"use strict";r.__esModule=!0;var i=function(){function i(e,t){for(var r=0;rt?1:this._height/t;e[9]=e[11]=e[13]=e[15]=this._topHeight*r,e[17]=e[19]=e[21]=e[23]=this._height-this._bottomHeight*r,e[25]=e[27]=e[29]=e[31]=this._height},s.prototype.updateVerticalVertices=function(){var e=this.vertices,t=this._leftWidth+this._rightWidth,r=this._width>t?1:this._width/t;e[2]=e[10]=e[18]=e[26]=this._leftWidth*r,e[4]=e[12]=e[20]=e[28]=this._width-this._rightWidth*r,e[6]=e[14]=e[22]=e[30]=this._width},s.prototype._renderCanvas=function(e){var t=e.context,r=this.worldTransform,i=e.resolution,n=16777215!==this.tint,o=this._texture;n&&this._cachedTint!==this.tint&&(this._cachedTint=this.tint,this._tintedTexture=w.default.getTintedTexture(this,this.tint));var a=n?this._tintedTexture:o.baseTexture.source;this._canvasUvs||(this._canvasUvs=[0,0,0,0,0,0,0,0]);var s=this.vertices,u=this._canvasUvs,c=n?0:o.frame.x,f=n?0:o.frame.y,l=c+o.frame.width,h=f+o.frame.height;u[0]=c,u[1]=c+this._leftWidth,u[2]=l-this._rightWidth,u[3]=l,u[4]=f,u[5]=f+this._topHeight,u[6]=h-this._bottomHeight,u[7]=h;for(var d=0;d<8;d++)u[d]*=o.baseTexture.resolution;t.globalAlpha=this.worldAlpha,e.setBlendMode(this.blendMode),e.roundPixels?t.setTransform(r.a*i,r.b*i,r.c*i,r.d*i,r.tx*i|0,r.ty*i|0):t.setTransform(r.a*i,r.b*i,r.c*i,r.d*i,r.tx*i,r.ty*i);for(var p=0;p<3;p++)for(var v=0;v<3;v++){var m=2*v+8*p,b=Math.max(1,u[v+1]-u[v]),g=Math.max(1,u[p+5]-u[p+4]),y=Math.max(1,s[10+m]-s[m]),_=Math.max(1,s[11+m]-s[1+m]);t.drawImage(a,u[v],u[p+4],b,g,s[m],s[1+m],y,_)}},s.prototype._refresh=function(){a.prototype._refresh.call(this);var e=this.uvs,t=this._texture;this._origWidth=t.orig.width,this._origHeight=t.orig.height;var r=1/this._origWidth,i=1/this._origHeight;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1,e[2]=e[10]=e[18]=e[26]=r*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-r*this._rightWidth,e[9]=e[11]=e[13]=e[15]=i*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-i*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.dirty++,this.multiplyUvs()},i(s,[{key:"width",get:function(){return this._width},set:function(e){this._width=e,this._refresh()}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,this._refresh()}},{key:"leftWidth",get:function(){return this._leftWidth},set:function(e){this._leftWidth=e,this._refresh()}},{key:"rightWidth",get:function(){return this._rightWidth},set:function(e){this._rightWidth=e,this._refresh()}},{key:"topHeight",get:function(){return this._topHeight},set:function(e){this._topHeight=e,this._refresh()}},{key:"bottomHeight",get:function(){return this._bottomHeight},set:function(e){this._bottomHeight=e,this._refresh()}}]),s}(n.default);r.default=a},{"../core/sprites/canvas/CanvasTinter":104,"./Plane":168}],168:[function(e,t,r){"use strict";r.__esModule=!0;var i,n=e("./Mesh"),a=(i=n)&&i.__esModule?i:{default:i};var o=function(n){function o(e,t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,n.call(this,e));return i._ready=!0,i.verticesX=t||10,i.verticesY=r||10,i.drawMode=a.default.DRAW_MODES.TRIANGLES,i.refresh(),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(o,n),o.prototype._refresh=function(){for(var e=this._texture,t=this.verticesX*this.verticesY,r=[],i=[],n=[],o=this.verticesX-1,a=this.verticesY-1,s=e.width/o,u=e.height/a,c=0;c=a.length){if(!e.autoResize)break;a.push(this._generateOneMoreBuffer(e))}var p=a[h];p.uploadDynamic(t,l,d);var v=e._bufferUpdateIDs[h]||0;(f=f||p._updateID 0) var gc = undefined");else{if(!ba&&!ca)throw"Unknown runtime environment. Where are we?";e.read=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},"undefined"!=typeof arguments&&(e.arguments=arguments),"undefined"!=typeof console?(e.print||(e.print=function(e){console.log(e)}),e.printErr||(e.printErr=function(e){console.log(e)})):e.print||(e.print=function(){}),ca&&(e.load=importScripts),void 0===e.setWindowTitle&&(e.setWindowTitle=function(e){document.title=e})}function ha(e){eval.call(null,e)}for(k in!e.load&&e.read&&(e.load=function(t){ha(e.read(t))}),e.print||(e.print=function(){}),e.printErr||(e.printErr=e.print),e.arguments||(e.arguments=[]),e.thisProgram||(e.thisProgram="./this.program"),e.print=e.print,e.W=e.printErr,e.preRun=[],e.postRun=[],aa)aa.hasOwnProperty(k)&&(e[k]=aa[k]);var n={rb:function(e){ka=e},fb:function(){return ka},ua:function(){return m},ba:function(e){m=e},Ka:function(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:return"*"===e[e.length-1]?n.J:"i"===e[0]?(assert(0==(e=parseInt(e.substr(1)))%8),e/8):0}},eb:function(e){return Math.max(n.Ka(e),n.J)},ud:16,Qd:function(e,t){return"double"===t||"i64"===t?7&e&&(assert(4==(7&e)),e+=4):assert(0==(3&e)),e},Ed:function(e,t,r){return r||"i64"!=e&&"double"!=e?e?Math.min(t||(e?n.eb(e):0),n.J):Math.min(t,8):8},L:function(t,r,i){return i&&i.length?(i.splice||(i=Array.prototype.slice.call(i)),i.splice(0,0,r),e["dynCall_"+t].apply(null,i)):e["dynCall_"+t].call(null,r)},Z:[],Xa:function(e){for(var t=0;t>>0)+4294967296*+(t>>>0):+(e>>>0)+4294967296*+(0|t)},Ua:8,J:4,vd:0};e.Runtime=n,n.addFunction=n.Xa,n.removeFunction=n.nb;var na=!1,oa,pa,ka,ra,sa;function assert(e,t){e||x("Assertion failed: "+t)}function qa(a){var b=e["_"+a];if(!b)try{b=eval("_"+a)}catch(e){}return assert(b,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)"),b}function wa(e,t,r){switch("*"===(r=r||"i8").charAt(r.length-1)&&(r="i32"),r){case"i1":case"i8":y[e>>0]=t;break;case"i16":z[e>>1]=t;break;case"i32":C[e>>2]=t;break;case"i64":pa=[t>>>0,(oa=t,1<=+xa(oa)?0>>0:~~+Aa((oa-+(~~oa>>>0))/4294967296)>>>0:0)],C[e>>2]=pa[0],C[e+4>>2]=pa[1];break;case"float":Ba[e>>2]=t;break;case"double":Ca[e>>3]=t;break;default:x("invalid type for setValue: "+r)}}function Da(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return y[e>>0];case"i16":return z[e>>1];case"i32":case"i64":return C[e>>2];case"float":return Ba[e>>2];case"double":return Ca[e>>3];default:x("invalid type for setValue: "+t)}return null}function D(e,t,r,i){var o,a;a="number"==typeof e?(o=!0,e):(o=!1,e.length);var s,u,c="string"==typeof t?t:null;if(r=4==r?i:[Ea,n.aa,n.Ra,n.R][void 0===r?2:r](Math.max(a,c?1:t.length)),o){for(assert(0==(3&(i=r))),e=r+(-4&a);i>2]=0;for(e=r+a;i>0]=0;return r}if("i8"===c)return e.subarray||e.slice?E.set(e,r):E.set(new Uint8Array(e),r),r;for(i=0;i>0],0!=i||r)&&(o++,!r||o!=r););if(r||(r=o),i="",n<128){for(;0>10,56320|1023&r)))):s+=String.fromCharCode(r)}}function Ka(e,t,r,i){if(!(0>6}else{if(a<=65535){if(i<=r+2)break;t[r++]=224|a>>12}else{if(a<=2097151){if(i<=r+3)break;t[r++]=240|a>>18}else{if(a<=67108863){if(i<=r+4)break;t[r++]=248|a>>24}else{if(i<=r+5)break;t[r++]=252|a>>30,t[r++]=128|a>>24&63}t[r++]=128|a>>18&63}t[r++]=128|a>>12&63}t[r++]=128|a>>6&63}t[r++]=128|63&a}}return t[r]=0,r-n}function La(e){for(var t=0,r=0;r"):o=n;e:for(;l>0];if(!r)return t;t+=String.fromCharCode(r)}},e.stringToAscii=function(e,t){return Ia(e,t,!1)},e.UTF8ArrayToString=Ja,e.UTF8ToString=function(e){return Ja(E,e)},e.stringToUTF8Array=Ka,e.stringToUTF8=function(e,t,r){return Ka(e,E,t,r)},e.lengthBytesUTF8=La,e.UTF16ToString=function(e){for(var t=0,r="";;){var i=z[e+2*t>>1];if(0==i)return r;++t,r+=String.fromCharCode(i)}},e.stringToUTF16=function(e,t,r){if(void 0===r&&(r=2147483647),r<2)return 0;var i=t;r=(r-=2)<2*e.length?r/2:e.length;for(var n=0;n>1]=e.charCodeAt(n),t+=2;return z[t>>1]=0,t-i},e.lengthBytesUTF16=function(e){return 2*e.length},e.UTF32ToString=function(e){for(var t=0,r="";;){var i=C[e+4*t>>2];if(0==i)return r;++t,65536<=i?(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i)):r+=String.fromCharCode(i)}},e.stringToUTF32=function(e,t,r){if(void 0===r&&(r=2147483647),r<4)return 0;var i=t;r=i+r-4;for(var n=0;n>2]=o,r<(t+=4)+4)break}return C[t>>2]=0,t-i},e.lengthBytesUTF32=function(e){for(var t=0,r=0;r>0]=e[r],r+=1}function ta(e,t){for(var r=0;r>0]=e[r]}function Ia(e,t,r){for(var i=0;i>0]=e.charCodeAt(i);r||(y[t>>0]=0)}e.addOnPreRun=fb,e.addOnInit=function(e){cb.unshift(e)},e.addOnPreMain=function(e){db.unshift(e)},e.addOnExit=function(e){H.unshift(e)},e.addOnPostRun=gb,e.intArrayFromString=hb,e.intArrayToString=function(e){for(var t=[],r=0;r>>16)*i+r*(t>>>16)<<16)|0}),Math.Jd=Math.imul,Math.clz32||(Math.clz32=function(e){e>>>=0;for(var t=0;t<32;t++)if(e&1<<31-t)return t;return 32}),Math.Ad=Math.clz32;var xa=Math.abs,Aa=Math.ceil,za=Math.floor,ya=Math.min,I=0,ib=null,jb=null;function kb(){I++,e.monitorRunDependencies&&e.monitorRunDependencies(I)}function lb(){if(I--,e.monitorRunDependencies&&e.monitorRunDependencies(I),0==I&&(null!==ib&&(clearInterval(ib),ib=null),jb)){var t=jb;jb=null,t()}}e.addRunDependency=kb,e.removeRunDependency=lb,e.preloadedImages={},e.preloadedAudios={},Ta=8,la=Ta+5888,cb.push(),D([124,0,0,0,98,7,0,0,124,0,0,0,111,7,0,0,164,0,0,0,124,7,0,0,16,0,0,0,0,0,0,0,164,0,0,0,157,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,227,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,191,7,0,0,56,0,0,0,0,0,0,0,164,0,0,0,5,8,0,0,40,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,40,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,88,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,114,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,1,0,0,236,1,0,0,236,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,239,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,4,0,0,0,231,16,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,115,40,37,117,41,58,32,65,115,115,101,114,116,105,111,110,32,102,97,105,108,117,114,101,58,32,34,37,115,34,10,0,109,95,115,105,122,101,32,60,61,32,109,95,99,97,112,97,99,105,116,121,0,46,47,99,114,110,95,100,101,99,111,109,112,46,104,0,109,105,110,95,110,101,119,95,99,97,112,97,99,105,116,121,32,60,32,40,48,120,55,70,70,70,48,48,48,48,85,32,47,32,101,108,101,109,101,110,116,95,115,105,122,101,41,0,110,101,119,95,99,97,112,97,99,105,116,121,32,38,38,32,40,110,101,119,95,99,97,112,97,99,105,116,121,32,62,32,109,95,99,97,112,97,99,105,116,121,41,0,110,117,109,95,99,111,100,101,115,91,99,93,0,115,111,114,116,101,100,95,112,111,115,32,60,32,116,111,116,97,108,95,117,115,101,100,95,115,121,109,115,0,112,67,111,100,101,115,105,122,101,115,91,115,121,109,95,105,110,100,101,120,93,32,61,61,32,99,111,100,101,115,105,122,101,0,116,32,60,32,40,49,85,32,60,60,32,116,97,98,108,101,95,98,105,116,115,41,0,109,95,108,111,111,107,117,112,91,116,93,32,61,61,32,99,85,73,78,84,51,50,95,77,65,88,0,99,114,110,100,95,109,97,108,108,111,99,58,32,115,105,122,101,32,116,111,111,32,98,105,103,0,99,114,110,100,95,109,97,108,108,111,99,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,0,40,40,117,105,110,116,51,50,41,112,95,110,101,119,32,38,32,40,67,82,78,68,95,77,73,78,95,65,76,76,79,67,95,65,76,73,71,78,77,69,78,84,32,45,32,49,41,41,32,61,61,32,48,0,99,114,110,100,95,114,101,97,108,108,111,99,58,32,98,97,100,32,112,116,114,0,99,114,110,100,95,102,114,101,101,58,32,98,97,100,32,112,116,114,0,102,97,108,115,101,0,40,116,111,116,97,108,95,115,121,109,115,32,62,61,32,49,41,32,38,38,32,40,116,111,116,97,108,95,115,121,109,115,32,60,61,32,112,114,101,102,105,120,95,99,111,100,105,110,103,58,58,99,77,97,120,83,117,112,112,111,114,116,101,100,83,121,109,115,41,0,17,18,19,20,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,16,48,0,110,117,109,95,98,105,116,115,32,60,61,32,51,50,85,0,109,95,98,105,116,95,99,111,117,110,116,32,60,61,32,99,66,105,116,66,117,102,83,105,122,101,0,116,32,33,61,32,99,85,73,78,84,51,50,95,77,65,88,0,109,111,100,101,108,46,109,95,99,111,100,101,95,115,105,122,101,115,91,115,121,109,93,32,61,61,32,108,101,110,0,0,2,3,1,0,2,3,4,5,6,7,1,40,108,101,110,32,62,61,32,49,41,32,38,38,32,40,108,101,110,32,60,61,32,99,77,97,120,69,120,112,101,99,116,101,100,67,111,100,101,83,105,122,101,41,0,105,32,60,32,109,95,115,105,122,101,0,110,101,120,116,95,108,101,118,101,108,95,111,102,115,32,62,32,99,117,114,95,108,101,118,101,108,95,111,102,115,0,1,2,2,3,3,3,3,4,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,2,1,2,0,0,0,1,0,2,1,0,2,0,0,1,2,3,110,117,109,32,38,38,32,40,110,117,109,32,61,61,32,126,110,117,109,95,99,104,101,99,107,41,0,83,116,57,101,120,99,101,112,116,105,111,110,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,117,110,99,97,117,103,104,116,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0],"i8",4,n.Ua);var mb=n.ja(D(12,"i8",2),8);function ob(t){return e.___errno_location&&(C[e.___errno_location()>>2]=t),t}assert(0==mb%8),e._i64Subtract=nb;var J={I:1,F:2,ed:3,bc:4,H:5,Aa:6,vb:7,zc:8,ea:9,Jb:10,va:11,qd:11,Ta:12,da:13,Vb:14,Lc:15,fa:16,wa:17,rd:18,ha:19,ya:20,P:21,q:22,uc:23,Sa:24,Q:25,nd:26,Wb:27,Hc:28,ia:29,bd:30,nc:31,Vc:32,Sb:33,Zc:34,Dc:42,Zb:43,Kb:44,ec:45,fc:46,gc:47,mc:48,od:49,xc:50,dc:51,Pb:35,Ac:37,Bb:52,Eb:53,sd:54,vc:55,Fb:56,Gb:57,Qb:35,Hb:59,Jc:60,yc:61,kd:62,Ic:63,Ec:64,Fc:65,ad:66,Bc:67,yb:68,gd:69,Lb:70,Wc:71,pc:72,Tb:73,Db:74,Qc:76,Cb:77,$c:78,hc:79,ic:80,lc:81,kc:82,jc:83,Kc:38,za:39,qc:36,ga:40,Rc:95,Uc:96,Ob:104,wc:105,zb:97,Yc:91,Oc:88,Gc:92,cd:108,Nb:111,wb:98,Mb:103,tc:101,rc:100,ld:110,Xb:112,Yb:113,ac:115,Ab:114,Rb:89,oc:90,Xc:93,dd:94,xb:99,sc:102,cc:106,Mc:107,md:109,pd:87,Ub:122,hd:116,Pc:95,Cc:123,$b:84,Sc:75,Ib:125,Nc:131,Tc:130,jd:86};function pb(e,t){H.push(function(){n.L("vi",e,[t])}),pb.level=H.length}function tb(){return!!tb.p}e._memset=qb,e._bitshift64Lshr=rb,e._bitshift64Shl=sb;var ub=[],vb={};function wb(e,t){wb.p||(wb.p={}),e in wb.p||(n.L("v",t),wb.p[e]=1)}var xb={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};function yb(e,t){for(var r=0,i=e.length-1;0<=i;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function zb(e){var t="/"===e.charAt(0),r="/"===e.substr(-1);return(e=yb(e.split("/").filter(function(e){return!!e}),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function Ab(e){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."}function Bb(e){if("/"===e)return"/";var t=e.lastIndexOf("/");return-1===t?e:e.substr(t+1)}function Cb(){return zb(Array.prototype.slice.call(arguments,0).join("/"))}function K(e,t){return zb(e+"/"+t)}function Db(){for(var e="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=yb(e.split("/").filter(function(e){return!!e}),!t).join("/"))||"."}var Eb=[];function Fb(e,t){Eb[e]={input:[],output:[],N:t},Gb(e,Hb)}var Hb={open:function(e){var t=Eb[e.g.rdev];if(!t)throw new L(J.ha);e.tty=t,e.seekable=!1},close:function(e){e.tty.N.flush(e.tty)},flush:function(e){e.tty.N.flush(e.tty)},read:function(e,t,r,i){if(!e.tty||!e.tty.N.La)throw new L(J.Aa);for(var n=0,o=0;oe.e.length&&(e.e=M.cb(e),e.o=e.e.length),!e.e||e.e.subarray){var r=e.e?e.e.buffer.byteLength:0;t<=r||(t=Math.max(t,r*(r<1048576?2:1.125)|0),0!=r&&(t=Math.max(t,256)),r=e.e,e.e=new Uint8Array(t),0t)e.e.length=t;else for(;e.e.length=e.g.o)return 0;if(assert(0<=(e=Math.min(e.g.o-n,i))),8>1)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return t.mode},B:function(e){for(var t=[];e.parent!==e;)t.push(e.name),e=e.parent;return t.push(e.A.pa.root),t.reverse(),Cb.apply(null,t)},Ha:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},$a:function(e){if((e&=-32769)in P.Ha)return P.Ha[e];throw new L(J.q)},k:{D:function(e){var t;e=P.B(e);try{t=fs.lstatSync(e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return P.$&&!t.K&&(t.K=4096),P.$&&!t.blocks&&(t.blocks=(t.size+t.K-1)/t.K|0),{dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,K:t.K,blocks:t.blocks}},u:function(e,t){var r=P.B(e);try{void 0!==t.mode&&(fs.chmodSync(r,t.mode),e.mode=t.mode),void 0!==t.size&&fs.truncateSync(r,t.size)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},lookup:function(e,t){var r=K(P.B(e),t);r=P.Ja(r);return P.createNode(e,t,r)},T:function(e,t,r,i){e=P.createNode(e,t,r,i),t=P.B(e);try{N(e.mode)?fs.mkdirSync(t,e.mode):fs.writeFileSync(t,"",{mode:e.mode})}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return e},rename:function(e,t,r){e=P.B(e),t=K(P.B(t),r);try{fs.renameSync(e,t)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},unlink:function(e,t){var r=K(P.B(e),t);try{fs.unlinkSync(r)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},rmdir:function(e,t){var r=K(P.B(e),t);try{fs.rmdirSync(r)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},readdir:function(e){e=P.B(e);try{return fs.readdirSync(e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},symlink:function(e,t,r){e=K(P.B(e),t);try{fs.symlinkSync(r,e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},readlink:function(e){var t=P.B(e);try{return t=fs.readlinkSync(t),t=Ob.relative(Ob.resolve(e.A.pa.root),t)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}}},n:{open:function(e){var t=P.B(e.g);try{32768==(61440&e.g.mode)&&(e.V=fs.openSync(t,P.$a(e.flags)))}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},close:function(e){try{32768==(61440&e.g.mode)&&e.V&&fs.closeSync(e.V)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},read:function(e,t,r,i,n){if(0===i)return 0;var o,a=new Buffer(i);try{o=fs.readSync(e.V,a,0,i,n)}catch(e){throw new L(J[e.code])}if(0>>0)%Q.length}function Xb(e){var t=Wb(e.parent.id,e.name);e.M=Q[t],Q[t]=e}function Nb(e,t){var r;if(r=(r=Yb(e,"x"))?r:e.k.lookup?0:J.da)throw new L(r,e);for(r=Q[Wb(e.id,t)];r;r=r.M){var i=r.name;if(r.parent.id===e.id&&i===t)return r}return e.k.lookup(e,t)}function Lb(e,t,r,i){return Zb||((Zb=function(e,t,r,i){e||(e=this),this.parent=e,this.A=e.A,this.U=null,this.id=Sb++,this.name=t,this.mode=r,this.k={},this.n={},this.rdev=i}).prototype={},Object.defineProperties(Zb.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},kb:{get:function(){return N(this.mode)}},jb:{get:function(){return 8192==(61440&this.mode)}}})),Xb(e=new Zb(e,t,r,i)),e}function N(e){return 16384==(61440&e)}var $b={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Yb(e,t){return Tb?0:(-1===t.indexOf("r")||292&e.mode)&&(-1===t.indexOf("w")||146&e.mode)&&(-1===t.indexOf("x")||73&e.mode)?0:J.da}function ac(e,t){try{return Nb(e,t),J.wa}catch(e){}return Yb(e,"wx")}function bc(){for(var e=0;e<=4096;e++)if(!Rb[e])return e;throw new L(J.Sa)}function cc(e){dc||((dc=function(){}).prototype={},Object.defineProperties(dc.prototype,{object:{get:function(){return this.g},set:function(e){this.g=e}},Ld:{get:function(){return 1!=(2097155&this.flags)}},Md:{get:function(){return 0!=(2097155&this.flags)}},Kd:{get:function(){return 1024&this.flags}}}));var t,r=new dc;for(t in e)r[t]=e[t];return e=r,r=bc(),e.fd=r,Rb[r]=e}var Kb={open:function(e){e.n=Qb[e.g.rdev].n,e.n.open&&e.n.open(e)},G:function(){throw new L(J.ia)}},qc;function Gb(e,t){Qb[e]={n:t}}function ec(e,t){var r,i="/"===t,n=!t;if(i&&Pb)throw new L(J.fa);if(!i&&!n){if(t=(r=S(t,{Ia:!1})).path,(r=r.g).U)throw new L(J.fa);if(!N(r.mode))throw new L(J.ya)}n={type:e,pa:{},Oa:t,lb:[]};var o=e.A(n);(o.A=n).root=o,i?Pb=o:r&&(r.U=n,r.A&&r.A.lb.push(n))}function fc(e,t,r){var i=S(e,{parent:!0}).g;if(!(e=Bb(e))||"."===e||".."===e)throw new L(J.q);var n=ac(i,e);if(n)throw new L(n);if(!i.k.T)throw new L(J.I);return i.k.T(i,e,t,r)}function gc(e,t){return t=4095&(void 0!==t?t:438),fc(e,t|=32768,0)}function V(e,t){return t=1023&(void 0!==t?t:511),fc(e,t|=16384,0)}function hc(e,t,r){return void 0===r&&(r=t,t=438),fc(e,8192|t,r)}function ic(e,t){if(!Db(e))throw new L(J.F);var r=S(t,{parent:!0}).g;if(!r)throw new L(J.F);var i=Bb(t),n=ac(r,i);if(n)throw new L(n);if(!r.k.symlink)throw new L(J.I);return r.k.symlink(r,i,e)}function Vb(e){if(!(e=S(e).g))throw new L(J.F);if(!e.k.readlink)throw new L(J.q);return Db(T(e.parent),e.k.readlink(e))}function jc(e,t){var r;if(!(r="string"==typeof e?S(e,{la:!0}).g:e).k.u)throw new L(J.I);r.k.u(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})}function kc(t,r){var i,n,o;if(""===t)throw new L(J.F);if("string"==typeof r){if(void 0===(n=$b[r]))throw Error("Unknown file open mode: "+r)}else n=r;if(i=64&(r=n)?4095&(void 0===i?438:i)|32768:0,"object"==typeof t)o=t;else{t=zb(t);try{o=S(t,{la:!(131072&r)}).g}catch(e){}}if(n=!1,64&r)if(o){if(128&r)throw new L(J.wa)}else o=fc(t,i,0),n=!0;if(!o)throw new L(J.F);if(8192==(61440&o.mode)&&(r&=-513),65536&r&&!N(o.mode))throw new L(J.ya);if(!n&&(i=o?40960==(61440&o.mode)?J.ga:N(o.mode)&&(0!=(2097155&r)||512&r)?J.P:(i=["r","w","rw"][3&r],512&r&&(i+="w"),Yb(o,i)):J.F))throw new L(i);if(512&r){var a;if(!(a="string"==typeof(i=o)?S(i,{la:!0}).g:i).k.u)throw new L(J.I);if(N(a.mode))throw new L(J.P);if(32768!=(61440&a.mode))throw new L(J.q);if(i=Yb(a,"w"))throw new L(i);a.k.u(a,{size:0,timestamp:Date.now()})}r&=-641,(o=cc({g:o,path:T(o),flags:r,seekable:!0,position:0,n:o.n,tb:[],error:!1})).n.open&&o.n.open(o),!e.logReadFiles||1&r||(lc||(lc={}),t in lc||(lc[t]=1,e.printErr("read file: "+t)));try{R.onOpenFile&&(a=0,1!=(2097155&r)&&(a|=1),0!=(2097155&r)&&(a|=2),R.onOpenFile(t,a))}catch(e){console.log("FS.trackingDelegate['onOpenFile']('"+t+"', flags) threw an exception: "+e.message)}return o}function mc(e){e.na&&(e.na=null);try{e.n.close&&e.n.close(e)}catch(e){throw e}finally{Rb[e.fd]=null}}function nc(e,t,r){if(!e.seekable||!e.n.G)throw new L(J.ia);e.position=e.n.G(e,t,r),e.tb=[]}function oc(e,t,r,i,n,o){if(i<0||n<0)throw new L(J.q);if(0==(2097155&e.flags))throw new L(J.ea);if(N(e.g.mode))throw new L(J.P);if(!e.n.write)throw new L(J.q);1024&e.flags&&nc(e,0,2);var a=!0;if(void 0===n)n=e.position,a=!1;else if(!e.seekable)throw new L(J.ia);t=e.n.write(e,t,r,i,n,o),a||(e.position+=t);try{e.path&&R.onWriteToFile&&R.onWriteToFile(e.path)}catch(e){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+e.message)}return t}function pc(){L||((L=function(e,t){this.g=t,this.qb=function(e){for(var t in this.S=e,J)if(J[t]===e){this.code=t;break}},this.qb(e),this.message=xb[e]}).prototype=Error(),L.prototype.constructor=L,[J.F].forEach(function(e){Mb[e]=new L(e),Mb[e].stack=""}))}function rc(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}function sc(e,t,r,i){return gc(e=K("string"==typeof e?e:T(e),t),rc(r,i))}function tc(e,t,r,i,n,o){if(n=gc(e=t?K("string"==typeof e?e:T(e),t):e,i=rc(i,n)),r){if("string"==typeof r){e=Array(r.length),t=0;for(var a=r.length;t>2]}function xc(){var e;if(e=X(),!(e=Rb[e]))throw new L(J.ea);return e}var yc={};function Ga(e){Ga.p||(r=Qa(r),Ga.p=!0,assert(n.R),Ga.bb=n.R,n.R=function(){x("cannot dynamically allocate, sbrk now has control")});var t=r;return 0==e||Ga.bb(e)?t:4294967295}e._i64Add=zc;var Ac=1;function Cc(e,t){if(Dc=e,Ec=t,!Fc)return 1;if(0==e)Y=function(){setTimeout(Gc,t)},Hc="timeout";else if(1==e)Y=function(){Ic(Gc)},Hc="rAF";else if(2==e){if(!window.setImmediate){var r=[];window.addEventListener("message",function(e){e.source===window&&"__emcc"===e.data&&(e.stopPropagation(),r.shift()())},!0),window.setImmediate=function(e){r.push(e),window.postMessage("__emcc","*")}}Y=function(){window.setImmediate(Gc)},Hc="immediate"}return 0}function Jc(a,t,r,s,i){e.noExitRuntime=!0,assert(!Fc,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),Fc=a,Kc=s;var u=Lc;if(Gc=function(){if(!na)if(0>r-6&63;r=r-6,e=e+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[n]}2==r?(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&t)<<4],e+="=="):4==r&&(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&t)<<2],e+="="),c.src="data:audio/x-"+a.substr(-3)+";base64,"+e,s(c)}},c.src=n,ad(function(){s(c)})}});var r=e.canvas;r&&(r.sa=r.requestPointerLock||r.mozRequestPointerLock||r.webkitRequestPointerLock||r.msRequestPointerLock||function(){},r.Fa=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},r.Fa=r.Fa.bind(document),document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1),document.addEventListener("mspointerlockchange",t,!1),e.elementPointerLock&&r.addEventListener("click",function(e){!Tc&&r.sa&&(r.sa(),e.preventDefault())},!1))}}function bd(t,r,i,n){if(r&&e.ka&&t==e.canvas)return e.ka;var o,a;if(r){if(a={antialias:!1,alpha:!1},n)for(var s in n)a[s]=n[s];(a=GL.createContext(t,a))&&(o=GL.getContext(a).td),t.style.backgroundColor="black"}else o=t.getContext("2d");return o?(i&&(r||assert("undefined"==typeof GLctx,"cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),e.ka=o,r&&GL.Od(a),e.Td=r,Uc.forEach(function(e){e()}),Vc()),o):null}var cd=!1,dd=void 0,ed=void 0;function fd(t,r,i){function n(){Sc=!1;var t=o.parentNode;(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===t?(o.Da=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msExitFullscreen||document.exitFullscreen||function(){},o.Da=o.Da.bind(document),dd&&o.sa(),Sc=!0,ed&&gd()):(t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),ed&&hd()),e.onFullScreen&&e.onFullScreen(Sc),id(o)}void 0===(dd=t)&&(dd=!0),void 0===(ed=r)&&(ed=!1),void 0===(jd=i)&&(jd=null);var o=e.canvas;cd||(cd=!0,document.addEventListener("fullscreenchange",n,!1),document.addEventListener("mozfullscreenchange",n,!1),document.addEventListener("webkitfullscreenchange",n,!1),document.addEventListener("MSFullscreenChange",n,!1));var a=document.createElement("div");o.parentNode.insertBefore(a,o),a.appendChild(o),a.p=a.requestFullScreen||a.mozRequestFullScreen||a.msRequestFullscreen||(a.webkitRequestFullScreen?function(){a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),i?a.p({Ud:i}):a.p()}var kd=0;function ld(e){var t=Date.now();if(0===kd)kd=t+1e3/60;else for(;kd<=t+2;)kd+=1e3/60;t=Math.max(kd-t,0),setTimeout(e,t)}function Ic(e){"undefined"==typeof window?ld(e):(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||ld),window.requestAnimationFrame(e))}function ad(t){e.noExitRuntime=!0,setTimeout(function(){na||t()},1e4)}function $c(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]}function md(e,t,r){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)}function nd(t,r,e){md(t,function(e){assert(e,'Loading data file "'+t+'" failed (no arrayBuffer).'),r(new Uint8Array(e)),lb()},function(){if(!e)throw'Loading data file "'+t+'" failed.';e()}),kb()}var od=[],Wc,Xc,Yc,Zc,jd;function pd(){var t=e.canvas;od.forEach(function(e){e(t.width,t.height)})}function gd(){if("undefined"!=typeof SDL){var e=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=8388608|e}pd()}function hd(){if("undefined"!=typeof SDL){var e=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=-8388609&e}pd()}function id(t,r,i){r&&i?(t.ub=r,t.hb=i):(r=t.ub,i=t.hb);var n=r,o=i;if(e.forcedAspectRatio&&0this.length-1||e<0)){var t=e%this.chunkSize;return this.gb(e/this.chunkSize|0)[t]}},a.prototype.pb=function(e){this.gb=e},a.prototype.Ca=function(){var e=new XMLHttpRequest;if(e.open("HEAD",u,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw Error("Couldn't load "+u+". Status: "+e.status);var t,o=Number(e.getResponseHeader("Content-length")),a=1048576;(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t||(a=o);var s=this;s.pb(function(e){var t=e*a,r=(e+1)*a-1;r=Math.min(r,o-1);if(void 0===s.Y[e]){var i=s.Y;if(r=(e=e.g.e).length)return 0;if(assert(0<=(i=Math.min(e.length-n,i))),e.slice)for(var o=0;o>2]=0;case 21520:return r.tty?-J.q:-J.Q;case 21531:if(n=X(),!r.n.ib)throw new L(J.Q);return r.n.ib(r,i,n);default:x("bad ioctl syscall "+i)}}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},___syscall6:function(e,t){wc=t;try{return mc(xc()),0}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},_emscripten_set_main_loop_timing:Cc,__ZSt18uncaught_exceptionv:tb,___setErrNo:ob,_sbrk:Ga,___cxa_begin_catch:function(e){var t;tb.p--,ub.push(e);e:{if(e&&!vb[e])for(t in vb)if(vb[t].wd===e)break e;t=e}return t&&vb[t].Sd++,e},_emscripten_memcpy_big:function(e,t,r){return E.set(E.subarray(t,t+r),e),e},_sysconf:function(e){switch(e){case 30:return 4096;case 85:return F/4096;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return"object"==typeof navigator&&navigator.hardwareConcurrency||1}return ob(J.q),-1},_pthread_getspecific:function(e){return yc[e]||0},_pthread_self:function(){return 0},_pthread_once:wb,_pthread_key_create:function(e){return 0==e?J.q:(C[e>>2]=Ac,yc[Ac]=0,Ac++,0)},___unlock:function(){},_emscripten_set_main_loop:Jc,_pthread_setspecific:function(e,t){return e in yc?(yc[e]=t,0):J.q},___lock:function(){},_abort:function(){e.abort()},_pthread_cleanup_push:pb,_time:function(e){var t=Date.now()/1e3|0;return e&&(C[e>>2]=t),t},___syscall140:function(e,t){wc=t;try{var r=xc(),i=X(),n=X(),o=X(),a=X();return assert(0===i),nc(r,n,a),C[o>>2]=r.position,r.na&&0===n&&0===a&&(r.na=null),0}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},___syscall146:function(e,t){wc=t;try{var r,i=xc(),n=X();e:{for(var o=X(),a=0,s=0;s>2],C[n+(8*s+4)>>2],void 0);if(u<0){r=-1;break e}a+=u}r=a}return r}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},STACKTOP:m,STACK_MAX:Va,tempDoublePtr:mb,ABORT:na,cttz_i8:qd};var Z=function(e,t,r){"use asm";var i=e.Int8Array;var n=e.Int16Array;var o=e.Int32Array;var a=e.Uint8Array;var s=e.Uint16Array;var u=e.Uint32Array;var c=e.Float32Array;var f=e.Float64Array;var de=new i(r);var $=new n(r);var pe=new o(r);var ve=new a(r);var me=new s(r);var l=new u(r);var h=new c(r);var ee=new f(r);var d=e.byteLength;var be=t.STACKTOP|0;var p=t.STACK_MAX|0;var te=t.tempDoublePtr|0;var v=t.ABORT|0;var m=t.cttz_i8|0;var b=0;var g=0;var y=0;var _=0;var w=e.NaN,x=e.Infinity;var T=0,S=0,E=0,M=0,C=0.0,P=0,A=0,k=0,I=0.0;var re=0;var R=0;var O=0;var D=0;var L=0;var j=0;var F=0;var B=0;var N=0;var U=0;var z=e.Math.floor;var X=e.Math.abs;var q=e.Math.sqrt;var G=e.Math.pow;var H=e.Math.cos;var V=e.Math.sin;var W=e.Math.tan;var Y=e.Math.acos;var K=e.Math.asin;var J=e.Math.atan;var Z=e.Math.atan2;var Q=e.Math.exp;var ie=e.Math.log;var ne=e.Math.ceil;var ge=e.Math.imul;var oe=e.Math.min;var ae=e.Math.clz32;var se=t.abort;var ue=t.assert;var ce=t.invoke_iiii;var fe=t.invoke_viiiii;var le=t.invoke_vi;var he=t.invoke_ii;var ye=t.invoke_viii;var _e=t.invoke_v;var we=t.invoke_viiiiii;var xe=t.invoke_iiiiii;var Te=t.invoke_viiii;var Se=t._pthread_cleanup_pop;var Ee=t.___syscall54;var Me=t.___syscall6;var Ce=t._emscripten_set_main_loop_timing;var Pe=t.__ZSt18uncaught_exceptionv;var Ae=t.___setErrNo;var ke=t._sbrk;var Ie=t.___cxa_begin_catch;var Re=t._emscripten_memcpy_big;var Oe=t._sysconf;var De=t._pthread_getspecific;var Le=t._pthread_self;var je=t._pthread_once;var Fe=t._pthread_key_create;var Be=t.___unlock;var Ne=t._emscripten_set_main_loop;var Ue=t._pthread_setspecific;var ze=t.___lock;var Xe=t._abort;var qe=t._pthread_cleanup_push;var Ge=t._time;var He=t.___syscall140;var Ve=t.___syscall146;var We=0.0;function Ye(e){if(d(e)&16777215||d(e)<=16777215||d(e)>2147483648)return false;de=new i(e);$=new n(e);pe=new o(e);ve=new a(e);me=new s(e);l=new u(e);h=new c(e);ee=new f(e);r=e;return true}function Ke(e){e=e|0;var t=0;t=be;be=be+e|0;be=be+15&-16;return t|0}function Je(){return be|0}function Ze(e){e=e|0;be=e}function Qe(e,t){e=e|0;t=t|0;be=e;p=t}function $e(e,t){e=e|0;t=t|0;if(!b){b=e;g=t}}function et(e){e=e|0;de[te>>0]=de[e>>0];de[te+1>>0]=de[e+1>>0];de[te+2>>0]=de[e+2>>0];de[te+3>>0]=de[e+3>>0]}function tt(e){e=e|0;de[te>>0]=de[e>>0];de[te+1>>0]=de[e+1>>0];de[te+2>>0]=de[e+2>>0];de[te+3>>0]=de[e+3>>0];de[te+4>>0]=de[e+4>>0];de[te+5>>0]=de[e+5>>0];de[te+6>>0]=de[e+6>>0];de[te+7>>0]=de[e+7>>0]}function rt(e){e=e|0;re=e}function it(){return re|0}function nt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0;v=be;be=be+608|0;h=v+88|0;l=v+72|0;u=v+64|0;s=v+48|0;a=v+24|0;o=v;f=v+96|0;d=v+92|0;c=e+4|0;p=e+8|0;if((pe[c>>2]|0)>>>0>(pe[p>>2]|0)>>>0){pe[o>>2]=1154;pe[o+4>>2]=2120;pe[o+8>>2]=1133;_r(f,1100,o)|0;yr(f,v+16|0)|0}if((2147418112/(i>>>0)|0)>>>0<=t>>>0){pe[a>>2]=1154;pe[a+4>>2]=2121;pe[a+8>>2]=1169;_r(f,1100,a)|0;yr(f,v+40|0)|0}a=pe[p>>2]|0;if(a>>>0>=t>>>0){p=1;be=v;return p|0}do{if(r){if(t){o=t+-1|0;if(!(o&t)){o=11;break}else t=o}else t=-1;t=t>>>16|t;t=t>>>8|t;t=t>>>4|t;t=t>>>2|t;t=(t>>>1|t)+1|0;o=10}else o=10}while(0);if((o|0)==10)if(!t){t=0;o=12}else o=11;if((o|0)==11)if(t>>>0<=a>>>0)o=12;if((o|0)==12){pe[s>>2]=1154;pe[s+4>>2]=2130;pe[s+8>>2]=1217;_r(f,1100,s)|0;yr(f,u)|0}r=ge(t,i)|0;do{if(!n){o=ot(pe[e>>2]|0,r,d,1)|0;if(!o){p=0;be=v;return p|0}else{pe[e>>2]=o;break}}else{a=at(r,d)|0;if(!a){p=0;be=v;return p|0}ki[n&0](a,pe[e>>2]|0,pe[c>>2]|0);o=pe[e>>2]|0;do{if(o)if(!(o&7)){Oi[pe[104>>2]&1](o,0,0,1,pe[27]|0)|0;break}else{pe[l>>2]=1154;pe[l+4>>2]=2499;pe[l+8>>2]=1516;_r(f,1100,l)|0;yr(f,h)|0;break}}while(0);pe[e>>2]=a}}while(0);o=pe[d>>2]|0;if(o>>>0>r>>>0)t=(o>>>0)/(i>>>0)|0;pe[p>>2]=t;p=1;be=v;return p|0}function ot(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0;c=be;be=be+592|0;u=c+48|0;o=c+24|0;n=c;s=c+72|0;a=c+68|0;if(e&7){pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1494;_r(s,1100,n)|0;yr(s,c+16|0)|0;u=0;be=c;return u|0}if(t>>>0>2147418112){pe[o>>2]=1154;pe[o+4>>2]=2499;pe[o+8>>2]=1387;_r(s,1100,o)|0;yr(s,c+40|0)|0;u=0;be=c;return u|0}pe[a>>2]=t;i=Oi[pe[104>>2]&1](e,t,a,i,pe[27]|0)|0;if(r)pe[r>>2]=pe[a>>2];if(!(i&7)){u=i;be=c;return u|0}pe[u>>2]=1154;pe[u+4>>2]=2551;pe[u+8>>2]=1440;_r(s,1100,u)|0;yr(s,c+64|0)|0;u=i;be=c;return u|0}function at(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0;u=be;be=be+592|0;a=u+48|0;s=u+24|0;r=u;o=u+72|0;n=u+68|0;i=e+3&-4;i=(i|0)!=0?i:4;if(i>>>0>2147418112){pe[r>>2]=1154;pe[r+4>>2]=2499;pe[r+8>>2]=1387;_r(o,1100,r)|0;yr(o,u+16|0)|0;s=0;be=u;return s|0}pe[n>>2]=i;r=Oi[pe[104>>2]&1](0,i,n,1,pe[27]|0)|0;e=pe[n>>2]|0;if(t)pe[t>>2]=e;if((r|0)==0|e>>>0>>0){pe[s>>2]=1154;pe[s+4>>2]=2499;pe[s+8>>2]=1413;_r(o,1100,s)|0;yr(o,u+40|0)|0;s=0;be=u;return s|0}if(!(r&7)){s=r;be=u;return s|0}pe[a>>2]=1154;pe[a+4>>2]=2526;pe[a+8>>2]=1440;_r(o,1100,a)|0;yr(o,u+64|0)|0;s=r;be=u;return s|0}function st(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0;B=be;be=be+960|0;L=B+232|0;D=B+216|0;O=B+208|0;R=B+192|0;I=B+184|0;k=B+168|0;A=B+160|0;P=B+144|0;E=B+136|0;S=B+120|0;T=B+112|0;x=B+96|0;y=B+88|0;g=B+72|0;b=B+64|0;m=B+48|0;l=B+40|0;d=B+24|0;h=B+16|0;f=B;C=B+440|0;j=B+376|0;F=B+304|0;v=B+236|0;if((t|0)==0|i>>>0>11){e=0;be=B;return e|0}pe[e>>2]=t;n=F;o=n+68|0;do{pe[n>>2]=0;n=n+4|0}while((n|0)<(o|0));o=0;do{n=de[r+o>>0]|0;if(n<<24>>24){M=F+((n&255)<<2)|0;pe[M>>2]=(pe[M>>2]|0)+1}o=o+1|0}while((o|0)!=(t|0));o=0;c=1;a=0;s=-1;u=0;while(1){n=pe[F+(c<<2)>>2]|0;if(!n)pe[e+28+(c+-1<<2)>>2]=0;else{M=c+-1|0;pe[j+(M<<2)>>2]=o;o=n+o|0;w=16-c|0;pe[e+28+(M<<2)>>2]=(o+-1<>2]=u;pe[v+(c<<2)>>2]=u;a=a>>>0>c>>>0?a:c;s=s>>>0>>0?s:c;u=n+u|0}c=c+1|0;if((c|0)==17){M=a;break}else o=o<<1}pe[e+4>>2]=u;o=e+172|0;do{if(u>>>0>(pe[o>>2]|0)>>>0){pe[o>>2]=u;if(u){n=u+-1|0;if(n&u)p=14}else{n=-1;p=14}if((p|0)==14){w=n>>>16|n;w=w>>>8|w;w=w>>>4|w;w=w>>>2|w;w=(w>>>1|w)+1|0;pe[o>>2]=w>>>0>t>>>0?t:w}a=e+176|0;n=pe[a>>2]|0;do{if(n){w=pe[n+-4>>2]|0;n=n+-8|0;if(!((w|0)!=0?(w|0)==(~pe[n>>2]|0):0)){pe[f>>2]=1154;pe[f+4>>2]=644;pe[f+8>>2]=1863;_r(C,1100,f)|0;yr(C,h)|0}if(!(n&7)){Oi[pe[104>>2]&1](n,0,0,1,pe[27]|0)|0;break}else{pe[d>>2]=1154;pe[d+4>>2]=2499;pe[d+8>>2]=1516;_r(C,1100,d)|0;yr(C,l)|0;break}}}while(0);o=pe[o>>2]|0;o=(o|0)!=0?o:1;n=at((o<<1)+8|0,0)|0;if(!n){pe[a>>2]=0;n=0;break}else{pe[n+4>>2]=o;pe[n>>2]=~o;pe[a>>2]=n+8;p=25;break}}else p=25}while(0);e:do{if((p|0)==25){w=e+24|0;de[w>>0]=s;de[e+25>>0]=M;o=e+176|0;a=0;do{_=de[r+a>>0]|0;n=_&255;if(_<<24>>24){if(!(pe[F+(n<<2)>>2]|0)){pe[m>>2]=1154;pe[m+4>>2]=2273;pe[m+8>>2]=1261;_r(C,1100,m)|0;yr(C,b)|0}_=v+(n<<2)|0;n=pe[_>>2]|0;pe[_>>2]=n+1;if(n>>>0>=u>>>0){pe[g>>2]=1154;pe[g+4>>2]=2277;pe[g+8>>2]=1274;_r(C,1100,g)|0;yr(C,y)|0}$[(pe[o>>2]|0)+(n<<1)>>1]=a}a=a+1|0}while((a|0)!=(t|0));n=de[w>>0]|0;y=(n&255)>>>0>>0?i:0;_=e+8|0;pe[_>>2]=y;g=(y|0)!=0;if(g){b=1<>>0>(pe[n>>2]|0)>>>0){pe[n>>2]=b;a=e+168|0;n=pe[a>>2]|0;do{if(n){m=pe[n+-4>>2]|0;n=n+-8|0;if(!((m|0)!=0?(m|0)==(~pe[n>>2]|0):0)){pe[x>>2]=1154;pe[x+4>>2]=644;pe[x+8>>2]=1863;_r(C,1100,x)|0;yr(C,T)|0}if(!(n&7)){Oi[pe[104>>2]&1](n,0,0,1,pe[27]|0)|0;break}else{pe[S>>2]=1154;pe[S+4>>2]=2499;pe[S+8>>2]=1516;_r(C,1100,S)|0;yr(C,E)|0;break}}}while(0);n=b<<2;o=at(n+8|0,0)|0;if(!o){pe[a>>2]=0;n=0;break e}else{E=o+8|0;pe[o+4>>2]=b;pe[o>>2]=~b;pe[a>>2]=E;o=E;break}}else{o=e+168|0;n=b<<2;a=o;o=pe[o>>2]|0}}while(0);Yr(o|0,-1,n|0)|0;p=e+176|0;m=1;do{if(pe[F+(m<<2)>>2]|0){t=y-m|0;v=1<>2]|0;if(o>>>0>=16){pe[P>>2]=1154;pe[P+4>>2]=1953;pe[P+8>>2]=1737;_r(C,1100,P)|0;yr(C,A)|0}n=pe[e+28+(o<<2)>>2]|0;if(!n)d=-1;else d=(n+-1|0)>>>(16-m|0);if(s>>>0<=d>>>0){l=(pe[e+96+(o<<2)>>2]|0)-s|0;h=m<<16;do{n=me[(pe[p>>2]|0)+(l+s<<1)>>1]|0;if((ve[r+n>>0]|0|0)!=(m|0)){pe[k>>2]=1154;pe[k+4>>2]=2319;pe[k+8>>2]=1303;_r(C,1100,k)|0;yr(C,I)|0}f=s<>>0>=b>>>0){pe[R>>2]=1154;pe[R+4>>2]=2325;pe[R+8>>2]=1337;_r(C,1100,R)|0;yr(C,O)|0}n=pe[a>>2]|0;if((pe[n+(u<<2)>>2]|0)!=-1){pe[D>>2]=1154;pe[D+4>>2]=2327;pe[D+8>>2]=1360;_r(C,1100,D)|0;yr(C,L)|0;n=pe[a>>2]|0}pe[n+(u<<2)>>2]=o;c=c+1|0}while(c>>>0>>0);s=s+1|0}while(s>>>0<=d>>>0)}}m=m+1|0}while(y>>>0>=m>>>0);n=de[w>>0]|0}o=e+96|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j>>2]|0);o=e+100|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+4>>2]|0);o=e+104|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+8>>2]|0);o=e+108|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+12>>2]|0);o=e+112|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+16>>2]|0);o=e+116|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+20>>2]|0);o=e+120|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+24>>2]|0);o=e+124|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+28>>2]|0);o=e+128|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+32>>2]|0);o=e+132|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+36>>2]|0);o=e+136|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+40>>2]|0);o=e+140|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+44>>2]|0);o=e+144|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+48>>2]|0);o=e+148|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+52>>2]|0);o=e+152|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+56>>2]|0);o=e+156|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+60>>2]|0);o=e+16|0;pe[o>>2]=0;a=e+20|0;pe[a>>2]=n&255;t:do{if(g){while(1){if(!i)break t;n=i+-1|0;if(!(pe[F+(i<<2)>>2]|0))i=n;else break}pe[o>>2]=pe[e+28+(n<<2)>>2];n=y+1|0;pe[a>>2]=n;if(n>>>0<=M>>>0){while(1){if(pe[F+(n<<2)>>2]|0)break;n=n+1|0;if(n>>>0>M>>>0)break t}pe[a>>2]=n}}}while(0);pe[e+92>>2]=-1;pe[e+160>>2]=1048575;pe[e+12>>2]=32-(pe[_>>2]|0);n=1}}while(0);e=n;be=B;return e|0}function ut(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0;if(!e){n=Ur(t)|0;if(!r){r=n;return r|0}if(!n)o=0;else o=qr(n)|0;pe[r>>2]=o;r=n;return r|0}if(!t){zr(e);if(!r){r=0;return r|0}pe[r>>2]=0;r=0;return r|0}n=Xr(e,t)|0;o=(n|0)!=0;if(o|i^1)o=o?n:e;else{n=Xr(e,t)|0;o=(n|0)==0?e:n}if(!r){r=n;return r|0}t=qr(o)|0;pe[r>>2]=t;r=n;return r|0}function ct(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(!((e|0)!=0&t>>>0>73&(r|0)!=0)){r=0;return r|0}if((pe[r>>2]|0)!=40|t>>>0<74){r=0;return r|0}if(((ve[e>>0]|0)<<8|(ve[e+1>>0]|0)|0)!=18552){r=0;return r|0}if(((ve[e+2>>0]|0)<<8|(ve[e+3>>0]|0))>>>0<74){r=0;return r|0}if(((ve[e+7>>0]|0)<<16|(ve[e+6>>0]|0)<<24|(ve[e+8>>0]|0)<<8|(ve[e+9>>0]|0))>>>0>t>>>0){r=0;return r|0}pe[r+4>>2]=(ve[e+12>>0]|0)<<8|(ve[e+13>>0]|0);pe[r+8>>2]=(ve[e+14>>0]|0)<<8|(ve[e+15>>0]|0);pe[r+12>>2]=ve[e+16>>0];pe[r+16>>2]=ve[e+17>>0];t=e+18|0;i=r+32|0;pe[i>>2]=ve[t>>0];pe[i+4>>2]=0;t=de[t>>0]|0;pe[r+20>>2]=t<<24>>24==0|t<<24>>24==9?8:16;pe[r+24>>2]=(ve[e+26>>0]|0)<<16|(ve[e+25>>0]|0)<<24|(ve[e+27>>0]|0)<<8|(ve[e+28>>0]|0);pe[r+28>>2]=(ve[e+30>>0]|0)<<16|(ve[e+29>>0]|0)<<24|(ve[e+31>>0]|0)<<8|(ve[e+32>>0]|0);r=1;return r|0}function ft(e){e=e|0;Ie(e|0)|0;zt()}function lt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0;o=be;be=be+544|0;n=o;i=o+24|0;t=pe[e+20>>2]|0;if(t)ht(t);t=e+4|0;r=pe[t>>2]|0;if(!r){n=e+16|0;de[n>>0]=0;be=o;return}if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1516;_r(i,1100,n)|0;yr(i,o+16|0)|0}pe[t>>2]=0;pe[e+8>>2]=0;pe[e+12>>2]=0;n=e+16|0;de[n>>0]=0;be=o;return}function ht(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;d=be;be=be+640|0;h=d+112|0;l=d+96|0;f=d+88|0;c=d+72|0;u=d+64|0;s=d+48|0;i=d+40|0;o=d+24|0;n=d+16|0;r=d;a=d+120|0;if(!e){be=d;return}t=pe[e+168>>2]|0;do{if(t){p=pe[t+-4>>2]|0;t=t+-8|0;if(!((p|0)!=0?(p|0)==(~pe[t>>2]|0):0)){pe[r>>2]=1154;pe[r+4>>2]=644;pe[r+8>>2]=1863;_r(a,1100,r)|0;yr(a,n)|0}if(!(t&7)){Oi[pe[104>>2]&1](t,0,0,1,pe[27]|0)|0;break}else{pe[o>>2]=1154;pe[o+4>>2]=2499;pe[o+8>>2]=1516;_r(a,1100,o)|0;yr(a,i)|0;break}}}while(0);t=pe[e+176>>2]|0;do{if(t){p=pe[t+-4>>2]|0;t=t+-8|0;if(!((p|0)!=0?(p|0)==(~pe[t>>2]|0):0)){pe[s>>2]=1154;pe[s+4>>2]=644;pe[s+8>>2]=1863;_r(a,1100,s)|0;yr(a,u)|0}if(!(t&7)){Oi[pe[104>>2]&1](t,0,0,1,pe[27]|0)|0;break}else{pe[c>>2]=1154;pe[c+4>>2]=2499;pe[c+8>>2]=1516;_r(a,1100,c)|0;yr(a,f)|0;break}}}while(0);if(!(e&7)){Oi[pe[104>>2]&1](e,0,0,1,pe[27]|0)|0;be=d;return}else{pe[l>>2]=1154;pe[l+4>>2]=2499;pe[l+8>>2]=1516;_r(a,1100,l)|0;yr(a,h)|0;be=d;return}}function dt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+560|0;a=f+40|0;s=f+24|0;t=f;o=f+48|0;n=e+8|0;r=pe[n>>2]|0;if((r+-1|0)>>>0>=8192){pe[t>>2]=1154;pe[t+4>>2]=2997;pe[t+8>>2]=1541;_r(o,1100,t)|0;yr(o,f+16|0)|0}pe[e>>2]=r;i=e+20|0;t=pe[i>>2]|0;if(!t){t=at(180,0)|0;if(!t)t=0;else{c=t+164|0;pe[c>>2]=0;pe[c+4>>2]=0;pe[c+8>>2]=0;pe[c+12>>2]=0}pe[i>>2]=t;c=t;u=pe[e>>2]|0}else{c=t;u=r}if(!(pe[n>>2]|0)){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(o,1100,s)|0;yr(o,a)|0;o=pe[e>>2]|0}else o=u;n=pe[e+4>>2]|0;if(o>>>0>16){r=o;t=0}else{e=0;c=st(c,u,n,e)|0;be=f;return c|0}while(1){i=t+1|0;if(r>>>0>3){r=r>>>1;t=i}else{r=i;break}}e=t+2+((r|0)!=32&1<>>0>>0&1)|0;e=e>>>0<11?e&255:11;c=st(c,u,n,e)|0;be=f;return c|0}function pt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0;L=be;be=be+800|0;k=L+256|0;A=L+240|0;P=L+232|0;C=L+216|0;M=L+208|0;E=L+192|0;S=L+184|0;T=L+168|0;x=L+160|0;w=L+144|0;_=L+136|0;y=L+120|0;g=L+112|0;b=L+96|0;m=L+88|0;v=L+72|0;l=L+64|0;f=L+48|0;s=L+40|0;u=L+24|0;o=L+16|0;n=L;O=L+288|0;D=L+264|0;I=vt(e,14)|0;if(!I){pe[t>>2]=0;r=t+4|0;i=pe[r>>2]|0;if(i){if(!(i&7))Oi[pe[104>>2]&1](i,0,0,1,pe[27]|0)|0;else{pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1516;_r(O,1100,n)|0;yr(O,o)|0}pe[r>>2]=0;pe[t+8>>2]=0;pe[t+12>>2]=0}de[t+16>>0]=0;r=t+20|0;i=pe[r>>2]|0;if(!i){t=1;be=L;return t|0}ht(i);pe[r>>2]=0;t=1;be=L;return t|0}d=t+4|0;p=t+8|0;r=pe[p>>2]|0;if((r|0)!=(I|0)){if(r>>>0<=I>>>0){do{if((pe[t+12>>2]|0)>>>0>>0){if(nt(d,I,(r+1|0)==(I|0),1,0)|0){r=pe[p>>2]|0;break}de[t+16>>0]=1;t=0;be=L;return t|0}}while(0);Yr((pe[d>>2]|0)+r|0,0,I-r|0)|0}pe[p>>2]=I}Yr(pe[d>>2]|0,0,I|0)|0;h=e+20|0;r=pe[h>>2]|0;if((r|0)<5){o=e+4|0;a=e+8|0;n=e+16|0;do{i=pe[o>>2]|0;if((i|0)==(pe[a>>2]|0))i=0;else{pe[o>>2]=i+1;i=ve[i>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[u>>2]=1154;pe[u+4>>2]=3199;pe[u+8>>2]=1650;_r(O,1100,u)|0;yr(O,s)|0;r=pe[h>>2]|0}i=i<<32-r|pe[n>>2];pe[n>>2]=i}while((r|0)<5)}else{i=e+16|0;n=i;i=pe[i>>2]|0}c=i>>>27;pe[n>>2]=i<<5;pe[h>>2]=r+-5;if((c+-1|0)>>>0>20){t=0;be=L;return t|0}pe[D+20>>2]=0;pe[D>>2]=0;pe[D+4>>2]=0;pe[D+8>>2]=0;pe[D+12>>2]=0;de[D+16>>0]=0;r=D+4|0;i=D+8|0;e:do{if(nt(r,21,0,1,0)|0){s=pe[i>>2]|0;u=pe[r>>2]|0;Yr(u+s|0,0,21-s|0)|0;pe[i>>2]=21;if(c){n=e+4|0;o=e+8|0;a=e+16|0;s=0;do{r=pe[h>>2]|0;if((r|0)<3)do{i=pe[n>>2]|0;if((i|0)==(pe[o>>2]|0))i=0;else{pe[n>>2]=i+1;i=ve[i>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[f>>2]=1154;pe[f+4>>2]=3199;pe[f+8>>2]=1650;_r(O,1100,f)|0;yr(O,l)|0;r=pe[h>>2]|0}i=i<<32-r|pe[a>>2];pe[a>>2]=i}while((r|0)<3);else i=pe[a>>2]|0;pe[a>>2]=i<<3;pe[h>>2]=r+-3;de[u+(ve[1611+s>>0]|0)>>0]=i>>>29;s=s+1|0}while((s|0)!=(c|0))}if(dt(D)|0){s=e+4|0;u=e+8|0;c=e+16|0;i=0;t:while(1){a=I-i|0;r=mt(e,D)|0;r:do{if(r>>>0<17){if((pe[p>>2]|0)>>>0<=i>>>0){pe[v>>2]=1154;pe[v+4>>2]=903;pe[v+8>>2]=1781;_r(O,1100,v)|0;yr(O,m)|0}de[(pe[d>>2]|0)+i>>0]=r;r=i+1|0}else switch(r|0){case 17:{r=pe[h>>2]|0;if((r|0)<3)do{n=pe[s>>2]|0;if((n|0)==(pe[u>>2]|0))n=0;else{pe[s>>2]=n+1;n=ve[n>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[b>>2]=1154;pe[b+4>>2]=3199;pe[b+8>>2]=1650;_r(O,1100,b)|0;yr(O,g)|0;r=pe[h>>2]|0}n=n<<32-r|pe[c>>2];pe[c>>2]=n}while((r|0)<3);else n=pe[c>>2]|0;pe[c>>2]=n<<3;pe[h>>2]=r+-3;r=(n>>>29)+3|0;if(r>>>0>a>>>0){r=0;break e}r=r+i|0;break r}case 18:{r=pe[h>>2]|0;if((r|0)<7)do{n=pe[s>>2]|0;if((n|0)==(pe[u>>2]|0))n=0;else{pe[s>>2]=n+1;n=ve[n>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[y>>2]=1154;pe[y+4>>2]=3199;pe[y+8>>2]=1650;_r(O,1100,y)|0;yr(O,_)|0;r=pe[h>>2]|0}n=n<<32-r|pe[c>>2];pe[c>>2]=n}while((r|0)<7);else n=pe[c>>2]|0;pe[c>>2]=n<<7;pe[h>>2]=r+-7;r=(n>>>25)+11|0;if(r>>>0>a>>>0){r=0;break e}r=r+i|0;break r}default:{if((r+-19|0)>>>0>=2){R=90;break t}o=pe[h>>2]|0;if((r|0)==19){if((o|0)<2){n=o;while(1){r=pe[s>>2]|0;if((r|0)==(pe[u>>2]|0))o=0;else{pe[s>>2]=r+1;o=ve[r>>0]|0}r=n+8|0;pe[h>>2]=r;if((r|0)>=33){pe[w>>2]=1154;pe[w+4>>2]=3199;pe[w+8>>2]=1650;_r(O,1100,w)|0;yr(O,x)|0;r=pe[h>>2]|0}n=o<<32-r|pe[c>>2];pe[c>>2]=n;if((r|0)<2)n=r;else break}}else{n=pe[c>>2]|0;r=o}pe[c>>2]=n<<2;pe[h>>2]=r+-2;o=(n>>>30)+3|0}else{if((o|0)<6){n=o;while(1){r=pe[s>>2]|0;if((r|0)==(pe[u>>2]|0))o=0;else{pe[s>>2]=r+1;o=ve[r>>0]|0}r=n+8|0;pe[h>>2]=r;if((r|0)>=33){pe[T>>2]=1154;pe[T+4>>2]=3199;pe[T+8>>2]=1650;_r(O,1100,T)|0;yr(O,S)|0;r=pe[h>>2]|0}n=o<<32-r|pe[c>>2];pe[c>>2]=n;if((r|0)<6)n=r;else break}}else{n=pe[c>>2]|0;r=o}pe[c>>2]=n<<6;pe[h>>2]=r+-6;o=(n>>>26)+7|0}if((i|0)==0|o>>>0>a>>>0){r=0;break e}r=i+-1|0;if((pe[p>>2]|0)>>>0<=r>>>0){pe[E>>2]=1154;pe[E+4>>2]=903;pe[E+8>>2]=1781;_r(O,1100,E)|0;yr(O,M)|0}n=de[(pe[d>>2]|0)+r>>0]|0;if(!(n<<24>>24)){r=0;break e}r=o+i|0;if(i>>>0>=r>>>0){r=i;break r}do{if((pe[p>>2]|0)>>>0<=i>>>0){pe[C>>2]=1154;pe[C+4>>2]=903;pe[C+8>>2]=1781;_r(O,1100,C)|0;yr(O,P)|0}de[(pe[d>>2]|0)+i>>0]=n;i=i+1|0}while((i|0)!=(r|0))}}}while(0);if(I>>>0>r>>>0)i=r;else break}if((R|0)==90){pe[A>>2]=1154;pe[A+4>>2]=3140;pe[A+8>>2]=1632;_r(O,1100,A)|0;yr(O,k)|0;r=0;break}if((I|0)==(r|0))r=dt(t)|0;else r=0}else r=0}else{de[D+16>>0]=1;r=0}}while(0);lt(D);t=r;be=L;return t|0}function vt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+544|0;s=f+16|0;a=f;o=f+24|0;if(!t){c=0;be=f;return c|0}if(t>>>0<=16){c=bt(e,t)|0;be=f;return c|0}u=bt(e,t+-16|0)|0;c=e+20|0;t=pe[c>>2]|0;if((t|0)<16){i=e+4|0;n=e+8|0;r=e+16|0;do{e=pe[i>>2]|0;if((e|0)==(pe[n>>2]|0))e=0;else{pe[i>>2]=e+1;e=ve[e>>0]|0}t=t+8|0;pe[c>>2]=t;if((t|0)>=33){pe[a>>2]=1154;pe[a+4>>2]=3199;pe[a+8>>2]=1650;_r(o,1100,a)|0;yr(o,s)|0;t=pe[c>>2]|0}e=e<<32-t|pe[r>>2];pe[r>>2]=e}while((t|0)<16)}else{e=e+16|0;r=e;e=pe[e>>2]|0}pe[r>>2]=e<<16;pe[c>>2]=t+-16;c=e>>>16|u<<16;be=f;return c|0}function mt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0;y=be;be=be+608|0;v=y+88|0;p=y+72|0;h=y+64|0;l=y+48|0;f=y+40|0;d=y+24|0;c=y+16|0;u=y;b=y+96|0;m=pe[t+20>>2]|0;g=e+20|0;s=pe[g>>2]|0;do{if((s|0)<24){a=e+4|0;i=pe[a>>2]|0;n=pe[e+8>>2]|0;r=i>>>0>>0;if((s|0)>=16){if(r){pe[a>>2]=i+1;r=ve[i>>0]|0}else r=0;pe[g>>2]=s+8;a=e+16|0;o=r<<24-s|pe[a>>2];pe[a>>2]=o;break}if(r){o=(ve[i>>0]|0)<<8;r=i+1|0}else{o=0;r=i}if(r>>>0>>0){i=ve[r>>0]|0;r=r+1|0}else i=0;pe[a>>2]=r;pe[g>>2]=s+16;a=e+16|0;o=(i|o)<<16-s|pe[a>>2];pe[a>>2]=o}else{o=e+16|0;a=o;o=pe[o>>2]|0}}while(0);n=(o>>>16)+1|0;do{if(n>>>0<=(pe[m+16>>2]|0)>>>0){i=pe[(pe[m+168>>2]|0)+(o>>>(32-(pe[m+8>>2]|0)|0)<<2)>>2]|0;if((i|0)==-1){pe[u>>2]=1154;pe[u+4>>2]=3244;pe[u+8>>2]=1677;_r(b,1100,u)|0;yr(b,c)|0}r=i&65535;i=i>>>16;if((pe[t+8>>2]|0)>>>0<=r>>>0){pe[d>>2]=1154;pe[d+4>>2]=902;pe[d+8>>2]=1781;_r(b,1100,d)|0;yr(b,f)|0}if((ve[(pe[t+4>>2]|0)+r>>0]|0|0)!=(i|0)){pe[l>>2]=1154;pe[l+4>>2]=3248;pe[l+8>>2]=1694;_r(b,1100,l)|0;yr(b,h)|0}}else{i=pe[m+20>>2]|0;while(1){r=i+-1|0;if(n>>>0>(pe[m+28+(r<<2)>>2]|0)>>>0)i=i+1|0;else break}r=(o>>>(32-i|0))+(pe[m+96+(r<<2)>>2]|0)|0;if(r>>>0<(pe[t>>2]|0)>>>0){r=me[(pe[m+176>>2]|0)+(r<<1)>>1]|0;break}pe[p>>2]=1154;pe[p+4>>2]=3266;pe[p+8>>2]=1632;_r(b,1100,p)|0;yr(b,v)|0;g=0;be=y;return g|0}}while(0);pe[a>>2]=pe[a>>2]<>2]=(pe[g>>2]|0)-i;g=r;be=y;return g|0}function bt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+560|0;s=f+40|0;u=f+24|0;r=f;a=f+48|0;if(t>>>0>=33){pe[r>>2]=1154;pe[r+4>>2]=3190;pe[r+8>>2]=1634;_r(a,1100,r)|0;yr(a,f+16|0)|0}c=e+20|0;r=pe[c>>2]|0;if((r|0)>=(t|0)){o=e+16|0;a=o;o=pe[o>>2]|0;s=r;u=32-t|0;u=o>>>u;o=o<>2]=o;t=s-t|0;pe[c>>2]=t;be=f;return u|0}n=e+4|0;o=e+8|0;i=e+16|0;do{e=pe[n>>2]|0;if((e|0)==(pe[o>>2]|0))e=0;else{pe[n>>2]=e+1;e=ve[e>>0]|0}r=r+8|0;pe[c>>2]=r;if((r|0)>=33){pe[u>>2]=1154;pe[u+4>>2]=3199;pe[u+8>>2]=1650;_r(a,1100,u)|0;yr(a,s)|0;r=pe[c>>2]|0}e=e<<32-r|pe[i>>2];pe[i>>2]=e}while((r|0)<(t|0));u=32-t|0;u=e>>>u;s=e<>2]=s;t=r-t|0;pe[c>>2]=t;be=f;return u|0}function gt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0;p=be;be=be+544|0;h=p+16|0;l=p;f=p+24|0;if((e|0)==0|t>>>0<62){d=0;be=p;return d|0}c=at(300,0)|0;if(!c){d=0;be=p;return d|0}pe[c>>2]=519686845;r=c+4|0;pe[r>>2]=0;i=c+8|0;pe[i>>2]=0;u=c+88|0;n=c+136|0;o=c+160|0;a=u;s=a+44|0;do{pe[a>>2]=0;a=a+4|0}while((a|0)<(s|0));de[u+44>>0]=0;v=c+184|0;a=c+208|0;s=c+232|0;m=c+252|0;pe[m>>2]=0;pe[m+4>>2]=0;pe[m+8>>2]=0;de[m+12>>0]=0;m=c+268|0;pe[m>>2]=0;pe[m+4>>2]=0;pe[m+8>>2]=0;de[m+12>>0]=0;m=c+284|0;pe[m>>2]=0;pe[m+4>>2]=0;pe[m+8>>2]=0;de[m+12>>0]=0;pe[n>>2]=0;pe[n+4>>2]=0;pe[n+8>>2]=0;pe[n+12>>2]=0;pe[n+16>>2]=0;de[n+20>>0]=0;pe[o>>2]=0;pe[o+4>>2]=0;pe[o+8>>2]=0;pe[o+12>>2]=0;pe[o+16>>2]=0;de[o+20>>0]=0;pe[v>>2]=0;pe[v+4>>2]=0;pe[v+8>>2]=0;pe[v+12>>2]=0;pe[v+16>>2]=0;de[v+20>>0]=0;pe[a>>2]=0;pe[a+4>>2]=0;pe[a+8>>2]=0;pe[a+12>>2]=0;pe[a+16>>2]=0;de[a+20>>0]=0;pe[s>>2]=0;pe[s+4>>2]=0;pe[s+8>>2]=0;pe[s+12>>2]=0;de[s+16>>0]=0;do{if(((t>>>0>=74?((ve[e>>0]|0)<<8|(ve[e+1>>0]|0)|0)==18552:0)?((ve[e+2>>0]|0)<<8|(ve[e+3>>0]|0))>>>0>=74:0)?((ve[e+7>>0]|0)<<16|(ve[e+6>>0]|0)<<24|(ve[e+8>>0]|0)<<8|(ve[e+9>>0]|0))>>>0<=t>>>0:0){pe[u>>2]=e;pe[r>>2]=e;pe[i>>2]=t;if(Ct(c)|0){r=pe[u>>2]|0;if((ve[r+39>>0]|0)<<8|(ve[r+40>>0]|0)){if(!(Pt(c)|0))break;if(!(At(c)|0))break;r=pe[u>>2]|0}if(!((ve[r+55>>0]|0)<<8|(ve[r+56>>0]|0))){m=c;be=p;return m|0}if(kt(c)|0?It(c)|0:0){m=c;be=p;return m|0}}}else d=7}while(0);if((d|0)==7)pe[u>>2]=0;jt(c);if(!(c&7)){Oi[pe[104>>2]&1](c,0,0,1,pe[27]|0)|0;m=0;be=p;return m|0}else{pe[l>>2]=1154;pe[l+4>>2]=2499;pe[l+8>>2]=1516;_r(f,1100,l)|0;yr(f,h)|0;m=0;be=p;return m|0}return 0}function yt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+544|0;c=f;u=f+24|0;o=pe[e+88>>2]|0;s=(ve[o+70+(n<<2)+1>>0]|0)<<16|(ve[o+70+(n<<2)>>0]|0)<<24|(ve[o+70+(n<<2)+2>>0]|0)<<8|(ve[o+70+(n<<2)+3>>0]|0);a=n+1|0;if(a>>>0<(ve[o+16>>0]|0)>>>0)o=(ve[o+70+(a<<2)+1>>0]|0)<<16|(ve[o+70+(a<<2)>>0]|0)<<24|(ve[o+70+(a<<2)+2>>0]|0)<<8|(ve[o+70+(a<<2)+3>>0]|0);else o=pe[e+8>>2]|0;if(o>>>0>s>>>0){u=e+4|0;u=pe[u>>2]|0;u=u+s|0;c=o-s|0;c=_t(e,u,c,t,r,i,n)|0;be=f;return c|0}pe[c>>2]=1154;pe[c+4>>2]=3704;pe[c+8>>2]=1792;_r(u,1100,c)|0;yr(u,f+16|0)|0;u=e+4|0;u=pe[u>>2]|0;u=u+s|0;c=o-s|0;c=_t(e,u,c,t,r,i,n)|0;be=f;return c|0}function _t(e,t,r,i,n,o,a){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;var s=0,u=0,c=0,f=0;f=pe[e+88>>2]|0;u=((ve[f+12>>0]|0)<<8|(ve[f+13>>0]|0))>>>a;c=((ve[f+14>>0]|0)<<8|(ve[f+15>>0]|0))>>>a;u=u>>>0>1?(u+3|0)>>>2:1;c=c>>>0>1?(c+3|0)>>>2:1;f=f+18|0;a=de[f>>0]|0;a=ge(a<<24>>24==0|a<<24>>24==9?8:16,u)|0;if(o)if((o&3|0)==0&a>>>0<=o>>>0)a=o;else{e=0;return e|0}if((ge(a,c)|0)>>>0>n>>>0){e=0;return e|0}o=(u+1|0)>>>1;s=(c+1|0)>>>1;if(!r){e=0;return e|0}pe[e+92>>2]=t;pe[e+96>>2]=t;pe[e+104>>2]=r;pe[e+100>>2]=t+r;pe[e+108>>2]=0;pe[e+112>>2]=0;switch(ve[f>>0]|0|0){case 0:{Rt(e,i,n,a,u,c,o,s)|0;e=1;return e|0}case 4:case 6:case 5:case 3:case 2:{Ot(e,i,n,a,u,c,o,s)|0;e=1;return e|0}case 9:{Dt(e,i,n,a,u,c,o,s)|0;e=1;return e|0}case 8:case 7:{Lt(e,i,n,a,u,c,o,s)|0;e=1;return e|0}default:{e=0;return e|0}}return 0}function wt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ct(e,t,r)|0;be=i;return pe[r+4>>2]|0}function xt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ct(e,t,r)|0;be=i;return pe[r+8>>2]|0}function Tt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ct(e,t,r)|0;be=i;return pe[r+12>>2]|0}function St(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ct(e,t,r)|0;be=i;return pe[r+32>>2]|0}function Et(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,c=0;u=be;be=be+576|0;a=u+56|0;o=u+40|0;n=u+64|0;c=u;pe[c>>2]=40;ct(e,t,c)|0;i=(((pe[c+4>>2]|0)>>>r)+3|0)>>>2;t=(((pe[c+8>>2]|0)>>>r)+3|0)>>>2;r=c+32|0;e=pe[r+4>>2]|0;do{switch(pe[r>>2]|0){case 0:{if(!e)e=8;else s=13;break}case 1:{if(!e)s=12;else s=13;break}case 2:{if(!e)s=12;else s=13;break}case 3:{if(!e)s=12;else s=13;break}case 4:{if(!e)s=12;else s=13;break}case 5:{if(!e)s=12;else s=13;break}case 6:{if(!e)s=12;else s=13;break}case 7:{if(!e)s=12;else s=13;break}case 8:{if(!e)s=12;else s=13;break}case 9:{if(!e)e=8;else s=13;break}default:s=13}}while(0);if((s|0)==12)e=16;else if((s|0)==13){pe[o>>2]=1154;pe[o+4>>2]=2663;pe[o+8>>2]=1535;_r(n,1100,o)|0;yr(n,a)|0;e=0}c=ge(ge(t,i)|0,e)|0;be=u;return c|0}function Mt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0;p=be;be=be+608|0;h=p+80|0;d=p+64|0;s=p+56|0;a=p+40|0;f=p+88|0;v=p;l=p+84|0;pe[v>>2]=40;ct(e,t,v)|0;u=(((pe[v+4>>2]|0)>>>n)+3|0)>>>2;v=v+32|0;o=pe[v+4>>2]|0;do{switch(pe[v>>2]|0){case 0:{if(!o)o=8;else c=13;break}case 1:{if(!o)c=12;else c=13;break}case 2:{if(!o)c=12;else c=13;break}case 3:{if(!o)c=12;else c=13;break}case 4:{if(!o)c=12;else c=13;break}case 5:{if(!o)c=12;else c=13;break}case 6:{if(!o)c=12;else c=13;break}case 7:{if(!o)c=12;else c=13;break}case 8:{if(!o)c=12;else c=13;break}case 9:{if(!o)o=8;else c=13;break}default:c=13}}while(0);if((c|0)==12)o=16;else if((c|0)==13){pe[a>>2]=1154;pe[a+4>>2]=2663;pe[a+8>>2]=1535;_r(f,1100,a)|0;yr(f,s)|0;o=0}s=ge(o,u)|0;a=gt(e,t)|0;pe[l>>2]=r;o=(a|0)==0;if(!(n>>>0>15|(i>>>0<8|o))?(pe[a>>2]|0)==519686845:0)yt(a,l,i,s,n)|0;if(o){be=p;return}if((pe[a>>2]|0)!=519686845){be=p;return}jt(a);if(!(a&7)){Oi[pe[104>>2]&1](a,0,0,1,pe[27]|0)|0;be=p;return}else{pe[d>>2]=1154;pe[d+4>>2]=2499;pe[d+8>>2]=1516;_r(f,1100,d)|0;yr(f,h)|0;be=p;return}}function Ct(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0;a=e+92|0;i=pe[e+4>>2]|0;o=e+88|0;n=pe[o>>2]|0;t=(ve[n+68>>0]|0)<<8|(ve[n+67>>0]|0)<<16|(ve[n+69>>0]|0);r=i+t|0;n=(ve[n+65>>0]|0)<<8|(ve[n+66>>0]|0);if(!n){e=0;return e|0}pe[a>>2]=r;pe[e+96>>2]=r;pe[e+104>>2]=n;pe[e+100>>2]=i+(n+t);pe[e+108>>2]=0;pe[e+112>>2]=0;if(!(pt(a,e+116|0)|0)){e=0;return e|0}t=pe[o>>2]|0;do{if(!((ve[t+39>>0]|0)<<8|(ve[t+40>>0]|0))){if(!((ve[t+55>>0]|0)<<8|(ve[t+56>>0]|0))){e=0;return e|0}}else{if(!(pt(a,e+140|0)|0)){e=0;return e|0}if(pt(a,e+188|0)|0){t=pe[o>>2]|0;break}else{e=0;return e|0}}}while(0);if((ve[t+55>>0]|0)<<8|(ve[t+56>>0]|0)){if(!(pt(a,e+164|0)|0)){e=0;return e|0}if(!(pt(a,e+212|0)|0)){e=0;return e|0}}e=1;return e|0}function Pt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;p=be;be=be+592|0;u=p+16|0;s=p;a=p+72|0;d=p+24|0;i=e+88|0;t=pe[i>>2]|0;h=(ve[t+39>>0]|0)<<8|(ve[t+40>>0]|0);f=e+236|0;o=e+240|0;r=pe[o>>2]|0;if((r|0)!=(h|0)){if(r>>>0<=h>>>0){do{if((pe[e+244>>2]|0)>>>0>>0){if(nt(f,h,(r+1|0)==(h|0),4,0)|0){t=pe[o>>2]|0;break}de[e+248>>0]=1;d=0;be=p;return d|0}else t=r}while(0);Yr((pe[f>>2]|0)+(t<<2)|0,0,h-t<<2|0)|0;t=pe[i>>2]|0}pe[o>>2]=h}c=e+92|0;r=pe[e+4>>2]|0;i=(ve[t+34>>0]|0)<<8|(ve[t+33>>0]|0)<<16|(ve[t+35>>0]|0);n=r+i|0;t=(ve[t+37>>0]|0)<<8|(ve[t+36>>0]|0)<<16|(ve[t+38>>0]|0);if(!t){d=0;be=p;return d|0}pe[c>>2]=n;pe[e+96>>2]=n;pe[e+104>>2]=t;pe[e+100>>2]=r+(t+i);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[d+20>>2]=0;pe[d>>2]=0;pe[d+4>>2]=0;pe[d+8>>2]=0;pe[d+12>>2]=0;de[d+16>>0]=0;e=d+24|0;pe[d+44>>2]=0;pe[e>>2]=0;pe[e+4>>2]=0;pe[e+8>>2]=0;pe[e+12>>2]=0;de[e+16>>0]=0;if(pt(c,d)|0?(l=d+24|0,pt(c,l)|0):0){if(!(pe[o>>2]|0)){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(a,1100,s)|0;yr(a,u)|0}if(!h)t=1;else{i=0;n=0;o=0;t=0;a=0;e=0;s=0;r=pe[f>>2]|0;while(1){i=(mt(c,d)|0)+i&31;n=(mt(c,l)|0)+n&63;o=(mt(c,d)|0)+o&31;t=(mt(c,d)|0)+t|0;a=(mt(c,l)|0)+a&63;e=(mt(c,d)|0)+e&31;pe[r>>2]=n<<5|i<<11|o|t<<27|a<<21|e<<16;s=s+1|0;if((s|0)==(h|0)){t=1;break}else{t=t&31;r=r+4|0}}}}else t=0;lt(d+24|0);lt(d);d=t;be=p;return d|0}function At(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0;E=be;be=be+1024|0;s=E+16|0;a=E;o=E+504|0;S=E+480|0;x=E+284|0;T=E+88|0;w=E+24|0;n=pe[e+88>>2]|0;_=(ve[n+47>>0]|0)<<8|(ve[n+48>>0]|0);y=e+92|0;t=pe[e+4>>2]|0;r=(ve[n+42>>0]|0)<<8|(ve[n+41>>0]|0)<<16|(ve[n+43>>0]|0);i=t+r|0;n=(ve[n+45>>0]|0)<<8|(ve[n+44>>0]|0)<<16|(ve[n+46>>0]|0);if(!n){S=0;be=E;return S|0}pe[y>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[S+20>>2]=0;pe[S>>2]=0;pe[S+4>>2]=0;pe[S+8>>2]=0;pe[S+12>>2]=0;de[S+16>>0]=0;if(pt(y,S)|0){r=0;i=-3;n=-3;while(1){pe[x+(r<<2)>>2]=i;pe[T+(r<<2)>>2]=n;t=(i|0)>2;r=r+1|0;if((r|0)==49)break;else{i=t?-3:i+1|0;n=(t&1)+n|0}}t=w;r=t+64|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(r|0));g=e+252|0;r=e+256|0;t=pe[r>>2]|0;e:do{if((t|0)==(_|0))u=13;else{if(t>>>0<=_>>>0){do{if((pe[e+260>>2]|0)>>>0<_>>>0)if(nt(g,_,(t+1|0)==(_|0),4,0)|0){t=pe[r>>2]|0;break}else{de[e+264>>0]=1;t=0;break e}}while(0);Yr((pe[g>>2]|0)+(t<<2)|0,0,_-t<<2|0)|0}pe[r>>2]=_;u=13}}while(0);do{if((u|0)==13){if(!_){pe[a>>2]=1154;pe[a+4>>2]=903;pe[a+8>>2]=1781;_r(o,1100,a)|0;yr(o,s)|0;t=1;break}i=w+4|0;n=w+8|0;e=w+12|0;o=w+16|0;a=w+20|0;s=w+24|0;u=w+28|0;c=w+32|0;f=w+36|0;l=w+40|0;h=w+44|0;d=w+48|0;p=w+52|0;v=w+56|0;m=w+60|0;b=0;r=pe[g>>2]|0;while(1){t=0;do{M=mt(y,S)|0;g=t<<1;C=w+(g<<2)|0;pe[C>>2]=(pe[C>>2]|0)+(pe[x+(M<<2)>>2]|0)&3;g=w+((g|1)<<2)|0;pe[g>>2]=(pe[g>>2]|0)+(pe[T+(M<<2)>>2]|0)&3;t=t+1|0}while((t|0)!=8);pe[r>>2]=(ve[1725+(pe[i>>2]|0)>>0]|0)<<2|(ve[1725+(pe[w>>2]|0)>>0]|0)|(ve[1725+(pe[n>>2]|0)>>0]|0)<<4|(ve[1725+(pe[e>>2]|0)>>0]|0)<<6|(ve[1725+(pe[o>>2]|0)>>0]|0)<<8|(ve[1725+(pe[a>>2]|0)>>0]|0)<<10|(ve[1725+(pe[s>>2]|0)>>0]|0)<<12|(ve[1725+(pe[u>>2]|0)>>0]|0)<<14|(ve[1725+(pe[c>>2]|0)>>0]|0)<<16|(ve[1725+(pe[f>>2]|0)>>0]|0)<<18|(ve[1725+(pe[l>>2]|0)>>0]|0)<<20|(ve[1725+(pe[h>>2]|0)>>0]|0)<<22|(ve[1725+(pe[d>>2]|0)>>0]|0)<<24|(ve[1725+(pe[p>>2]|0)>>0]|0)<<26|(ve[1725+(pe[v>>2]|0)>>0]|0)<<28|(ve[1725+(pe[m>>2]|0)>>0]|0)<<30;b=b+1|0;if((b|0)==(_|0)){t=1;break}else r=r+4|0}}}while(0)}else t=0;lt(S);C=t;be=E;return C|0}function kt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0;h=be;be=be+560|0;u=h+16|0;s=h;a=h+48|0;l=h+24|0;n=pe[e+88>>2]|0;f=(ve[n+55>>0]|0)<<8|(ve[n+56>>0]|0);c=e+92|0;t=pe[e+4>>2]|0;r=(ve[n+50>>0]|0)<<8|(ve[n+49>>0]|0)<<16|(ve[n+51>>0]|0);i=t+r|0;n=(ve[n+53>>0]|0)<<8|(ve[n+52>>0]|0)<<16|(ve[n+54>>0]|0);if(!n){l=0;be=h;return l|0}pe[c>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[l+20>>2]=0;pe[l>>2]=0;pe[l+4>>2]=0;pe[l+8>>2]=0;pe[l+12>>2]=0;de[l+16>>0]=0;e:do{if(pt(c,l)|0){o=e+268|0;r=e+272|0;t=pe[r>>2]|0;if((t|0)!=(f|0)){if(t>>>0<=f>>>0){do{if((pe[e+276>>2]|0)>>>0>>0)if(nt(o,f,(t+1|0)==(f|0),2,0)|0){t=pe[r>>2]|0;break}else{de[e+280>>0]=1;t=0;break e}}while(0);Yr((pe[o>>2]|0)+(t<<1)|0,0,f-t<<1|0)|0}pe[r>>2]=f}if(!f){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(a,1100,s)|0;yr(a,u)|0;t=1;break}r=0;i=0;n=0;t=pe[o>>2]|0;while(1){u=mt(c,l)|0;r=u+r&255;i=(mt(c,l)|0)+i&255;$[t>>1]=i<<8|r;n=n+1|0;if((n|0)==(f|0)){t=1;break}else t=t+2|0}}else t=0}while(0);lt(l);l=t;be=h;return l|0}function It(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0;E=be;be=be+2432|0;s=E+16|0;a=E;o=E+1912|0;S=E+1888|0;x=E+988|0;T=E+88|0;w=E+24|0;n=pe[e+88>>2]|0;_=(ve[n+63>>0]|0)<<8|(ve[n+64>>0]|0);y=e+92|0;t=pe[e+4>>2]|0;r=(ve[n+58>>0]|0)<<8|(ve[n+57>>0]|0)<<16|(ve[n+59>>0]|0);i=t+r|0;n=(ve[n+61>>0]|0)<<8|(ve[n+60>>0]|0)<<16|(ve[n+62>>0]|0);if(!n){S=0;be=E;return S|0}pe[y>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[S+20>>2]=0;pe[S>>2]=0;pe[S+4>>2]=0;pe[S+8>>2]=0;pe[S+12>>2]=0;de[S+16>>0]=0;if(pt(y,S)|0){r=0;i=-7;n=-7;while(1){pe[x+(r<<2)>>2]=i;pe[T+(r<<2)>>2]=n;t=(i|0)>6;r=r+1|0;if((r|0)==225)break;else{i=t?-7:i+1|0;n=(t&1)+n|0}}t=w;r=t+64|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(r|0));g=e+284|0;r=_*3|0;i=e+288|0;t=pe[i>>2]|0;e:do{if((t|0)==(r|0))u=13;else{if(t>>>0<=r>>>0){do{if((pe[e+292>>2]|0)>>>0>>0)if(nt(g,r,(t+1|0)==(r|0),2,0)|0){t=pe[i>>2]|0;break}else{de[e+296>>0]=1;t=0;break e}}while(0);Yr((pe[g>>2]|0)+(t<<1)|0,0,r-t<<1|0)|0}pe[i>>2]=r;u=13}}while(0);do{if((u|0)==13){if(!_){pe[a>>2]=1154;pe[a+4>>2]=903;pe[a+8>>2]=1781;_r(o,1100,a)|0;yr(o,s)|0;t=1;break}i=w+4|0;n=w+8|0;e=w+12|0;o=w+16|0;a=w+20|0;s=w+24|0;u=w+28|0;c=w+32|0;f=w+36|0;l=w+40|0;h=w+44|0;d=w+48|0;p=w+52|0;v=w+56|0;m=w+60|0;b=0;r=pe[g>>2]|0;while(1){t=0;do{M=mt(y,S)|0;g=t<<1;C=w+(g<<2)|0;pe[C>>2]=(pe[C>>2]|0)+(pe[x+(M<<2)>>2]|0)&7;g=w+((g|1)<<2)|0;pe[g>>2]=(pe[g>>2]|0)+(pe[T+(M<<2)>>2]|0)&7;t=t+1|0}while((t|0)!=8);M=ve[1729+(pe[a>>2]|0)>>0]|0;$[r>>1]=(ve[1729+(pe[i>>2]|0)>>0]|0)<<3|(ve[1729+(pe[w>>2]|0)>>0]|0)|(ve[1729+(pe[n>>2]|0)>>0]|0)<<6|(ve[1729+(pe[e>>2]|0)>>0]|0)<<9|(ve[1729+(pe[o>>2]|0)>>0]|0)<<12|M<<15;C=ve[1729+(pe[l>>2]|0)>>0]|0;$[r+2>>1]=(ve[1729+(pe[s>>2]|0)>>0]|0)<<2|M>>>1|(ve[1729+(pe[u>>2]|0)>>0]|0)<<5|(ve[1729+(pe[c>>2]|0)>>0]|0)<<8|(ve[1729+(pe[f>>2]|0)>>0]|0)<<11|C<<14;$[r+4>>1]=(ve[1729+(pe[h>>2]|0)>>0]|0)<<1|C>>>2|(ve[1729+(pe[d>>2]|0)>>0]|0)<<4|(ve[1729+(pe[p>>2]|0)>>0]|0)<<7|(ve[1729+(pe[v>>2]|0)>>0]|0)<<10|(ve[1729+(pe[m>>2]|0)>>0]|0)<<13;b=b+1|0;if((b|0)==(_|0)){t=1;break}else r=r+6|0}}}while(0)}else t=0;lt(S);C=t;be=E;return C|0}function Rt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0,se=0,ue=0,ce=0,fe=0,le=0,he=0;fe=be;be=be+720|0;ce=fe+184|0;se=fe+168|0;ae=fe+160|0;oe=fe+144|0;ne=fe+136|0;ie=fe+120|0;re=fe+112|0;ee=fe+96|0;$=fe+88|0;Q=fe+72|0;Z=fe+64|0;J=fe+48|0;K=fe+40|0;ue=fe+24|0;te=fe+16|0;Y=fe;V=fe+208|0;W=fe+192|0;N=e+240|0;U=pe[N>>2]|0;q=e+256|0;G=pe[q>>2]|0;r=de[(pe[e+88>>2]|0)+17>>0]|0;H=i>>>2;if(!(r<<24>>24)){be=fe;return 1}z=(s|0)==0;X=s+-1|0;R=(o&1|0)!=0;O=i<<1;D=e+92|0;L=e+116|0;j=e+140|0;F=e+236|0;B=a+-1|0;I=(n&1|0)!=0;k=e+188|0;E=e+252|0;M=H+1|0;C=H+2|0;P=H+3|0;A=B<<4;T=r&255;r=0;o=0;n=1;S=0;do{if(!z){w=pe[t+(S<<2)>>2]|0;x=0;while(1){g=x&1;u=(g|0)==0;b=(g<<5^32)+-16|0;g=(g<<1^2)+-1|0;_=u?a:-1;c=u?0:B;e=(x|0)==(X|0);y=R&e;if((c|0)!=(_|0)){m=R&e^1;v=u?w:w+A|0;while(1){if((n|0)==1)n=mt(D,L)|0|512;p=n&7;n=n>>>3;u=ve[1823+p>>0]|0;e=0;do{h=(mt(D,j)|0)+o|0;d=h-U|0;o=d>>31;o=o&h|d&~o;if((pe[N>>2]|0)>>>0<=o>>>0){pe[Y>>2]=1154;pe[Y+4>>2]=903;pe[Y+8>>2]=1781;_r(V,1100,Y)|0;yr(V,te)|0}pe[W+(e<<2)>>2]=pe[(pe[F>>2]|0)+(o<<2)>>2];e=e+1|0}while(e>>>0>>0);d=I&(c|0)==(B|0);if(y|d){h=0;do{f=ge(h,i)|0;e=v+f|0;u=(h|0)==0|m;l=h<<1;he=(mt(D,k)|0)+r|0;le=he-G|0;r=le>>31;r=r&he|le&~r;do{if(d){if(!u){le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;break}pe[e>>2]=pe[W+((ve[1831+(p<<2)+l>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(V,1100,oe)|0;yr(V,ae)|0}pe[v+(f+4)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r}else{if(!u){le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;break}pe[e>>2]=pe[W+((ve[1831+(p<<2)+l>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[ie>>2]=1154;pe[ie+4>>2]=903;pe[ie+8>>2]=1781;_r(V,1100,ie)|0;yr(V,ne)|0}pe[v+(f+4)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;pe[v+(f+8)>>2]=pe[W+((ve[(l|1)+(1831+(p<<2))>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[se>>2]=1154;pe[se+4>>2]=903;pe[se+8>>2]=1781;_r(V,1100,se)|0;yr(V,ce)|0}pe[v+(f+12)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2]}}while(0);h=h+1|0}while((h|0)!=2)}else{pe[v>>2]=pe[W+((ve[1831+(p<<2)>>0]|0)<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[ue>>2]=1154;pe[ue+4>>2]=903;pe[ue+8>>2]=1781;_r(V,1100,ue)|0;yr(V,K)|0}pe[v+4>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[v+8>>2]=pe[W+((ve[1831+(p<<2)+1>>0]|0)<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[J>>2]=1154;pe[J+4>>2]=903;pe[J+8>>2]=1781;_r(V,1100,J)|0;yr(V,Z)|0}pe[v+12>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[v+(H<<2)>>2]=pe[W+((ve[1831+(p<<2)+2>>0]|0)<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[Q>>2]=1154;pe[Q+4>>2]=903;pe[Q+8>>2]=1781;_r(V,1100,Q)|0;yr(V,$)|0}pe[v+(M<<2)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[v+(C<<2)>>2]=pe[W+((ve[1831+(p<<2)+3>>0]|0)<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[ee>>2]=1154;pe[ee+4>>2]=903;pe[ee+8>>2]=1781;_r(V,1100,ee)|0;yr(V,re)|0}pe[v+(P<<2)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2]}c=c+g|0;if((c|0)==(_|0))break;else v=v+b|0}}x=x+1|0;if((x|0)==(s|0))break;else w=w+O|0}}S=S+1|0}while((S|0)!=(T|0));be=fe;return 1}function Ot(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0,se=0,ue=0,ce=0,fe=0,le=0,he=0;le=be;be=be+640|0;ue=le+88|0;se=le+72|0;ae=le+64|0;oe=le+48|0;ne=le+40|0;fe=le+24|0;ce=le+16|0;ie=le;te=le+128|0;re=le+112|0;ee=le+96|0;N=e+240|0;U=pe[N>>2]|0;q=e+256|0;Z=pe[q>>2]|0;Q=e+272|0;$=pe[Q>>2]|0;r=pe[e+88>>2]|0;z=(ve[r+63>>0]|0)<<8|(ve[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=le;return 1}X=(s|0)==0;G=s+-1|0;H=i<<1;V=e+92|0;W=e+116|0;Y=a+-1|0;K=e+212|0;J=e+188|0;B=(n&1|0)==0;F=(o&1|0)==0;I=e+288|0;R=e+284|0;O=e+252|0;D=e+140|0;L=e+236|0;j=e+164|0;A=e+268|0;k=Y<<5;C=r&255;r=0;n=0;o=0;e=0;u=1;P=0;do{if(!X){E=pe[t+(P<<2)>>2]|0;M=0;while(1){T=M&1;c=(T|0)==0;x=(T<<6^64)+-32|0;T=(T<<1^2)+-1|0;S=c?a:-1;f=c?0:Y;if((f|0)!=(S|0)){w=F|(M|0)!=(G|0);_=c?E:E+k|0;while(1){if((u|0)==1)u=mt(V,W)|0|512;y=u&7;u=u>>>3;l=ve[1823+y>>0]|0;c=0;do{b=(mt(V,j)|0)+n|0;g=b-$|0;n=g>>31;n=n&b|g&~n;if((pe[Q>>2]|0)>>>0<=n>>>0){pe[ie>>2]=1154;pe[ie+4>>2]=903;pe[ie+8>>2]=1781;_r(te,1100,ie)|0;yr(te,ce)|0}pe[ee+(c<<2)>>2]=me[(pe[A>>2]|0)+(n<<1)>>1];c=c+1|0}while(c>>>0>>0);c=0;do{b=(mt(V,D)|0)+e|0;g=b-U|0;e=g>>31;e=e&b|g&~e;if((pe[N>>2]|0)>>>0<=e>>>0){pe[fe>>2]=1154;pe[fe+4>>2]=903;pe[fe+8>>2]=1781;_r(te,1100,fe)|0;yr(te,ne)|0}pe[re+(c<<2)>>2]=pe[(pe[L>>2]|0)+(e<<2)>>2];c=c+1|0}while(c>>>0>>0);g=B|(f|0)!=(Y|0);m=0;b=_;while(1){v=w|(m|0)==0;p=m<<1;h=0;d=b;while(1){l=(mt(V,K)|0)+r|0;c=l-z|0;r=c>>31;r=r&l|c&~r;c=(mt(V,J)|0)+o|0;l=c-Z|0;o=l>>31;o=o&c|l&~o;if((g|(h|0)==0)&v){c=ve[h+p+(1831+(y<<2))>>0]|0;l=r*3|0;if((pe[I>>2]|0)>>>0<=l>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(te,1100,oe)|0;yr(te,ae)|0}he=pe[R>>2]|0;pe[d>>2]=(me[he+(l<<1)>>1]|0)<<16|pe[ee+(c<<2)>>2];pe[d+4>>2]=(me[he+(l+2<<1)>>1]|0)<<16|(me[he+(l+1<<1)>>1]|0);pe[d+8>>2]=pe[re+(c<<2)>>2];if((pe[q>>2]|0)>>>0<=o>>>0){pe[se>>2]=1154;pe[se+4>>2]=903;pe[se+8>>2]=1781;_r(te,1100,se)|0;yr(te,ue)|0}pe[d+12>>2]=pe[(pe[O>>2]|0)+(o<<2)>>2]}h=h+1|0;if((h|0)==2)break;else d=d+16|0}m=m+1|0;if((m|0)==2)break;else b=b+i|0}f=f+T|0;if((f|0)==(S|0))break;else _=_+x|0}}M=M+1|0;if((M|0)==(s|0))break;else E=E+H|0}}P=P+1|0}while((P|0)!=(C|0));be=le;return 1}function Dt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0;Z=be;be=be+608|0;Y=Z+64|0;W=Z+48|0;V=Z+40|0;J=Z+24|0;K=Z+16|0;H=Z;G=Z+88|0;q=Z+72|0;O=e+272|0;D=pe[O>>2]|0;r=pe[e+88>>2]|0;L=(ve[r+63>>0]|0)<<8|(ve[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=Z;return 1}j=(s|0)==0;F=s+-1|0;B=i<<1;N=e+92|0;U=e+116|0;z=a+-1|0;X=e+212|0;R=(o&1|0)==0;A=e+288|0;k=e+284|0;I=e+164|0;C=e+268|0;P=z<<4;M=r&255;E=(n&1|0)!=0;r=0;o=0;e=1;S=0;do{if(!j){x=pe[t+(S<<2)>>2]|0;T=0;while(1){_=T&1;n=(_|0)==0;y=(_<<5^32)+-16|0;_=(_<<1^2)+-1|0;w=n?a:-1;u=n?0:z;if((u|0)!=(w|0)){g=R|(T|0)!=(F|0);b=n?x:x+P|0;while(1){if((e|0)==1)e=mt(N,U)|0|512;m=e&7;e=e>>>3;c=ve[1823+m>>0]|0;n=0;do{p=(mt(N,I)|0)+o|0;v=p-D|0;o=v>>31;o=o&p|v&~o;if((pe[O>>2]|0)>>>0<=o>>>0){pe[H>>2]=1154;pe[H+4>>2]=903;pe[H+8>>2]=1781;_r(G,1100,H)|0;yr(G,K)|0}pe[q+(n<<2)>>2]=me[(pe[C>>2]|0)+(o<<1)>>1];n=n+1|0}while(n>>>0>>0);v=(u|0)==(z|0)&E;d=0;p=b;while(1){h=g|(d|0)==0;l=d<<1;n=(mt(N,X)|0)+r|0;f=n-L|0;c=f>>31;c=c&n|f&~c;if(h){r=ve[1831+(m<<2)+l>>0]|0;n=c*3|0;if((pe[A>>2]|0)>>>0<=n>>>0){pe[J>>2]=1154;pe[J+4>>2]=903;pe[J+8>>2]=1781;_r(G,1100,J)|0;yr(G,V)|0}f=pe[k>>2]|0;pe[p>>2]=(me[f+(n<<1)>>1]|0)<<16|pe[q+(r<<2)>>2];pe[p+4>>2]=(me[f+(n+2<<1)>>1]|0)<<16|(me[f+(n+1<<1)>>1]|0)}f=p+8|0;n=(mt(N,X)|0)+c|0;c=n-L|0;r=c>>31;r=r&n|c&~r;if(!(v|h^1)){n=ve[(l|1)+(1831+(m<<2))>>0]|0;c=r*3|0;if((pe[A>>2]|0)>>>0<=c>>>0){pe[W>>2]=1154;pe[W+4>>2]=903;pe[W+8>>2]=1781;_r(G,1100,W)|0;yr(G,Y)|0}h=pe[k>>2]|0;pe[f>>2]=(me[h+(c<<1)>>1]|0)<<16|pe[q+(n<<2)>>2];pe[p+12>>2]=(me[h+(c+2<<1)>>1]|0)<<16|(me[h+(c+1<<1)>>1]|0)}d=d+1|0;if((d|0)==2)break;else p=p+i|0}u=u+_|0;if((u|0)==(w|0))break;else b=b+y|0}}T=T+1|0;if((T|0)==(s|0))break;else x=x+B|0}}S=S+1|0}while((S|0)!=(M|0));be=Z;return 1}function Lt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0;ae=be;be=be+640|0;ie=ae+88|0;re=ae+72|0;te=ae+64|0;ee=ae+48|0;$=ae+40|0;oe=ae+24|0;ne=ae+16|0;Q=ae;Z=ae+128|0;K=ae+112|0;J=ae+96|0;N=e+272|0;U=pe[N>>2]|0;r=pe[e+88>>2]|0;z=(ve[r+63>>0]|0)<<8|(ve[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=ae;return 1}X=(s|0)==0;q=s+-1|0;G=i<<1;H=e+92|0;V=e+116|0;W=a+-1|0;Y=e+212|0;B=(n&1|0)==0;F=(o&1|0)==0;D=e+288|0;L=e+284|0;j=e+164|0;R=e+268|0;O=W<<5;k=r&255;r=0;n=0;o=0;e=0;u=1;I=0;do{if(!X){P=pe[t+(I<<2)>>2]|0;A=0;while(1){M=A&1;c=(M|0)==0;E=(M<<6^64)+-32|0;M=(M<<1^2)+-1|0;C=c?a:-1;f=c?0:W;if((f|0)!=(C|0)){S=F|(A|0)!=(q|0);T=c?P:P+O|0;while(1){if((u|0)==1)u=mt(H,V)|0|512;x=u&7;u=u>>>3;l=ve[1823+x>>0]|0;c=0;do{_=(mt(H,j)|0)+e|0;w=_-U|0;e=w>>31;e=e&_|w&~e;if((pe[N>>2]|0)>>>0<=e>>>0){pe[Q>>2]=1154;pe[Q+4>>2]=903;pe[Q+8>>2]=1781;_r(Z,1100,Q)|0;yr(Z,ne)|0}pe[K+(c<<2)>>2]=me[(pe[R>>2]|0)+(e<<1)>>1];c=c+1|0}while(c>>>0>>0);c=0;do{_=(mt(H,j)|0)+n|0;w=_-U|0;n=w>>31;n=n&_|w&~n;if((pe[N>>2]|0)>>>0<=n>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(Z,1100,oe)|0;yr(Z,$)|0}pe[J+(c<<2)>>2]=me[(pe[R>>2]|0)+(n<<1)>>1];c=c+1|0}while(c>>>0>>0);w=B|(f|0)!=(W|0);y=0;_=T;while(1){g=S|(y|0)==0;b=y<<1;v=0;m=_;while(1){p=(mt(H,Y)|0)+o|0;d=p-z|0;o=d>>31;o=o&p|d&~o;d=(mt(H,Y)|0)+r|0;p=d-z|0;r=p>>31;r=r&d|p&~r;if((w|(v|0)==0)&g){d=ve[v+b+(1831+(x<<2))>>0]|0;p=o*3|0;c=pe[D>>2]|0;if(c>>>0<=p>>>0){pe[ee>>2]=1154;pe[ee+4>>2]=903;pe[ee+8>>2]=1781;_r(Z,1100,ee)|0;yr(Z,te)|0;c=pe[D>>2]|0}l=pe[L>>2]|0;h=r*3|0;if(c>>>0>h>>>0)c=l;else{pe[re>>2]=1154;pe[re+4>>2]=903;pe[re+8>>2]=1781;_r(Z,1100,re)|0;yr(Z,ie)|0;c=pe[L>>2]|0}pe[m>>2]=(me[l+(p<<1)>>1]|0)<<16|pe[K+(d<<2)>>2];pe[m+4>>2]=(me[l+(p+2<<1)>>1]|0)<<16|(me[l+(p+1<<1)>>1]|0);pe[m+8>>2]=(me[c+(h<<1)>>1]|0)<<16|pe[J+(d<<2)>>2];pe[m+12>>2]=(me[c+(h+2<<1)>>1]|0)<<16|(me[c+(h+1<<1)>>1]|0)}v=v+1|0;if((v|0)==2)break;else m=m+16|0}y=y+1|0;if((y|0)==2)break;else _=_+i|0}f=f+M|0;if((f|0)==(C|0))break;else T=T+E|0}}A=A+1|0;if((A|0)==(s|0))break;else P=P+G|0}}I=I+1|0}while((I|0)!=(k|0));be=ae;return 1}function jt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0;h=be;be=be+608|0;l=h+88|0;f=h+72|0;u=h+64|0;s=h+48|0;o=h+40|0;a=h+24|0;n=h+16|0;i=h;c=h+96|0;pe[e>>2]=0;t=e+284|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[i>>2]=1154;pe[i+4>>2]=2499;pe[i+8>>2]=1516;_r(c,1100,i)|0;yr(c,n)|0}pe[t>>2]=0;pe[e+288>>2]=0;pe[e+292>>2]=0}de[e+296>>0]=0;t=e+268|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[a>>2]=1154;pe[a+4>>2]=2499;pe[a+8>>2]=1516;_r(c,1100,a)|0;yr(c,o)|0}pe[t>>2]=0;pe[e+272>>2]=0;pe[e+276>>2]=0}de[e+280>>0]=0;t=e+252|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[s>>2]=1154;pe[s+4>>2]=2499;pe[s+8>>2]=1516;_r(c,1100,s)|0;yr(c,u)|0}pe[t>>2]=0;pe[e+256>>2]=0;pe[e+260>>2]=0}de[e+264>>0]=0;t=e+236|0;r=pe[t>>2]|0;if(!r){l=e+248|0;de[l>>0]=0;l=e+212|0;lt(l);l=e+188|0;lt(l);l=e+164|0;lt(l);l=e+140|0;lt(l);l=e+116|0;lt(l);be=h;return}if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[f>>2]=1154;pe[f+4>>2]=2499;pe[f+8>>2]=1516;_r(c,1100,f)|0;yr(c,l)|0}pe[t>>2]=0;pe[e+240>>2]=0;pe[e+244>>2]=0;l=e+248|0;de[l>>0]=0;l=e+212|0;lt(l);l=e+188|0;lt(l);l=e+164|0;lt(l);l=e+140|0;lt(l);l=e+116|0;lt(l);be=h;return}function Ft(e,t){e=e|0;t=t|0;var r=0;r=be;be=be+16|0;pe[r>>2]=t;t=pe[63]|0;wr(t,e,r)|0;br(10,t)|0;Xe()}function Bt(){var e=0,t=0;e=be;be=be+16|0;if(!(je(200,2)|0)){t=De(pe[49]|0)|0;be=e;return t|0}else Ft(2090,e);return 0}function Nt(e){e=e|0;zr(e);return}function Ut(e){e=e|0;var t=0;t=be;be=be+16|0;Ii[e&3]();Ft(2139,t)}function zt(){var e=0,t=0;e=Bt()|0;if(((e|0)!=0?(t=pe[e>>2]|0,(t|0)!=0):0)?(e=t+48|0,(pe[e>>2]&-256|0)==1126902528?(pe[e+4>>2]|0)==1129074247:0):0)Ut(pe[t+12>>2]|0);t=pe[28]|0;pe[28]=t+0;Ut(t)}function Xt(e){e=e|0;return}function qt(e){e=e|0;return}function Gt(e){e=e|0;return}function Ht(e){e=e|0;return}function Vt(e){e=e|0;Nt(e);return}function Wt(e){e=e|0;Nt(e);return}function Yt(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;a=be;be=be+64|0;o=a;if((e|0)!=(t|0))if((t|0)!=0?(n=Qt(t,24,40,0)|0,(n|0)!=0):0){t=o;i=t+56|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(i|0));pe[o>>2]=n;pe[o+8>>2]=e;pe[o+12>>2]=-1;pe[o+48>>2]=1;Di[pe[(pe[n>>2]|0)+28>>2]&3](n,o,pe[r>>2]|0,1);if((pe[o+24>>2]|0)==1){pe[r>>2]=pe[o+16>>2];t=1}else t=0}else t=0;else t=1;be=a;return t|0}function Kt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0;e=t+16|0;n=pe[e>>2]|0;do{if(n){if((n|0)!=(r|0)){i=t+36|0;pe[i>>2]=(pe[i>>2]|0)+1;pe[t+24>>2]=2;de[t+54>>0]=1;break}e=t+24|0;if((pe[e>>2]|0)==2)pe[e>>2]=i}else{pe[e>>2]=r;pe[t+24>>2]=i;pe[t+36>>2]=1}}while(0);return}function Jt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;if((e|0)==(pe[t+8>>2]|0))Kt(0,t,r,i);return}function Zt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;if((e|0)==(pe[t+8>>2]|0))Kt(0,t,r,i);else{e=pe[e+8>>2]|0;Di[pe[(pe[e>>2]|0)+28>>2]&3](e,t,r,i)}return}function Qt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0;d=be;be=be+64|0;h=d;l=pe[e>>2]|0;f=e+(pe[l+-8>>2]|0)|0;l=pe[l+-4>>2]|0;pe[h>>2]=r;pe[h+4>>2]=e;pe[h+8>>2]=t;pe[h+12>>2]=i;i=h+16|0;e=h+20|0;t=h+24|0;n=h+28|0;o=h+32|0;a=h+40|0;s=(l|0)==(r|0);u=i;c=u+36|0;do{pe[u>>2]=0;u=u+4|0}while((u|0)<(c|0));$[i+36>>1]=0;de[i+38>>0]=0;e:do{if(s){pe[h+48>>2]=1;Ri[pe[(pe[r>>2]|0)+20>>2]&3](r,h,f,f,1,0);i=(pe[t>>2]|0)==1?f:0}else{Ci[pe[(pe[l>>2]|0)+24>>2]&3](l,h,f,1,0);switch(pe[h+36>>2]|0){case 0:{i=(pe[a>>2]|0)==1&(pe[n>>2]|0)==1&(pe[o>>2]|0)==1?pe[e>>2]|0:0;break e}case 1:break;default:{i=0;break e}}if((pe[t>>2]|0)!=1?!((pe[a>>2]|0)==0&(pe[n>>2]|0)==1&(pe[o>>2]|0)==1):0){i=0;break}i=pe[i>>2]|0}}while(0);be=d;return i|0}function $t(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;de[t+53>>0]=1;do{if((pe[t+4>>2]|0)==(i|0)){de[t+52>>0]=1;i=t+16|0;e=pe[i>>2]|0;if(!e){pe[i>>2]=r;pe[t+24>>2]=n;pe[t+36>>2]=1;if(!((n|0)==1?(pe[t+48>>2]|0)==1:0))break;de[t+54>>0]=1;break}if((e|0)!=(r|0)){n=t+36|0;pe[n>>2]=(pe[n>>2]|0)+1;de[t+54>>0]=1;break}e=t+24|0;i=pe[e>>2]|0;if((i|0)==2){pe[e>>2]=n;i=n}if((i|0)==1?(pe[t+48>>2]|0)==1:0)de[t+54>>0]=1}}while(0);return}function er(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0;e:do{if((e|0)==(pe[t+8>>2]|0)){if((pe[t+4>>2]|0)==(r|0)?(o=t+28|0,(pe[o>>2]|0)!=1):0)pe[o>>2]=i}else{if((e|0)!=(pe[t>>2]|0)){s=pe[e+8>>2]|0;Ci[pe[(pe[s>>2]|0)+24>>2]&3](s,t,r,i,n);break}if((pe[t+16>>2]|0)!=(r|0)?(a=t+20|0,(pe[a>>2]|0)!=(r|0)):0){pe[t+32>>2]=i;i=t+44|0;if((pe[i>>2]|0)==4)break;o=t+52|0;de[o>>0]=0;u=t+53|0;de[u>>0]=0;e=pe[e+8>>2]|0;Ri[pe[(pe[e>>2]|0)+20>>2]&3](e,t,r,r,1,n);if(de[u>>0]|0){if(!(de[o>>0]|0)){o=1;s=13}}else{o=0;s=13}do{if((s|0)==13){pe[a>>2]=r;u=t+40|0;pe[u>>2]=(pe[u>>2]|0)+1;if((pe[t+36>>2]|0)==1?(pe[t+24>>2]|0)==2:0){de[t+54>>0]=1;if(o)break}else s=16;if((s|0)==16?o:0)break;pe[i>>2]=4;break e}}while(0);pe[i>>2]=3;break}if((i|0)==1)pe[t+32>>2]=1}}while(0);return}function tr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0;do{if((e|0)==(pe[t+8>>2]|0)){if((pe[t+4>>2]|0)==(r|0)?(a=t+28|0,(pe[a>>2]|0)!=1):0)pe[a>>2]=i}else if((e|0)==(pe[t>>2]|0)){if((pe[t+16>>2]|0)!=(r|0)?(o=t+20|0,(pe[o>>2]|0)!=(r|0)):0){pe[t+32>>2]=i;pe[o>>2]=r;n=t+40|0;pe[n>>2]=(pe[n>>2]|0)+1;if((pe[t+36>>2]|0)==1?(pe[t+24>>2]|0)==2:0)de[t+54>>0]=1;pe[t+44>>2]=4;break}if((i|0)==1)pe[t+32>>2]=1}}while(0);return}function rr(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;if((e|0)==(pe[t+8>>2]|0))$t(0,t,r,i,n);else{e=pe[e+8>>2]|0;Ri[pe[(pe[e>>2]|0)+20>>2]&3](e,t,r,i,n,o)}return}function ir(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;if((e|0)==(pe[t+8>>2]|0))$t(0,t,r,i,n);return}function nr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;n=be;be=be+16|0;i=n;pe[i>>2]=pe[r>>2];e=Mi[pe[(pe[e>>2]|0)+16>>2]&7](e,t,i)|0;if(e)pe[r>>2]=pe[i>>2];be=n;return e&1|0}function or(e){e=e|0;if(!e)e=0;else e=(Qt(e,24,72,0)|0)!=0;return e&1|0}function ar(){var e=0,t=0,r=0,i=0,n=0,o=0,a=0,s=0;n=be;be=be+48|0;a=n+32|0;r=n+24|0;s=n+16|0;o=n;n=n+36|0;e=Bt()|0;if((e|0)!=0?(i=pe[e>>2]|0,(i|0)!=0):0){e=i+48|0;t=pe[e>>2]|0;e=pe[e+4>>2]|0;if(!((t&-256|0)==1126902528&(e|0)==1129074247)){pe[r>>2]=pe[51];Ft(2368,r)}if((t|0)==1126902529&(e|0)==1129074247)e=pe[i+44>>2]|0;else e=i+80|0;pe[n>>2]=e;i=pe[i>>2]|0;e=pe[i+4>>2]|0;if(Mi[pe[(pe[8>>2]|0)+16>>2]&7](8,i,n)|0){s=pe[n>>2]|0;n=pe[51]|0;s=Ai[pe[(pe[s>>2]|0)+8>>2]&1](s)|0;pe[o>>2]=n;pe[o+4>>2]=e;pe[o+8>>2]=s;Ft(2282,o)}else{pe[s>>2]=pe[51];pe[s+4>>2]=e;Ft(2327,s)}}Ft(2406,a)}function sr(){var e=0;e=be;be=be+16|0;if(!(Fe(196,6)|0)){be=e;return}else Ft(2179,e)}function ur(e){e=e|0;var t=0;t=be;be=be+16|0;zr(e);if(!(Ue(pe[49]|0,0)|0)){be=t;return}else Ft(2229,t)}function cr(e){e=e|0;var t=0,r=0;t=0;while(1){if((ve[2427+t>>0]|0)==(e|0)){r=2;break}t=t+1|0;if((t|0)==87){t=87;e=2515;r=5;break}}if((r|0)==2)if(!t)e=2515;else{e=2515;r=5}if((r|0)==5)while(1){r=e;while(1){e=r+1|0;if(!(de[r>>0]|0))break;else r=e}t=t+-1|0;if(!t)break;else r=5}return e|0}function fr(){var e=0;if(!(pe[52]|0))e=264;else{e=(Le()|0)+60|0;e=pe[e>>2]|0}return e|0}function lr(e){e=e|0;var t=0;if(e>>>0>4294963200){t=fr()|0;pe[t>>2]=0-e;e=-1}return e|0}function hr(e,t){e=+e;t=t|0;var r=0,i=0,n=0;ee[te>>3]=e;r=pe[te>>2]|0;i=pe[te+4>>2]|0;n=Kr(r|0,i|0,52)|0;n=n&2047;switch(n|0){case 0:{if(e!=0.0){e=+hr(e*18446744073709552.0e3,t);r=(pe[t>>2]|0)+-64|0}else r=0;pe[t>>2]=r;break}case 2047:break;default:{pe[t>>2]=n+-1022;pe[te>>2]=r;pe[te+4>>2]=i&-2146435073|1071644672;e=+ee[te>>3]}}return+e}function dr(e,t){e=+e;t=t|0;return+ +hr(e,t)}function pr(e,t,r){e=e|0;t=t|0;r=r|0;do{if(e){if(t>>>0<128){de[e>>0]=t;e=1;break}if(t>>>0<2048){de[e>>0]=t>>>6|192;de[e+1>>0]=t&63|128;e=2;break}if(t>>>0<55296|(t&-8192|0)==57344){de[e>>0]=t>>>12|224;de[e+1>>0]=t>>>6&63|128;de[e+2>>0]=t&63|128;e=3;break}if((t+-65536|0)>>>0<1048576){de[e>>0]=t>>>18|240;de[e+1>>0]=t>>>12&63|128;de[e+2>>0]=t>>>6&63|128;de[e+3>>0]=t&63|128;e=4;break}else{e=fr()|0;pe[e>>2]=84;e=-1;break}}else e=1}while(0);return e|0}function vr(e,t){e=e|0;t=t|0;if(!e)e=0;else e=pr(e,t,0)|0;return e|0}function mr(e){e=e|0;var t=0,r=0;do{if(e){if((pe[e+76>>2]|0)<=-1){t=Or(e)|0;break}r=(Sr(e)|0)==0;t=Or(e)|0;if(!r)Er(e)}else{if(!(pe[65]|0))t=0;else t=mr(pe[65]|0)|0;ze(236);e=pe[58]|0;if(e)do{if((pe[e+76>>2]|0)>-1)r=Sr(e)|0;else r=0;if((pe[e+20>>2]|0)>>>0>(pe[e+28>>2]|0)>>>0)t=Or(e)|0|t;if(r)Er(e);e=pe[e+56>>2]|0}while((e|0)!=0);Be(236)}}while(0);return t|0}function br(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0;if((pe[t+76>>2]|0)>=0?(Sr(t)|0)!=0:0){if((de[t+75>>0]|0)!=(e|0)?(i=t+20|0,n=pe[i>>2]|0,n>>>0<(pe[t+16>>2]|0)>>>0):0){pe[i>>2]=n+1;de[n>>0]=e;r=e&255}else r=Mr(t,e)|0;Er(t)}else a=3;do{if((a|0)==3){if((de[t+75>>0]|0)!=(e|0)?(o=t+20|0,r=pe[o>>2]|0,r>>>0<(pe[t+16>>2]|0)>>>0):0){pe[o>>2]=r+1;de[r>>0]=e;r=e&255;break}r=Mr(t,e)|0}}while(0);return r|0}function gr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;i=r+16|0;n=pe[i>>2]|0;if(!n)if(!(Ir(r)|0)){n=pe[i>>2]|0;o=4}else i=0;else o=4;e:do{if((o|0)==4){a=r+20|0;o=pe[a>>2]|0;if((n-o|0)>>>0>>0){i=Mi[pe[r+36>>2]&7](r,e,t)|0;break}t:do{if((de[r+75>>0]|0)>-1){i=t;while(1){if(!i){n=o;i=0;break t}n=i+-1|0;if((de[e+n>>0]|0)==10)break;else i=n}if((Mi[pe[r+36>>2]&7](r,e,i)|0)>>>0>>0)break e;t=t-i|0;e=e+i|0;n=pe[a>>2]|0}else{n=o;i=0}}while(0);Qr(n|0,e|0,t|0)|0;pe[a>>2]=(pe[a>>2]|0)+t;i=i+t|0}}while(0);return i|0}function yr(e,t){e=e|0;t=t|0;var r=0,i=0;r=be;be=be+16|0;i=r;pe[i>>2]=t;t=wr(pe[64]|0,e,i)|0;be=r;return t|0}function _r(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;i=be;be=be+16|0;n=i;pe[n>>2]=r;r=Tr(e,t,n)|0;be=i;return r|0}function wr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0;v=be;be=be+224|0;l=v+120|0;p=v+80|0;d=v;h=v+136|0;i=p;n=i+40|0;do{pe[i>>2]=0;i=i+4|0}while((i|0)<(n|0));pe[l>>2]=pe[r>>2];if((Dr(0,t,l,d,p)|0)<0)r=-1;else{if((pe[e+76>>2]|0)>-1)c=Sr(e)|0;else c=0;r=pe[e>>2]|0;f=r&32;if((de[e+74>>0]|0)<1)pe[e>>2]=r&-33;r=e+48|0;if(!(pe[r>>2]|0)){n=e+44|0;o=pe[n>>2]|0;pe[n>>2]=h;a=e+28|0;pe[a>>2]=h;s=e+20|0;pe[s>>2]=h;pe[r>>2]=80;u=e+16|0;pe[u>>2]=h+80;i=Dr(e,t,l,d,p)|0;if(o){Mi[pe[e+36>>2]&7](e,0,0)|0;i=(pe[s>>2]|0)==0?-1:i;pe[n>>2]=o;pe[r>>2]=0;pe[u>>2]=0;pe[a>>2]=0;pe[s>>2]=0}}else i=Dr(e,t,l,d,p)|0;r=pe[e>>2]|0;pe[e>>2]=r|f;if(c)Er(e);r=(r&32|0)==0?i:-1}be=v;return r|0}function xr(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+128|0;n=f+112|0;c=f;o=c;a=268;s=o+112|0;do{pe[o>>2]=pe[a>>2];o=o+4|0;a=a+4|0}while((o|0)<(s|0));if((t+-1|0)>>>0>2147483646)if(!t){t=1;u=4}else{t=fr()|0;pe[t>>2]=75;t=-1}else{n=e;u=4}if((u|0)==4){u=-2-n|0;u=t>>>0>u>>>0?u:t;pe[c+48>>2]=u;e=c+20|0;pe[e>>2]=n;pe[c+44>>2]=n;t=n+u|0;n=c+16|0;pe[n>>2]=t;pe[c+28>>2]=t;t=wr(c,r,i)|0;if(u){r=pe[e>>2]|0;de[r+(((r|0)==(pe[n>>2]|0))<<31>>31)>>0]=0}}be=f;return t|0}function Tr(e,t,r){e=e|0;t=t|0;r=r|0;return xr(e,2147483647,t,r)|0}function Sr(e){e=e|0;return 0}function Er(e){e=e|0;return}function Mr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0;u=be;be=be+16|0;s=u;a=t&255;de[s>>0]=a;i=e+16|0;n=pe[i>>2]|0;if(!n)if(!(Ir(e)|0)){n=pe[i>>2]|0;o=4}else r=-1;else o=4;do{if((o|0)==4){i=e+20|0;o=pe[i>>2]|0;if(o>>>0>>0?(r=t&255,(r|0)!=(de[e+75>>0]|0)):0){pe[i>>2]=o+1;de[o>>0]=a;break}if((Mi[pe[e+36>>2]&7](e,s,1)|0)==1)r=ve[s>>0]|0;else r=-1}}while(0);be=u;return r|0}function Cr(e){e=e|0;var t=0,r=0;t=be;be=be+16|0;r=t;pe[r>>2]=pe[e+60>>2];e=lr(Me(6,r|0)|0)|0;be=t;return e|0}function Pr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0;n=be;be=be+32|0;o=n;i=n+20|0;pe[o>>2]=pe[e+60>>2];pe[o+4>>2]=0;pe[o+8>>2]=t;pe[o+12>>2]=i;pe[o+16>>2]=r;if((lr(He(140,o|0)|0)|0)<0){pe[i>>2]=-1;e=-1}else e=pe[i>>2]|0;be=n;return e|0}function Ar(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;p=be;be=be+48|0;l=p+16|0;f=p;i=p+32|0;h=e+28|0;n=pe[h>>2]|0;pe[i>>2]=n;d=e+20|0;n=(pe[d>>2]|0)-n|0;pe[i+4>>2]=n;pe[i+8>>2]=t;pe[i+12>>2]=r;u=e+60|0;c=e+44|0;t=2;n=n+r|0;while(1){if(!(pe[52]|0)){pe[l>>2]=pe[u>>2];pe[l+4>>2]=i;pe[l+8>>2]=t;a=lr(Ve(146,l|0)|0)|0}else{qe(7,e|0);pe[f>>2]=pe[u>>2];pe[f+4>>2]=i;pe[f+8>>2]=t;a=lr(Ve(146,f|0)|0)|0;Se(0)}if((n|0)==(a|0)){n=6;break}if((a|0)<0){n=8;break}n=n-a|0;o=pe[i+4>>2]|0;if(a>>>0<=o>>>0)if((t|0)==2){pe[h>>2]=(pe[h>>2]|0)+a;s=o;t=2}else s=o;else{s=pe[c>>2]|0;pe[h>>2]=s;pe[d>>2]=s;s=pe[i+12>>2]|0;a=a-o|0;i=i+8|0;t=t+-1|0}pe[i>>2]=(pe[i>>2]|0)+a;pe[i+4>>2]=s-a}if((n|0)==6){l=pe[c>>2]|0;pe[e+16>>2]=l+(pe[e+48>>2]|0);e=l;pe[h>>2]=e;pe[d>>2]=e}else if((n|0)==8){pe[e+16>>2]=0;pe[h>>2]=0;pe[d>>2]=0;pe[e>>2]=pe[e>>2]|32;if((t|0)==2)r=0;else r=r-(pe[i+4>>2]|0)|0}be=p;return r|0}function kr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;n=be;be=be+80|0;i=n;pe[e+36>>2]=3;if((pe[e>>2]&64|0)==0?(pe[i>>2]=pe[e+60>>2],pe[i+4>>2]=21505,pe[i+8>>2]=n+12,(Ee(54,i|0)|0)!=0):0)de[e+75>>0]=-1;i=Ar(e,t,r)|0;be=n;return i|0}function Ir(e){e=e|0;var t=0,r=0;t=e+74|0;r=de[t>>0]|0;de[t>>0]=r+255|r;t=pe[e>>2]|0;if(!(t&8)){pe[e+8>>2]=0;pe[e+4>>2]=0;t=pe[e+44>>2]|0;pe[e+28>>2]=t;pe[e+20>>2]=t;pe[e+16>>2]=t+(pe[e+48>>2]|0);t=0}else{pe[e>>2]=t|32;t=-1}return t|0}function Rr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;o=t&255;i=(r|0)!=0;e:do{if(i&(e&3|0)!=0){n=t&255;while(1){if((de[e>>0]|0)==n<<24>>24){a=6;break e}e=e+1|0;r=r+-1|0;i=(r|0)!=0;if(!(i&(e&3|0)!=0)){a=5;break}}}else a=5}while(0);if((a|0)==5)if(i)a=6;else r=0;e:do{if((a|0)==6){n=t&255;if((de[e>>0]|0)!=n<<24>>24){i=ge(o,16843009)|0;t:do{if(r>>>0>3)while(1){o=pe[e>>2]^i;if((o&-2139062144^-2139062144)&o+-16843009)break;e=e+4|0;r=r+-4|0;if(r>>>0<=3){a=11;break t}}else a=11}while(0);if((a|0)==11)if(!r){r=0;break}while(1){if((de[e>>0]|0)==n<<24>>24)break e;e=e+1|0;r=r+-1|0;if(!r){r=0;break}}}}}while(0);return((r|0)!=0?e:0)|0}function Or(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0;t=e+20|0;o=e+28|0;if((pe[t>>2]|0)>>>0>(pe[o>>2]|0)>>>0?(Mi[pe[e+36>>2]&7](e,0,0)|0,(pe[t>>2]|0)==0):0)t=-1;else{a=e+4|0;r=pe[a>>2]|0;i=e+8|0;n=pe[i>>2]|0;if(r>>>0>>0)Mi[pe[e+40>>2]&7](e,r-n|0,1)|0;pe[e+16>>2]=0;pe[o>>2]=0;pe[t>>2]=0;pe[i>>2]=0;pe[a>>2]=0;t=0}return t|0}function Dr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0.0,f=0,l=0,h=0,d=0,p=0.0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0,Q=0;Q=be;be=be+624|0;W=Q+24|0;K=Q+16|0;Y=Q+588|0;X=Q+576|0;V=Q;N=Q+536|0;Z=Q+8|0;J=Q+528|0;k=(e|0)!=0;I=N+40|0;B=I;N=N+39|0;U=Z+4|0;z=X+12|0;X=X+11|0;q=Y;G=z;H=G-q|0;R=-2-q|0;O=G+2|0;D=W+288|0;L=Y+9|0;j=L;F=Y+8|0;o=0;v=t;a=0;t=0;e:while(1){do{if((o|0)>-1)if((a|0)>(2147483647-o|0)){o=fr()|0;pe[o>>2]=75;o=-1;break}else{o=a+o|0;break}}while(0);a=de[v>>0]|0;if(!(a<<24>>24)){A=245;break}else s=v;t:while(1){switch(a<<24>>24){case 37:{a=s;A=9;break t}case 0:{a=s;break t}default:{}}P=s+1|0;a=de[P>>0]|0;s=P}t:do{if((A|0)==9)while(1){A=0;if((de[a+1>>0]|0)!=37)break t;s=s+1|0;a=a+2|0;if((de[a>>0]|0)==37)A=9;else break}}while(0);b=s-v|0;if(k?(pe[e>>2]&32|0)==0:0)gr(v,b,e)|0;if((s|0)!=(v|0)){v=a;a=b;continue}f=a+1|0;s=de[f>>0]|0;u=(s<<24>>24)+-48|0;if(u>>>0<10){P=(de[a+2>>0]|0)==36;f=P?a+3|0:f;s=de[f>>0]|0;d=P?u:-1;t=P?1:t}else d=-1;a=s<<24>>24;t:do{if((a&-32|0)==32){u=0;while(1){if(!(1<>24)+-32|u;f=f+1|0;s=de[f>>0]|0;a=s<<24>>24;if((a&-32|0)!=32){l=u;a=f;break}}}else{l=0;a=f}}while(0);do{if(s<<24>>24==42){u=a+1|0;s=(de[u>>0]|0)+-48|0;if(s>>>0<10?(de[a+2>>0]|0)==36:0){pe[n+(s<<2)>>2]=10;t=1;a=a+3|0;s=pe[i+((de[u>>0]|0)+-48<<3)>>2]|0}else{if(t){o=-1;break e}if(!k){m=l;a=u;t=0;P=0;break}t=(pe[r>>2]|0)+(4-1)&~(4-1);s=pe[t>>2]|0;pe[r>>2]=t+4;t=0;a=u}if((s|0)<0){m=l|8192;P=0-s|0}else{m=l;P=s}}else{u=(s<<24>>24)+-48|0;if(u>>>0<10){s=0;do{s=(s*10|0)+u|0;a=a+1|0;u=(de[a>>0]|0)+-48|0}while(u>>>0<10);if((s|0)<0){o=-1;break e}else{m=l;P=s}}else{m=l;P=0}}}while(0);t:do{if((de[a>>0]|0)==46){u=a+1|0;s=de[u>>0]|0;if(s<<24>>24!=42){f=(s<<24>>24)+-48|0;if(f>>>0<10){a=u;s=0}else{a=u;f=0;break}while(1){s=(s*10|0)+f|0;a=a+1|0;f=(de[a>>0]|0)+-48|0;if(f>>>0>=10){f=s;break t}}}u=a+2|0;s=(de[u>>0]|0)+-48|0;if(s>>>0<10?(de[a+3>>0]|0)==36:0){pe[n+(s<<2)>>2]=10;a=a+4|0;f=pe[i+((de[u>>0]|0)+-48<<3)>>2]|0;break}if(t){o=-1;break e}if(k){a=(pe[r>>2]|0)+(4-1)&~(4-1);f=pe[a>>2]|0;pe[r>>2]=a+4;a=u}else{a=u;f=0}}else f=-1}while(0);h=0;while(1){s=(de[a>>0]|0)+-65|0;if(s>>>0>57){o=-1;break e}u=a+1|0;s=de[5359+(h*58|0)+s>>0]|0;l=s&255;if((l+-1|0)>>>0<8){a=u;h=l}else{C=u;break}}if(!(s<<24>>24)){o=-1;break}u=(d|0)>-1;do{if(s<<24>>24==19)if(u){o=-1;break e}else A=52;else{if(u){pe[n+(d<<2)>>2]=l;E=i+(d<<3)|0;M=pe[E+4>>2]|0;A=V;pe[A>>2]=pe[E>>2];pe[A+4>>2]=M;A=52;break}if(!k){o=0;break e}Fr(V,l,r)}}while(0);if((A|0)==52?(A=0,!k):0){v=C;a=b;continue}d=de[a>>0]|0;d=(h|0)!=0&(d&15|0)==3?d&-33:d;u=m&-65537;M=(m&8192|0)==0?m:u;t:do{switch(d|0){case 110:switch(h|0){case 0:{pe[pe[V>>2]>>2]=o;v=C;a=b;continue e}case 1:{pe[pe[V>>2]>>2]=o;v=C;a=b;continue e}case 2:{v=pe[V>>2]|0;pe[v>>2]=o;pe[v+4>>2]=((o|0)<0)<<31>>31;v=C;a=b;continue e}case 3:{$[pe[V>>2]>>1]=o;v=C;a=b;continue e}case 4:{de[pe[V>>2]>>0]=o;v=C;a=b;continue e}case 6:{pe[pe[V>>2]>>2]=o;v=C;a=b;continue e}case 7:{v=pe[V>>2]|0;pe[v>>2]=o;pe[v+4>>2]=((o|0)<0)<<31>>31;v=C;a=b;continue e}default:{v=C;a=b;continue e}}case 112:{h=M|8;f=f>>>0>8?f:8;d=120;A=64;break}case 88:case 120:{h=M;A=64;break}case 111:{u=V;s=pe[u>>2]|0;u=pe[u+4>>2]|0;if((s|0)==0&(u|0)==0)a=I;else{a=I;do{a=a+-1|0;de[a>>0]=s&7|48;s=Kr(s|0,u|0,3)|0;u=re}while(!((s|0)==0&(u|0)==0))}if(!(M&8)){s=M;h=0;l=5839;A=77}else{h=B-a+1|0;s=M;f=(f|0)<(h|0)?h:f;h=0;l=5839;A=77}break}case 105:case 100:{s=V;a=pe[s>>2]|0;s=pe[s+4>>2]|0;if((s|0)<0){a=Wr(0,0,a|0,s|0)|0;s=re;u=V;pe[u>>2]=a;pe[u+4>>2]=s;u=1;l=5839;A=76;break t}if(!(M&2048)){l=M&1;u=l;l=(l|0)==0?5839:5841;A=76}else{u=1;l=5840;A=76}break}case 117:{s=V;a=pe[s>>2]|0;s=pe[s+4>>2]|0;u=0;l=5839;A=76;break}case 99:{de[N>>0]=pe[V>>2];v=N;s=1;h=0;d=5839;a=I;break}case 109:{a=fr()|0;a=cr(pe[a>>2]|0)|0;A=82;break}case 115:{a=pe[V>>2]|0;a=(a|0)!=0?a:5849;A=82;break}case 67:{pe[Z>>2]=pe[V>>2];pe[U>>2]=0;pe[V>>2]=Z;f=-1;A=86;break}case 83:{if(!f){Nr(e,32,P,0,M);a=0;A=98}else A=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{c=+ee[V>>3];pe[K>>2]=0;ee[te>>3]=c;if((pe[te+4>>2]|0)>=0)if(!(M&2048)){E=M&1;S=E;E=(E|0)==0?5857:5862}else{S=1;E=5859}else{c=-c;S=1;E=5856}ee[te>>3]=c;T=pe[te+4>>2]&2146435072;do{if(T>>>0<2146435072|(T|0)==2146435072&0<0){p=+dr(c,K)*2.0;s=p!=0.0;if(s)pe[K>>2]=(pe[K>>2]|0)+-1;w=d|32;if((w|0)==97){v=d&32;b=(v|0)==0?E:E+9|0;m=S|2;a=12-f|0;do{if(!(f>>>0>11|(a|0)==0)){c=8.0;do{a=a+-1|0;c=c*16.0}while((a|0)!=0);if((de[b>>0]|0)==45){c=-(c+(-p-c));break}else{c=p+c-c;break}}else c=p}while(0);s=pe[K>>2]|0;a=(s|0)<0?0-s|0:s;a=Br(a,((a|0)<0)<<31>>31,z)|0;if((a|0)==(z|0)){de[X>>0]=48;a=X}de[a+-1>>0]=(s>>31&2)+43;h=a+-2|0;de[h>>0]=d+15;l=(f|0)<1;u=(M&8|0)==0;s=Y;while(1){E=~~c;a=s+1|0;de[s>>0]=ve[5823+E>>0]|v;c=(c-+(E|0))*16.0;do{if((a-q|0)==1){if(u&(l&c==0.0))break;de[a>>0]=46;a=s+2|0}}while(0);if(!(c!=0.0))break;else s=a}f=(f|0)!=0&(R+a|0)<(f|0)?O+f-h|0:H-h+a|0;u=f+m|0;Nr(e,32,P,u,M);if(!(pe[e>>2]&32))gr(b,m,e)|0;Nr(e,48,P,u,M^65536);a=a-q|0;if(!(pe[e>>2]&32))gr(Y,a,e)|0;s=G-h|0;Nr(e,48,f-(a+s)|0,0,0);if(!(pe[e>>2]&32))gr(h,s,e)|0;Nr(e,32,P,u,M^8192);a=(u|0)<(P|0)?P:u;break}a=(f|0)<0?6:f;if(s){s=(pe[K>>2]|0)+-28|0;pe[K>>2]=s;c=p*268435456.0}else{c=p;s=pe[K>>2]|0}T=(s|0)<0?W:D;x=T;s=T;do{_=~~c>>>0;pe[s>>2]=_;s=s+4|0;c=(c-+(_>>>0))*1.0e9}while(c!=0.0);u=s;s=pe[K>>2]|0;if((s|0)>0){l=T;while(1){h=(s|0)>29?29:s;f=u+-4|0;do{if(f>>>0>>0)f=l;else{s=0;do{_=Jr(pe[f>>2]|0,0,h|0)|0;_=Zr(_|0,re|0,s|0,0)|0;s=re;y=ai(_|0,s|0,1e9,0)|0;pe[f>>2]=y;s=oi(_|0,s|0,1e9,0)|0;f=f+-4|0}while(f>>>0>=l>>>0);if(!s){f=l;break}f=l+-4|0;pe[f>>2]=s}}while(0);while(1){if(u>>>0<=f>>>0)break;s=u+-4|0;if(!(pe[s>>2]|0))u=s;else break}s=(pe[K>>2]|0)-h|0;pe[K>>2]=s;if((s|0)>0)l=f;else break}}else f=T;if((s|0)<0){b=((a+25|0)/9|0)+1|0;g=(w|0)==102;v=f;while(1){m=0-s|0;m=(m|0)>9?9:m;do{if(v>>>0>>0){s=(1<>>m;f=0;h=v;do{_=pe[h>>2]|0;pe[h>>2]=(_>>>m)+f;f=ge(_&s,l)|0;h=h+4|0}while(h>>>0>>0);s=(pe[v>>2]|0)==0?v+4|0:v;if(!f){f=s;break}pe[u>>2]=f;f=s;u=u+4|0}else f=(pe[v>>2]|0)==0?v+4|0:v}while(0);s=g?T:f;u=(u-s>>2|0)>(b|0)?s+(b<<2)|0:u;s=(pe[K>>2]|0)+m|0;pe[K>>2]=s;if((s|0)>=0){v=f;break}else v=f}}else v=f;do{if(v>>>0>>0){s=(x-v>>2)*9|0;l=pe[v>>2]|0;if(l>>>0<10)break;else f=10;do{f=f*10|0;s=s+1|0}while(l>>>0>=f>>>0)}else s=0}while(0);y=(w|0)==103;_=(a|0)!=0;f=a-((w|0)!=102?s:0)+((_&y)<<31>>31)|0;if((f|0)<(((u-x>>2)*9|0)+-9|0)){h=f+9216|0;g=(h|0)/9|0;f=T+(g+-1023<<2)|0;h=((h|0)%9|0)+1|0;if((h|0)<9){l=10;do{l=l*10|0;h=h+1|0}while((h|0)!=9)}else l=10;m=pe[f>>2]|0;b=(m>>>0)%(l>>>0)|0;if((b|0)==0?(T+(g+-1022<<2)|0)==(u|0):0)l=v;else A=163;do{if((A|0)==163){A=0;p=(((m>>>0)/(l>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;h=(l|0)/2|0;do{if(b>>>0>>0)c=.5;else{if((b|0)==(h|0)?(T+(g+-1022<<2)|0)==(u|0):0){c=1.0;break}c=1.5}}while(0);do{if(S){if((de[E>>0]|0)!=45)break;p=-p;c=-c}}while(0);h=m-b|0;pe[f>>2]=h;if(!(p+c!=p)){l=v;break}w=h+l|0;pe[f>>2]=w;if(w>>>0>999999999){s=v;while(1){l=f+-4|0;pe[f>>2]=0;if(l>>>0>>0){s=s+-4|0;pe[s>>2]=0}w=(pe[l>>2]|0)+1|0;pe[l>>2]=w;if(w>>>0>999999999)f=l;else{v=s;f=l;break}}}s=(x-v>>2)*9|0;h=pe[v>>2]|0;if(h>>>0<10){l=v;break}else l=10;do{l=l*10|0;s=s+1|0}while(h>>>0>=l>>>0);l=v}}while(0);w=f+4|0;v=l;u=u>>>0>w>>>0?w:u}b=0-s|0;while(1){if(u>>>0<=v>>>0){g=0;w=u;break}f=u+-4|0;if(!(pe[f>>2]|0))u=f;else{g=1;w=u;break}}do{if(y){a=(_&1^1)+a|0;if((a|0)>(s|0)&(s|0)>-5){d=d+-1|0;a=a+-1-s|0}else{d=d+-2|0;a=a+-1|0}u=M&8;if(u)break;do{if(g){u=pe[w+-4>>2]|0;if(!u){f=9;break}if(!((u>>>0)%10|0)){l=10;f=0}else{f=0;break}do{l=l*10|0;f=f+1|0}while(((u>>>0)%(l>>>0)|0|0)==0)}else f=9}while(0);u=((w-x>>2)*9|0)+-9|0;if((d|32|0)==102){u=u-f|0;u=(u|0)<0?0:u;a=(a|0)<(u|0)?a:u;u=0;break}else{u=u+s-f|0;u=(u|0)<0?0:u;a=(a|0)<(u|0)?a:u;u=0;break}}else u=M&8}while(0);m=a|u;l=(m|0)!=0&1;h=(d|32|0)==102;if(h){s=(s|0)>0?s:0;d=0}else{f=(s|0)<0?b:s;f=Br(f,((f|0)<0)<<31>>31,z)|0;if((G-f|0)<2)do{f=f+-1|0;de[f>>0]=48}while((G-f|0)<2);de[f+-1>>0]=(s>>31&2)+43;x=f+-2|0;de[x>>0]=d;s=G-x|0;d=x}b=S+1+a+l+s|0;Nr(e,32,P,b,M);if(!(pe[e>>2]&32))gr(E,S,e)|0;Nr(e,48,P,b,M^65536);do{if(h){f=v>>>0>T>>>0?T:v;s=f;do{u=Br(pe[s>>2]|0,0,L)|0;do{if((s|0)==(f|0)){if((u|0)!=(L|0))break;de[F>>0]=48;u=F}else{if(u>>>0<=Y>>>0)break;do{u=u+-1|0;de[u>>0]=48}while(u>>>0>Y>>>0)}}while(0);if(!(pe[e>>2]&32))gr(u,j-u|0,e)|0;s=s+4|0}while(s>>>0<=T>>>0);do{if(m){if(pe[e>>2]&32)break;gr(5891,1,e)|0}}while(0);if((a|0)>0&s>>>0>>0){u=s;while(1){s=Br(pe[u>>2]|0,0,L)|0;if(s>>>0>Y>>>0)do{s=s+-1|0;de[s>>0]=48}while(s>>>0>Y>>>0);if(!(pe[e>>2]&32))gr(s,(a|0)>9?9:a,e)|0;u=u+4|0;s=a+-9|0;if(!((a|0)>9&u>>>0>>0)){a=s;break}else a=s}}Nr(e,48,a+9|0,9,0)}else{h=g?w:v+4|0;if((a|0)>-1){l=(u|0)==0;f=v;do{s=Br(pe[f>>2]|0,0,L)|0;if((s|0)==(L|0)){de[F>>0]=48;s=F}do{if((f|0)==(v|0)){u=s+1|0;if(!(pe[e>>2]&32))gr(s,1,e)|0;if(l&(a|0)<1){s=u;break}if(pe[e>>2]&32){s=u;break}gr(5891,1,e)|0;s=u}else{if(s>>>0<=Y>>>0)break;do{s=s+-1|0;de[s>>0]=48}while(s>>>0>Y>>>0)}}while(0);u=j-s|0;if(!(pe[e>>2]&32))gr(s,(a|0)>(u|0)?u:a,e)|0;a=a-u|0;f=f+4|0}while(f>>>0>>0&(a|0)>-1)}Nr(e,48,a+18|0,18,0);if(pe[e>>2]&32)break;gr(d,G-d|0,e)|0}}while(0);Nr(e,32,P,b,M^8192);a=(b|0)<(P|0)?P:b}else{h=(d&32|0)!=0;l=c!=c|0.0!=0.0;s=l?0:S;f=s+3|0;Nr(e,32,P,f,u);a=pe[e>>2]|0;if(!(a&32)){gr(E,s,e)|0;a=pe[e>>2]|0}if(!(a&32))gr(l?h?5883:5887:h?5875:5879,3,e)|0;Nr(e,32,P,f,M^8192);a=(f|0)<(P|0)?P:f}}while(0);v=C;continue e}default:{u=M;s=f;h=0;d=5839;a=I}}}while(0);t:do{if((A|0)==64){u=V;s=pe[u>>2]|0;u=pe[u+4>>2]|0;l=d&32;if(!((s|0)==0&(u|0)==0)){a=I;do{a=a+-1|0;de[a>>0]=ve[5823+(s&15)>>0]|l;s=Kr(s|0,u|0,4)|0;u=re}while(!((s|0)==0&(u|0)==0));A=V;if((h&8|0)==0|(pe[A>>2]|0)==0&(pe[A+4>>2]|0)==0){s=h;h=0;l=5839;A=77}else{s=h;h=2;l=5839+(d>>4)|0;A=77}}else{a=I;s=h;h=0;l=5839;A=77}}else if((A|0)==76){a=Br(a,s,I)|0;s=M;h=u;A=77}else if((A|0)==82){A=0;M=Rr(a,0,f)|0;E=(M|0)==0;v=a;s=E?f:M-a|0;h=0;d=5839;a=E?a+f|0:M}else if((A|0)==86){A=0;s=0;a=0;l=pe[V>>2]|0;while(1){u=pe[l>>2]|0;if(!u)break;a=vr(J,u)|0;if((a|0)<0|a>>>0>(f-s|0)>>>0)break;s=a+s|0;if(f>>>0>s>>>0)l=l+4|0;else break}if((a|0)<0){o=-1;break e}Nr(e,32,P,s,M);if(!s){a=0;A=98}else{u=0;f=pe[V>>2]|0;while(1){a=pe[f>>2]|0;if(!a){a=s;A=98;break t}a=vr(J,a)|0;u=a+u|0;if((u|0)>(s|0)){a=s;A=98;break t}if(!(pe[e>>2]&32))gr(J,a,e)|0;if(u>>>0>=s>>>0){a=s;A=98;break}else f=f+4|0}}}}while(0);if((A|0)==98){A=0;Nr(e,32,P,a,M^8192);v=C;a=(P|0)>(a|0)?P:a;continue}if((A|0)==77){A=0;u=(f|0)>-1?s&-65537:s;s=V;s=(pe[s>>2]|0)!=0|(pe[s+4>>2]|0)!=0;if((f|0)!=0|s){s=(s&1^1)+(B-a)|0;v=a;s=(f|0)>(s|0)?f:s;d=l;a=I}else{v=I;s=0;d=l;a=I}}l=a-v|0;s=(s|0)<(l|0)?l:s;f=h+s|0;a=(P|0)<(f|0)?f:P;Nr(e,32,a,f,u);if(!(pe[e>>2]&32))gr(d,h,e)|0;Nr(e,48,a,f,u^65536);Nr(e,48,s,l,0);if(!(pe[e>>2]&32))gr(v,l,e)|0;Nr(e,32,a,f,u^8192);v=C}e:do{if((A|0)==245)if(!e)if(t){o=1;while(1){t=pe[n+(o<<2)>>2]|0;if(!t)break;Fr(i+(o<<3)|0,t,r);o=o+1|0;if((o|0)>=10){o=1;break e}}if((o|0)<10)while(1){if(pe[n+(o<<2)>>2]|0){o=-1;break e}o=o+1|0;if((o|0)>=10){o=1;break}}else o=1}else o=0}while(0);be=Q;return o|0}function Lr(e){e=e|0;if(!(pe[e+68>>2]|0))Er(e);return}function jr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;i=e+20|0;n=pe[i>>2]|0;e=(pe[e+16>>2]|0)-n|0;e=e>>>0>r>>>0?r:e;Qr(n|0,t|0,e|0)|0;pe[i>>2]=(pe[i>>2]|0)+e;return r|0}function Fr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0.0;e:do{if(t>>>0<=20)do{switch(t|0){case 9:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;pe[e>>2]=t;break e}case 10:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;i=e;pe[i>>2]=t;pe[i+4>>2]=((t|0)<0)<<31>>31;break e}case 11:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;i=e;pe[i>>2]=t;pe[i+4>>2]=0;break e}case 12:{i=(pe[r>>2]|0)+(8-1)&~(8-1);t=i;n=pe[t>>2]|0;t=pe[t+4>>2]|0;pe[r>>2]=i+8;i=e;pe[i>>2]=n;pe[i+4>>2]=t;break e}case 13:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;i=(i&65535)<<16>>16;n=e;pe[n>>2]=i;pe[n+4>>2]=((i|0)<0)<<31>>31;break e}case 14:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;n=e;pe[n>>2]=i&65535;pe[n+4>>2]=0;break e}case 15:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;i=(i&255)<<24>>24;n=e;pe[n>>2]=i;pe[n+4>>2]=((i|0)<0)<<31>>31;break e}case 16:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;n=e;pe[n>>2]=i&255;pe[n+4>>2]=0;break e}case 17:{n=(pe[r>>2]|0)+(8-1)&~(8-1);o=+ee[n>>3];pe[r>>2]=n+8;ee[e>>3]=o;break e}case 18:{n=(pe[r>>2]|0)+(8-1)&~(8-1);o=+ee[n>>3];pe[r>>2]=n+8;ee[e>>3]=o;break e}default:break e}}while(0)}while(0);return}function Br(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(t>>>0>0|(t|0)==0&e>>>0>4294967295)while(1){i=ai(e|0,t|0,10,0)|0;r=r+-1|0;de[r>>0]=i|48;i=oi(e|0,t|0,10,0)|0;if(t>>>0>9|(t|0)==9&e>>>0>4294967295){e=i;t=re}else{e=i;break}}if(e)while(1){r=r+-1|0;de[r>>0]=(e>>>0)%10|0|48;if(e>>>0<10)break;else e=(e>>>0)/10|0}return r|0}function Nr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0;s=be;be=be+256|0;a=s;do{if((r|0)>(i|0)&(n&73728|0)==0){n=r-i|0;Yr(a|0,t|0,(n>>>0>256?256:n)|0)|0;t=pe[e>>2]|0;o=(t&32|0)==0;if(n>>>0>255){i=r-i|0;do{if(o){gr(a,256,e)|0;t=pe[e>>2]|0}n=n+-256|0;o=(t&32|0)==0}while(n>>>0>255);if(o)n=i&255;else break}else if(!o)break;gr(a,n,e)|0}}while(0);be=s;return}function Ur(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0;do{if(e>>>0<245){d=e>>>0<11?16:e+11&-8;e=d>>>3;s=pe[151]|0;r=s>>>e;if(r&3){e=(r&1^1)+e|0;i=e<<1;r=644+(i<<2)|0;i=644+(i+2<<2)|0;n=pe[i>>2]|0;o=n+8|0;a=pe[o>>2]|0;do{if((r|0)!=(a|0)){if(a>>>0<(pe[155]|0)>>>0)Xe();t=a+12|0;if((pe[t>>2]|0)==(n|0)){pe[t>>2]=r;pe[i>>2]=a;break}else Xe()}else pe[151]=s&~(1<>2]=F|3;F=n+(F|4)|0;pe[F>>2]=pe[F>>2]|1;F=o;return F|0}a=pe[153]|0;if(d>>>0>a>>>0){if(r){i=2<>>12&16;i=i>>>u;n=i>>>5&8;i=i>>>n;o=i>>>2&4;i=i>>>o;r=i>>>1&2;i=i>>>r;e=i>>>1&1;e=(n|u|o|r|e)+(i>>>e)|0;i=e<<1;r=644+(i<<2)|0;i=644+(i+2<<2)|0;o=pe[i>>2]|0;u=o+8|0;n=pe[u>>2]|0;do{if((r|0)!=(n|0)){if(n>>>0<(pe[155]|0)>>>0)Xe();t=n+12|0;if((pe[t>>2]|0)==(o|0)){pe[t>>2]=r;pe[i>>2]=n;c=pe[153]|0;break}else Xe()}else{pe[151]=s&~(1<>2]=d|3;s=o+d|0;pe[o+(d|4)>>2]=a|1;pe[o+F>>2]=a;if(c){n=pe[156]|0;r=c>>>3;t=r<<1;i=644+(t<<2)|0;e=pe[151]|0;r=1<>2]|0;if(t>>>0<(pe[155]|0)>>>0)Xe();else{f=e;l=t}}else{pe[151]=e|r;f=644+(t+2<<2)|0;l=i}pe[f>>2]=n;pe[l+12>>2]=n;pe[n+8>>2]=l;pe[n+12>>2]=i}pe[153]=a;pe[156]=s;F=u;return F|0}e=pe[152]|0;if(e){r=(e&0-e)+-1|0;j=r>>>12&16;r=r>>>j;L=r>>>5&8;r=r>>>L;F=r>>>2&4;r=r>>>F;e=r>>>1&2;r=r>>>e;i=r>>>1&1;i=pe[908+((L|j|F|e|i)+(r>>>i)<<2)>>2]|0;r=(pe[i+4>>2]&-8)-d|0;e=i;while(1){t=pe[e+16>>2]|0;if(!t){t=pe[e+20>>2]|0;if(!t){u=r;break}}e=(pe[t+4>>2]&-8)-d|0;F=e>>>0>>0;r=F?e:r;e=t;i=F?t:i}o=pe[155]|0;if(i>>>0>>0)Xe();s=i+d|0;if(i>>>0>=s>>>0)Xe();a=pe[i+24>>2]|0;r=pe[i+12>>2]|0;do{if((r|0)==(i|0)){e=i+20|0;t=pe[e>>2]|0;if(!t){e=i+16|0;t=pe[e>>2]|0;if(!t){h=0;break}}while(1){r=t+20|0;n=pe[r>>2]|0;if(n){t=n;e=r;continue}r=t+16|0;n=pe[r>>2]|0;if(!n)break;else{t=n;e=r}}if(e>>>0>>0)Xe();else{pe[e>>2]=0;h=t;break}}else{n=pe[i+8>>2]|0;if(n>>>0>>0)Xe();t=n+12|0;if((pe[t>>2]|0)!=(i|0))Xe();e=r+8|0;if((pe[e>>2]|0)==(i|0)){pe[t>>2]=r;pe[e>>2]=n;h=r;break}else Xe()}}while(0);do{if(a){t=pe[i+28>>2]|0;e=908+(t<<2)|0;if((i|0)==(pe[e>>2]|0)){pe[e>>2]=h;if(!h){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(i|0))pe[t>>2]=h;else pe[a+20>>2]=h;if(!h)break}e=pe[155]|0;if(h>>>0>>0)Xe();pe[h+24>>2]=a;t=pe[i+16>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[h+16>>2]=t;pe[t+24>>2]=h;break}}while(0);t=pe[i+20>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[h+20>>2]=t;pe[t+24>>2]=h;break}}}while(0);if(u>>>0<16){F=u+d|0;pe[i+4>>2]=F|3;F=i+(F+4)|0;pe[F>>2]=pe[F>>2]|1}else{pe[i+4>>2]=d|3;pe[i+(d|4)>>2]=u|1;pe[i+(u+d)>>2]=u;t=pe[153]|0;if(t){o=pe[156]|0;r=t>>>3;t=r<<1;n=644+(t<<2)|0;e=pe[151]|0;r=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{p=t;v=e}}else{pe[151]=e|r;p=644+(t+2<<2)|0;v=n}pe[p>>2]=o;pe[v+12>>2]=o;pe[o+8>>2]=v;pe[o+12>>2]=n}pe[153]=u;pe[156]=s}F=i+8|0;return F|0}else v=d}else v=d}else if(e>>>0<=4294967231){e=e+11|0;l=e&-8;f=pe[152]|0;if(f){r=0-l|0;e=e>>>8;if(e)if(l>>>0>16777215)c=31;else{v=(e+1048320|0)>>>16&8;_=e<>>16&4;_=_<>>16&2;c=14-(p|v|c)+(_<>>15)|0;c=l>>>(c+7|0)&1|c<<1}else c=0;e=pe[908+(c<<2)>>2]|0;e:do{if(!e){n=0;e=0;_=86}else{a=r;n=0;s=l<<((c|0)==31?0:25-(c>>>1)|0);u=e;e=0;while(1){o=pe[u+4>>2]&-8;r=o-l|0;if(r>>>0>>0)if((o|0)==(l|0)){o=u;e=u;_=90;break e}else e=u;else r=a;_=pe[u+20>>2]|0;u=pe[u+16+(s>>>31<<2)>>2]|0;n=(_|0)==0|(_|0)==(u|0)?n:_;if(!u){_=86;break}else{a=r;s=s<<1}}}}while(0);if((_|0)==86){if((n|0)==0&(e|0)==0){e=2<>>12&16;e=e>>>h;f=e>>>5&8;e=e>>>f;p=e>>>2&4;e=e>>>p;v=e>>>1&2;e=e>>>v;n=e>>>1&1;n=pe[908+((f|h|p|v|n)+(e>>>n)<<2)>>2]|0;e=0}if(!n){s=r;u=e}else{o=n;_=90}}if((_|0)==90)while(1){_=0;v=(pe[o+4>>2]&-8)-l|0;n=v>>>0>>0;r=n?v:r;e=n?o:e;n=pe[o+16>>2]|0;if(n){o=n;_=90;continue}o=pe[o+20>>2]|0;if(!o){s=r;u=e;break}else _=90}if((u|0)!=0?s>>>0<((pe[153]|0)-l|0)>>>0:0){n=pe[155]|0;if(u>>>0>>0)Xe();a=u+l|0;if(u>>>0>=a>>>0)Xe();o=pe[u+24>>2]|0;r=pe[u+12>>2]|0;do{if((r|0)==(u|0)){e=u+20|0;t=pe[e>>2]|0;if(!t){e=u+16|0;t=pe[e>>2]|0;if(!t){d=0;break}}while(1){r=t+20|0;i=pe[r>>2]|0;if(i){t=i;e=r;continue}r=t+16|0;i=pe[r>>2]|0;if(!i)break;else{t=i;e=r}}if(e>>>0>>0)Xe();else{pe[e>>2]=0;d=t;break}}else{i=pe[u+8>>2]|0;if(i>>>0>>0)Xe();t=i+12|0;if((pe[t>>2]|0)!=(u|0))Xe();e=r+8|0;if((pe[e>>2]|0)==(u|0)){pe[t>>2]=r;pe[e>>2]=i;d=r;break}else Xe()}}while(0);do{if(o){t=pe[u+28>>2]|0;e=908+(t<<2)|0;if((u|0)==(pe[e>>2]|0)){pe[e>>2]=d;if(!d){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=o+16|0;if((pe[t>>2]|0)==(u|0))pe[t>>2]=d;else pe[o+20>>2]=d;if(!d)break}e=pe[155]|0;if(d>>>0>>0)Xe();pe[d+24>>2]=o;t=pe[u+16>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[d+16>>2]=t;pe[t+24>>2]=d;break}}while(0);t=pe[u+20>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[d+20>>2]=t;pe[t+24>>2]=d;break}}}while(0);e:do{if(s>>>0>=16){pe[u+4>>2]=l|3;pe[u+(l|4)>>2]=s|1;pe[u+(s+l)>>2]=s;t=s>>>3;if(s>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{b=t;g=e}}else{pe[151]=r|t;b=644+(e+2<<2)|0;g=i}pe[b>>2]=a;pe[g+12>>2]=a;pe[u+(l+8)>>2]=g;pe[u+(l+12)>>2]=i;break}t=s>>>8;if(t)if(s>>>0>16777215)i=31;else{j=(t+1048320|0)>>>16&8;F=t<>>16&4;F=F<>>16&2;i=14-(L|j|i)+(F<>>15)|0;i=s>>>(i+7|0)&1|i<<1}else i=0;t=908+(i<<2)|0;pe[u+(l+28)>>2]=i;pe[u+(l+20)>>2]=0;pe[u+(l+16)>>2]=0;e=pe[152]|0;r=1<>2]=a;pe[u+(l+24)>>2]=t;pe[u+(l+12)>>2]=a;pe[u+(l+8)>>2]=a;break}t=pe[t>>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(s|0)){i=s<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(s|0)){T=r;break t}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=a;pe[u+(l+24)>>2]=t;pe[u+(l+12)>>2]=a;pe[u+(l+8)>>2]=a;break e}}else T=t}while(0);t=T+8|0;e=pe[t>>2]|0;F=pe[155]|0;if(e>>>0>=F>>>0&T>>>0>=F>>>0){pe[e+12>>2]=a;pe[t>>2]=a;pe[u+(l+8)>>2]=e;pe[u+(l+12)>>2]=T;pe[u+(l+24)>>2]=0;break}else Xe()}else{F=s+l|0;pe[u+4>>2]=F|3;F=u+(F+4)|0;pe[F>>2]=pe[F>>2]|1}}while(0);F=u+8|0;return F|0}else v=l}else v=l}else v=-1}while(0);r=pe[153]|0;if(r>>>0>=v>>>0){t=r-v|0;e=pe[156]|0;if(t>>>0>15){pe[156]=e+v;pe[153]=t;pe[e+(v+4)>>2]=t|1;pe[e+r>>2]=t;pe[e+4>>2]=v|3}else{pe[153]=0;pe[156]=0;pe[e+4>>2]=r|3;F=e+(r+4)|0;pe[F>>2]=pe[F>>2]|1}F=e+8|0;return F|0}e=pe[154]|0;if(e>>>0>v>>>0){j=e-v|0;pe[154]=j;F=pe[157]|0;pe[157]=F+v;pe[F+(v+4)>>2]=j|1;pe[F+4>>2]=v|3;F=F+8|0;return F|0}do{if(!(pe[269]|0)){e=Oe(30)|0;if(!(e+-1&e)){pe[271]=e;pe[270]=e;pe[272]=-1;pe[273]=-1;pe[274]=0;pe[262]=0;T=(Ge(0)|0)&-16^1431655768;pe[269]=T;break}else Xe()}}while(0);u=v+48|0;s=pe[271]|0;c=v+47|0;a=s+c|0;s=0-s|0;f=a&s;if(f>>>0<=v>>>0){F=0;return F|0}e=pe[261]|0;if((e|0)!=0?(g=pe[259]|0,T=g+f|0,T>>>0<=g>>>0|T>>>0>e>>>0):0){F=0;return F|0}e:do{if(!(pe[262]&4)){e=pe[157]|0;t:do{if(e){n=1052;while(1){r=pe[n>>2]|0;if(r>>>0<=e>>>0?(m=n+4|0,(r+(pe[m>>2]|0)|0)>>>0>e>>>0):0){o=n;e=m;break}n=pe[n+8>>2]|0;if(!n){_=174;break t}}r=a-(pe[154]|0)&s;if(r>>>0<2147483647){n=ke(r|0)|0;T=(n|0)==((pe[o>>2]|0)+(pe[e>>2]|0)|0);e=T?r:0;if(T){if((n|0)!=(-1|0)){w=n;p=e;_=194;break e}}else _=184}else e=0}else _=174}while(0);do{if((_|0)==174){o=ke(0)|0;if((o|0)!=(-1|0)){e=o;r=pe[270]|0;n=r+-1|0;if(!(n&e))r=f;else r=f-e+(n+e&0-r)|0;e=pe[259]|0;n=e+r|0;if(r>>>0>v>>>0&r>>>0<2147483647){T=pe[261]|0;if((T|0)!=0?n>>>0<=e>>>0|n>>>0>T>>>0:0){e=0;break}n=ke(r|0)|0;T=(n|0)==(o|0);e=T?r:0;if(T){w=o;p=e;_=194;break e}else _=184}else e=0}else e=0}}while(0);t:do{if((_|0)==184){o=0-r|0;do{if(u>>>0>r>>>0&(r>>>0<2147483647&(n|0)!=(-1|0))?(y=pe[271]|0,y=c-r+y&0-y,y>>>0<2147483647):0)if((ke(y|0)|0)==(-1|0)){ke(o|0)|0;break t}else{r=y+r|0;break}}while(0);if((n|0)!=(-1|0)){w=n;p=r;_=194;break e}}}while(0);pe[262]=pe[262]|4;_=191}else{e=0;_=191}}while(0);if((((_|0)==191?f>>>0<2147483647:0)?(w=ke(f|0)|0,x=ke(0)|0,w>>>0>>0&((w|0)!=(-1|0)&(x|0)!=(-1|0))):0)?(S=x-w|0,E=S>>>0>(v+40|0)>>>0,E):0){p=E?S:e;_=194}if((_|0)==194){e=(pe[259]|0)+p|0;pe[259]=e;if(e>>>0>(pe[260]|0)>>>0)pe[260]=e;a=pe[157]|0;e:do{if(a){o=1052;do{e=pe[o>>2]|0;r=o+4|0;n=pe[r>>2]|0;if((w|0)==(e+n|0)){M=e;C=r;P=n;A=o;_=204;break}o=pe[o+8>>2]|0}while((o|0)!=0);if(((_|0)==204?(pe[A+12>>2]&8|0)==0:0)?a>>>0>>0&a>>>0>=M>>>0:0){pe[C>>2]=P+p;F=(pe[154]|0)+p|0;j=a+8|0;j=(j&7|0)==0?0:0-j&7;L=F-j|0;pe[157]=a+j;pe[154]=L;pe[a+(j+4)>>2]=L|1;pe[a+(F+4)>>2]=40;pe[158]=pe[273];break}e=pe[155]|0;if(w>>>0>>0){pe[155]=w;e=w}r=w+p|0;o=1052;while(1){if((pe[o>>2]|0)==(r|0)){n=o;r=o;_=212;break}o=pe[o+8>>2]|0;if(!o){r=1052;break}}if((_|0)==212)if(!(pe[r+12>>2]&8)){pe[n>>2]=w;h=r+4|0;pe[h>>2]=(pe[h>>2]|0)+p;h=w+8|0;h=(h&7|0)==0?0:0-h&7;c=w+(p+8)|0;c=(c&7|0)==0?0:0-c&7;t=w+(c+p)|0;l=h+v|0;d=w+l|0;f=t-(w+h)-v|0;pe[w+(h+4)>>2]=v|3;t:do{if((t|0)!=(a|0)){if((t|0)==(pe[156]|0)){F=(pe[153]|0)+f|0;pe[153]=F;pe[156]=d;pe[w+(l+4)>>2]=F|1;pe[w+(F+l)>>2]=F;break}s=p+4|0;r=pe[w+(s+c)>>2]|0;if((r&3|0)==1){u=r&-8;o=r>>>3;r:do{if(r>>>0>=256){a=pe[w+((c|24)+p)>>2]|0;i=pe[w+(p+12+c)>>2]|0;do{if((i|0)==(t|0)){n=c|16;i=w+(s+n)|0;r=pe[i>>2]|0;if(!r){i=w+(n+p)|0;r=pe[i>>2]|0;if(!r){D=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;D=r;break}}else{n=pe[w+((c|8)+p)>>2]|0;if(n>>>0>>0)Xe();e=n+12|0;if((pe[e>>2]|0)!=(t|0))Xe();r=i+8|0;if((pe[r>>2]|0)==(t|0)){pe[e>>2]=i;pe[r>>2]=n;D=i;break}else Xe()}}while(0);if(!a)break;e=pe[w+(p+28+c)>>2]|0;r=908+(e<<2)|0;do{if((t|0)!=(pe[r>>2]|0)){if(a>>>0<(pe[155]|0)>>>0)Xe();e=a+16|0;if((pe[e>>2]|0)==(t|0))pe[e>>2]=D;else pe[a+20>>2]=D;if(!D)break r}else{pe[r>>2]=D;if(D)break;pe[152]=pe[152]&~(1<>>0>>0)Xe();pe[D+24>>2]=a;t=c|16;e=pe[w+(t+p)>>2]|0;do{if(e)if(e>>>0>>0)Xe();else{pe[D+16>>2]=e;pe[e+24>>2]=D;break}}while(0);t=pe[w+(s+t)>>2]|0;if(!t)break;if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[D+20>>2]=t;pe[t+24>>2]=D;break}}else{i=pe[w+((c|8)+p)>>2]|0;n=pe[w+(p+12+c)>>2]|0;r=644+(o<<1<<2)|0;do{if((i|0)!=(r|0)){if(i>>>0>>0)Xe();if((pe[i+12>>2]|0)==(t|0))break;Xe()}}while(0);if((n|0)==(i|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();e=n+8|0;if((pe[e>>2]|0)==(t|0)){k=e;break}Xe()}}while(0);pe[i+12>>2]=n;pe[k>>2]=i}}while(0);t=w+((u|c)+p)|0;n=u+f|0}else n=f;t=t+4|0;pe[t>>2]=pe[t>>2]&-2;pe[w+(l+4)>>2]=n|1;pe[w+(n+l)>>2]=n;t=n>>>3;if(n>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0>=(pe[155]|0)>>>0){L=t;j=e;break}Xe()}}while(0);pe[L>>2]=d;pe[j+12>>2]=d;pe[w+(l+8)>>2]=j;pe[w+(l+12)>>2]=i;break}t=n>>>8;do{if(!t)i=0;else{if(n>>>0>16777215){i=31;break}L=(t+1048320|0)>>>16&8;j=t<>>16&4;j=j<>>16&2;i=14-(D|L|i)+(j<>>15)|0;i=n>>>(i+7|0)&1|i<<1}}while(0);t=908+(i<<2)|0;pe[w+(l+28)>>2]=i;pe[w+(l+20)>>2]=0;pe[w+(l+16)>>2]=0;e=pe[152]|0;r=1<>2]=d;pe[w+(l+24)>>2]=t;pe[w+(l+12)>>2]=d;pe[w+(l+8)>>2]=d;break}t=pe[t>>2]|0;r:do{if((pe[t+4>>2]&-8|0)!=(n|0)){i=n<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(n|0)){F=r;break r}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=d;pe[w+(l+24)>>2]=t;pe[w+(l+12)>>2]=d;pe[w+(l+8)>>2]=d;break t}}else F=t}while(0);t=F+8|0;e=pe[t>>2]|0;j=pe[155]|0;if(e>>>0>=j>>>0&F>>>0>=j>>>0){pe[e+12>>2]=d;pe[t>>2]=d;pe[w+(l+8)>>2]=e;pe[w+(l+12)>>2]=F;pe[w+(l+24)>>2]=0;break}else Xe()}else{F=(pe[154]|0)+f|0;pe[154]=F;pe[157]=d;pe[w+(l+4)>>2]=F|1}}while(0);F=w+(h|8)|0;return F|0}else r=1052;while(1){e=pe[r>>2]|0;if(e>>>0<=a>>>0?(t=pe[r+4>>2]|0,i=e+t|0,i>>>0>a>>>0):0)break;r=pe[r+8>>2]|0}n=e+(t+-39)|0;e=e+(t+-47+((n&7|0)==0?0:0-n&7))|0;n=a+16|0;e=e>>>0>>0?a:e;t=e+8|0;r=w+8|0;r=(r&7|0)==0?0:0-r&7;F=p+-40-r|0;pe[157]=w+r;pe[154]=F;pe[w+(r+4)>>2]=F|1;pe[w+(p+-36)>>2]=40;pe[158]=pe[273];r=e+4|0;pe[r>>2]=27;pe[t>>2]=pe[263];pe[t+4>>2]=pe[264];pe[t+8>>2]=pe[265];pe[t+12>>2]=pe[266];pe[263]=w;pe[264]=p;pe[266]=0;pe[265]=t;t=e+28|0;pe[t>>2]=7;if((e+32|0)>>>0>>0)do{F=t;t=t+4|0;pe[t>>2]=7}while((F+8|0)>>>0>>0);if((e|0)!=(a|0)){o=e-a|0;pe[r>>2]=pe[r>>2]&-2;pe[a+4>>2]=o|1;pe[e>>2]=o;t=o>>>3;if(o>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{I=t;R=e}}else{pe[151]=r|t;I=644+(e+2<<2)|0;R=i}pe[I>>2]=a;pe[R+12>>2]=a;pe[a+8>>2]=R;pe[a+12>>2]=i;break}t=o>>>8;if(t)if(o>>>0>16777215)i=31;else{j=(t+1048320|0)>>>16&8;F=t<>>16&4;F=F<>>16&2;i=14-(L|j|i)+(F<>>15)|0;i=o>>>(i+7|0)&1|i<<1}else i=0;r=908+(i<<2)|0;pe[a+28>>2]=i;pe[a+20>>2]=0;pe[n>>2]=0;t=pe[152]|0;e=1<>2]=a;pe[a+24>>2]=r;pe[a+12>>2]=a;pe[a+8>>2]=a;break}t=pe[r>>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(o|0)){i=o<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(o|0)){O=r;break t}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=a;pe[a+24>>2]=t;pe[a+12>>2]=a;pe[a+8>>2]=a;break e}}else O=t}while(0);t=O+8|0;e=pe[t>>2]|0;F=pe[155]|0;if(e>>>0>=F>>>0&O>>>0>=F>>>0){pe[e+12>>2]=a;pe[t>>2]=a;pe[a+8>>2]=e;pe[a+12>>2]=O;pe[a+24>>2]=0;break}else Xe()}}else{F=pe[155]|0;if((F|0)==0|w>>>0>>0)pe[155]=w;pe[263]=w;pe[264]=p;pe[266]=0;pe[160]=pe[269];pe[159]=-1;t=0;do{F=t<<1;j=644+(F<<2)|0;pe[644+(F+3<<2)>>2]=j;pe[644+(F+2<<2)>>2]=j;t=t+1|0}while((t|0)!=32);F=w+8|0;F=(F&7|0)==0?0:0-F&7;j=p+-40-F|0;pe[157]=w+F;pe[154]=j;pe[w+(F+4)>>2]=j|1;pe[w+(p+-36)>>2]=40;pe[158]=pe[273]}}while(0);t=pe[154]|0;if(t>>>0>v>>>0){j=t-v|0;pe[154]=j;F=pe[157]|0;pe[157]=F+v;pe[F+(v+4)>>2]=j|1;pe[F+4>>2]=v|3;F=F+8|0;return F|0}}F=fr()|0;pe[F>>2]=12;F=0;return F|0}function zr(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0;if(!e)return;t=e+-8|0;s=pe[155]|0;if(t>>>0>>0)Xe();r=pe[e+-4>>2]|0;i=r&3;if((i|0)==1)Xe();d=r&-8;v=e+(d+-8)|0;do{if(!(r&1)){t=pe[t>>2]|0;if(!i)return;u=-8-t|0;f=e+u|0;l=t+d|0;if(f>>>0>>0)Xe();if((f|0)==(pe[156]|0)){t=e+(d+-4)|0;r=pe[t>>2]|0;if((r&3|0)!=3){y=f;o=l;break}pe[153]=l;pe[t>>2]=r&-2;pe[e+(u+4)>>2]=l|1;pe[v>>2]=l;return}n=t>>>3;if(t>>>0<256){i=pe[e+(u+8)>>2]|0;r=pe[e+(u+12)>>2]|0;t=644+(n<<1<<2)|0;if((i|0)!=(t|0)){if(i>>>0>>0)Xe();if((pe[i+12>>2]|0)!=(f|0))Xe()}if((r|0)==(i|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();t=r+8|0;if((pe[t>>2]|0)==(f|0))a=t;else Xe()}else a=r+8|0;pe[i+12>>2]=r;pe[a>>2]=i;y=f;o=l;break}a=pe[e+(u+24)>>2]|0;i=pe[e+(u+12)>>2]|0;do{if((i|0)==(f|0)){r=e+(u+20)|0;t=pe[r>>2]|0;if(!t){r=e+(u+16)|0;t=pe[r>>2]|0;if(!t){c=0;break}}while(1){i=t+20|0;n=pe[i>>2]|0;if(n){t=n;r=i;continue}i=t+16|0;n=pe[i>>2]|0;if(!n)break;else{t=n;r=i}}if(r>>>0>>0)Xe();else{pe[r>>2]=0;c=t;break}}else{n=pe[e+(u+8)>>2]|0;if(n>>>0>>0)Xe();t=n+12|0;if((pe[t>>2]|0)!=(f|0))Xe();r=i+8|0;if((pe[r>>2]|0)==(f|0)){pe[t>>2]=i;pe[r>>2]=n;c=i;break}else Xe()}}while(0);if(a){t=pe[e+(u+28)>>2]|0;r=908+(t<<2)|0;if((f|0)==(pe[r>>2]|0)){pe[r>>2]=c;if(!c){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(f|0))pe[t>>2]=c;else pe[a+20>>2]=c;if(!c){y=f;o=l;break}}r=pe[155]|0;if(c>>>0>>0)Xe();pe[c+24>>2]=a;t=pe[e+(u+16)>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[c+16>>2]=t;pe[t+24>>2]=c;break}}while(0);t=pe[e+(u+20)>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[c+20>>2]=t;pe[t+24>>2]=c;y=f;o=l;break}else{y=f;o=l}}else{y=f;o=l}}else{y=t;o=d}}while(0);if(y>>>0>=v>>>0)Xe();t=e+(d+-4)|0;r=pe[t>>2]|0;if(!(r&1))Xe();if(!(r&2)){if((v|0)==(pe[157]|0)){g=(pe[154]|0)+o|0;pe[154]=g;pe[157]=y;pe[y+4>>2]=g|1;if((y|0)!=(pe[156]|0))return;pe[156]=0;pe[153]=0;return}if((v|0)==(pe[156]|0)){g=(pe[153]|0)+o|0;pe[153]=g;pe[156]=y;pe[y+4>>2]=g|1;pe[y+g>>2]=g;return}o=(r&-8)+o|0;n=r>>>3;do{if(r>>>0>=256){a=pe[e+(d+16)>>2]|0;t=pe[e+(d|4)>>2]|0;do{if((t|0)==(v|0)){r=e+(d+12)|0;t=pe[r>>2]|0;if(!t){r=e+(d+8)|0;t=pe[r>>2]|0;if(!t){p=0;break}}while(1){i=t+20|0;n=pe[i>>2]|0;if(n){t=n;r=i;continue}i=t+16|0;n=pe[i>>2]|0;if(!n)break;else{t=n;r=i}}if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[r>>2]=0;p=t;break}}else{r=pe[e+d>>2]|0;if(r>>>0<(pe[155]|0)>>>0)Xe();i=r+12|0;if((pe[i>>2]|0)!=(v|0))Xe();n=t+8|0;if((pe[n>>2]|0)==(v|0)){pe[i>>2]=t;pe[n>>2]=r;p=t;break}else Xe()}}while(0);if(a){t=pe[e+(d+20)>>2]|0;r=908+(t<<2)|0;if((v|0)==(pe[r>>2]|0)){pe[r>>2]=p;if(!p){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(v|0))pe[t>>2]=p;else pe[a+20>>2]=p;if(!p)break}r=pe[155]|0;if(p>>>0>>0)Xe();pe[p+24>>2]=a;t=pe[e+(d+8)>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[p+16>>2]=t;pe[t+24>>2]=p;break}}while(0);t=pe[e+(d+12)>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[p+20>>2]=t;pe[t+24>>2]=p;break}}}else{i=pe[e+d>>2]|0;r=pe[e+(d|4)>>2]|0;t=644+(n<<1<<2)|0;if((i|0)!=(t|0)){if(i>>>0<(pe[155]|0)>>>0)Xe();if((pe[i+12>>2]|0)!=(v|0))Xe()}if((r|0)==(i|0)){pe[151]=pe[151]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=r+8|0;if((pe[t>>2]|0)==(v|0))h=t;else Xe()}else h=r+8|0;pe[i+12>>2]=r;pe[h>>2]=i}}while(0);pe[y+4>>2]=o|1;pe[y+o>>2]=o;if((y|0)==(pe[156]|0)){pe[153]=o;return}}else{pe[t>>2]=r&-2;pe[y+4>>2]=o|1;pe[y+o>>2]=o}t=o>>>3;if(o>>>0<256){r=t<<1;n=644+(r<<2)|0;i=pe[151]|0;t=1<>2]|0;if(r>>>0<(pe[155]|0)>>>0)Xe();else{m=t;b=r}}else{pe[151]=i|t;m=644+(r+2<<2)|0;b=n}pe[m>>2]=y;pe[b+12>>2]=y;pe[y+8>>2]=b;pe[y+12>>2]=n;return}t=o>>>8;if(t)if(o>>>0>16777215)n=31;else{m=(t+1048320|0)>>>16&8;b=t<>>16&4;b=b<>>16&2;n=14-(v|m|n)+(b<>>15)|0;n=o>>>(n+7|0)&1|n<<1}else n=0;t=908+(n<<2)|0;pe[y+28>>2]=n;pe[y+20>>2]=0;pe[y+16>>2]=0;r=pe[152]|0;i=1<>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(o|0)){n=o<<((n|0)==31?0:25-(n>>>1)|0);while(1){r=t+16+(n>>>31<<2)|0;i=pe[r>>2]|0;if(!i)break;if((pe[i+4>>2]&-8|0)==(o|0)){g=i;break t}else{n=n<<1;t=i}}if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[r>>2]=y;pe[y+24>>2]=t;pe[y+12>>2]=y;pe[y+8>>2]=y;break e}}else g=t}while(0);t=g+8|0;r=pe[t>>2]|0;b=pe[155]|0;if(r>>>0>=b>>>0&g>>>0>=b>>>0){pe[r+12>>2]=y;pe[t>>2]=y;pe[y+8>>2]=r;pe[y+12>>2]=g;pe[y+24>>2]=0;break}else Xe()}else{pe[152]=r|i;pe[t>>2]=y;pe[y+24>>2]=t;pe[y+12>>2]=y;pe[y+8>>2]=y}}while(0);y=(pe[159]|0)+-1|0;pe[159]=y;if(!y)t=1060;else return;while(1){t=pe[t>>2]|0;if(!t)break;else t=t+8|0}pe[159]=-1;return}function Xr(e,t){e=e|0;t=t|0;var r=0,i=0;if(!e){e=Ur(t)|0;return e|0}if(t>>>0>4294967231){e=fr()|0;pe[e>>2]=12;e=0;return e|0}r=Gr(e+-8|0,t>>>0<11?16:t+11&-8)|0;if(r){e=r+8|0;return e|0}r=Ur(t)|0;if(!r){e=0;return e|0}i=pe[e+-4>>2]|0;i=(i&-8)-((i&3|0)==0?8:4)|0;Qr(r|0,e|0,(i>>>0>>0?i:t)|0)|0;zr(e);e=r;return e|0}function qr(e){e=e|0;var t=0;if(!e){t=0;return t|0}e=pe[e+-4>>2]|0;t=e&3;if((t|0)==1){t=0;return t|0}t=(e&-8)-((t|0)==0?8:4)|0;return t|0}function Gr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;d=e+4|0;p=pe[d>>2]|0;u=p&-8;f=e+u|0;s=pe[155]|0;r=p&3;if(!((r|0)!=1&e>>>0>=s>>>0&e>>>0>>0))Xe();i=e+(u|4)|0;n=pe[i>>2]|0;if(!(n&1))Xe();if(!r){if(t>>>0<256){e=0;return e|0}if(u>>>0>=(t+4|0)>>>0?(u-t|0)>>>0<=pe[271]<<1>>>0:0)return e|0;e=0;return e|0}if(u>>>0>=t>>>0){r=u-t|0;if(r>>>0<=15)return e|0;pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=r|3;pe[i>>2]=pe[i>>2]|1;Hr(e+t|0,r);return e|0}if((f|0)==(pe[157]|0)){r=(pe[154]|0)+u|0;if(r>>>0<=t>>>0){e=0;return e|0}h=r-t|0;pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=h|1;pe[157]=e+t;pe[154]=h;return e|0}if((f|0)==(pe[156]|0)){i=(pe[153]|0)+u|0;if(i>>>0>>0){e=0;return e|0}r=i-t|0;if(r>>>0>15){pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=r|1;pe[e+i>>2]=r;i=e+(i+4)|0;pe[i>>2]=pe[i>>2]&-2;i=e+t|0}else{pe[d>>2]=p&1|i|2;i=e+(i+4)|0;pe[i>>2]=pe[i>>2]|1;i=0;r=0}pe[153]=r;pe[156]=i;return e|0}if(n&2){e=0;return e|0}l=(n&-8)+u|0;if(l>>>0>>0){e=0;return e|0}h=l-t|0;o=n>>>3;do{if(n>>>0>=256){a=pe[e+(u+24)>>2]|0;o=pe[e+(u+12)>>2]|0;do{if((o|0)==(f|0)){i=e+(u+20)|0;r=pe[i>>2]|0;if(!r){i=e+(u+16)|0;r=pe[i>>2]|0;if(!r){c=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;c=r;break}}else{n=pe[e+(u+8)>>2]|0;if(n>>>0>>0)Xe();r=n+12|0;if((pe[r>>2]|0)!=(f|0))Xe();i=o+8|0;if((pe[i>>2]|0)==(f|0)){pe[r>>2]=o;pe[i>>2]=n;c=o;break}else Xe()}}while(0);if(a){r=pe[e+(u+28)>>2]|0;i=908+(r<<2)|0;if((f|0)==(pe[i>>2]|0)){pe[i>>2]=c;if(!c){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=a+16|0;if((pe[r>>2]|0)==(f|0))pe[r>>2]=c;else pe[a+20>>2]=c;if(!c)break}i=pe[155]|0;if(c>>>0>>0)Xe();pe[c+24>>2]=a;r=pe[e+(u+16)>>2]|0;do{if(r)if(r>>>0>>0)Xe();else{pe[c+16>>2]=r;pe[r+24>>2]=c;break}}while(0);r=pe[e+(u+20)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[c+20>>2]=r;pe[r+24>>2]=c;break}}}else{n=pe[e+(u+8)>>2]|0;i=pe[e+(u+12)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(f|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(f|0))a=r;else Xe()}else a=i+8|0;pe[n+12>>2]=i;pe[a>>2]=n}}while(0);if(h>>>0<16){pe[d>>2]=l|p&1|2;t=e+(l|4)|0;pe[t>>2]=pe[t>>2]|1;return e|0}else{pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=h|3;p=e+(l|4)|0;pe[p>>2]=pe[p>>2]|1;Hr(e+t|0,h);return e|0}return 0}function Hr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0;v=e+t|0;r=pe[e+4>>2]|0;do{if(!(r&1)){c=pe[e>>2]|0;if(!(r&3))return;h=e+(0-c)|0;l=c+t|0;u=pe[155]|0;if(h>>>0>>0)Xe();if((h|0)==(pe[156]|0)){i=e+(t+4)|0;r=pe[i>>2]|0;if((r&3|0)!=3){g=h;a=l;break}pe[153]=l;pe[i>>2]=r&-2;pe[e+(4-c)>>2]=l|1;pe[v>>2]=l;return}o=c>>>3;if(c>>>0<256){n=pe[e+(8-c)>>2]|0;i=pe[e+(12-c)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(h|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(h|0))s=r;else Xe()}else s=i+8|0;pe[n+12>>2]=i;pe[s>>2]=n;g=h;a=l;break}s=pe[e+(24-c)>>2]|0;n=pe[e+(12-c)>>2]|0;do{if((n|0)==(h|0)){n=16-c|0;i=e+(n+4)|0;r=pe[i>>2]|0;if(!r){i=e+n|0;r=pe[i>>2]|0;if(!r){f=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;f=r;break}}else{o=pe[e+(8-c)>>2]|0;if(o>>>0>>0)Xe();r=o+12|0;if((pe[r>>2]|0)!=(h|0))Xe();i=n+8|0;if((pe[i>>2]|0)==(h|0)){pe[r>>2]=n;pe[i>>2]=o;f=n;break}else Xe()}}while(0);if(s){r=pe[e+(28-c)>>2]|0;i=908+(r<<2)|0;if((h|0)==(pe[i>>2]|0)){pe[i>>2]=f;if(!f){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=s+16|0;if((pe[r>>2]|0)==(h|0))pe[r>>2]=f;else pe[s+20>>2]=f;if(!f){g=h;a=l;break}}n=pe[155]|0;if(f>>>0>>0)Xe();pe[f+24>>2]=s;r=16-c|0;i=pe[e+r>>2]|0;do{if(i)if(i>>>0>>0)Xe();else{pe[f+16>>2]=i;pe[i+24>>2]=f;break}}while(0);r=pe[e+(r+4)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[f+20>>2]=r;pe[r+24>>2]=f;g=h;a=l;break}else{g=h;a=l}}else{g=h;a=l}}else{g=e;a=t}}while(0);u=pe[155]|0;if(v>>>0>>0)Xe();r=e+(t+4)|0;i=pe[r>>2]|0;if(!(i&2)){if((v|0)==(pe[157]|0)){b=(pe[154]|0)+a|0;pe[154]=b;pe[157]=g;pe[g+4>>2]=b|1;if((g|0)!=(pe[156]|0))return;pe[156]=0;pe[153]=0;return}if((v|0)==(pe[156]|0)){b=(pe[153]|0)+a|0;pe[153]=b;pe[156]=g;pe[g+4>>2]=b|1;pe[g+b>>2]=b;return}a=(i&-8)+a|0;o=i>>>3;do{if(i>>>0>=256){s=pe[e+(t+24)>>2]|0;n=pe[e+(t+12)>>2]|0;do{if((n|0)==(v|0)){i=e+(t+20)|0;r=pe[i>>2]|0;if(!r){i=e+(t+16)|0;r=pe[i>>2]|0;if(!r){p=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;p=r;break}}else{o=pe[e+(t+8)>>2]|0;if(o>>>0>>0)Xe();r=o+12|0;if((pe[r>>2]|0)!=(v|0))Xe();i=n+8|0;if((pe[i>>2]|0)==(v|0)){pe[r>>2]=n;pe[i>>2]=o;p=n;break}else Xe()}}while(0);if(s){r=pe[e+(t+28)>>2]|0;i=908+(r<<2)|0;if((v|0)==(pe[i>>2]|0)){pe[i>>2]=p;if(!p){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=s+16|0;if((pe[r>>2]|0)==(v|0))pe[r>>2]=p;else pe[s+20>>2]=p;if(!p)break}i=pe[155]|0;if(p>>>0>>0)Xe();pe[p+24>>2]=s;r=pe[e+(t+16)>>2]|0;do{if(r)if(r>>>0>>0)Xe();else{pe[p+16>>2]=r;pe[r+24>>2]=p;break}}while(0);r=pe[e+(t+20)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[p+20>>2]=r;pe[r+24>>2]=p;break}}}else{n=pe[e+(t+8)>>2]|0;i=pe[e+(t+12)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(v|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(v|0))d=r;else Xe()}else d=i+8|0;pe[n+12>>2]=i;pe[d>>2]=n}}while(0);pe[g+4>>2]=a|1;pe[g+a>>2]=a;if((g|0)==(pe[156]|0)){pe[153]=a;return}}else{pe[r>>2]=i&-2;pe[g+4>>2]=a|1;pe[g+a>>2]=a}r=a>>>3;if(a>>>0<256){i=r<<1;o=644+(i<<2)|0;n=pe[151]|0;r=1<>2]|0;if(i>>>0<(pe[155]|0)>>>0)Xe();else{m=r;b=i}}else{pe[151]=n|r;m=644+(i+2<<2)|0;b=o}pe[m>>2]=g;pe[b+12>>2]=g;pe[g+8>>2]=b;pe[g+12>>2]=o;return}r=a>>>8;if(r)if(a>>>0>16777215)o=31;else{m=(r+1048320|0)>>>16&8;b=r<>>16&4;b=b<>>16&2;o=14-(v|m|o)+(b<>>15)|0;o=a>>>(o+7|0)&1|o<<1}else o=0;r=908+(o<<2)|0;pe[g+28>>2]=o;pe[g+20>>2]=0;pe[g+16>>2]=0;i=pe[152]|0;n=1<>2]=g;pe[g+24>>2]=r;pe[g+12>>2]=g;pe[g+8>>2]=g;return}r=pe[r>>2]|0;e:do{if((pe[r+4>>2]&-8|0)!=(a|0)){o=a<<((o|0)==31?0:25-(o>>>1)|0);while(1){i=r+16+(o>>>31<<2)|0;n=pe[i>>2]|0;if(!n)break;if((pe[n+4>>2]&-8|0)==(a|0)){r=n;break e}else{o=o<<1;r=n}}if(i>>>0<(pe[155]|0)>>>0)Xe();pe[i>>2]=g;pe[g+24>>2]=r;pe[g+12>>2]=g;pe[g+8>>2]=g;return}}while(0);i=r+8|0;n=pe[i>>2]|0;b=pe[155]|0;if(!(n>>>0>=b>>>0&r>>>0>=b>>>0))Xe();pe[n+12>>2]=g;pe[i>>2]=g;pe[g+8>>2]=n;pe[g+12>>2]=r;pe[g+24>>2]=0;return}function Vr(){}function Wr(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;i=t-i-(r>>>0>e>>>0|0)>>>0;return(re=i,e-r>>>0|0)|0}function Yr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;i=e+r|0;if((r|0)>=20){t=t&255;o=e&3;a=t|t<<8|t<<16|t<<24;n=i&~3;if(o){o=e+4-o|0;while((e|0)<(o|0)){de[e>>0]=t;e=e+1|0}}while((e|0)<(n|0)){pe[e>>2]=a;e=e+4|0}}while((e|0)<(i|0)){de[e>>0]=t;e=e+1|0}return e-r|0}function Kr(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t>>>r;return e>>>r|(t&(1<>>r-32|0}function Jr(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t<>>32-r;return e<>>0;return(re=t+i+(r>>>0>>0|0)>>>0,r|0)|0}function Qr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if((r|0)>=4096)return Re(e|0,t|0,r|0)|0;i=e|0;if((e&3)==(t&3)){while(e&3){if(!r)return i|0;de[e>>0]=de[t>>0]|0;e=e+1|0;t=t+1|0;r=r-1|0}while((r|0)>=4){pe[e>>2]=pe[t>>2];e=e+4|0;t=t+4|0;r=r-4|0}}while((r|0)>0){de[e>>0]=de[t>>0]|0;e=e+1|0;t=t+1|0;r=r-1|0}return i|0}function $r(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t>>r;return e>>>r|(t&(1<>r-32|0}function ei(e){e=e|0;var t=0;t=de[m+(e&255)>>0]|0;if((t|0)<8)return t|0;t=de[m+(e>>8&255)>>0]|0;if((t|0)<8)return t+8|0;t=de[m+(e>>16&255)>>0]|0;if((t|0)<8)return t+16|0;return(de[m+(e>>>24)>>0]|0)+24|0}function ti(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0;o=e&65535;n=t&65535;r=ge(n,o)|0;i=e>>>16;e=(r>>>16)+(ge(n,i)|0)|0;n=t>>>16;t=ge(n,o)|0;return(re=(e>>>16)+(ge(n,i)|0)+(((e&65535)+t|0)>>>16)|0,e+t<<16|r&65535|0)|0}function ri(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0;c=t>>31|((t|0)<0?-1:0)<<1;u=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1;o=i>>31|((i|0)<0?-1:0)<<1;n=((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1;s=Wr(c^e,u^t,c,u)|0;a=re;e=o^c;t=n^u;return Wr((si(s,a,Wr(o^r,n^i,o,n)|0,re,0)|0)^e,re^t,e,t)|0}function ii(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0;n=be;be=be+16|0;s=n|0;a=t>>31|((t|0)<0?-1:0)<<1;o=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1;c=i>>31|((i|0)<0?-1:0)<<1;u=((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1;e=Wr(a^e,o^t,a,o)|0;t=re;si(e,t,Wr(c^r,u^i,c,u)|0,re,s)|0;i=Wr(pe[s>>2]^a,pe[s+4>>2]^o,a,o)|0;r=re;be=n;return(re=r,i)|0}function ni(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0;n=e;o=r;r=ti(n,o)|0;e=re;return(re=(ge(t,o)|0)+(ge(i,n)|0)+e|e&0,r|0|0)|0}function oi(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;return si(e,t,r,i,0)|0}function ai(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0;o=be;be=be+16|0;n=o|0;si(e,t,r,i,n)|0;be=o;return(re=pe[n+4>>2]|0,pe[n>>2]|0)|0}function si(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;f=e;u=t;c=u;a=r;h=i;s=h;if(!c){o=(n|0)!=0;if(!s){if(o){pe[n>>2]=(f>>>0)%(a>>>0);pe[n+4>>2]=0}h=0;n=(f>>>0)/(a>>>0)>>>0;return(re=h,n)|0}else{if(!o){h=0;n=0;return(re=h,n)|0}pe[n>>2]=e|0;pe[n+4>>2]=t&0;h=0;n=0;return(re=h,n)|0}}o=(s|0)==0;do{if(a){if(!o){o=(ae(s|0)|0)-(ae(c|0)|0)|0;if(o>>>0<=31){l=o+1|0;s=31-o|0;t=o-31>>31;a=l;e=f>>>(l>>>0)&t|c<>>(l>>>0)&t;o=0;s=f<>2]=e|0;pe[n+4>>2]=u|t&0;h=0;n=0;return(re=h,n)|0}o=a-1|0;if(o&a){s=(ae(a|0)|0)+33-(ae(c|0)|0)|0;p=64-s|0;l=32-s|0;u=l>>31;d=s-32|0;t=d>>31;a=s;e=l-1>>31&c>>>(d>>>0)|(c<>>(s>>>0))&t;t=t&c>>>(s>>>0);o=f<>>(d>>>0))&u|f<>31;break}if(n){pe[n>>2]=o&f;pe[n+4>>2]=0}if((a|0)==1){d=u|t&0;p=e|0|0;return(re=d,p)|0}else{p=ei(a|0)|0;d=c>>>(p>>>0)|0;p=c<<32-p|f>>>(p>>>0)|0;return(re=d,p)|0}}else{if(o){if(n){pe[n>>2]=(c>>>0)%(a>>>0);pe[n+4>>2]=0}d=0;p=(c>>>0)/(a>>>0)>>>0;return(re=d,p)|0}if(!f){if(n){pe[n>>2]=0;pe[n+4>>2]=(c>>>0)%(s>>>0)}d=0;p=(c>>>0)/(s>>>0)>>>0;return(re=d,p)|0}o=s-1|0;if(!(o&s)){if(n){pe[n>>2]=e|0;pe[n+4>>2]=o&c|t&0}d=0;p=c>>>((ei(s|0)|0)>>>0);return(re=d,p)|0}o=(ae(s|0)|0)-(ae(c|0)|0)|0;if(o>>>0<=30){t=o+1|0;s=31-o|0;a=t;e=c<>>(t>>>0);t=c>>>(t>>>0);o=0;s=f<>2]=e|0;pe[n+4>>2]=u|t&0;d=0;p=0;return(re=d,p)|0}}while(0);if(!a){c=s;u=0;s=0}else{l=r|0|0;f=h|i&0;c=Zr(l|0,f|0,-1,-1)|0;r=re;u=s;s=0;do{i=u;u=o>>>31|u<<1;o=s|o<<1;i=e<<1|i>>>31|0;h=e>>>31|t<<1|0;Wr(c,r,i,h)|0;p=re;d=p>>31|((p|0)<0?-1:0)<<1;s=d&1;e=Wr(i,h,d&l,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&f)|0;t=re;a=a-1|0}while((a|0)!=0);c=u;u=0}a=0;if(n){pe[n>>2]=e;pe[n+4>>2]=t}d=(o|0)>>>31|(c|a)<<1|(a<<1|o>>>31)&0|u;p=(o<<1|0>>>31)&-2|s;return(re=d,p)|0}function ui(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;return Mi[e&7](t|0,r|0,i|0)|0}function ci(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;Ci[e&3](t|0,r|0,i|0,n|0,o|0)}function fi(e,t){e=e|0;t=t|0;Pi[e&7](t|0)}function li(e,t){e=e|0;t=t|0;return Ai[e&1](t|0)|0}function hi(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;ki[e&0](t|0,r|0,i|0)}function di(e){e=e|0;Ii[e&3]()}function pi(e,t,r,i,n,o,a){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;Ri[e&3](t|0,r|0,i|0,n|0,o|0,a|0)}function vi(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;return Oi[e&1](t|0,r|0,i|0,n|0,o|0)|0}function mi(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;Di[e&3](t|0,r|0,i|0,n|0)}function bi(e,t,r){e=e|0;t=t|0;r=r|0;se(0);return 0}function gi(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;se(1)}function yi(e){e=e|0;se(2)}function _i(e){e=e|0;se(3);return 0}function wi(e,t,r){e=e|0;t=t|0;r=r|0;se(4)}function xi(){se(5)}function Ti(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;se(6)}function Si(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;se(7);return 0}function Ei(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;se(8)}var Mi=[bi,Yt,jr,Ar,Pr,kr,bi,bi];var Ci=[gi,tr,er,gi];var Pi=[yi,qt,Vt,Gt,Ht,Wt,ur,Lr];var Ai=[_i,Cr];var ki=[wi];var Ii=[xi,ar,sr,xi];var Ri=[Ti,ir,rr,Ti];var Oi=[Si,ut];var Di=[Ei,Jt,Zt,Ei];return{___cxa_can_catch:nr,_crn_get_levels:Tt,_crn_get_uncompressed_size:Et,_crn_decompress:Mt,_i64Add:Zr,_crn_get_width:wt,___cxa_is_pointer_type:or,_i64Subtract:Wr,_memset:Yr,_malloc:Ur,_free:zr,_memcpy:Qr,_bitshift64Lshr:Kr,_fflush:mr,_bitshift64Shl:Jr,_crn_get_height:xt,___errno_location:fr,_crn_get_dxt_format:St,runPostSets:Vr,_emscripten_replace_memory:Ye,stackAlloc:Ke,stackSave:Je,stackRestore:Ze,establishStackSpace:Qe,setThrew:$e,setTempRet0:rt,getTempRet0:it,dynCall_iiii:ui,dynCall_viiiii:ci,dynCall_vi:fi,dynCall_ii:li,dynCall_viii:hi,dynCall_v:di,dynCall_viiiiii:pi,dynCall_iiiiii:vi,dynCall_viiii:mi}}(e.Ya,e.Za,buffer);e.___cxa_can_catch=Z.___cxa_can_catch,e._crn_get_levels=Z._crn_get_levels,e.runPostSets=Z.runPostSets,e._crn_get_uncompressed_size=Z._crn_get_uncompressed_size,e._crn_decompress=Z._crn_decompress;var zc=e._i64Add=Z._i64Add;e._crn_get_height=Z._crn_get_height,e.___cxa_is_pointer_type=Z.___cxa_is_pointer_type;var nb=e._i64Subtract=Z._i64Subtract,qb=e._memset=Z._memset,Ea=e._malloc=Z._malloc,Bc=e._memcpy=Z._memcpy,Xa=e._emscripten_replace_memory=Z._emscripten_replace_memory;e._crn_get_dxt_format=Z._crn_get_dxt_format;var rb=e._bitshift64Lshr=Z._bitshift64Lshr,Na=e._free=Z._free;e._fflush=Z._fflush,e._crn_get_width=Z._crn_get_width,e.___errno_location=Z.___errno_location;var sb=e._bitshift64Shl=Z._bitshift64Shl;function ia(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}e.dynCall_iiii=Z.dynCall_iiii,e.dynCall_viiiii=Z.dynCall_viiiii,e.dynCall_vi=Z.dynCall_vi,e.dynCall_ii=Z.dynCall_ii,e.dynCall_viii=Z.dynCall_viii,e.dynCall_v=Z.dynCall_v,e.dynCall_viiiiii=Z.dynCall_viiiiii,e.dynCall_iiiiii=Z.dynCall_iiiiii,e.dynCall_viiii=Z.dynCall_viiii,n.aa=Z.stackAlloc,n.ua=Z.stackSave,n.ba=Z.stackRestore,n.Cd=Z.establishStackSpace,n.rb=Z.setTempRet0,n.fb=Z.getTempRet0,ia.prototype=Error(),ia.prototype.constructor=ia;var rd=null,jb=function t(){e.calledRun||td(),e.calledRun||(jb=t)};function td(t){function r(){if(!e.calledRun&&(e.calledRun=!0,!na)){if(Ha||(Ha=!0,ab(cb)),ab(db),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e._main&&vd&&e.callMain(t),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)gb(e.postRun.shift());ab(eb)}}if(t=t||e.arguments,null===rd&&(rd=Date.now()),!(0 0) var gc = undefined");else{if(!ba&&!ca)throw"Unknown runtime environment. Where are we?";e.read=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},void 0!==arguments&&(e.arguments=arguments),"undefined"!=typeof console?(e.print||(e.print=function(e){console.log(e)}),e.printErr||(e.printErr=function(e){console.log(e)})):e.print||(e.print=function(){}),ca&&(e.load=importScripts),void 0===e.setWindowTitle&&(e.setWindowTitle=function(e){document.title=e})}function ha(e){eval.call(null,e)}for(k in!e.load&&e.read&&(e.load=function(t){ha(e.read(t))}),e.print||(e.print=function(){}),e.printErr||(e.printErr=e.print),e.arguments||(e.arguments=[]),e.thisProgram||(e.thisProgram="./this.program"),e.print=e.print,e.W=e.printErr,e.preRun=[],e.postRun=[],aa)aa.hasOwnProperty(k)&&(e[k]=aa[k]);var n={rb:function(e){ka=e},fb:function(){return ka},ua:function(){return m},ba:function(e){m=e},Ka:function(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:return"*"===e[e.length-1]?n.J:"i"===e[0]?(assert(0==(e=parseInt(e.substr(1)))%8),e/8):0}},eb:function(e){return Math.max(n.Ka(e),n.J)},ud:16,Qd:function(e,t){return"double"===t||"i64"===t?7&e&&(assert(4==(7&e)),e+=4):assert(0==(3&e)),e},Ed:function(e,t,r){return r||"i64"!=e&&"double"!=e?e?Math.min(t||(e?n.eb(e):0),n.J):Math.min(t,8):8},L:function(t,r,i){return i&&i.length?(i.splice||(i=Array.prototype.slice.call(i)),i.splice(0,0,r),e["dynCall_"+t].apply(null,i)):e["dynCall_"+t].call(null,r)},Z:[],Xa:function(e){for(var t=0;t>>0)+4294967296*+(t>>>0):+(e>>>0)+4294967296*+(0|t)},Ua:8,J:4,vd:0};e.Runtime=n,n.addFunction=n.Xa,n.removeFunction=n.nb;var na=!1,oa,pa,ka,ra,sa;function assert(e,t){e||x("Assertion failed: "+t)}function qa(a){var b=e["_"+a];if(!b)try{b=eval("_"+a)}catch(e){}return assert(b,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)"),b}function wa(e,t,r){switch("*"===(r=r||"i8").charAt(r.length-1)&&(r="i32"),r){case"i1":case"i8":y[e>>0]=t;break;case"i16":z[e>>1]=t;break;case"i32":C[e>>2]=t;break;case"i64":pa=[t>>>0,(oa=t,1<=+xa(oa)?0>>0:~~+Aa((oa-+(~~oa>>>0))/4294967296)>>>0:0)],C[e>>2]=pa[0],C[e+4>>2]=pa[1];break;case"float":Ba[e>>2]=t;break;case"double":Ca[e>>3]=t;break;default:x("invalid type for setValue: "+r)}}function Da(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return y[e>>0];case"i16":return z[e>>1];case"i32":case"i64":return C[e>>2];case"float":return Ba[e>>2];case"double":return Ca[e>>3];default:x("invalid type for setValue: "+t)}return null}function D(e,t,r,i){var o,a;a="number"==typeof e?(o=!0,e):(o=!1,e.length);var s,u,c="string"==typeof t?t:null;if(r=4==r?i:[Ea,n.aa,n.Ra,n.R][void 0===r?2:r](Math.max(a,c?1:t.length)),o){for(assert(0==(3&(i=r))),e=r+(-4&a);i>2]=0;for(e=r+a;i>0]=0;return r}if("i8"===c)return e.subarray||e.slice?E.set(e,r):E.set(new Uint8Array(e),r),r;for(i=0;i>0],0!=i||r)&&(o++,!r||o!=r););if(r||(r=o),i="",n<128){for(;0>10,56320|1023&r)))):s+=String.fromCharCode(r)}}function Ka(e,t,r,i){if(!(0>6}else{if(a<=65535){if(i<=r+2)break;t[r++]=224|a>>12}else{if(a<=2097151){if(i<=r+3)break;t[r++]=240|a>>18}else{if(a<=67108863){if(i<=r+4)break;t[r++]=248|a>>24}else{if(i<=r+5)break;t[r++]=252|a>>30,t[r++]=128|a>>24&63}t[r++]=128|a>>18&63}t[r++]=128|a>>12&63}t[r++]=128|a>>6&63}t[r++]=128|63&a}}return t[r]=0,r-n}function La(e){for(var t=0,r=0;r"):o=n;e:for(;l>0];if(!r)return t;t+=String.fromCharCode(r)}},e.stringToAscii=function(e,t){return Ia(e,t,!1)},e.UTF8ArrayToString=Ja,e.UTF8ToString=function(e){return Ja(E,e)},e.stringToUTF8Array=Ka,e.stringToUTF8=function(e,t,r){return Ka(e,E,t,r)},e.lengthBytesUTF8=La,e.UTF16ToString=function(e){for(var t=0,r="";;){var i=z[e+2*t>>1];if(0==i)return r;++t,r+=String.fromCharCode(i)}},e.stringToUTF16=function(e,t,r){if(void 0===r&&(r=2147483647),r<2)return 0;var i=t;r=(r-=2)<2*e.length?r/2:e.length;for(var n=0;n>1]=e.charCodeAt(n),t+=2;return z[t>>1]=0,t-i},e.lengthBytesUTF16=function(e){return 2*e.length},e.UTF32ToString=function(e){for(var t=0,r="";;){var i=C[e+4*t>>2];if(0==i)return r;++t,65536<=i?(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i)):r+=String.fromCharCode(i)}},e.stringToUTF32=function(e,t,r){if(void 0===r&&(r=2147483647),r<4)return 0;var i=t;r=i+r-4;for(var n=0;n>2]=o,r<(t+=4)+4)break}return C[t>>2]=0,t-i},e.lengthBytesUTF32=function(e){for(var t=0,r=0;r>0]=e[r],r+=1}function ta(e,t){for(var r=0;r>0]=e[r]}function Ia(e,t,r){for(var i=0;i>0]=e.charCodeAt(i);r||(y[t>>0]=0)}e.addOnPreRun=fb,e.addOnInit=function(e){cb.unshift(e)},e.addOnPreMain=function(e){db.unshift(e)},e.addOnExit=function(e){H.unshift(e)},e.addOnPostRun=gb,e.intArrayFromString=hb,e.intArrayToString=function(e){for(var t=[],r=0;r>>16)*i+r*(t>>>16)<<16)|0}),Math.Jd=Math.imul,Math.clz32||(Math.clz32=function(e){e>>>=0;for(var t=0;t<32;t++)if(e&1<<31-t)return t;return 32}),Math.Ad=Math.clz32;var xa=Math.abs,Aa=Math.ceil,za=Math.floor,ya=Math.min,I=0,ib=null,jb=null;function kb(){I++,e.monitorRunDependencies&&e.monitorRunDependencies(I)}function lb(){if(I--,e.monitorRunDependencies&&e.monitorRunDependencies(I),0==I&&(null!==ib&&(clearInterval(ib),ib=null),jb)){var t=jb;jb=null,t()}}e.addRunDependency=kb,e.removeRunDependency=lb,e.preloadedImages={},e.preloadedAudios={},Ta=8,la=Ta+5888,cb.push(),D([124,0,0,0,98,7,0,0,124,0,0,0,111,7,0,0,164,0,0,0,124,7,0,0,16,0,0,0,0,0,0,0,164,0,0,0,157,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,227,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,191,7,0,0,56,0,0,0,0,0,0,0,164,0,0,0,5,8,0,0,40,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,40,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,88,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,114,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,1,0,0,236,1,0,0,236,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,239,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,4,0,0,0,231,16,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,115,40,37,117,41,58,32,65,115,115,101,114,116,105,111,110,32,102,97,105,108,117,114,101,58,32,34,37,115,34,10,0,109,95,115,105,122,101,32,60,61,32,109,95,99,97,112,97,99,105,116,121,0,46,47,99,114,110,95,100,101,99,111,109,112,46,104,0,109,105,110,95,110,101,119,95,99,97,112,97,99,105,116,121,32,60,32,40,48,120,55,70,70,70,48,48,48,48,85,32,47,32,101,108,101,109,101,110,116,95,115,105,122,101,41,0,110,101,119,95,99,97,112,97,99,105,116,121,32,38,38,32,40,110,101,119,95,99,97,112,97,99,105,116,121,32,62,32,109,95,99,97,112,97,99,105,116,121,41,0,110,117,109,95,99,111,100,101,115,91,99,93,0,115,111,114,116,101,100,95,112,111,115,32,60,32,116,111,116,97,108,95,117,115,101,100,95,115,121,109,115,0,112,67,111,100,101,115,105,122,101,115,91,115,121,109,95,105,110,100,101,120,93,32,61,61,32,99,111,100,101,115,105,122,101,0,116,32,60,32,40,49,85,32,60,60,32,116,97,98,108,101,95,98,105,116,115,41,0,109,95,108,111,111,107,117,112,91,116,93,32,61,61,32,99,85,73,78,84,51,50,95,77,65,88,0,99,114,110,100,95,109,97,108,108,111,99,58,32,115,105,122,101,32,116,111,111,32,98,105,103,0,99,114,110,100,95,109,97,108,108,111,99,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,0,40,40,117,105,110,116,51,50,41,112,95,110,101,119,32,38,32,40,67,82,78,68,95,77,73,78,95,65,76,76,79,67,95,65,76,73,71,78,77,69,78,84,32,45,32,49,41,41,32,61,61,32,48,0,99,114,110,100,95,114,101,97,108,108,111,99,58,32,98,97,100,32,112,116,114,0,99,114,110,100,95,102,114,101,101,58,32,98,97,100,32,112,116,114,0,102,97,108,115,101,0,40,116,111,116,97,108,95,115,121,109,115,32,62,61,32,49,41,32,38,38,32,40,116,111,116,97,108,95,115,121,109,115,32,60,61,32,112,114,101,102,105,120,95,99,111,100,105,110,103,58,58,99,77,97,120,83,117,112,112,111,114,116,101,100,83,121,109,115,41,0,17,18,19,20,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,16,48,0,110,117,109,95,98,105,116,115,32,60,61,32,51,50,85,0,109,95,98,105,116,95,99,111,117,110,116,32,60,61,32,99,66,105,116,66,117,102,83,105,122,101,0,116,32,33,61,32,99,85,73,78,84,51,50,95,77,65,88,0,109,111,100,101,108,46,109,95,99,111,100,101,95,115,105,122,101,115,91,115,121,109,93,32,61,61,32,108,101,110,0,0,2,3,1,0,2,3,4,5,6,7,1,40,108,101,110,32,62,61,32,49,41,32,38,38,32,40,108,101,110,32,60,61,32,99,77,97,120,69,120,112,101,99,116,101,100,67,111,100,101,83,105,122,101,41,0,105,32,60,32,109,95,115,105,122,101,0,110,101,120,116,95,108,101,118,101,108,95,111,102,115,32,62,32,99,117,114,95,108,101,118,101,108,95,111,102,115,0,1,2,2,3,3,3,3,4,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,2,1,2,0,0,0,1,0,2,1,0,2,0,0,1,2,3,110,117,109,32,38,38,32,40,110,117,109,32,61,61,32,126,110,117,109,95,99,104,101,99,107,41,0,83,116,57,101,120,99,101,112,116,105,111,110,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,117,110,99,97,117,103,104,116,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0],"i8",4,n.Ua);var mb=n.ja(D(12,"i8",2),8);function ob(t){return e.___errno_location&&(C[e.___errno_location()>>2]=t),t}assert(0==mb%8),e._i64Subtract=nb;var J={I:1,F:2,ed:3,bc:4,H:5,Aa:6,vb:7,zc:8,ea:9,Jb:10,va:11,qd:11,Ta:12,da:13,Vb:14,Lc:15,fa:16,wa:17,rd:18,ha:19,ya:20,P:21,q:22,uc:23,Sa:24,Q:25,nd:26,Wb:27,Hc:28,ia:29,bd:30,nc:31,Vc:32,Sb:33,Zc:34,Dc:42,Zb:43,Kb:44,ec:45,fc:46,gc:47,mc:48,od:49,xc:50,dc:51,Pb:35,Ac:37,Bb:52,Eb:53,sd:54,vc:55,Fb:56,Gb:57,Qb:35,Hb:59,Jc:60,yc:61,kd:62,Ic:63,Ec:64,Fc:65,ad:66,Bc:67,yb:68,gd:69,Lb:70,Wc:71,pc:72,Tb:73,Db:74,Qc:76,Cb:77,$c:78,hc:79,ic:80,lc:81,kc:82,jc:83,Kc:38,za:39,qc:36,ga:40,Rc:95,Uc:96,Ob:104,wc:105,zb:97,Yc:91,Oc:88,Gc:92,cd:108,Nb:111,wb:98,Mb:103,tc:101,rc:100,ld:110,Xb:112,Yb:113,ac:115,Ab:114,Rb:89,oc:90,Xc:93,dd:94,xb:99,sc:102,cc:106,Mc:107,md:109,pd:87,Ub:122,hd:116,Pc:95,Cc:123,$b:84,Sc:75,Ib:125,Nc:131,Tc:130,jd:86};function pb(e,t){H.push(function(){n.L("vi",e,[t])}),pb.level=H.length}function tb(){return!!tb.p}e._memset=qb,e._bitshift64Lshr=rb,e._bitshift64Shl=sb;var ub=[],vb={};function wb(e,t){wb.p||(wb.p={}),e in wb.p||(n.L("v",t),wb.p[e]=1)}var xb={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};function yb(e,t){for(var r=0,i=e.length-1;0<=i;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function zb(e){var t="/"===e.charAt(0),r="/"===e.substr(-1);return(e=yb(e.split("/").filter(function(e){return!!e}),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function Ab(e){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."}function Bb(e){if("/"===e)return"/";var t=e.lastIndexOf("/");return-1===t?e:e.substr(t+1)}function Cb(){return zb(Array.prototype.slice.call(arguments,0).join("/"))}function K(e,t){return zb(e+"/"+t)}function Db(){for(var e="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=yb(e.split("/").filter(function(e){return!!e}),!t).join("/"))||"."}var Eb=[];function Fb(e,t){Eb[e]={input:[],output:[],N:t},Gb(e,Hb)}var Hb={open:function(e){var t=Eb[e.g.rdev];if(!t)throw new L(J.ha);e.tty=t,e.seekable=!1},close:function(e){e.tty.N.flush(e.tty)},flush:function(e){e.tty.N.flush(e.tty)},read:function(e,t,r,i){if(!e.tty||!e.tty.N.La)throw new L(J.Aa);for(var n=0,o=0;oe.e.length&&(e.e=M.cb(e),e.o=e.e.length),!e.e||e.e.subarray){var r=e.e?e.e.buffer.byteLength:0;t<=r||(t=Math.max(t,r*(r<1048576?2:1.125)|0),0!=r&&(t=Math.max(t,256)),r=e.e,e.e=new Uint8Array(t),0t)e.e.length=t;else for(;e.e.length=e.g.o)return 0;if(assert(0<=(e=Math.min(e.g.o-n,i))),8>1)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return t.mode},B:function(e){for(var t=[];e.parent!==e;)t.push(e.name),e=e.parent;return t.push(e.A.pa.root),t.reverse(),Cb.apply(null,t)},Ha:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},$a:function(e){if((e&=-32769)in P.Ha)return P.Ha[e];throw new L(J.q)},k:{D:function(e){var t;e=P.B(e);try{t=fs.lstatSync(e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return P.$&&!t.K&&(t.K=4096),P.$&&!t.blocks&&(t.blocks=(t.size+t.K-1)/t.K|0),{dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,K:t.K,blocks:t.blocks}},u:function(e,t){var r=P.B(e);try{void 0!==t.mode&&(fs.chmodSync(r,t.mode),e.mode=t.mode),void 0!==t.size&&fs.truncateSync(r,t.size)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},lookup:function(e,t){var r=K(P.B(e),t);r=P.Ja(r);return P.createNode(e,t,r)},T:function(e,t,r,i){e=P.createNode(e,t,r,i),t=P.B(e);try{N(e.mode)?fs.mkdirSync(t,e.mode):fs.writeFileSync(t,"",{mode:e.mode})}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return e},rename:function(e,t,r){e=P.B(e),t=K(P.B(t),r);try{fs.renameSync(e,t)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},unlink:function(e,t){var r=K(P.B(e),t);try{fs.unlinkSync(r)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},rmdir:function(e,t){var r=K(P.B(e),t);try{fs.rmdirSync(r)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},readdir:function(e){e=P.B(e);try{return fs.readdirSync(e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},symlink:function(e,t,r){e=K(P.B(e),t);try{fs.symlinkSync(r,e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},readlink:function(e){var t=P.B(e);try{return t=fs.readlinkSync(t),t=Ob.relative(Ob.resolve(e.A.pa.root),t)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}}},n:{open:function(e){var t=P.B(e.g);try{32768==(61440&e.g.mode)&&(e.V=fs.openSync(t,P.$a(e.flags)))}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},close:function(e){try{32768==(61440&e.g.mode)&&e.V&&fs.closeSync(e.V)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},read:function(e,t,r,i,n){if(0===i)return 0;var o,a=new Buffer(i);try{o=fs.readSync(e.V,a,0,i,n)}catch(e){throw new L(J[e.code])}if(0>>0)%Q.length}function Xb(e){var t=Wb(e.parent.id,e.name);e.M=Q[t],Q[t]=e}function Nb(e,t){var r;if(r=(r=Yb(e,"x"))?r:e.k.lookup?0:J.da)throw new L(r,e);for(r=Q[Wb(e.id,t)];r;r=r.M){var i=r.name;if(r.parent.id===e.id&&i===t)return r}return e.k.lookup(e,t)}function Lb(e,t,r,i){return Zb||((Zb=function(e,t,r,i){e||(e=this),this.parent=e,this.A=e.A,this.U=null,this.id=Sb++,this.name=t,this.mode=r,this.k={},this.n={},this.rdev=i}).prototype={},Object.defineProperties(Zb.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},kb:{get:function(){return N(this.mode)}},jb:{get:function(){return 8192==(61440&this.mode)}}})),Xb(e=new Zb(e,t,r,i)),e}function N(e){return 16384==(61440&e)}var $b={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Yb(e,t){return Tb?0:(-1===t.indexOf("r")||292&e.mode)&&(-1===t.indexOf("w")||146&e.mode)&&(-1===t.indexOf("x")||73&e.mode)?0:J.da}function ac(e,t){try{return Nb(e,t),J.wa}catch(e){}return Yb(e,"wx")}function bc(){for(var e=0;e<=4096;e++)if(!Rb[e])return e;throw new L(J.Sa)}function cc(e){dc||((dc=function(){}).prototype={},Object.defineProperties(dc.prototype,{object:{get:function(){return this.g},set:function(e){this.g=e}},Ld:{get:function(){return 1!=(2097155&this.flags)}},Md:{get:function(){return 0!=(2097155&this.flags)}},Kd:{get:function(){return 1024&this.flags}}}));var t,r=new dc;for(t in e)r[t]=e[t];return e=r,r=bc(),e.fd=r,Rb[r]=e}var Kb={open:function(e){e.n=Qb[e.g.rdev].n,e.n.open&&e.n.open(e)},G:function(){throw new L(J.ia)}},qc;function Gb(e,t){Qb[e]={n:t}}function ec(e,t){var r,i="/"===t,n=!t;if(i&&Pb)throw new L(J.fa);if(!i&&!n){if(t=(r=S(t,{Ia:!1})).path,(r=r.g).U)throw new L(J.fa);if(!N(r.mode))throw new L(J.ya)}n={type:e,pa:{},Oa:t,lb:[]};var o=e.A(n);(o.A=n).root=o,i?Pb=o:r&&(r.U=n,r.A&&r.A.lb.push(n))}function fc(e,t,r){var i=S(e,{parent:!0}).g;if(!(e=Bb(e))||"."===e||".."===e)throw new L(J.q);var n=ac(i,e);if(n)throw new L(n);if(!i.k.T)throw new L(J.I);return i.k.T(i,e,t,r)}function gc(e,t){return t=4095&(void 0!==t?t:438),fc(e,t|=32768,0)}function V(e,t){return t=1023&(void 0!==t?t:511),fc(e,t|=16384,0)}function hc(e,t,r){return void 0===r&&(r=t,t=438),fc(e,8192|t,r)}function ic(e,t){if(!Db(e))throw new L(J.F);var r=S(t,{parent:!0}).g;if(!r)throw new L(J.F);var i=Bb(t),n=ac(r,i);if(n)throw new L(n);if(!r.k.symlink)throw new L(J.I);return r.k.symlink(r,i,e)}function Vb(e){if(!(e=S(e).g))throw new L(J.F);if(!e.k.readlink)throw new L(J.q);return Db(T(e.parent),e.k.readlink(e))}function jc(e,t){var r;if(!(r="string"==typeof e?S(e,{la:!0}).g:e).k.u)throw new L(J.I);r.k.u(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})}function kc(t,r){var i,n,o;if(""===t)throw new L(J.F);if("string"==typeof r){if(void 0===(n=$b[r]))throw Error("Unknown file open mode: "+r)}else n=r;if(i=64&(r=n)?4095&(void 0===i?438:i)|32768:0,"object"==typeof t)o=t;else{t=zb(t);try{o=S(t,{la:!(131072&r)}).g}catch(e){}}if(n=!1,64&r)if(o){if(128&r)throw new L(J.wa)}else o=fc(t,i,0),n=!0;if(!o)throw new L(J.F);if(8192==(61440&o.mode)&&(r&=-513),65536&r&&!N(o.mode))throw new L(J.ya);if(!n&&(i=o?40960==(61440&o.mode)?J.ga:N(o.mode)&&(0!=(2097155&r)||512&r)?J.P:(i=["r","w","rw"][3&r],512&r&&(i+="w"),Yb(o,i)):J.F))throw new L(i);if(512&r){var a;if(!(a="string"==typeof(i=o)?S(i,{la:!0}).g:i).k.u)throw new L(J.I);if(N(a.mode))throw new L(J.P);if(32768!=(61440&a.mode))throw new L(J.q);if(i=Yb(a,"w"))throw new L(i);a.k.u(a,{size:0,timestamp:Date.now()})}r&=-641,(o=cc({g:o,path:T(o),flags:r,seekable:!0,position:0,n:o.n,tb:[],error:!1})).n.open&&o.n.open(o),!e.logReadFiles||1&r||(lc||(lc={}),t in lc||(lc[t]=1,e.printErr("read file: "+t)));try{R.onOpenFile&&(a=0,1!=(2097155&r)&&(a|=1),0!=(2097155&r)&&(a|=2),R.onOpenFile(t,a))}catch(e){console.log("FS.trackingDelegate['onOpenFile']('"+t+"', flags) threw an exception: "+e.message)}return o}function mc(e){e.na&&(e.na=null);try{e.n.close&&e.n.close(e)}catch(e){throw e}finally{Rb[e.fd]=null}}function nc(e,t,r){if(!e.seekable||!e.n.G)throw new L(J.ia);e.position=e.n.G(e,t,r),e.tb=[]}function oc(e,t,r,i,n,o){if(i<0||n<0)throw new L(J.q);if(0==(2097155&e.flags))throw new L(J.ea);if(N(e.g.mode))throw new L(J.P);if(!e.n.write)throw new L(J.q);1024&e.flags&&nc(e,0,2);var a=!0;if(void 0===n)n=e.position,a=!1;else if(!e.seekable)throw new L(J.ia);t=e.n.write(e,t,r,i,n,o),a||(e.position+=t);try{e.path&&R.onWriteToFile&&R.onWriteToFile(e.path)}catch(e){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+e.message)}return t}function pc(){L||((L=function(e,t){this.g=t,this.qb=function(e){for(var t in this.S=e,J)if(J[t]===e){this.code=t;break}},this.qb(e),this.message=xb[e]}).prototype=Error(),L.prototype.constructor=L,[J.F].forEach(function(e){Mb[e]=new L(e),Mb[e].stack=""}))}function rc(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}function sc(e,t,r,i){return gc(e=K("string"==typeof e?e:T(e),t),rc(r,i))}function tc(e,t,r,i,n,o){if(n=gc(e=t?K("string"==typeof e?e:T(e),t):e,i=rc(i,n)),r){if("string"==typeof r){e=Array(r.length),t=0;for(var a=r.length;t>2]}function xc(){var e;if(e=X(),!(e=Rb[e]))throw new L(J.ea);return e}var yc={};function Ga(e){Ga.p||(r=Qa(r),Ga.p=!0,assert(n.R),Ga.bb=n.R,n.R=function(){x("cannot dynamically allocate, sbrk now has control")});var t=r;return 0==e||Ga.bb(e)?t:4294967295}e._i64Add=zc;var Ac=1;function Cc(e,t){if(Dc=e,Ec=t,!Fc)return 1;if(0==e)Y=function(){setTimeout(Gc,t)},Hc="timeout";else if(1==e)Y=function(){Ic(Gc)},Hc="rAF";else if(2==e){if(!window.setImmediate){var r=[];window.addEventListener("message",function(e){e.source===window&&"__emcc"===e.data&&(e.stopPropagation(),r.shift()())},!0),window.setImmediate=function(e){r.push(e),window.postMessage("__emcc","*")}}Y=function(){window.setImmediate(Gc)},Hc="immediate"}return 0}function Jc(a,t,r,s,i){e.noExitRuntime=!0,assert(!Fc,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),Fc=a,Kc=s;var u=Lc;if(Gc=function(){if(!na)if(0>r-6&63;r=r-6,e=e+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[n]}2==r?(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&t)<<4],e+="=="):4==r&&(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&t)<<2],e+="="),c.src="data:audio/x-"+a.substr(-3)+";base64,"+e,s(c)}},c.src=n,ad(function(){s(c)})}});var r=e.canvas;r&&(r.sa=r.requestPointerLock||r.mozRequestPointerLock||r.webkitRequestPointerLock||r.msRequestPointerLock||function(){},r.Fa=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},r.Fa=r.Fa.bind(document),document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1),document.addEventListener("mspointerlockchange",t,!1),e.elementPointerLock&&r.addEventListener("click",function(e){!Tc&&r.sa&&(r.sa(),e.preventDefault())},!1))}}function bd(t,r,i,n){if(r&&e.ka&&t==e.canvas)return e.ka;var o,a;if(r){if(a={antialias:!1,alpha:!1},n)for(var s in n)a[s]=n[s];(a=GL.createContext(t,a))&&(o=GL.getContext(a).td),t.style.backgroundColor="black"}else o=t.getContext("2d");return o?(i&&(r||assert("undefined"==typeof GLctx,"cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),e.ka=o,r&&GL.Od(a),e.Td=r,Uc.forEach(function(e){e()}),Vc()),o):null}var cd=!1,dd=void 0,ed=void 0;function fd(t,r,i){function n(){Sc=!1;var t=o.parentNode;(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===t?(o.Da=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msExitFullscreen||document.exitFullscreen||function(){},o.Da=o.Da.bind(document),dd&&o.sa(),Sc=!0,ed&&gd()):(t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),ed&&hd()),e.onFullScreen&&e.onFullScreen(Sc),id(o)}void 0===(dd=t)&&(dd=!0),void 0===(ed=r)&&(ed=!1),void 0===(jd=i)&&(jd=null);var o=e.canvas;cd||(cd=!0,document.addEventListener("fullscreenchange",n,!1),document.addEventListener("mozfullscreenchange",n,!1),document.addEventListener("webkitfullscreenchange",n,!1),document.addEventListener("MSFullscreenChange",n,!1));var a=document.createElement("div");o.parentNode.insertBefore(a,o),a.appendChild(o),a.p=a.requestFullScreen||a.mozRequestFullScreen||a.msRequestFullscreen||(a.webkitRequestFullScreen?function(){a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),i?a.p({Ud:i}):a.p()}var kd=0;function ld(e){var t=Date.now();if(0===kd)kd=t+1e3/60;else for(;kd<=t+2;)kd+=1e3/60;t=Math.max(kd-t,0),setTimeout(e,t)}function Ic(e){"undefined"==typeof window?ld(e):(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||ld),window.requestAnimationFrame(e))}function ad(t){e.noExitRuntime=!0,setTimeout(function(){na||t()},1e4)}function $c(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]}function md(e,t,r){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)}function nd(t,r,e){md(t,function(e){assert(e,'Loading data file "'+t+'" failed (no arrayBuffer).'),r(new Uint8Array(e)),lb()},function(){if(!e)throw'Loading data file "'+t+'" failed.';e()}),kb()}var od=[],Wc,Xc,Yc,Zc,jd;function pd(){var t=e.canvas;od.forEach(function(e){e(t.width,t.height)})}function gd(){if("undefined"!=typeof SDL){var e=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=8388608|e}pd()}function hd(){if("undefined"!=typeof SDL){var e=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=-8388609&e}pd()}function id(t,r,i){r&&i?(t.ub=r,t.hb=i):(r=t.ub,i=t.hb);var n=r,o=i;if(e.forcedAspectRatio&&0this.length-1||e<0)){var t=e%this.chunkSize;return this.gb(e/this.chunkSize|0)[t]}},a.prototype.pb=function(e){this.gb=e},a.prototype.Ca=function(){var e=new XMLHttpRequest;if(e.open("HEAD",u,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw Error("Couldn't load "+u+". Status: "+e.status);var t,o=Number(e.getResponseHeader("Content-length")),a=1048576;(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t||(a=o);var s=this;s.pb(function(e){var t=e*a,r=(e+1)*a-1;r=Math.min(r,o-1);if(void 0===s.Y[e]){var i=s.Y;if(r=(e=e.g.e).length)return 0;if(assert(0<=(i=Math.min(e.length-n,i))),e.slice)for(var o=0;o>2]=0;case 21520:return r.tty?-J.q:-J.Q;case 21531:if(n=X(),!r.n.ib)throw new L(J.Q);return r.n.ib(r,i,n);default:x("bad ioctl syscall "+i)}}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},___syscall6:function(e,t){wc=t;try{return mc(xc()),0}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},_emscripten_set_main_loop_timing:Cc,__ZSt18uncaught_exceptionv:tb,___setErrNo:ob,_sbrk:Ga,___cxa_begin_catch:function(e){var t;tb.p--,ub.push(e);e:{if(e&&!vb[e])for(t in vb)if(vb[t].wd===e)break e;t=e}return t&&vb[t].Sd++,e},_emscripten_memcpy_big:function(e,t,r){return E.set(E.subarray(t,t+r),e),e},_sysconf:function(e){switch(e){case 30:return 4096;case 85:return F/4096;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return"object"==typeof navigator&&navigator.hardwareConcurrency||1}return ob(J.q),-1},_pthread_getspecific:function(e){return yc[e]||0},_pthread_self:function(){return 0},_pthread_once:wb,_pthread_key_create:function(e){return 0==e?J.q:(C[e>>2]=Ac,yc[Ac]=0,Ac++,0)},___unlock:function(){},_emscripten_set_main_loop:Jc,_pthread_setspecific:function(e,t){return e in yc?(yc[e]=t,0):J.q},___lock:function(){},_abort:function(){e.abort()},_pthread_cleanup_push:pb,_time:function(e){var t=Date.now()/1e3|0;return e&&(C[e>>2]=t),t},___syscall140:function(e,t){wc=t;try{var r=xc(),i=X(),n=X(),o=X(),a=X();return assert(0===i),nc(r,n,a),C[o>>2]=r.position,r.na&&0===n&&0===a&&(r.na=null),0}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},___syscall146:function(e,t){wc=t;try{var r,i=xc(),n=X();e:{for(var o=X(),a=0,s=0;s>2],C[n+(8*s+4)>>2],void 0);if(u<0){r=-1;break e}a+=u}r=a}return r}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},STACKTOP:m,STACK_MAX:Va,tempDoublePtr:mb,ABORT:na,cttz_i8:qd};var Z=function(e,t,r){"use asm";var i=e.Int8Array;var n=e.Int16Array;var o=e.Int32Array;var a=e.Uint8Array;var s=e.Uint16Array;var u=e.Uint32Array;var c=e.Float32Array;var f=e.Float64Array;var de=new i(r);var $=new n(r);var pe=new o(r);var ve=new a(r);var me=new s(r);var l=new u(r);var h=new c(r);var ee=new f(r);var d=e.byteLength;var be=t.STACKTOP|0;var p=t.STACK_MAX|0;var te=t.tempDoublePtr|0;var v=t.ABORT|0;var m=t.cttz_i8|0;var b=0;var g=0;var y=0;var _=0;var w=e.NaN,x=e.Infinity;var T=0,S=0,E=0,M=0,C=0.0,P=0,A=0,k=0,I=0.0;var re=0;var R=0;var O=0;var D=0;var L=0;var j=0;var F=0;var B=0;var N=0;var U=0;var z=e.Math.floor;var X=e.Math.abs;var q=e.Math.sqrt;var G=e.Math.pow;var H=e.Math.cos;var V=e.Math.sin;var W=e.Math.tan;var Y=e.Math.acos;var K=e.Math.asin;var J=e.Math.atan;var Z=e.Math.atan2;var Q=e.Math.exp;var ie=e.Math.log;var ne=e.Math.ceil;var ge=e.Math.imul;var oe=e.Math.min;var ae=e.Math.clz32;var se=t.abort;var ue=t.assert;var ce=t.invoke_iiii;var fe=t.invoke_viiiii;var le=t.invoke_vi;var he=t.invoke_ii;var ye=t.invoke_viii;var _e=t.invoke_v;var we=t.invoke_viiiiii;var xe=t.invoke_iiiiii;var Te=t.invoke_viiii;var Se=t._pthread_cleanup_pop;var Ee=t.___syscall54;var Me=t.___syscall6;var Ce=t._emscripten_set_main_loop_timing;var Pe=t.__ZSt18uncaught_exceptionv;var Ae=t.___setErrNo;var ke=t._sbrk;var Ie=t.___cxa_begin_catch;var Re=t._emscripten_memcpy_big;var Oe=t._sysconf;var De=t._pthread_getspecific;var Le=t._pthread_self;var je=t._pthread_once;var Fe=t._pthread_key_create;var Be=t.___unlock;var Ne=t._emscripten_set_main_loop;var Ue=t._pthread_setspecific;var ze=t.___lock;var Xe=t._abort;var qe=t._pthread_cleanup_push;var Ge=t._time;var He=t.___syscall140;var Ve=t.___syscall146;var We=0.0;function Ye(e){if(d(e)&16777215||d(e)<=16777215||d(e)>2147483648)return false;de=new i(e);$=new n(e);pe=new o(e);ve=new a(e);me=new s(e);l=new u(e);h=new c(e);ee=new f(e);r=e;return true}function Ke(e){e=e|0;var t=0;t=be;be=be+e|0;be=be+15&-16;return t|0}function Je(){return be|0}function Ze(e){e=e|0;be=e}function Qe(e,t){e=e|0;t=t|0;be=e;p=t}function $e(e,t){e=e|0;t=t|0;if(!b){b=e;g=t}}function et(e){e=e|0;de[te>>0]=de[e>>0];de[te+1>>0]=de[e+1>>0];de[te+2>>0]=de[e+2>>0];de[te+3>>0]=de[e+3>>0]}function tt(e){e=e|0;de[te>>0]=de[e>>0];de[te+1>>0]=de[e+1>>0];de[te+2>>0]=de[e+2>>0];de[te+3>>0]=de[e+3>>0];de[te+4>>0]=de[e+4>>0];de[te+5>>0]=de[e+5>>0];de[te+6>>0]=de[e+6>>0];de[te+7>>0]=de[e+7>>0]}function rt(e){e=e|0;re=e}function it(){return re|0}function nt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0;v=be;be=be+608|0;h=v+88|0;l=v+72|0;u=v+64|0;s=v+48|0;a=v+24|0;o=v;f=v+96|0;d=v+92|0;c=e+4|0;p=e+8|0;if((pe[c>>2]|0)>>>0>(pe[p>>2]|0)>>>0){pe[o>>2]=1154;pe[o+4>>2]=2120;pe[o+8>>2]=1133;_r(f,1100,o)|0;yr(f,v+16|0)|0}if((2147418112/(i>>>0)|0)>>>0<=t>>>0){pe[a>>2]=1154;pe[a+4>>2]=2121;pe[a+8>>2]=1169;_r(f,1100,a)|0;yr(f,v+40|0)|0}a=pe[p>>2]|0;if(a>>>0>=t>>>0){p=1;be=v;return p|0}do{if(r){if(t){o=t+-1|0;if(!(o&t)){o=11;break}else t=o}else t=-1;t=t>>>16|t;t=t>>>8|t;t=t>>>4|t;t=t>>>2|t;t=(t>>>1|t)+1|0;o=10}else o=10}while(0);if((o|0)==10)if(!t){t=0;o=12}else o=11;if((o|0)==11)if(t>>>0<=a>>>0)o=12;if((o|0)==12){pe[s>>2]=1154;pe[s+4>>2]=2130;pe[s+8>>2]=1217;_r(f,1100,s)|0;yr(f,u)|0}r=ge(t,i)|0;do{if(!n){o=ot(pe[e>>2]|0,r,d,1)|0;if(!o){p=0;be=v;return p|0}else{pe[e>>2]=o;break}}else{a=at(r,d)|0;if(!a){p=0;be=v;return p|0}ki[n&0](a,pe[e>>2]|0,pe[c>>2]|0);o=pe[e>>2]|0;do{if(o)if(!(o&7)){Oi[pe[104>>2]&1](o,0,0,1,pe[27]|0)|0;break}else{pe[l>>2]=1154;pe[l+4>>2]=2499;pe[l+8>>2]=1516;_r(f,1100,l)|0;yr(f,h)|0;break}}while(0);pe[e>>2]=a}}while(0);o=pe[d>>2]|0;if(o>>>0>r>>>0)t=(o>>>0)/(i>>>0)|0;pe[p>>2]=t;p=1;be=v;return p|0}function ot(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0;c=be;be=be+592|0;u=c+48|0;o=c+24|0;n=c;s=c+72|0;a=c+68|0;if(e&7){pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1494;_r(s,1100,n)|0;yr(s,c+16|0)|0;u=0;be=c;return u|0}if(t>>>0>2147418112){pe[o>>2]=1154;pe[o+4>>2]=2499;pe[o+8>>2]=1387;_r(s,1100,o)|0;yr(s,c+40|0)|0;u=0;be=c;return u|0}pe[a>>2]=t;i=Oi[pe[104>>2]&1](e,t,a,i,pe[27]|0)|0;if(r)pe[r>>2]=pe[a>>2];if(!(i&7)){u=i;be=c;return u|0}pe[u>>2]=1154;pe[u+4>>2]=2551;pe[u+8>>2]=1440;_r(s,1100,u)|0;yr(s,c+64|0)|0;u=i;be=c;return u|0}function at(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0;u=be;be=be+592|0;a=u+48|0;s=u+24|0;r=u;o=u+72|0;n=u+68|0;i=e+3&-4;i=(i|0)!=0?i:4;if(i>>>0>2147418112){pe[r>>2]=1154;pe[r+4>>2]=2499;pe[r+8>>2]=1387;_r(o,1100,r)|0;yr(o,u+16|0)|0;s=0;be=u;return s|0}pe[n>>2]=i;r=Oi[pe[104>>2]&1](0,i,n,1,pe[27]|0)|0;e=pe[n>>2]|0;if(t)pe[t>>2]=e;if((r|0)==0|e>>>0>>0){pe[s>>2]=1154;pe[s+4>>2]=2499;pe[s+8>>2]=1413;_r(o,1100,s)|0;yr(o,u+40|0)|0;s=0;be=u;return s|0}if(!(r&7)){s=r;be=u;return s|0}pe[a>>2]=1154;pe[a+4>>2]=2526;pe[a+8>>2]=1440;_r(o,1100,a)|0;yr(o,u+64|0)|0;s=r;be=u;return s|0}function st(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0;B=be;be=be+960|0;L=B+232|0;D=B+216|0;O=B+208|0;R=B+192|0;I=B+184|0;k=B+168|0;A=B+160|0;P=B+144|0;E=B+136|0;S=B+120|0;T=B+112|0;x=B+96|0;y=B+88|0;g=B+72|0;b=B+64|0;m=B+48|0;l=B+40|0;d=B+24|0;h=B+16|0;f=B;C=B+440|0;j=B+376|0;F=B+304|0;v=B+236|0;if((t|0)==0|i>>>0>11){e=0;be=B;return e|0}pe[e>>2]=t;n=F;o=n+68|0;do{pe[n>>2]=0;n=n+4|0}while((n|0)<(o|0));o=0;do{n=de[r+o>>0]|0;if(n<<24>>24){M=F+((n&255)<<2)|0;pe[M>>2]=(pe[M>>2]|0)+1}o=o+1|0}while((o|0)!=(t|0));o=0;c=1;a=0;s=-1;u=0;while(1){n=pe[F+(c<<2)>>2]|0;if(!n)pe[e+28+(c+-1<<2)>>2]=0;else{M=c+-1|0;pe[j+(M<<2)>>2]=o;o=n+o|0;w=16-c|0;pe[e+28+(M<<2)>>2]=(o+-1<>2]=u;pe[v+(c<<2)>>2]=u;a=a>>>0>c>>>0?a:c;s=s>>>0>>0?s:c;u=n+u|0}c=c+1|0;if((c|0)==17){M=a;break}else o=o<<1}pe[e+4>>2]=u;o=e+172|0;do{if(u>>>0>(pe[o>>2]|0)>>>0){pe[o>>2]=u;if(u){n=u+-1|0;if(n&u)p=14}else{n=-1;p=14}if((p|0)==14){w=n>>>16|n;w=w>>>8|w;w=w>>>4|w;w=w>>>2|w;w=(w>>>1|w)+1|0;pe[o>>2]=w>>>0>t>>>0?t:w}a=e+176|0;n=pe[a>>2]|0;do{if(n){w=pe[n+-4>>2]|0;n=n+-8|0;if(!((w|0)!=0?(w|0)==(~pe[n>>2]|0):0)){pe[f>>2]=1154;pe[f+4>>2]=644;pe[f+8>>2]=1863;_r(C,1100,f)|0;yr(C,h)|0}if(!(n&7)){Oi[pe[104>>2]&1](n,0,0,1,pe[27]|0)|0;break}else{pe[d>>2]=1154;pe[d+4>>2]=2499;pe[d+8>>2]=1516;_r(C,1100,d)|0;yr(C,l)|0;break}}}while(0);o=pe[o>>2]|0;o=(o|0)!=0?o:1;n=at((o<<1)+8|0,0)|0;if(!n){pe[a>>2]=0;n=0;break}else{pe[n+4>>2]=o;pe[n>>2]=~o;pe[a>>2]=n+8;p=25;break}}else p=25}while(0);e:do{if((p|0)==25){w=e+24|0;de[w>>0]=s;de[e+25>>0]=M;o=e+176|0;a=0;do{_=de[r+a>>0]|0;n=_&255;if(_<<24>>24){if(!(pe[F+(n<<2)>>2]|0)){pe[m>>2]=1154;pe[m+4>>2]=2273;pe[m+8>>2]=1261;_r(C,1100,m)|0;yr(C,b)|0}_=v+(n<<2)|0;n=pe[_>>2]|0;pe[_>>2]=n+1;if(n>>>0>=u>>>0){pe[g>>2]=1154;pe[g+4>>2]=2277;pe[g+8>>2]=1274;_r(C,1100,g)|0;yr(C,y)|0}$[(pe[o>>2]|0)+(n<<1)>>1]=a}a=a+1|0}while((a|0)!=(t|0));n=de[w>>0]|0;y=(n&255)>>>0>>0?i:0;_=e+8|0;pe[_>>2]=y;g=(y|0)!=0;if(g){b=1<>>0>(pe[n>>2]|0)>>>0){pe[n>>2]=b;a=e+168|0;n=pe[a>>2]|0;do{if(n){m=pe[n+-4>>2]|0;n=n+-8|0;if(!((m|0)!=0?(m|0)==(~pe[n>>2]|0):0)){pe[x>>2]=1154;pe[x+4>>2]=644;pe[x+8>>2]=1863;_r(C,1100,x)|0;yr(C,T)|0}if(!(n&7)){Oi[pe[104>>2]&1](n,0,0,1,pe[27]|0)|0;break}else{pe[S>>2]=1154;pe[S+4>>2]=2499;pe[S+8>>2]=1516;_r(C,1100,S)|0;yr(C,E)|0;break}}}while(0);n=b<<2;o=at(n+8|0,0)|0;if(!o){pe[a>>2]=0;n=0;break e}else{E=o+8|0;pe[o+4>>2]=b;pe[o>>2]=~b;pe[a>>2]=E;o=E;break}}else{o=e+168|0;n=b<<2;a=o;o=pe[o>>2]|0}}while(0);Yr(o|0,-1,n|0)|0;p=e+176|0;m=1;do{if(pe[F+(m<<2)>>2]|0){t=y-m|0;v=1<>2]|0;if(o>>>0>=16){pe[P>>2]=1154;pe[P+4>>2]=1953;pe[P+8>>2]=1737;_r(C,1100,P)|0;yr(C,A)|0}n=pe[e+28+(o<<2)>>2]|0;if(!n)d=-1;else d=(n+-1|0)>>>(16-m|0);if(s>>>0<=d>>>0){l=(pe[e+96+(o<<2)>>2]|0)-s|0;h=m<<16;do{n=me[(pe[p>>2]|0)+(l+s<<1)>>1]|0;if((ve[r+n>>0]|0|0)!=(m|0)){pe[k>>2]=1154;pe[k+4>>2]=2319;pe[k+8>>2]=1303;_r(C,1100,k)|0;yr(C,I)|0}f=s<>>0>=b>>>0){pe[R>>2]=1154;pe[R+4>>2]=2325;pe[R+8>>2]=1337;_r(C,1100,R)|0;yr(C,O)|0}n=pe[a>>2]|0;if((pe[n+(u<<2)>>2]|0)!=-1){pe[D>>2]=1154;pe[D+4>>2]=2327;pe[D+8>>2]=1360;_r(C,1100,D)|0;yr(C,L)|0;n=pe[a>>2]|0}pe[n+(u<<2)>>2]=o;c=c+1|0}while(c>>>0>>0);s=s+1|0}while(s>>>0<=d>>>0)}}m=m+1|0}while(y>>>0>=m>>>0);n=de[w>>0]|0}o=e+96|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j>>2]|0);o=e+100|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+4>>2]|0);o=e+104|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+8>>2]|0);o=e+108|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+12>>2]|0);o=e+112|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+16>>2]|0);o=e+116|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+20>>2]|0);o=e+120|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+24>>2]|0);o=e+124|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+28>>2]|0);o=e+128|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+32>>2]|0);o=e+132|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+36>>2]|0);o=e+136|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+40>>2]|0);o=e+140|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+44>>2]|0);o=e+144|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+48>>2]|0);o=e+148|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+52>>2]|0);o=e+152|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+56>>2]|0);o=e+156|0;pe[o>>2]=(pe[o>>2]|0)-(pe[j+60>>2]|0);o=e+16|0;pe[o>>2]=0;a=e+20|0;pe[a>>2]=n&255;t:do{if(g){while(1){if(!i)break t;n=i+-1|0;if(!(pe[F+(i<<2)>>2]|0))i=n;else break}pe[o>>2]=pe[e+28+(n<<2)>>2];n=y+1|0;pe[a>>2]=n;if(n>>>0<=M>>>0){while(1){if(pe[F+(n<<2)>>2]|0)break;n=n+1|0;if(n>>>0>M>>>0)break t}pe[a>>2]=n}}}while(0);pe[e+92>>2]=-1;pe[e+160>>2]=1048575;pe[e+12>>2]=32-(pe[_>>2]|0);n=1}}while(0);e=n;be=B;return e|0}function ut(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0;if(!e){n=Ur(t)|0;if(!r){r=n;return r|0}if(!n)o=0;else o=qr(n)|0;pe[r>>2]=o;r=n;return r|0}if(!t){zr(e);if(!r){r=0;return r|0}pe[r>>2]=0;r=0;return r|0}n=Xr(e,t)|0;o=(n|0)!=0;if(o|i^1)o=o?n:e;else{n=Xr(e,t)|0;o=(n|0)==0?e:n}if(!r){r=n;return r|0}t=qr(o)|0;pe[r>>2]=t;r=n;return r|0}function ct(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(!((e|0)!=0&t>>>0>73&(r|0)!=0)){r=0;return r|0}if((pe[r>>2]|0)!=40|t>>>0<74){r=0;return r|0}if(((ve[e>>0]|0)<<8|(ve[e+1>>0]|0)|0)!=18552){r=0;return r|0}if(((ve[e+2>>0]|0)<<8|(ve[e+3>>0]|0))>>>0<74){r=0;return r|0}if(((ve[e+7>>0]|0)<<16|(ve[e+6>>0]|0)<<24|(ve[e+8>>0]|0)<<8|(ve[e+9>>0]|0))>>>0>t>>>0){r=0;return r|0}pe[r+4>>2]=(ve[e+12>>0]|0)<<8|(ve[e+13>>0]|0);pe[r+8>>2]=(ve[e+14>>0]|0)<<8|(ve[e+15>>0]|0);pe[r+12>>2]=ve[e+16>>0];pe[r+16>>2]=ve[e+17>>0];t=e+18|0;i=r+32|0;pe[i>>2]=ve[t>>0];pe[i+4>>2]=0;t=de[t>>0]|0;pe[r+20>>2]=t<<24>>24==0|t<<24>>24==9?8:16;pe[r+24>>2]=(ve[e+26>>0]|0)<<16|(ve[e+25>>0]|0)<<24|(ve[e+27>>0]|0)<<8|(ve[e+28>>0]|0);pe[r+28>>2]=(ve[e+30>>0]|0)<<16|(ve[e+29>>0]|0)<<24|(ve[e+31>>0]|0)<<8|(ve[e+32>>0]|0);r=1;return r|0}function ft(e){e=e|0;Ie(e|0)|0;zt()}function lt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0;o=be;be=be+544|0;n=o;i=o+24|0;t=pe[e+20>>2]|0;if(t)ht(t);t=e+4|0;r=pe[t>>2]|0;if(!r){n=e+16|0;de[n>>0]=0;be=o;return}if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1516;_r(i,1100,n)|0;yr(i,o+16|0)|0}pe[t>>2]=0;pe[e+8>>2]=0;pe[e+12>>2]=0;n=e+16|0;de[n>>0]=0;be=o;return}function ht(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;d=be;be=be+640|0;h=d+112|0;l=d+96|0;f=d+88|0;c=d+72|0;u=d+64|0;s=d+48|0;i=d+40|0;o=d+24|0;n=d+16|0;r=d;a=d+120|0;if(!e){be=d;return}t=pe[e+168>>2]|0;do{if(t){p=pe[t+-4>>2]|0;t=t+-8|0;if(!((p|0)!=0?(p|0)==(~pe[t>>2]|0):0)){pe[r>>2]=1154;pe[r+4>>2]=644;pe[r+8>>2]=1863;_r(a,1100,r)|0;yr(a,n)|0}if(!(t&7)){Oi[pe[104>>2]&1](t,0,0,1,pe[27]|0)|0;break}else{pe[o>>2]=1154;pe[o+4>>2]=2499;pe[o+8>>2]=1516;_r(a,1100,o)|0;yr(a,i)|0;break}}}while(0);t=pe[e+176>>2]|0;do{if(t){p=pe[t+-4>>2]|0;t=t+-8|0;if(!((p|0)!=0?(p|0)==(~pe[t>>2]|0):0)){pe[s>>2]=1154;pe[s+4>>2]=644;pe[s+8>>2]=1863;_r(a,1100,s)|0;yr(a,u)|0}if(!(t&7)){Oi[pe[104>>2]&1](t,0,0,1,pe[27]|0)|0;break}else{pe[c>>2]=1154;pe[c+4>>2]=2499;pe[c+8>>2]=1516;_r(a,1100,c)|0;yr(a,f)|0;break}}}while(0);if(!(e&7)){Oi[pe[104>>2]&1](e,0,0,1,pe[27]|0)|0;be=d;return}else{pe[l>>2]=1154;pe[l+4>>2]=2499;pe[l+8>>2]=1516;_r(a,1100,l)|0;yr(a,h)|0;be=d;return}}function dt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+560|0;a=f+40|0;s=f+24|0;t=f;o=f+48|0;n=e+8|0;r=pe[n>>2]|0;if((r+-1|0)>>>0>=8192){pe[t>>2]=1154;pe[t+4>>2]=2997;pe[t+8>>2]=1541;_r(o,1100,t)|0;yr(o,f+16|0)|0}pe[e>>2]=r;i=e+20|0;t=pe[i>>2]|0;if(!t){t=at(180,0)|0;if(!t)t=0;else{c=t+164|0;pe[c>>2]=0;pe[c+4>>2]=0;pe[c+8>>2]=0;pe[c+12>>2]=0}pe[i>>2]=t;c=t;u=pe[e>>2]|0}else{c=t;u=r}if(!(pe[n>>2]|0)){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(o,1100,s)|0;yr(o,a)|0;o=pe[e>>2]|0}else o=u;n=pe[e+4>>2]|0;if(o>>>0>16){r=o;t=0}else{e=0;c=st(c,u,n,e)|0;be=f;return c|0}while(1){i=t+1|0;if(r>>>0>3){r=r>>>1;t=i}else{r=i;break}}e=t+2+((r|0)!=32&1<>>0>>0&1)|0;e=e>>>0<11?e&255:11;c=st(c,u,n,e)|0;be=f;return c|0}function pt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0;L=be;be=be+800|0;k=L+256|0;A=L+240|0;P=L+232|0;C=L+216|0;M=L+208|0;E=L+192|0;S=L+184|0;T=L+168|0;x=L+160|0;w=L+144|0;_=L+136|0;y=L+120|0;g=L+112|0;b=L+96|0;m=L+88|0;v=L+72|0;l=L+64|0;f=L+48|0;s=L+40|0;u=L+24|0;o=L+16|0;n=L;O=L+288|0;D=L+264|0;I=vt(e,14)|0;if(!I){pe[t>>2]=0;r=t+4|0;i=pe[r>>2]|0;if(i){if(!(i&7))Oi[pe[104>>2]&1](i,0,0,1,pe[27]|0)|0;else{pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1516;_r(O,1100,n)|0;yr(O,o)|0}pe[r>>2]=0;pe[t+8>>2]=0;pe[t+12>>2]=0}de[t+16>>0]=0;r=t+20|0;i=pe[r>>2]|0;if(!i){t=1;be=L;return t|0}ht(i);pe[r>>2]=0;t=1;be=L;return t|0}d=t+4|0;p=t+8|0;r=pe[p>>2]|0;if((r|0)!=(I|0)){if(r>>>0<=I>>>0){do{if((pe[t+12>>2]|0)>>>0>>0){if(nt(d,I,(r+1|0)==(I|0),1,0)|0){r=pe[p>>2]|0;break}de[t+16>>0]=1;t=0;be=L;return t|0}}while(0);Yr((pe[d>>2]|0)+r|0,0,I-r|0)|0}pe[p>>2]=I}Yr(pe[d>>2]|0,0,I|0)|0;h=e+20|0;r=pe[h>>2]|0;if((r|0)<5){o=e+4|0;a=e+8|0;n=e+16|0;do{i=pe[o>>2]|0;if((i|0)==(pe[a>>2]|0))i=0;else{pe[o>>2]=i+1;i=ve[i>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[u>>2]=1154;pe[u+4>>2]=3199;pe[u+8>>2]=1650;_r(O,1100,u)|0;yr(O,s)|0;r=pe[h>>2]|0}i=i<<32-r|pe[n>>2];pe[n>>2]=i}while((r|0)<5)}else{i=e+16|0;n=i;i=pe[i>>2]|0}c=i>>>27;pe[n>>2]=i<<5;pe[h>>2]=r+-5;if((c+-1|0)>>>0>20){t=0;be=L;return t|0}pe[D+20>>2]=0;pe[D>>2]=0;pe[D+4>>2]=0;pe[D+8>>2]=0;pe[D+12>>2]=0;de[D+16>>0]=0;r=D+4|0;i=D+8|0;e:do{if(nt(r,21,0,1,0)|0){s=pe[i>>2]|0;u=pe[r>>2]|0;Yr(u+s|0,0,21-s|0)|0;pe[i>>2]=21;if(c){n=e+4|0;o=e+8|0;a=e+16|0;s=0;do{r=pe[h>>2]|0;if((r|0)<3)do{i=pe[n>>2]|0;if((i|0)==(pe[o>>2]|0))i=0;else{pe[n>>2]=i+1;i=ve[i>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[f>>2]=1154;pe[f+4>>2]=3199;pe[f+8>>2]=1650;_r(O,1100,f)|0;yr(O,l)|0;r=pe[h>>2]|0}i=i<<32-r|pe[a>>2];pe[a>>2]=i}while((r|0)<3);else i=pe[a>>2]|0;pe[a>>2]=i<<3;pe[h>>2]=r+-3;de[u+(ve[1611+s>>0]|0)>>0]=i>>>29;s=s+1|0}while((s|0)!=(c|0))}if(dt(D)|0){s=e+4|0;u=e+8|0;c=e+16|0;i=0;t:while(1){a=I-i|0;r=mt(e,D)|0;r:do{if(r>>>0<17){if((pe[p>>2]|0)>>>0<=i>>>0){pe[v>>2]=1154;pe[v+4>>2]=903;pe[v+8>>2]=1781;_r(O,1100,v)|0;yr(O,m)|0}de[(pe[d>>2]|0)+i>>0]=r;r=i+1|0}else switch(r|0){case 17:{r=pe[h>>2]|0;if((r|0)<3)do{n=pe[s>>2]|0;if((n|0)==(pe[u>>2]|0))n=0;else{pe[s>>2]=n+1;n=ve[n>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[b>>2]=1154;pe[b+4>>2]=3199;pe[b+8>>2]=1650;_r(O,1100,b)|0;yr(O,g)|0;r=pe[h>>2]|0}n=n<<32-r|pe[c>>2];pe[c>>2]=n}while((r|0)<3);else n=pe[c>>2]|0;pe[c>>2]=n<<3;pe[h>>2]=r+-3;r=(n>>>29)+3|0;if(r>>>0>a>>>0){r=0;break e}r=r+i|0;break r}case 18:{r=pe[h>>2]|0;if((r|0)<7)do{n=pe[s>>2]|0;if((n|0)==(pe[u>>2]|0))n=0;else{pe[s>>2]=n+1;n=ve[n>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[y>>2]=1154;pe[y+4>>2]=3199;pe[y+8>>2]=1650;_r(O,1100,y)|0;yr(O,_)|0;r=pe[h>>2]|0}n=n<<32-r|pe[c>>2];pe[c>>2]=n}while((r|0)<7);else n=pe[c>>2]|0;pe[c>>2]=n<<7;pe[h>>2]=r+-7;r=(n>>>25)+11|0;if(r>>>0>a>>>0){r=0;break e}r=r+i|0;break r}default:{if((r+-19|0)>>>0>=2){R=90;break t}o=pe[h>>2]|0;if((r|0)==19){if((o|0)<2){n=o;while(1){r=pe[s>>2]|0;if((r|0)==(pe[u>>2]|0))o=0;else{pe[s>>2]=r+1;o=ve[r>>0]|0}r=n+8|0;pe[h>>2]=r;if((r|0)>=33){pe[w>>2]=1154;pe[w+4>>2]=3199;pe[w+8>>2]=1650;_r(O,1100,w)|0;yr(O,x)|0;r=pe[h>>2]|0}n=o<<32-r|pe[c>>2];pe[c>>2]=n;if((r|0)<2)n=r;else break}}else{n=pe[c>>2]|0;r=o}pe[c>>2]=n<<2;pe[h>>2]=r+-2;o=(n>>>30)+3|0}else{if((o|0)<6){n=o;while(1){r=pe[s>>2]|0;if((r|0)==(pe[u>>2]|0))o=0;else{pe[s>>2]=r+1;o=ve[r>>0]|0}r=n+8|0;pe[h>>2]=r;if((r|0)>=33){pe[T>>2]=1154;pe[T+4>>2]=3199;pe[T+8>>2]=1650;_r(O,1100,T)|0;yr(O,S)|0;r=pe[h>>2]|0}n=o<<32-r|pe[c>>2];pe[c>>2]=n;if((r|0)<6)n=r;else break}}else{n=pe[c>>2]|0;r=o}pe[c>>2]=n<<6;pe[h>>2]=r+-6;o=(n>>>26)+7|0}if((i|0)==0|o>>>0>a>>>0){r=0;break e}r=i+-1|0;if((pe[p>>2]|0)>>>0<=r>>>0){pe[E>>2]=1154;pe[E+4>>2]=903;pe[E+8>>2]=1781;_r(O,1100,E)|0;yr(O,M)|0}n=de[(pe[d>>2]|0)+r>>0]|0;if(!(n<<24>>24)){r=0;break e}r=o+i|0;if(i>>>0>=r>>>0){r=i;break r}do{if((pe[p>>2]|0)>>>0<=i>>>0){pe[C>>2]=1154;pe[C+4>>2]=903;pe[C+8>>2]=1781;_r(O,1100,C)|0;yr(O,P)|0}de[(pe[d>>2]|0)+i>>0]=n;i=i+1|0}while((i|0)!=(r|0))}}}while(0);if(I>>>0>r>>>0)i=r;else break}if((R|0)==90){pe[A>>2]=1154;pe[A+4>>2]=3140;pe[A+8>>2]=1632;_r(O,1100,A)|0;yr(O,k)|0;r=0;break}if((I|0)==(r|0))r=dt(t)|0;else r=0}else r=0}else{de[D+16>>0]=1;r=0}}while(0);lt(D);t=r;be=L;return t|0}function vt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+544|0;s=f+16|0;a=f;o=f+24|0;if(!t){c=0;be=f;return c|0}if(t>>>0<=16){c=bt(e,t)|0;be=f;return c|0}u=bt(e,t+-16|0)|0;c=e+20|0;t=pe[c>>2]|0;if((t|0)<16){i=e+4|0;n=e+8|0;r=e+16|0;do{e=pe[i>>2]|0;if((e|0)==(pe[n>>2]|0))e=0;else{pe[i>>2]=e+1;e=ve[e>>0]|0}t=t+8|0;pe[c>>2]=t;if((t|0)>=33){pe[a>>2]=1154;pe[a+4>>2]=3199;pe[a+8>>2]=1650;_r(o,1100,a)|0;yr(o,s)|0;t=pe[c>>2]|0}e=e<<32-t|pe[r>>2];pe[r>>2]=e}while((t|0)<16)}else{e=e+16|0;r=e;e=pe[e>>2]|0}pe[r>>2]=e<<16;pe[c>>2]=t+-16;c=e>>>16|u<<16;be=f;return c|0}function mt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0;y=be;be=be+608|0;v=y+88|0;p=y+72|0;h=y+64|0;l=y+48|0;f=y+40|0;d=y+24|0;c=y+16|0;u=y;b=y+96|0;m=pe[t+20>>2]|0;g=e+20|0;s=pe[g>>2]|0;do{if((s|0)<24){a=e+4|0;i=pe[a>>2]|0;n=pe[e+8>>2]|0;r=i>>>0>>0;if((s|0)>=16){if(r){pe[a>>2]=i+1;r=ve[i>>0]|0}else r=0;pe[g>>2]=s+8;a=e+16|0;o=r<<24-s|pe[a>>2];pe[a>>2]=o;break}if(r){o=(ve[i>>0]|0)<<8;r=i+1|0}else{o=0;r=i}if(r>>>0>>0){i=ve[r>>0]|0;r=r+1|0}else i=0;pe[a>>2]=r;pe[g>>2]=s+16;a=e+16|0;o=(i|o)<<16-s|pe[a>>2];pe[a>>2]=o}else{o=e+16|0;a=o;o=pe[o>>2]|0}}while(0);n=(o>>>16)+1|0;do{if(n>>>0<=(pe[m+16>>2]|0)>>>0){i=pe[(pe[m+168>>2]|0)+(o>>>(32-(pe[m+8>>2]|0)|0)<<2)>>2]|0;if((i|0)==-1){pe[u>>2]=1154;pe[u+4>>2]=3244;pe[u+8>>2]=1677;_r(b,1100,u)|0;yr(b,c)|0}r=i&65535;i=i>>>16;if((pe[t+8>>2]|0)>>>0<=r>>>0){pe[d>>2]=1154;pe[d+4>>2]=902;pe[d+8>>2]=1781;_r(b,1100,d)|0;yr(b,f)|0}if((ve[(pe[t+4>>2]|0)+r>>0]|0|0)!=(i|0)){pe[l>>2]=1154;pe[l+4>>2]=3248;pe[l+8>>2]=1694;_r(b,1100,l)|0;yr(b,h)|0}}else{i=pe[m+20>>2]|0;while(1){r=i+-1|0;if(n>>>0>(pe[m+28+(r<<2)>>2]|0)>>>0)i=i+1|0;else break}r=(o>>>(32-i|0))+(pe[m+96+(r<<2)>>2]|0)|0;if(r>>>0<(pe[t>>2]|0)>>>0){r=me[(pe[m+176>>2]|0)+(r<<1)>>1]|0;break}pe[p>>2]=1154;pe[p+4>>2]=3266;pe[p+8>>2]=1632;_r(b,1100,p)|0;yr(b,v)|0;g=0;be=y;return g|0}}while(0);pe[a>>2]=pe[a>>2]<>2]=(pe[g>>2]|0)-i;g=r;be=y;return g|0}function bt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+560|0;s=f+40|0;u=f+24|0;r=f;a=f+48|0;if(t>>>0>=33){pe[r>>2]=1154;pe[r+4>>2]=3190;pe[r+8>>2]=1634;_r(a,1100,r)|0;yr(a,f+16|0)|0}c=e+20|0;r=pe[c>>2]|0;if((r|0)>=(t|0)){o=e+16|0;a=o;o=pe[o>>2]|0;s=r;u=32-t|0;u=o>>>u;o=o<>2]=o;t=s-t|0;pe[c>>2]=t;be=f;return u|0}n=e+4|0;o=e+8|0;i=e+16|0;do{e=pe[n>>2]|0;if((e|0)==(pe[o>>2]|0))e=0;else{pe[n>>2]=e+1;e=ve[e>>0]|0}r=r+8|0;pe[c>>2]=r;if((r|0)>=33){pe[u>>2]=1154;pe[u+4>>2]=3199;pe[u+8>>2]=1650;_r(a,1100,u)|0;yr(a,s)|0;r=pe[c>>2]|0}e=e<<32-r|pe[i>>2];pe[i>>2]=e}while((r|0)<(t|0));u=32-t|0;u=e>>>u;s=e<>2]=s;t=r-t|0;pe[c>>2]=t;be=f;return u|0}function gt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0;p=be;be=be+544|0;h=p+16|0;l=p;f=p+24|0;if((e|0)==0|t>>>0<62){d=0;be=p;return d|0}c=at(300,0)|0;if(!c){d=0;be=p;return d|0}pe[c>>2]=519686845;r=c+4|0;pe[r>>2]=0;i=c+8|0;pe[i>>2]=0;u=c+88|0;n=c+136|0;o=c+160|0;a=u;s=a+44|0;do{pe[a>>2]=0;a=a+4|0}while((a|0)<(s|0));de[u+44>>0]=0;v=c+184|0;a=c+208|0;s=c+232|0;m=c+252|0;pe[m>>2]=0;pe[m+4>>2]=0;pe[m+8>>2]=0;de[m+12>>0]=0;m=c+268|0;pe[m>>2]=0;pe[m+4>>2]=0;pe[m+8>>2]=0;de[m+12>>0]=0;m=c+284|0;pe[m>>2]=0;pe[m+4>>2]=0;pe[m+8>>2]=0;de[m+12>>0]=0;pe[n>>2]=0;pe[n+4>>2]=0;pe[n+8>>2]=0;pe[n+12>>2]=0;pe[n+16>>2]=0;de[n+20>>0]=0;pe[o>>2]=0;pe[o+4>>2]=0;pe[o+8>>2]=0;pe[o+12>>2]=0;pe[o+16>>2]=0;de[o+20>>0]=0;pe[v>>2]=0;pe[v+4>>2]=0;pe[v+8>>2]=0;pe[v+12>>2]=0;pe[v+16>>2]=0;de[v+20>>0]=0;pe[a>>2]=0;pe[a+4>>2]=0;pe[a+8>>2]=0;pe[a+12>>2]=0;pe[a+16>>2]=0;de[a+20>>0]=0;pe[s>>2]=0;pe[s+4>>2]=0;pe[s+8>>2]=0;pe[s+12>>2]=0;de[s+16>>0]=0;do{if(((t>>>0>=74?((ve[e>>0]|0)<<8|(ve[e+1>>0]|0)|0)==18552:0)?((ve[e+2>>0]|0)<<8|(ve[e+3>>0]|0))>>>0>=74:0)?((ve[e+7>>0]|0)<<16|(ve[e+6>>0]|0)<<24|(ve[e+8>>0]|0)<<8|(ve[e+9>>0]|0))>>>0<=t>>>0:0){pe[u>>2]=e;pe[r>>2]=e;pe[i>>2]=t;if(Ct(c)|0){r=pe[u>>2]|0;if((ve[r+39>>0]|0)<<8|(ve[r+40>>0]|0)){if(!(Pt(c)|0))break;if(!(At(c)|0))break;r=pe[u>>2]|0}if(!((ve[r+55>>0]|0)<<8|(ve[r+56>>0]|0))){m=c;be=p;return m|0}if(kt(c)|0?It(c)|0:0){m=c;be=p;return m|0}}}else d=7}while(0);if((d|0)==7)pe[u>>2]=0;jt(c);if(!(c&7)){Oi[pe[104>>2]&1](c,0,0,1,pe[27]|0)|0;m=0;be=p;return m|0}else{pe[l>>2]=1154;pe[l+4>>2]=2499;pe[l+8>>2]=1516;_r(f,1100,l)|0;yr(f,h)|0;m=0;be=p;return m|0}return 0}function yt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+544|0;c=f;u=f+24|0;o=pe[e+88>>2]|0;s=(ve[o+70+(n<<2)+1>>0]|0)<<16|(ve[o+70+(n<<2)>>0]|0)<<24|(ve[o+70+(n<<2)+2>>0]|0)<<8|(ve[o+70+(n<<2)+3>>0]|0);a=n+1|0;if(a>>>0<(ve[o+16>>0]|0)>>>0)o=(ve[o+70+(a<<2)+1>>0]|0)<<16|(ve[o+70+(a<<2)>>0]|0)<<24|(ve[o+70+(a<<2)+2>>0]|0)<<8|(ve[o+70+(a<<2)+3>>0]|0);else o=pe[e+8>>2]|0;if(o>>>0>s>>>0){u=e+4|0;u=pe[u>>2]|0;u=u+s|0;c=o-s|0;c=_t(e,u,c,t,r,i,n)|0;be=f;return c|0}pe[c>>2]=1154;pe[c+4>>2]=3704;pe[c+8>>2]=1792;_r(u,1100,c)|0;yr(u,f+16|0)|0;u=e+4|0;u=pe[u>>2]|0;u=u+s|0;c=o-s|0;c=_t(e,u,c,t,r,i,n)|0;be=f;return c|0}function _t(e,t,r,i,n,o,a){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;var s=0,u=0,c=0,f=0;f=pe[e+88>>2]|0;u=((ve[f+12>>0]|0)<<8|(ve[f+13>>0]|0))>>>a;c=((ve[f+14>>0]|0)<<8|(ve[f+15>>0]|0))>>>a;u=u>>>0>1?(u+3|0)>>>2:1;c=c>>>0>1?(c+3|0)>>>2:1;f=f+18|0;a=de[f>>0]|0;a=ge(a<<24>>24==0|a<<24>>24==9?8:16,u)|0;if(o)if((o&3|0)==0&a>>>0<=o>>>0)a=o;else{e=0;return e|0}if((ge(a,c)|0)>>>0>n>>>0){e=0;return e|0}o=(u+1|0)>>>1;s=(c+1|0)>>>1;if(!r){e=0;return e|0}pe[e+92>>2]=t;pe[e+96>>2]=t;pe[e+104>>2]=r;pe[e+100>>2]=t+r;pe[e+108>>2]=0;pe[e+112>>2]=0;switch(ve[f>>0]|0|0){case 0:{Rt(e,i,n,a,u,c,o,s)|0;e=1;return e|0}case 4:case 6:case 5:case 3:case 2:{Ot(e,i,n,a,u,c,o,s)|0;e=1;return e|0}case 9:{Dt(e,i,n,a,u,c,o,s)|0;e=1;return e|0}case 8:case 7:{Lt(e,i,n,a,u,c,o,s)|0;e=1;return e|0}default:{e=0;return e|0}}return 0}function wt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ct(e,t,r)|0;be=i;return pe[r+4>>2]|0}function xt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ct(e,t,r)|0;be=i;return pe[r+8>>2]|0}function Tt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ct(e,t,r)|0;be=i;return pe[r+12>>2]|0}function St(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ct(e,t,r)|0;be=i;return pe[r+32>>2]|0}function Et(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,c=0;u=be;be=be+576|0;a=u+56|0;o=u+40|0;n=u+64|0;c=u;pe[c>>2]=40;ct(e,t,c)|0;i=(((pe[c+4>>2]|0)>>>r)+3|0)>>>2;t=(((pe[c+8>>2]|0)>>>r)+3|0)>>>2;r=c+32|0;e=pe[r+4>>2]|0;do{switch(pe[r>>2]|0){case 0:{if(!e)e=8;else s=13;break}case 1:{if(!e)s=12;else s=13;break}case 2:{if(!e)s=12;else s=13;break}case 3:{if(!e)s=12;else s=13;break}case 4:{if(!e)s=12;else s=13;break}case 5:{if(!e)s=12;else s=13;break}case 6:{if(!e)s=12;else s=13;break}case 7:{if(!e)s=12;else s=13;break}case 8:{if(!e)s=12;else s=13;break}case 9:{if(!e)e=8;else s=13;break}default:s=13}}while(0);if((s|0)==12)e=16;else if((s|0)==13){pe[o>>2]=1154;pe[o+4>>2]=2663;pe[o+8>>2]=1535;_r(n,1100,o)|0;yr(n,a)|0;e=0}c=ge(ge(t,i)|0,e)|0;be=u;return c|0}function Mt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0;p=be;be=be+608|0;h=p+80|0;d=p+64|0;s=p+56|0;a=p+40|0;f=p+88|0;v=p;l=p+84|0;pe[v>>2]=40;ct(e,t,v)|0;u=(((pe[v+4>>2]|0)>>>n)+3|0)>>>2;v=v+32|0;o=pe[v+4>>2]|0;do{switch(pe[v>>2]|0){case 0:{if(!o)o=8;else c=13;break}case 1:{if(!o)c=12;else c=13;break}case 2:{if(!o)c=12;else c=13;break}case 3:{if(!o)c=12;else c=13;break}case 4:{if(!o)c=12;else c=13;break}case 5:{if(!o)c=12;else c=13;break}case 6:{if(!o)c=12;else c=13;break}case 7:{if(!o)c=12;else c=13;break}case 8:{if(!o)c=12;else c=13;break}case 9:{if(!o)o=8;else c=13;break}default:c=13}}while(0);if((c|0)==12)o=16;else if((c|0)==13){pe[a>>2]=1154;pe[a+4>>2]=2663;pe[a+8>>2]=1535;_r(f,1100,a)|0;yr(f,s)|0;o=0}s=ge(o,u)|0;a=gt(e,t)|0;pe[l>>2]=r;o=(a|0)==0;if(!(n>>>0>15|(i>>>0<8|o))?(pe[a>>2]|0)==519686845:0)yt(a,l,i,s,n)|0;if(o){be=p;return}if((pe[a>>2]|0)!=519686845){be=p;return}jt(a);if(!(a&7)){Oi[pe[104>>2]&1](a,0,0,1,pe[27]|0)|0;be=p;return}else{pe[d>>2]=1154;pe[d+4>>2]=2499;pe[d+8>>2]=1516;_r(f,1100,d)|0;yr(f,h)|0;be=p;return}}function Ct(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0;a=e+92|0;i=pe[e+4>>2]|0;o=e+88|0;n=pe[o>>2]|0;t=(ve[n+68>>0]|0)<<8|(ve[n+67>>0]|0)<<16|(ve[n+69>>0]|0);r=i+t|0;n=(ve[n+65>>0]|0)<<8|(ve[n+66>>0]|0);if(!n){e=0;return e|0}pe[a>>2]=r;pe[e+96>>2]=r;pe[e+104>>2]=n;pe[e+100>>2]=i+(n+t);pe[e+108>>2]=0;pe[e+112>>2]=0;if(!(pt(a,e+116|0)|0)){e=0;return e|0}t=pe[o>>2]|0;do{if(!((ve[t+39>>0]|0)<<8|(ve[t+40>>0]|0))){if(!((ve[t+55>>0]|0)<<8|(ve[t+56>>0]|0))){e=0;return e|0}}else{if(!(pt(a,e+140|0)|0)){e=0;return e|0}if(pt(a,e+188|0)|0){t=pe[o>>2]|0;break}else{e=0;return e|0}}}while(0);if((ve[t+55>>0]|0)<<8|(ve[t+56>>0]|0)){if(!(pt(a,e+164|0)|0)){e=0;return e|0}if(!(pt(a,e+212|0)|0)){e=0;return e|0}}e=1;return e|0}function Pt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;p=be;be=be+592|0;u=p+16|0;s=p;a=p+72|0;d=p+24|0;i=e+88|0;t=pe[i>>2]|0;h=(ve[t+39>>0]|0)<<8|(ve[t+40>>0]|0);f=e+236|0;o=e+240|0;r=pe[o>>2]|0;if((r|0)!=(h|0)){if(r>>>0<=h>>>0){do{if((pe[e+244>>2]|0)>>>0>>0){if(nt(f,h,(r+1|0)==(h|0),4,0)|0){t=pe[o>>2]|0;break}de[e+248>>0]=1;d=0;be=p;return d|0}else t=r}while(0);Yr((pe[f>>2]|0)+(t<<2)|0,0,h-t<<2|0)|0;t=pe[i>>2]|0}pe[o>>2]=h}c=e+92|0;r=pe[e+4>>2]|0;i=(ve[t+34>>0]|0)<<8|(ve[t+33>>0]|0)<<16|(ve[t+35>>0]|0);n=r+i|0;t=(ve[t+37>>0]|0)<<8|(ve[t+36>>0]|0)<<16|(ve[t+38>>0]|0);if(!t){d=0;be=p;return d|0}pe[c>>2]=n;pe[e+96>>2]=n;pe[e+104>>2]=t;pe[e+100>>2]=r+(t+i);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[d+20>>2]=0;pe[d>>2]=0;pe[d+4>>2]=0;pe[d+8>>2]=0;pe[d+12>>2]=0;de[d+16>>0]=0;e=d+24|0;pe[d+44>>2]=0;pe[e>>2]=0;pe[e+4>>2]=0;pe[e+8>>2]=0;pe[e+12>>2]=0;de[e+16>>0]=0;if(pt(c,d)|0?(l=d+24|0,pt(c,l)|0):0){if(!(pe[o>>2]|0)){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(a,1100,s)|0;yr(a,u)|0}if(!h)t=1;else{i=0;n=0;o=0;t=0;a=0;e=0;s=0;r=pe[f>>2]|0;while(1){i=(mt(c,d)|0)+i&31;n=(mt(c,l)|0)+n&63;o=(mt(c,d)|0)+o&31;t=(mt(c,d)|0)+t|0;a=(mt(c,l)|0)+a&63;e=(mt(c,d)|0)+e&31;pe[r>>2]=n<<5|i<<11|o|t<<27|a<<21|e<<16;s=s+1|0;if((s|0)==(h|0)){t=1;break}else{t=t&31;r=r+4|0}}}}else t=0;lt(d+24|0);lt(d);d=t;be=p;return d|0}function At(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0;E=be;be=be+1024|0;s=E+16|0;a=E;o=E+504|0;S=E+480|0;x=E+284|0;T=E+88|0;w=E+24|0;n=pe[e+88>>2]|0;_=(ve[n+47>>0]|0)<<8|(ve[n+48>>0]|0);y=e+92|0;t=pe[e+4>>2]|0;r=(ve[n+42>>0]|0)<<8|(ve[n+41>>0]|0)<<16|(ve[n+43>>0]|0);i=t+r|0;n=(ve[n+45>>0]|0)<<8|(ve[n+44>>0]|0)<<16|(ve[n+46>>0]|0);if(!n){S=0;be=E;return S|0}pe[y>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[S+20>>2]=0;pe[S>>2]=0;pe[S+4>>2]=0;pe[S+8>>2]=0;pe[S+12>>2]=0;de[S+16>>0]=0;if(pt(y,S)|0){r=0;i=-3;n=-3;while(1){pe[x+(r<<2)>>2]=i;pe[T+(r<<2)>>2]=n;t=(i|0)>2;r=r+1|0;if((r|0)==49)break;else{i=t?-3:i+1|0;n=(t&1)+n|0}}t=w;r=t+64|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(r|0));g=e+252|0;r=e+256|0;t=pe[r>>2]|0;e:do{if((t|0)==(_|0))u=13;else{if(t>>>0<=_>>>0){do{if((pe[e+260>>2]|0)>>>0<_>>>0)if(nt(g,_,(t+1|0)==(_|0),4,0)|0){t=pe[r>>2]|0;break}else{de[e+264>>0]=1;t=0;break e}}while(0);Yr((pe[g>>2]|0)+(t<<2)|0,0,_-t<<2|0)|0}pe[r>>2]=_;u=13}}while(0);do{if((u|0)==13){if(!_){pe[a>>2]=1154;pe[a+4>>2]=903;pe[a+8>>2]=1781;_r(o,1100,a)|0;yr(o,s)|0;t=1;break}i=w+4|0;n=w+8|0;e=w+12|0;o=w+16|0;a=w+20|0;s=w+24|0;u=w+28|0;c=w+32|0;f=w+36|0;l=w+40|0;h=w+44|0;d=w+48|0;p=w+52|0;v=w+56|0;m=w+60|0;b=0;r=pe[g>>2]|0;while(1){t=0;do{M=mt(y,S)|0;g=t<<1;C=w+(g<<2)|0;pe[C>>2]=(pe[C>>2]|0)+(pe[x+(M<<2)>>2]|0)&3;g=w+((g|1)<<2)|0;pe[g>>2]=(pe[g>>2]|0)+(pe[T+(M<<2)>>2]|0)&3;t=t+1|0}while((t|0)!=8);pe[r>>2]=(ve[1725+(pe[i>>2]|0)>>0]|0)<<2|(ve[1725+(pe[w>>2]|0)>>0]|0)|(ve[1725+(pe[n>>2]|0)>>0]|0)<<4|(ve[1725+(pe[e>>2]|0)>>0]|0)<<6|(ve[1725+(pe[o>>2]|0)>>0]|0)<<8|(ve[1725+(pe[a>>2]|0)>>0]|0)<<10|(ve[1725+(pe[s>>2]|0)>>0]|0)<<12|(ve[1725+(pe[u>>2]|0)>>0]|0)<<14|(ve[1725+(pe[c>>2]|0)>>0]|0)<<16|(ve[1725+(pe[f>>2]|0)>>0]|0)<<18|(ve[1725+(pe[l>>2]|0)>>0]|0)<<20|(ve[1725+(pe[h>>2]|0)>>0]|0)<<22|(ve[1725+(pe[d>>2]|0)>>0]|0)<<24|(ve[1725+(pe[p>>2]|0)>>0]|0)<<26|(ve[1725+(pe[v>>2]|0)>>0]|0)<<28|(ve[1725+(pe[m>>2]|0)>>0]|0)<<30;b=b+1|0;if((b|0)==(_|0)){t=1;break}else r=r+4|0}}}while(0)}else t=0;lt(S);C=t;be=E;return C|0}function kt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0;h=be;be=be+560|0;u=h+16|0;s=h;a=h+48|0;l=h+24|0;n=pe[e+88>>2]|0;f=(ve[n+55>>0]|0)<<8|(ve[n+56>>0]|0);c=e+92|0;t=pe[e+4>>2]|0;r=(ve[n+50>>0]|0)<<8|(ve[n+49>>0]|0)<<16|(ve[n+51>>0]|0);i=t+r|0;n=(ve[n+53>>0]|0)<<8|(ve[n+52>>0]|0)<<16|(ve[n+54>>0]|0);if(!n){l=0;be=h;return l|0}pe[c>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[l+20>>2]=0;pe[l>>2]=0;pe[l+4>>2]=0;pe[l+8>>2]=0;pe[l+12>>2]=0;de[l+16>>0]=0;e:do{if(pt(c,l)|0){o=e+268|0;r=e+272|0;t=pe[r>>2]|0;if((t|0)!=(f|0)){if(t>>>0<=f>>>0){do{if((pe[e+276>>2]|0)>>>0>>0)if(nt(o,f,(t+1|0)==(f|0),2,0)|0){t=pe[r>>2]|0;break}else{de[e+280>>0]=1;t=0;break e}}while(0);Yr((pe[o>>2]|0)+(t<<1)|0,0,f-t<<1|0)|0}pe[r>>2]=f}if(!f){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(a,1100,s)|0;yr(a,u)|0;t=1;break}r=0;i=0;n=0;t=pe[o>>2]|0;while(1){u=mt(c,l)|0;r=u+r&255;i=(mt(c,l)|0)+i&255;$[t>>1]=i<<8|r;n=n+1|0;if((n|0)==(f|0)){t=1;break}else t=t+2|0}}else t=0}while(0);lt(l);l=t;be=h;return l|0}function It(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0;E=be;be=be+2432|0;s=E+16|0;a=E;o=E+1912|0;S=E+1888|0;x=E+988|0;T=E+88|0;w=E+24|0;n=pe[e+88>>2]|0;_=(ve[n+63>>0]|0)<<8|(ve[n+64>>0]|0);y=e+92|0;t=pe[e+4>>2]|0;r=(ve[n+58>>0]|0)<<8|(ve[n+57>>0]|0)<<16|(ve[n+59>>0]|0);i=t+r|0;n=(ve[n+61>>0]|0)<<8|(ve[n+60>>0]|0)<<16|(ve[n+62>>0]|0);if(!n){S=0;be=E;return S|0}pe[y>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[S+20>>2]=0;pe[S>>2]=0;pe[S+4>>2]=0;pe[S+8>>2]=0;pe[S+12>>2]=0;de[S+16>>0]=0;if(pt(y,S)|0){r=0;i=-7;n=-7;while(1){pe[x+(r<<2)>>2]=i;pe[T+(r<<2)>>2]=n;t=(i|0)>6;r=r+1|0;if((r|0)==225)break;else{i=t?-7:i+1|0;n=(t&1)+n|0}}t=w;r=t+64|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(r|0));g=e+284|0;r=_*3|0;i=e+288|0;t=pe[i>>2]|0;e:do{if((t|0)==(r|0))u=13;else{if(t>>>0<=r>>>0){do{if((pe[e+292>>2]|0)>>>0>>0)if(nt(g,r,(t+1|0)==(r|0),2,0)|0){t=pe[i>>2]|0;break}else{de[e+296>>0]=1;t=0;break e}}while(0);Yr((pe[g>>2]|0)+(t<<1)|0,0,r-t<<1|0)|0}pe[i>>2]=r;u=13}}while(0);do{if((u|0)==13){if(!_){pe[a>>2]=1154;pe[a+4>>2]=903;pe[a+8>>2]=1781;_r(o,1100,a)|0;yr(o,s)|0;t=1;break}i=w+4|0;n=w+8|0;e=w+12|0;o=w+16|0;a=w+20|0;s=w+24|0;u=w+28|0;c=w+32|0;f=w+36|0;l=w+40|0;h=w+44|0;d=w+48|0;p=w+52|0;v=w+56|0;m=w+60|0;b=0;r=pe[g>>2]|0;while(1){t=0;do{M=mt(y,S)|0;g=t<<1;C=w+(g<<2)|0;pe[C>>2]=(pe[C>>2]|0)+(pe[x+(M<<2)>>2]|0)&7;g=w+((g|1)<<2)|0;pe[g>>2]=(pe[g>>2]|0)+(pe[T+(M<<2)>>2]|0)&7;t=t+1|0}while((t|0)!=8);M=ve[1729+(pe[a>>2]|0)>>0]|0;$[r>>1]=(ve[1729+(pe[i>>2]|0)>>0]|0)<<3|(ve[1729+(pe[w>>2]|0)>>0]|0)|(ve[1729+(pe[n>>2]|0)>>0]|0)<<6|(ve[1729+(pe[e>>2]|0)>>0]|0)<<9|(ve[1729+(pe[o>>2]|0)>>0]|0)<<12|M<<15;C=ve[1729+(pe[l>>2]|0)>>0]|0;$[r+2>>1]=(ve[1729+(pe[s>>2]|0)>>0]|0)<<2|M>>>1|(ve[1729+(pe[u>>2]|0)>>0]|0)<<5|(ve[1729+(pe[c>>2]|0)>>0]|0)<<8|(ve[1729+(pe[f>>2]|0)>>0]|0)<<11|C<<14;$[r+4>>1]=(ve[1729+(pe[h>>2]|0)>>0]|0)<<1|C>>>2|(ve[1729+(pe[d>>2]|0)>>0]|0)<<4|(ve[1729+(pe[p>>2]|0)>>0]|0)<<7|(ve[1729+(pe[v>>2]|0)>>0]|0)<<10|(ve[1729+(pe[m>>2]|0)>>0]|0)<<13;b=b+1|0;if((b|0)==(_|0)){t=1;break}else r=r+6|0}}}while(0)}else t=0;lt(S);C=t;be=E;return C|0}function Rt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0,se=0,ue=0,ce=0,fe=0,le=0,he=0;fe=be;be=be+720|0;ce=fe+184|0;se=fe+168|0;ae=fe+160|0;oe=fe+144|0;ne=fe+136|0;ie=fe+120|0;re=fe+112|0;ee=fe+96|0;$=fe+88|0;Q=fe+72|0;Z=fe+64|0;J=fe+48|0;K=fe+40|0;ue=fe+24|0;te=fe+16|0;Y=fe;V=fe+208|0;W=fe+192|0;N=e+240|0;U=pe[N>>2]|0;q=e+256|0;G=pe[q>>2]|0;r=de[(pe[e+88>>2]|0)+17>>0]|0;H=i>>>2;if(!(r<<24>>24)){be=fe;return 1}z=(s|0)==0;X=s+-1|0;R=(o&1|0)!=0;O=i<<1;D=e+92|0;L=e+116|0;j=e+140|0;F=e+236|0;B=a+-1|0;I=(n&1|0)!=0;k=e+188|0;E=e+252|0;M=H+1|0;C=H+2|0;P=H+3|0;A=B<<4;T=r&255;r=0;o=0;n=1;S=0;do{if(!z){w=pe[t+(S<<2)>>2]|0;x=0;while(1){g=x&1;u=(g|0)==0;b=(g<<5^32)+-16|0;g=(g<<1^2)+-1|0;_=u?a:-1;c=u?0:B;e=(x|0)==(X|0);y=R&e;if((c|0)!=(_|0)){m=R&e^1;v=u?w:w+A|0;while(1){if((n|0)==1)n=mt(D,L)|0|512;p=n&7;n=n>>>3;u=ve[1823+p>>0]|0;e=0;do{h=(mt(D,j)|0)+o|0;d=h-U|0;o=d>>31;o=o&h|d&~o;if((pe[N>>2]|0)>>>0<=o>>>0){pe[Y>>2]=1154;pe[Y+4>>2]=903;pe[Y+8>>2]=1781;_r(V,1100,Y)|0;yr(V,te)|0}pe[W+(e<<2)>>2]=pe[(pe[F>>2]|0)+(o<<2)>>2];e=e+1|0}while(e>>>0>>0);d=I&(c|0)==(B|0);if(y|d){h=0;do{f=ge(h,i)|0;e=v+f|0;u=(h|0)==0|m;l=h<<1;he=(mt(D,k)|0)+r|0;le=he-G|0;r=le>>31;r=r&he|le&~r;do{if(d){if(!u){le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;break}pe[e>>2]=pe[W+((ve[1831+(p<<2)+l>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(V,1100,oe)|0;yr(V,ae)|0}pe[v+(f+4)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r}else{if(!u){le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;break}pe[e>>2]=pe[W+((ve[1831+(p<<2)+l>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[ie>>2]=1154;pe[ie+4>>2]=903;pe[ie+8>>2]=1781;_r(V,1100,ie)|0;yr(V,ne)|0}pe[v+(f+4)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;pe[v+(f+8)>>2]=pe[W+((ve[(l|1)+(1831+(p<<2))>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[se>>2]=1154;pe[se+4>>2]=903;pe[se+8>>2]=1781;_r(V,1100,se)|0;yr(V,ce)|0}pe[v+(f+12)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2]}}while(0);h=h+1|0}while((h|0)!=2)}else{pe[v>>2]=pe[W+((ve[1831+(p<<2)>>0]|0)<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[ue>>2]=1154;pe[ue+4>>2]=903;pe[ue+8>>2]=1781;_r(V,1100,ue)|0;yr(V,K)|0}pe[v+4>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[v+8>>2]=pe[W+((ve[1831+(p<<2)+1>>0]|0)<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[J>>2]=1154;pe[J+4>>2]=903;pe[J+8>>2]=1781;_r(V,1100,J)|0;yr(V,Z)|0}pe[v+12>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[v+(H<<2)>>2]=pe[W+((ve[1831+(p<<2)+2>>0]|0)<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[Q>>2]=1154;pe[Q+4>>2]=903;pe[Q+8>>2]=1781;_r(V,1100,Q)|0;yr(V,$)|0}pe[v+(M<<2)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[v+(C<<2)>>2]=pe[W+((ve[1831+(p<<2)+3>>0]|0)<<2)>>2];le=(mt(D,k)|0)+r|0;he=le-G|0;r=he>>31;r=r&le|he&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[ee>>2]=1154;pe[ee+4>>2]=903;pe[ee+8>>2]=1781;_r(V,1100,ee)|0;yr(V,re)|0}pe[v+(P<<2)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2]}c=c+g|0;if((c|0)==(_|0))break;else v=v+b|0}}x=x+1|0;if((x|0)==(s|0))break;else w=w+O|0}}S=S+1|0}while((S|0)!=(T|0));be=fe;return 1}function Ot(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0,se=0,ue=0,ce=0,fe=0,le=0,he=0;le=be;be=be+640|0;ue=le+88|0;se=le+72|0;ae=le+64|0;oe=le+48|0;ne=le+40|0;fe=le+24|0;ce=le+16|0;ie=le;te=le+128|0;re=le+112|0;ee=le+96|0;N=e+240|0;U=pe[N>>2]|0;q=e+256|0;Z=pe[q>>2]|0;Q=e+272|0;$=pe[Q>>2]|0;r=pe[e+88>>2]|0;z=(ve[r+63>>0]|0)<<8|(ve[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=le;return 1}X=(s|0)==0;G=s+-1|0;H=i<<1;V=e+92|0;W=e+116|0;Y=a+-1|0;K=e+212|0;J=e+188|0;B=(n&1|0)==0;F=(o&1|0)==0;I=e+288|0;R=e+284|0;O=e+252|0;D=e+140|0;L=e+236|0;j=e+164|0;A=e+268|0;k=Y<<5;C=r&255;r=0;n=0;o=0;e=0;u=1;P=0;do{if(!X){E=pe[t+(P<<2)>>2]|0;M=0;while(1){T=M&1;c=(T|0)==0;x=(T<<6^64)+-32|0;T=(T<<1^2)+-1|0;S=c?a:-1;f=c?0:Y;if((f|0)!=(S|0)){w=F|(M|0)!=(G|0);_=c?E:E+k|0;while(1){if((u|0)==1)u=mt(V,W)|0|512;y=u&7;u=u>>>3;l=ve[1823+y>>0]|0;c=0;do{b=(mt(V,j)|0)+n|0;g=b-$|0;n=g>>31;n=n&b|g&~n;if((pe[Q>>2]|0)>>>0<=n>>>0){pe[ie>>2]=1154;pe[ie+4>>2]=903;pe[ie+8>>2]=1781;_r(te,1100,ie)|0;yr(te,ce)|0}pe[ee+(c<<2)>>2]=me[(pe[A>>2]|0)+(n<<1)>>1];c=c+1|0}while(c>>>0>>0);c=0;do{b=(mt(V,D)|0)+e|0;g=b-U|0;e=g>>31;e=e&b|g&~e;if((pe[N>>2]|0)>>>0<=e>>>0){pe[fe>>2]=1154;pe[fe+4>>2]=903;pe[fe+8>>2]=1781;_r(te,1100,fe)|0;yr(te,ne)|0}pe[re+(c<<2)>>2]=pe[(pe[L>>2]|0)+(e<<2)>>2];c=c+1|0}while(c>>>0>>0);g=B|(f|0)!=(Y|0);m=0;b=_;while(1){v=w|(m|0)==0;p=m<<1;h=0;d=b;while(1){l=(mt(V,K)|0)+r|0;c=l-z|0;r=c>>31;r=r&l|c&~r;c=(mt(V,J)|0)+o|0;l=c-Z|0;o=l>>31;o=o&c|l&~o;if((g|(h|0)==0)&v){c=ve[h+p+(1831+(y<<2))>>0]|0;l=r*3|0;if((pe[I>>2]|0)>>>0<=l>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(te,1100,oe)|0;yr(te,ae)|0}he=pe[R>>2]|0;pe[d>>2]=(me[he+(l<<1)>>1]|0)<<16|pe[ee+(c<<2)>>2];pe[d+4>>2]=(me[he+(l+2<<1)>>1]|0)<<16|(me[he+(l+1<<1)>>1]|0);pe[d+8>>2]=pe[re+(c<<2)>>2];if((pe[q>>2]|0)>>>0<=o>>>0){pe[se>>2]=1154;pe[se+4>>2]=903;pe[se+8>>2]=1781;_r(te,1100,se)|0;yr(te,ue)|0}pe[d+12>>2]=pe[(pe[O>>2]|0)+(o<<2)>>2]}h=h+1|0;if((h|0)==2)break;else d=d+16|0}m=m+1|0;if((m|0)==2)break;else b=b+i|0}f=f+T|0;if((f|0)==(S|0))break;else _=_+x|0}}M=M+1|0;if((M|0)==(s|0))break;else E=E+H|0}}P=P+1|0}while((P|0)!=(C|0));be=le;return 1}function Dt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0;Z=be;be=be+608|0;Y=Z+64|0;W=Z+48|0;V=Z+40|0;J=Z+24|0;K=Z+16|0;H=Z;G=Z+88|0;q=Z+72|0;O=e+272|0;D=pe[O>>2]|0;r=pe[e+88>>2]|0;L=(ve[r+63>>0]|0)<<8|(ve[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=Z;return 1}j=(s|0)==0;F=s+-1|0;B=i<<1;N=e+92|0;U=e+116|0;z=a+-1|0;X=e+212|0;R=(o&1|0)==0;A=e+288|0;k=e+284|0;I=e+164|0;C=e+268|0;P=z<<4;M=r&255;E=(n&1|0)!=0;r=0;o=0;e=1;S=0;do{if(!j){x=pe[t+(S<<2)>>2]|0;T=0;while(1){_=T&1;n=(_|0)==0;y=(_<<5^32)+-16|0;_=(_<<1^2)+-1|0;w=n?a:-1;u=n?0:z;if((u|0)!=(w|0)){g=R|(T|0)!=(F|0);b=n?x:x+P|0;while(1){if((e|0)==1)e=mt(N,U)|0|512;m=e&7;e=e>>>3;c=ve[1823+m>>0]|0;n=0;do{p=(mt(N,I)|0)+o|0;v=p-D|0;o=v>>31;o=o&p|v&~o;if((pe[O>>2]|0)>>>0<=o>>>0){pe[H>>2]=1154;pe[H+4>>2]=903;pe[H+8>>2]=1781;_r(G,1100,H)|0;yr(G,K)|0}pe[q+(n<<2)>>2]=me[(pe[C>>2]|0)+(o<<1)>>1];n=n+1|0}while(n>>>0>>0);v=(u|0)==(z|0)&E;d=0;p=b;while(1){h=g|(d|0)==0;l=d<<1;n=(mt(N,X)|0)+r|0;f=n-L|0;c=f>>31;c=c&n|f&~c;if(h){r=ve[1831+(m<<2)+l>>0]|0;n=c*3|0;if((pe[A>>2]|0)>>>0<=n>>>0){pe[J>>2]=1154;pe[J+4>>2]=903;pe[J+8>>2]=1781;_r(G,1100,J)|0;yr(G,V)|0}f=pe[k>>2]|0;pe[p>>2]=(me[f+(n<<1)>>1]|0)<<16|pe[q+(r<<2)>>2];pe[p+4>>2]=(me[f+(n+2<<1)>>1]|0)<<16|(me[f+(n+1<<1)>>1]|0)}f=p+8|0;n=(mt(N,X)|0)+c|0;c=n-L|0;r=c>>31;r=r&n|c&~r;if(!(v|h^1)){n=ve[(l|1)+(1831+(m<<2))>>0]|0;c=r*3|0;if((pe[A>>2]|0)>>>0<=c>>>0){pe[W>>2]=1154;pe[W+4>>2]=903;pe[W+8>>2]=1781;_r(G,1100,W)|0;yr(G,Y)|0}h=pe[k>>2]|0;pe[f>>2]=(me[h+(c<<1)>>1]|0)<<16|pe[q+(n<<2)>>2];pe[p+12>>2]=(me[h+(c+2<<1)>>1]|0)<<16|(me[h+(c+1<<1)>>1]|0)}d=d+1|0;if((d|0)==2)break;else p=p+i|0}u=u+_|0;if((u|0)==(w|0))break;else b=b+y|0}}T=T+1|0;if((T|0)==(s|0))break;else x=x+B|0}}S=S+1|0}while((S|0)!=(M|0));be=Z;return 1}function Lt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0;ae=be;be=be+640|0;ie=ae+88|0;re=ae+72|0;te=ae+64|0;ee=ae+48|0;$=ae+40|0;oe=ae+24|0;ne=ae+16|0;Q=ae;Z=ae+128|0;K=ae+112|0;J=ae+96|0;N=e+272|0;U=pe[N>>2]|0;r=pe[e+88>>2]|0;z=(ve[r+63>>0]|0)<<8|(ve[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=ae;return 1}X=(s|0)==0;q=s+-1|0;G=i<<1;H=e+92|0;V=e+116|0;W=a+-1|0;Y=e+212|0;B=(n&1|0)==0;F=(o&1|0)==0;D=e+288|0;L=e+284|0;j=e+164|0;R=e+268|0;O=W<<5;k=r&255;r=0;n=0;o=0;e=0;u=1;I=0;do{if(!X){P=pe[t+(I<<2)>>2]|0;A=0;while(1){M=A&1;c=(M|0)==0;E=(M<<6^64)+-32|0;M=(M<<1^2)+-1|0;C=c?a:-1;f=c?0:W;if((f|0)!=(C|0)){S=F|(A|0)!=(q|0);T=c?P:P+O|0;while(1){if((u|0)==1)u=mt(H,V)|0|512;x=u&7;u=u>>>3;l=ve[1823+x>>0]|0;c=0;do{_=(mt(H,j)|0)+e|0;w=_-U|0;e=w>>31;e=e&_|w&~e;if((pe[N>>2]|0)>>>0<=e>>>0){pe[Q>>2]=1154;pe[Q+4>>2]=903;pe[Q+8>>2]=1781;_r(Z,1100,Q)|0;yr(Z,ne)|0}pe[K+(c<<2)>>2]=me[(pe[R>>2]|0)+(e<<1)>>1];c=c+1|0}while(c>>>0>>0);c=0;do{_=(mt(H,j)|0)+n|0;w=_-U|0;n=w>>31;n=n&_|w&~n;if((pe[N>>2]|0)>>>0<=n>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(Z,1100,oe)|0;yr(Z,$)|0}pe[J+(c<<2)>>2]=me[(pe[R>>2]|0)+(n<<1)>>1];c=c+1|0}while(c>>>0>>0);w=B|(f|0)!=(W|0);y=0;_=T;while(1){g=S|(y|0)==0;b=y<<1;v=0;m=_;while(1){p=(mt(H,Y)|0)+o|0;d=p-z|0;o=d>>31;o=o&p|d&~o;d=(mt(H,Y)|0)+r|0;p=d-z|0;r=p>>31;r=r&d|p&~r;if((w|(v|0)==0)&g){d=ve[v+b+(1831+(x<<2))>>0]|0;p=o*3|0;c=pe[D>>2]|0;if(c>>>0<=p>>>0){pe[ee>>2]=1154;pe[ee+4>>2]=903;pe[ee+8>>2]=1781;_r(Z,1100,ee)|0;yr(Z,te)|0;c=pe[D>>2]|0}l=pe[L>>2]|0;h=r*3|0;if(c>>>0>h>>>0)c=l;else{pe[re>>2]=1154;pe[re+4>>2]=903;pe[re+8>>2]=1781;_r(Z,1100,re)|0;yr(Z,ie)|0;c=pe[L>>2]|0}pe[m>>2]=(me[l+(p<<1)>>1]|0)<<16|pe[K+(d<<2)>>2];pe[m+4>>2]=(me[l+(p+2<<1)>>1]|0)<<16|(me[l+(p+1<<1)>>1]|0);pe[m+8>>2]=(me[c+(h<<1)>>1]|0)<<16|pe[J+(d<<2)>>2];pe[m+12>>2]=(me[c+(h+2<<1)>>1]|0)<<16|(me[c+(h+1<<1)>>1]|0)}v=v+1|0;if((v|0)==2)break;else m=m+16|0}y=y+1|0;if((y|0)==2)break;else _=_+i|0}f=f+M|0;if((f|0)==(C|0))break;else T=T+E|0}}A=A+1|0;if((A|0)==(s|0))break;else P=P+G|0}}I=I+1|0}while((I|0)!=(k|0));be=ae;return 1}function jt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0;h=be;be=be+608|0;l=h+88|0;f=h+72|0;u=h+64|0;s=h+48|0;o=h+40|0;a=h+24|0;n=h+16|0;i=h;c=h+96|0;pe[e>>2]=0;t=e+284|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[i>>2]=1154;pe[i+4>>2]=2499;pe[i+8>>2]=1516;_r(c,1100,i)|0;yr(c,n)|0}pe[t>>2]=0;pe[e+288>>2]=0;pe[e+292>>2]=0}de[e+296>>0]=0;t=e+268|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[a>>2]=1154;pe[a+4>>2]=2499;pe[a+8>>2]=1516;_r(c,1100,a)|0;yr(c,o)|0}pe[t>>2]=0;pe[e+272>>2]=0;pe[e+276>>2]=0}de[e+280>>0]=0;t=e+252|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[s>>2]=1154;pe[s+4>>2]=2499;pe[s+8>>2]=1516;_r(c,1100,s)|0;yr(c,u)|0}pe[t>>2]=0;pe[e+256>>2]=0;pe[e+260>>2]=0}de[e+264>>0]=0;t=e+236|0;r=pe[t>>2]|0;if(!r){l=e+248|0;de[l>>0]=0;l=e+212|0;lt(l);l=e+188|0;lt(l);l=e+164|0;lt(l);l=e+140|0;lt(l);l=e+116|0;lt(l);be=h;return}if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[f>>2]=1154;pe[f+4>>2]=2499;pe[f+8>>2]=1516;_r(c,1100,f)|0;yr(c,l)|0}pe[t>>2]=0;pe[e+240>>2]=0;pe[e+244>>2]=0;l=e+248|0;de[l>>0]=0;l=e+212|0;lt(l);l=e+188|0;lt(l);l=e+164|0;lt(l);l=e+140|0;lt(l);l=e+116|0;lt(l);be=h;return}function Ft(e,t){e=e|0;t=t|0;var r=0;r=be;be=be+16|0;pe[r>>2]=t;t=pe[63]|0;wr(t,e,r)|0;br(10,t)|0;Xe()}function Bt(){var e=0,t=0;e=be;be=be+16|0;if(!(je(200,2)|0)){t=De(pe[49]|0)|0;be=e;return t|0}else Ft(2090,e);return 0}function Nt(e){e=e|0;zr(e);return}function Ut(e){e=e|0;var t=0;t=be;be=be+16|0;Ii[e&3]();Ft(2139,t)}function zt(){var e=0,t=0;e=Bt()|0;if(((e|0)!=0?(t=pe[e>>2]|0,(t|0)!=0):0)?(e=t+48|0,(pe[e>>2]&-256|0)==1126902528?(pe[e+4>>2]|0)==1129074247:0):0)Ut(pe[t+12>>2]|0);t=pe[28]|0;pe[28]=t+0;Ut(t)}function Xt(e){e=e|0;return}function qt(e){e=e|0;return}function Gt(e){e=e|0;return}function Ht(e){e=e|0;return}function Vt(e){e=e|0;Nt(e);return}function Wt(e){e=e|0;Nt(e);return}function Yt(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;a=be;be=be+64|0;o=a;if((e|0)!=(t|0))if((t|0)!=0?(n=Qt(t,24,40,0)|0,(n|0)!=0):0){t=o;i=t+56|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(i|0));pe[o>>2]=n;pe[o+8>>2]=e;pe[o+12>>2]=-1;pe[o+48>>2]=1;Di[pe[(pe[n>>2]|0)+28>>2]&3](n,o,pe[r>>2]|0,1);if((pe[o+24>>2]|0)==1){pe[r>>2]=pe[o+16>>2];t=1}else t=0}else t=0;else t=1;be=a;return t|0}function Kt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0;e=t+16|0;n=pe[e>>2]|0;do{if(n){if((n|0)!=(r|0)){i=t+36|0;pe[i>>2]=(pe[i>>2]|0)+1;pe[t+24>>2]=2;de[t+54>>0]=1;break}e=t+24|0;if((pe[e>>2]|0)==2)pe[e>>2]=i}else{pe[e>>2]=r;pe[t+24>>2]=i;pe[t+36>>2]=1}}while(0);return}function Jt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;if((e|0)==(pe[t+8>>2]|0))Kt(0,t,r,i);return}function Zt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;if((e|0)==(pe[t+8>>2]|0))Kt(0,t,r,i);else{e=pe[e+8>>2]|0;Di[pe[(pe[e>>2]|0)+28>>2]&3](e,t,r,i)}return}function Qt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0;d=be;be=be+64|0;h=d;l=pe[e>>2]|0;f=e+(pe[l+-8>>2]|0)|0;l=pe[l+-4>>2]|0;pe[h>>2]=r;pe[h+4>>2]=e;pe[h+8>>2]=t;pe[h+12>>2]=i;i=h+16|0;e=h+20|0;t=h+24|0;n=h+28|0;o=h+32|0;a=h+40|0;s=(l|0)==(r|0);u=i;c=u+36|0;do{pe[u>>2]=0;u=u+4|0}while((u|0)<(c|0));$[i+36>>1]=0;de[i+38>>0]=0;e:do{if(s){pe[h+48>>2]=1;Ri[pe[(pe[r>>2]|0)+20>>2]&3](r,h,f,f,1,0);i=(pe[t>>2]|0)==1?f:0}else{Ci[pe[(pe[l>>2]|0)+24>>2]&3](l,h,f,1,0);switch(pe[h+36>>2]|0){case 0:{i=(pe[a>>2]|0)==1&(pe[n>>2]|0)==1&(pe[o>>2]|0)==1?pe[e>>2]|0:0;break e}case 1:break;default:{i=0;break e}}if((pe[t>>2]|0)!=1?!((pe[a>>2]|0)==0&(pe[n>>2]|0)==1&(pe[o>>2]|0)==1):0){i=0;break}i=pe[i>>2]|0}}while(0);be=d;return i|0}function $t(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;de[t+53>>0]=1;do{if((pe[t+4>>2]|0)==(i|0)){de[t+52>>0]=1;i=t+16|0;e=pe[i>>2]|0;if(!e){pe[i>>2]=r;pe[t+24>>2]=n;pe[t+36>>2]=1;if(!((n|0)==1?(pe[t+48>>2]|0)==1:0))break;de[t+54>>0]=1;break}if((e|0)!=(r|0)){n=t+36|0;pe[n>>2]=(pe[n>>2]|0)+1;de[t+54>>0]=1;break}e=t+24|0;i=pe[e>>2]|0;if((i|0)==2){pe[e>>2]=n;i=n}if((i|0)==1?(pe[t+48>>2]|0)==1:0)de[t+54>>0]=1}}while(0);return}function er(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0;e:do{if((e|0)==(pe[t+8>>2]|0)){if((pe[t+4>>2]|0)==(r|0)?(o=t+28|0,(pe[o>>2]|0)!=1):0)pe[o>>2]=i}else{if((e|0)!=(pe[t>>2]|0)){s=pe[e+8>>2]|0;Ci[pe[(pe[s>>2]|0)+24>>2]&3](s,t,r,i,n);break}if((pe[t+16>>2]|0)!=(r|0)?(a=t+20|0,(pe[a>>2]|0)!=(r|0)):0){pe[t+32>>2]=i;i=t+44|0;if((pe[i>>2]|0)==4)break;o=t+52|0;de[o>>0]=0;u=t+53|0;de[u>>0]=0;e=pe[e+8>>2]|0;Ri[pe[(pe[e>>2]|0)+20>>2]&3](e,t,r,r,1,n);if(de[u>>0]|0){if(!(de[o>>0]|0)){o=1;s=13}}else{o=0;s=13}do{if((s|0)==13){pe[a>>2]=r;u=t+40|0;pe[u>>2]=(pe[u>>2]|0)+1;if((pe[t+36>>2]|0)==1?(pe[t+24>>2]|0)==2:0){de[t+54>>0]=1;if(o)break}else s=16;if((s|0)==16?o:0)break;pe[i>>2]=4;break e}}while(0);pe[i>>2]=3;break}if((i|0)==1)pe[t+32>>2]=1}}while(0);return}function tr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0;do{if((e|0)==(pe[t+8>>2]|0)){if((pe[t+4>>2]|0)==(r|0)?(a=t+28|0,(pe[a>>2]|0)!=1):0)pe[a>>2]=i}else if((e|0)==(pe[t>>2]|0)){if((pe[t+16>>2]|0)!=(r|0)?(o=t+20|0,(pe[o>>2]|0)!=(r|0)):0){pe[t+32>>2]=i;pe[o>>2]=r;n=t+40|0;pe[n>>2]=(pe[n>>2]|0)+1;if((pe[t+36>>2]|0)==1?(pe[t+24>>2]|0)==2:0)de[t+54>>0]=1;pe[t+44>>2]=4;break}if((i|0)==1)pe[t+32>>2]=1}}while(0);return}function rr(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;if((e|0)==(pe[t+8>>2]|0))$t(0,t,r,i,n);else{e=pe[e+8>>2]|0;Ri[pe[(pe[e>>2]|0)+20>>2]&3](e,t,r,i,n,o)}return}function ir(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;if((e|0)==(pe[t+8>>2]|0))$t(0,t,r,i,n);return}function nr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;n=be;be=be+16|0;i=n;pe[i>>2]=pe[r>>2];e=Mi[pe[(pe[e>>2]|0)+16>>2]&7](e,t,i)|0;if(e)pe[r>>2]=pe[i>>2];be=n;return e&1|0}function or(e){e=e|0;if(!e)e=0;else e=(Qt(e,24,72,0)|0)!=0;return e&1|0}function ar(){var e=0,t=0,r=0,i=0,n=0,o=0,a=0,s=0;n=be;be=be+48|0;a=n+32|0;r=n+24|0;s=n+16|0;o=n;n=n+36|0;e=Bt()|0;if((e|0)!=0?(i=pe[e>>2]|0,(i|0)!=0):0){e=i+48|0;t=pe[e>>2]|0;e=pe[e+4>>2]|0;if(!((t&-256|0)==1126902528&(e|0)==1129074247)){pe[r>>2]=pe[51];Ft(2368,r)}if((t|0)==1126902529&(e|0)==1129074247)e=pe[i+44>>2]|0;else e=i+80|0;pe[n>>2]=e;i=pe[i>>2]|0;e=pe[i+4>>2]|0;if(Mi[pe[(pe[8>>2]|0)+16>>2]&7](8,i,n)|0){s=pe[n>>2]|0;n=pe[51]|0;s=Ai[pe[(pe[s>>2]|0)+8>>2]&1](s)|0;pe[o>>2]=n;pe[o+4>>2]=e;pe[o+8>>2]=s;Ft(2282,o)}else{pe[s>>2]=pe[51];pe[s+4>>2]=e;Ft(2327,s)}}Ft(2406,a)}function sr(){var e=0;e=be;be=be+16|0;if(!(Fe(196,6)|0)){be=e;return}else Ft(2179,e)}function ur(e){e=e|0;var t=0;t=be;be=be+16|0;zr(e);if(!(Ue(pe[49]|0,0)|0)){be=t;return}else Ft(2229,t)}function cr(e){e=e|0;var t=0,r=0;t=0;while(1){if((ve[2427+t>>0]|0)==(e|0)){r=2;break}t=t+1|0;if((t|0)==87){t=87;e=2515;r=5;break}}if((r|0)==2)if(!t)e=2515;else{e=2515;r=5}if((r|0)==5)while(1){r=e;while(1){e=r+1|0;if(!(de[r>>0]|0))break;else r=e}t=t+-1|0;if(!t)break;else r=5}return e|0}function fr(){var e=0;if(!(pe[52]|0))e=264;else{e=(Le()|0)+60|0;e=pe[e>>2]|0}return e|0}function lr(e){e=e|0;var t=0;if(e>>>0>4294963200){t=fr()|0;pe[t>>2]=0-e;e=-1}return e|0}function hr(e,t){e=+e;t=t|0;var r=0,i=0,n=0;ee[te>>3]=e;r=pe[te>>2]|0;i=pe[te+4>>2]|0;n=Kr(r|0,i|0,52)|0;n=n&2047;switch(n|0){case 0:{if(e!=0.0){e=+hr(e*18446744073709552.0e3,t);r=(pe[t>>2]|0)+-64|0}else r=0;pe[t>>2]=r;break}case 2047:break;default:{pe[t>>2]=n+-1022;pe[te>>2]=r;pe[te+4>>2]=i&-2146435073|1071644672;e=+ee[te>>3]}}return+e}function dr(e,t){e=+e;t=t|0;return+ +hr(e,t)}function pr(e,t,r){e=e|0;t=t|0;r=r|0;do{if(e){if(t>>>0<128){de[e>>0]=t;e=1;break}if(t>>>0<2048){de[e>>0]=t>>>6|192;de[e+1>>0]=t&63|128;e=2;break}if(t>>>0<55296|(t&-8192|0)==57344){de[e>>0]=t>>>12|224;de[e+1>>0]=t>>>6&63|128;de[e+2>>0]=t&63|128;e=3;break}if((t+-65536|0)>>>0<1048576){de[e>>0]=t>>>18|240;de[e+1>>0]=t>>>12&63|128;de[e+2>>0]=t>>>6&63|128;de[e+3>>0]=t&63|128;e=4;break}else{e=fr()|0;pe[e>>2]=84;e=-1;break}}else e=1}while(0);return e|0}function vr(e,t){e=e|0;t=t|0;if(!e)e=0;else e=pr(e,t,0)|0;return e|0}function mr(e){e=e|0;var t=0,r=0;do{if(e){if((pe[e+76>>2]|0)<=-1){t=Or(e)|0;break}r=(Sr(e)|0)==0;t=Or(e)|0;if(!r)Er(e)}else{if(!(pe[65]|0))t=0;else t=mr(pe[65]|0)|0;ze(236);e=pe[58]|0;if(e)do{if((pe[e+76>>2]|0)>-1)r=Sr(e)|0;else r=0;if((pe[e+20>>2]|0)>>>0>(pe[e+28>>2]|0)>>>0)t=Or(e)|0|t;if(r)Er(e);e=pe[e+56>>2]|0}while((e|0)!=0);Be(236)}}while(0);return t|0}function br(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0;if((pe[t+76>>2]|0)>=0?(Sr(t)|0)!=0:0){if((de[t+75>>0]|0)!=(e|0)?(i=t+20|0,n=pe[i>>2]|0,n>>>0<(pe[t+16>>2]|0)>>>0):0){pe[i>>2]=n+1;de[n>>0]=e;r=e&255}else r=Mr(t,e)|0;Er(t)}else a=3;do{if((a|0)==3){if((de[t+75>>0]|0)!=(e|0)?(o=t+20|0,r=pe[o>>2]|0,r>>>0<(pe[t+16>>2]|0)>>>0):0){pe[o>>2]=r+1;de[r>>0]=e;r=e&255;break}r=Mr(t,e)|0}}while(0);return r|0}function gr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;i=r+16|0;n=pe[i>>2]|0;if(!n)if(!(Ir(r)|0)){n=pe[i>>2]|0;o=4}else i=0;else o=4;e:do{if((o|0)==4){a=r+20|0;o=pe[a>>2]|0;if((n-o|0)>>>0>>0){i=Mi[pe[r+36>>2]&7](r,e,t)|0;break}t:do{if((de[r+75>>0]|0)>-1){i=t;while(1){if(!i){n=o;i=0;break t}n=i+-1|0;if((de[e+n>>0]|0)==10)break;else i=n}if((Mi[pe[r+36>>2]&7](r,e,i)|0)>>>0>>0)break e;t=t-i|0;e=e+i|0;n=pe[a>>2]|0}else{n=o;i=0}}while(0);Qr(n|0,e|0,t|0)|0;pe[a>>2]=(pe[a>>2]|0)+t;i=i+t|0}}while(0);return i|0}function yr(e,t){e=e|0;t=t|0;var r=0,i=0;r=be;be=be+16|0;i=r;pe[i>>2]=t;t=wr(pe[64]|0,e,i)|0;be=r;return t|0}function _r(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;i=be;be=be+16|0;n=i;pe[n>>2]=r;r=Tr(e,t,n)|0;be=i;return r|0}function wr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0;v=be;be=be+224|0;l=v+120|0;p=v+80|0;d=v;h=v+136|0;i=p;n=i+40|0;do{pe[i>>2]=0;i=i+4|0}while((i|0)<(n|0));pe[l>>2]=pe[r>>2];if((Dr(0,t,l,d,p)|0)<0)r=-1;else{if((pe[e+76>>2]|0)>-1)c=Sr(e)|0;else c=0;r=pe[e>>2]|0;f=r&32;if((de[e+74>>0]|0)<1)pe[e>>2]=r&-33;r=e+48|0;if(!(pe[r>>2]|0)){n=e+44|0;o=pe[n>>2]|0;pe[n>>2]=h;a=e+28|0;pe[a>>2]=h;s=e+20|0;pe[s>>2]=h;pe[r>>2]=80;u=e+16|0;pe[u>>2]=h+80;i=Dr(e,t,l,d,p)|0;if(o){Mi[pe[e+36>>2]&7](e,0,0)|0;i=(pe[s>>2]|0)==0?-1:i;pe[n>>2]=o;pe[r>>2]=0;pe[u>>2]=0;pe[a>>2]=0;pe[s>>2]=0}}else i=Dr(e,t,l,d,p)|0;r=pe[e>>2]|0;pe[e>>2]=r|f;if(c)Er(e);r=(r&32|0)==0?i:-1}be=v;return r|0}function xr(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0,f=0;f=be;be=be+128|0;n=f+112|0;c=f;o=c;a=268;s=o+112|0;do{pe[o>>2]=pe[a>>2];o=o+4|0;a=a+4|0}while((o|0)<(s|0));if((t+-1|0)>>>0>2147483646)if(!t){t=1;u=4}else{t=fr()|0;pe[t>>2]=75;t=-1}else{n=e;u=4}if((u|0)==4){u=-2-n|0;u=t>>>0>u>>>0?u:t;pe[c+48>>2]=u;e=c+20|0;pe[e>>2]=n;pe[c+44>>2]=n;t=n+u|0;n=c+16|0;pe[n>>2]=t;pe[c+28>>2]=t;t=wr(c,r,i)|0;if(u){r=pe[e>>2]|0;de[r+(((r|0)==(pe[n>>2]|0))<<31>>31)>>0]=0}}be=f;return t|0}function Tr(e,t,r){e=e|0;t=t|0;r=r|0;return xr(e,2147483647,t,r)|0}function Sr(e){e=e|0;return 0}function Er(e){e=e|0;return}function Mr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0;u=be;be=be+16|0;s=u;a=t&255;de[s>>0]=a;i=e+16|0;n=pe[i>>2]|0;if(!n)if(!(Ir(e)|0)){n=pe[i>>2]|0;o=4}else r=-1;else o=4;do{if((o|0)==4){i=e+20|0;o=pe[i>>2]|0;if(o>>>0>>0?(r=t&255,(r|0)!=(de[e+75>>0]|0)):0){pe[i>>2]=o+1;de[o>>0]=a;break}if((Mi[pe[e+36>>2]&7](e,s,1)|0)==1)r=ve[s>>0]|0;else r=-1}}while(0);be=u;return r|0}function Cr(e){e=e|0;var t=0,r=0;t=be;be=be+16|0;r=t;pe[r>>2]=pe[e+60>>2];e=lr(Me(6,r|0)|0)|0;be=t;return e|0}function Pr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0;n=be;be=be+32|0;o=n;i=n+20|0;pe[o>>2]=pe[e+60>>2];pe[o+4>>2]=0;pe[o+8>>2]=t;pe[o+12>>2]=i;pe[o+16>>2]=r;if((lr(He(140,o|0)|0)|0)<0){pe[i>>2]=-1;e=-1}else e=pe[i>>2]|0;be=n;return e|0}function Ar(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;p=be;be=be+48|0;l=p+16|0;f=p;i=p+32|0;h=e+28|0;n=pe[h>>2]|0;pe[i>>2]=n;d=e+20|0;n=(pe[d>>2]|0)-n|0;pe[i+4>>2]=n;pe[i+8>>2]=t;pe[i+12>>2]=r;u=e+60|0;c=e+44|0;t=2;n=n+r|0;while(1){if(!(pe[52]|0)){pe[l>>2]=pe[u>>2];pe[l+4>>2]=i;pe[l+8>>2]=t;a=lr(Ve(146,l|0)|0)|0}else{qe(7,e|0);pe[f>>2]=pe[u>>2];pe[f+4>>2]=i;pe[f+8>>2]=t;a=lr(Ve(146,f|0)|0)|0;Se(0)}if((n|0)==(a|0)){n=6;break}if((a|0)<0){n=8;break}n=n-a|0;o=pe[i+4>>2]|0;if(a>>>0<=o>>>0)if((t|0)==2){pe[h>>2]=(pe[h>>2]|0)+a;s=o;t=2}else s=o;else{s=pe[c>>2]|0;pe[h>>2]=s;pe[d>>2]=s;s=pe[i+12>>2]|0;a=a-o|0;i=i+8|0;t=t+-1|0}pe[i>>2]=(pe[i>>2]|0)+a;pe[i+4>>2]=s-a}if((n|0)==6){l=pe[c>>2]|0;pe[e+16>>2]=l+(pe[e+48>>2]|0);e=l;pe[h>>2]=e;pe[d>>2]=e}else if((n|0)==8){pe[e+16>>2]=0;pe[h>>2]=0;pe[d>>2]=0;pe[e>>2]=pe[e>>2]|32;if((t|0)==2)r=0;else r=r-(pe[i+4>>2]|0)|0}be=p;return r|0}function kr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;n=be;be=be+80|0;i=n;pe[e+36>>2]=3;if((pe[e>>2]&64|0)==0?(pe[i>>2]=pe[e+60>>2],pe[i+4>>2]=21505,pe[i+8>>2]=n+12,(Ee(54,i|0)|0)!=0):0)de[e+75>>0]=-1;i=Ar(e,t,r)|0;be=n;return i|0}function Ir(e){e=e|0;var t=0,r=0;t=e+74|0;r=de[t>>0]|0;de[t>>0]=r+255|r;t=pe[e>>2]|0;if(!(t&8)){pe[e+8>>2]=0;pe[e+4>>2]=0;t=pe[e+44>>2]|0;pe[e+28>>2]=t;pe[e+20>>2]=t;pe[e+16>>2]=t+(pe[e+48>>2]|0);t=0}else{pe[e>>2]=t|32;t=-1}return t|0}function Rr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;o=t&255;i=(r|0)!=0;e:do{if(i&(e&3|0)!=0){n=t&255;while(1){if((de[e>>0]|0)==n<<24>>24){a=6;break e}e=e+1|0;r=r+-1|0;i=(r|0)!=0;if(!(i&(e&3|0)!=0)){a=5;break}}}else a=5}while(0);if((a|0)==5)if(i)a=6;else r=0;e:do{if((a|0)==6){n=t&255;if((de[e>>0]|0)!=n<<24>>24){i=ge(o,16843009)|0;t:do{if(r>>>0>3)while(1){o=pe[e>>2]^i;if((o&-2139062144^-2139062144)&o+-16843009)break;e=e+4|0;r=r+-4|0;if(r>>>0<=3){a=11;break t}}else a=11}while(0);if((a|0)==11)if(!r){r=0;break}while(1){if((de[e>>0]|0)==n<<24>>24)break e;e=e+1|0;r=r+-1|0;if(!r){r=0;break}}}}}while(0);return((r|0)!=0?e:0)|0}function Or(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0;t=e+20|0;o=e+28|0;if((pe[t>>2]|0)>>>0>(pe[o>>2]|0)>>>0?(Mi[pe[e+36>>2]&7](e,0,0)|0,(pe[t>>2]|0)==0):0)t=-1;else{a=e+4|0;r=pe[a>>2]|0;i=e+8|0;n=pe[i>>2]|0;if(r>>>0>>0)Mi[pe[e+40>>2]&7](e,r-n|0,1)|0;pe[e+16>>2]=0;pe[o>>2]=0;pe[t>>2]=0;pe[i>>2]=0;pe[a>>2]=0;t=0}return t|0}function Dr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0.0,f=0,l=0,h=0,d=0,p=0.0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0,B=0,N=0,U=0,z=0,X=0,q=0,G=0,H=0,V=0,W=0,Y=0,K=0,J=0,Z=0,Q=0;Q=be;be=be+624|0;W=Q+24|0;K=Q+16|0;Y=Q+588|0;X=Q+576|0;V=Q;N=Q+536|0;Z=Q+8|0;J=Q+528|0;k=(e|0)!=0;I=N+40|0;B=I;N=N+39|0;U=Z+4|0;z=X+12|0;X=X+11|0;q=Y;G=z;H=G-q|0;R=-2-q|0;O=G+2|0;D=W+288|0;L=Y+9|0;j=L;F=Y+8|0;o=0;v=t;a=0;t=0;e:while(1){do{if((o|0)>-1)if((a|0)>(2147483647-o|0)){o=fr()|0;pe[o>>2]=75;o=-1;break}else{o=a+o|0;break}}while(0);a=de[v>>0]|0;if(!(a<<24>>24)){A=245;break}else s=v;t:while(1){switch(a<<24>>24){case 37:{a=s;A=9;break t}case 0:{a=s;break t}default:{}}P=s+1|0;a=de[P>>0]|0;s=P}t:do{if((A|0)==9)while(1){A=0;if((de[a+1>>0]|0)!=37)break t;s=s+1|0;a=a+2|0;if((de[a>>0]|0)==37)A=9;else break}}while(0);b=s-v|0;if(k?(pe[e>>2]&32|0)==0:0)gr(v,b,e)|0;if((s|0)!=(v|0)){v=a;a=b;continue}f=a+1|0;s=de[f>>0]|0;u=(s<<24>>24)+-48|0;if(u>>>0<10){P=(de[a+2>>0]|0)==36;f=P?a+3|0:f;s=de[f>>0]|0;d=P?u:-1;t=P?1:t}else d=-1;a=s<<24>>24;t:do{if((a&-32|0)==32){u=0;while(1){if(!(1<>24)+-32|u;f=f+1|0;s=de[f>>0]|0;a=s<<24>>24;if((a&-32|0)!=32){l=u;a=f;break}}}else{l=0;a=f}}while(0);do{if(s<<24>>24==42){u=a+1|0;s=(de[u>>0]|0)+-48|0;if(s>>>0<10?(de[a+2>>0]|0)==36:0){pe[n+(s<<2)>>2]=10;t=1;a=a+3|0;s=pe[i+((de[u>>0]|0)+-48<<3)>>2]|0}else{if(t){o=-1;break e}if(!k){m=l;a=u;t=0;P=0;break}t=(pe[r>>2]|0)+(4-1)&~(4-1);s=pe[t>>2]|0;pe[r>>2]=t+4;t=0;a=u}if((s|0)<0){m=l|8192;P=0-s|0}else{m=l;P=s}}else{u=(s<<24>>24)+-48|0;if(u>>>0<10){s=0;do{s=(s*10|0)+u|0;a=a+1|0;u=(de[a>>0]|0)+-48|0}while(u>>>0<10);if((s|0)<0){o=-1;break e}else{m=l;P=s}}else{m=l;P=0}}}while(0);t:do{if((de[a>>0]|0)==46){u=a+1|0;s=de[u>>0]|0;if(s<<24>>24!=42){f=(s<<24>>24)+-48|0;if(f>>>0<10){a=u;s=0}else{a=u;f=0;break}while(1){s=(s*10|0)+f|0;a=a+1|0;f=(de[a>>0]|0)+-48|0;if(f>>>0>=10){f=s;break t}}}u=a+2|0;s=(de[u>>0]|0)+-48|0;if(s>>>0<10?(de[a+3>>0]|0)==36:0){pe[n+(s<<2)>>2]=10;a=a+4|0;f=pe[i+((de[u>>0]|0)+-48<<3)>>2]|0;break}if(t){o=-1;break e}if(k){a=(pe[r>>2]|0)+(4-1)&~(4-1);f=pe[a>>2]|0;pe[r>>2]=a+4;a=u}else{a=u;f=0}}else f=-1}while(0);h=0;while(1){s=(de[a>>0]|0)+-65|0;if(s>>>0>57){o=-1;break e}u=a+1|0;s=de[5359+(h*58|0)+s>>0]|0;l=s&255;if((l+-1|0)>>>0<8){a=u;h=l}else{C=u;break}}if(!(s<<24>>24)){o=-1;break}u=(d|0)>-1;do{if(s<<24>>24==19)if(u){o=-1;break e}else A=52;else{if(u){pe[n+(d<<2)>>2]=l;E=i+(d<<3)|0;M=pe[E+4>>2]|0;A=V;pe[A>>2]=pe[E>>2];pe[A+4>>2]=M;A=52;break}if(!k){o=0;break e}Fr(V,l,r)}}while(0);if((A|0)==52?(A=0,!k):0){v=C;a=b;continue}d=de[a>>0]|0;d=(h|0)!=0&(d&15|0)==3?d&-33:d;u=m&-65537;M=(m&8192|0)==0?m:u;t:do{switch(d|0){case 110:switch(h|0){case 0:{pe[pe[V>>2]>>2]=o;v=C;a=b;continue e}case 1:{pe[pe[V>>2]>>2]=o;v=C;a=b;continue e}case 2:{v=pe[V>>2]|0;pe[v>>2]=o;pe[v+4>>2]=((o|0)<0)<<31>>31;v=C;a=b;continue e}case 3:{$[pe[V>>2]>>1]=o;v=C;a=b;continue e}case 4:{de[pe[V>>2]>>0]=o;v=C;a=b;continue e}case 6:{pe[pe[V>>2]>>2]=o;v=C;a=b;continue e}case 7:{v=pe[V>>2]|0;pe[v>>2]=o;pe[v+4>>2]=((o|0)<0)<<31>>31;v=C;a=b;continue e}default:{v=C;a=b;continue e}}case 112:{h=M|8;f=f>>>0>8?f:8;d=120;A=64;break}case 88:case 120:{h=M;A=64;break}case 111:{u=V;s=pe[u>>2]|0;u=pe[u+4>>2]|0;if((s|0)==0&(u|0)==0)a=I;else{a=I;do{a=a+-1|0;de[a>>0]=s&7|48;s=Kr(s|0,u|0,3)|0;u=re}while(!((s|0)==0&(u|0)==0))}if(!(M&8)){s=M;h=0;l=5839;A=77}else{h=B-a+1|0;s=M;f=(f|0)<(h|0)?h:f;h=0;l=5839;A=77}break}case 105:case 100:{s=V;a=pe[s>>2]|0;s=pe[s+4>>2]|0;if((s|0)<0){a=Wr(0,0,a|0,s|0)|0;s=re;u=V;pe[u>>2]=a;pe[u+4>>2]=s;u=1;l=5839;A=76;break t}if(!(M&2048)){l=M&1;u=l;l=(l|0)==0?5839:5841;A=76}else{u=1;l=5840;A=76}break}case 117:{s=V;a=pe[s>>2]|0;s=pe[s+4>>2]|0;u=0;l=5839;A=76;break}case 99:{de[N>>0]=pe[V>>2];v=N;s=1;h=0;d=5839;a=I;break}case 109:{a=fr()|0;a=cr(pe[a>>2]|0)|0;A=82;break}case 115:{a=pe[V>>2]|0;a=(a|0)!=0?a:5849;A=82;break}case 67:{pe[Z>>2]=pe[V>>2];pe[U>>2]=0;pe[V>>2]=Z;f=-1;A=86;break}case 83:{if(!f){Nr(e,32,P,0,M);a=0;A=98}else A=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{c=+ee[V>>3];pe[K>>2]=0;ee[te>>3]=c;if((pe[te+4>>2]|0)>=0)if(!(M&2048)){E=M&1;S=E;E=(E|0)==0?5857:5862}else{S=1;E=5859}else{c=-c;S=1;E=5856}ee[te>>3]=c;T=pe[te+4>>2]&2146435072;do{if(T>>>0<2146435072|(T|0)==2146435072&0<0){p=+dr(c,K)*2.0;s=p!=0.0;if(s)pe[K>>2]=(pe[K>>2]|0)+-1;w=d|32;if((w|0)==97){v=d&32;b=(v|0)==0?E:E+9|0;m=S|2;a=12-f|0;do{if(!(f>>>0>11|(a|0)==0)){c=8.0;do{a=a+-1|0;c=c*16.0}while((a|0)!=0);if((de[b>>0]|0)==45){c=-(c+(-p-c));break}else{c=p+c-c;break}}else c=p}while(0);s=pe[K>>2]|0;a=(s|0)<0?0-s|0:s;a=Br(a,((a|0)<0)<<31>>31,z)|0;if((a|0)==(z|0)){de[X>>0]=48;a=X}de[a+-1>>0]=(s>>31&2)+43;h=a+-2|0;de[h>>0]=d+15;l=(f|0)<1;u=(M&8|0)==0;s=Y;while(1){E=~~c;a=s+1|0;de[s>>0]=ve[5823+E>>0]|v;c=(c-+(E|0))*16.0;do{if((a-q|0)==1){if(u&(l&c==0.0))break;de[a>>0]=46;a=s+2|0}}while(0);if(!(c!=0.0))break;else s=a}f=(f|0)!=0&(R+a|0)<(f|0)?O+f-h|0:H-h+a|0;u=f+m|0;Nr(e,32,P,u,M);if(!(pe[e>>2]&32))gr(b,m,e)|0;Nr(e,48,P,u,M^65536);a=a-q|0;if(!(pe[e>>2]&32))gr(Y,a,e)|0;s=G-h|0;Nr(e,48,f-(a+s)|0,0,0);if(!(pe[e>>2]&32))gr(h,s,e)|0;Nr(e,32,P,u,M^8192);a=(u|0)<(P|0)?P:u;break}a=(f|0)<0?6:f;if(s){s=(pe[K>>2]|0)+-28|0;pe[K>>2]=s;c=p*268435456.0}else{c=p;s=pe[K>>2]|0}T=(s|0)<0?W:D;x=T;s=T;do{_=~~c>>>0;pe[s>>2]=_;s=s+4|0;c=(c-+(_>>>0))*1.0e9}while(c!=0.0);u=s;s=pe[K>>2]|0;if((s|0)>0){l=T;while(1){h=(s|0)>29?29:s;f=u+-4|0;do{if(f>>>0>>0)f=l;else{s=0;do{_=Jr(pe[f>>2]|0,0,h|0)|0;_=Zr(_|0,re|0,s|0,0)|0;s=re;y=ai(_|0,s|0,1e9,0)|0;pe[f>>2]=y;s=oi(_|0,s|0,1e9,0)|0;f=f+-4|0}while(f>>>0>=l>>>0);if(!s){f=l;break}f=l+-4|0;pe[f>>2]=s}}while(0);while(1){if(u>>>0<=f>>>0)break;s=u+-4|0;if(!(pe[s>>2]|0))u=s;else break}s=(pe[K>>2]|0)-h|0;pe[K>>2]=s;if((s|0)>0)l=f;else break}}else f=T;if((s|0)<0){b=((a+25|0)/9|0)+1|0;g=(w|0)==102;v=f;while(1){m=0-s|0;m=(m|0)>9?9:m;do{if(v>>>0>>0){s=(1<>>m;f=0;h=v;do{_=pe[h>>2]|0;pe[h>>2]=(_>>>m)+f;f=ge(_&s,l)|0;h=h+4|0}while(h>>>0>>0);s=(pe[v>>2]|0)==0?v+4|0:v;if(!f){f=s;break}pe[u>>2]=f;f=s;u=u+4|0}else f=(pe[v>>2]|0)==0?v+4|0:v}while(0);s=g?T:f;u=(u-s>>2|0)>(b|0)?s+(b<<2)|0:u;s=(pe[K>>2]|0)+m|0;pe[K>>2]=s;if((s|0)>=0){v=f;break}else v=f}}else v=f;do{if(v>>>0>>0){s=(x-v>>2)*9|0;l=pe[v>>2]|0;if(l>>>0<10)break;else f=10;do{f=f*10|0;s=s+1|0}while(l>>>0>=f>>>0)}else s=0}while(0);y=(w|0)==103;_=(a|0)!=0;f=a-((w|0)!=102?s:0)+((_&y)<<31>>31)|0;if((f|0)<(((u-x>>2)*9|0)+-9|0)){h=f+9216|0;g=(h|0)/9|0;f=T+(g+-1023<<2)|0;h=((h|0)%9|0)+1|0;if((h|0)<9){l=10;do{l=l*10|0;h=h+1|0}while((h|0)!=9)}else l=10;m=pe[f>>2]|0;b=(m>>>0)%(l>>>0)|0;if((b|0)==0?(T+(g+-1022<<2)|0)==(u|0):0)l=v;else A=163;do{if((A|0)==163){A=0;p=(((m>>>0)/(l>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;h=(l|0)/2|0;do{if(b>>>0>>0)c=.5;else{if((b|0)==(h|0)?(T+(g+-1022<<2)|0)==(u|0):0){c=1.0;break}c=1.5}}while(0);do{if(S){if((de[E>>0]|0)!=45)break;p=-p;c=-c}}while(0);h=m-b|0;pe[f>>2]=h;if(!(p+c!=p)){l=v;break}w=h+l|0;pe[f>>2]=w;if(w>>>0>999999999){s=v;while(1){l=f+-4|0;pe[f>>2]=0;if(l>>>0>>0){s=s+-4|0;pe[s>>2]=0}w=(pe[l>>2]|0)+1|0;pe[l>>2]=w;if(w>>>0>999999999)f=l;else{v=s;f=l;break}}}s=(x-v>>2)*9|0;h=pe[v>>2]|0;if(h>>>0<10){l=v;break}else l=10;do{l=l*10|0;s=s+1|0}while(h>>>0>=l>>>0);l=v}}while(0);w=f+4|0;v=l;u=u>>>0>w>>>0?w:u}b=0-s|0;while(1){if(u>>>0<=v>>>0){g=0;w=u;break}f=u+-4|0;if(!(pe[f>>2]|0))u=f;else{g=1;w=u;break}}do{if(y){a=(_&1^1)+a|0;if((a|0)>(s|0)&(s|0)>-5){d=d+-1|0;a=a+-1-s|0}else{d=d+-2|0;a=a+-1|0}u=M&8;if(u)break;do{if(g){u=pe[w+-4>>2]|0;if(!u){f=9;break}if(!((u>>>0)%10|0)){l=10;f=0}else{f=0;break}do{l=l*10|0;f=f+1|0}while(((u>>>0)%(l>>>0)|0|0)==0)}else f=9}while(0);u=((w-x>>2)*9|0)+-9|0;if((d|32|0)==102){u=u-f|0;u=(u|0)<0?0:u;a=(a|0)<(u|0)?a:u;u=0;break}else{u=u+s-f|0;u=(u|0)<0?0:u;a=(a|0)<(u|0)?a:u;u=0;break}}else u=M&8}while(0);m=a|u;l=(m|0)!=0&1;h=(d|32|0)==102;if(h){s=(s|0)>0?s:0;d=0}else{f=(s|0)<0?b:s;f=Br(f,((f|0)<0)<<31>>31,z)|0;if((G-f|0)<2)do{f=f+-1|0;de[f>>0]=48}while((G-f|0)<2);de[f+-1>>0]=(s>>31&2)+43;x=f+-2|0;de[x>>0]=d;s=G-x|0;d=x}b=S+1+a+l+s|0;Nr(e,32,P,b,M);if(!(pe[e>>2]&32))gr(E,S,e)|0;Nr(e,48,P,b,M^65536);do{if(h){f=v>>>0>T>>>0?T:v;s=f;do{u=Br(pe[s>>2]|0,0,L)|0;do{if((s|0)==(f|0)){if((u|0)!=(L|0))break;de[F>>0]=48;u=F}else{if(u>>>0<=Y>>>0)break;do{u=u+-1|0;de[u>>0]=48}while(u>>>0>Y>>>0)}}while(0);if(!(pe[e>>2]&32))gr(u,j-u|0,e)|0;s=s+4|0}while(s>>>0<=T>>>0);do{if(m){if(pe[e>>2]&32)break;gr(5891,1,e)|0}}while(0);if((a|0)>0&s>>>0>>0){u=s;while(1){s=Br(pe[u>>2]|0,0,L)|0;if(s>>>0>Y>>>0)do{s=s+-1|0;de[s>>0]=48}while(s>>>0>Y>>>0);if(!(pe[e>>2]&32))gr(s,(a|0)>9?9:a,e)|0;u=u+4|0;s=a+-9|0;if(!((a|0)>9&u>>>0>>0)){a=s;break}else a=s}}Nr(e,48,a+9|0,9,0)}else{h=g?w:v+4|0;if((a|0)>-1){l=(u|0)==0;f=v;do{s=Br(pe[f>>2]|0,0,L)|0;if((s|0)==(L|0)){de[F>>0]=48;s=F}do{if((f|0)==(v|0)){u=s+1|0;if(!(pe[e>>2]&32))gr(s,1,e)|0;if(l&(a|0)<1){s=u;break}if(pe[e>>2]&32){s=u;break}gr(5891,1,e)|0;s=u}else{if(s>>>0<=Y>>>0)break;do{s=s+-1|0;de[s>>0]=48}while(s>>>0>Y>>>0)}}while(0);u=j-s|0;if(!(pe[e>>2]&32))gr(s,(a|0)>(u|0)?u:a,e)|0;a=a-u|0;f=f+4|0}while(f>>>0>>0&(a|0)>-1)}Nr(e,48,a+18|0,18,0);if(pe[e>>2]&32)break;gr(d,G-d|0,e)|0}}while(0);Nr(e,32,P,b,M^8192);a=(b|0)<(P|0)?P:b}else{h=(d&32|0)!=0;l=c!=c|0.0!=0.0;s=l?0:S;f=s+3|0;Nr(e,32,P,f,u);a=pe[e>>2]|0;if(!(a&32)){gr(E,s,e)|0;a=pe[e>>2]|0}if(!(a&32))gr(l?h?5883:5887:h?5875:5879,3,e)|0;Nr(e,32,P,f,M^8192);a=(f|0)<(P|0)?P:f}}while(0);v=C;continue e}default:{u=M;s=f;h=0;d=5839;a=I}}}while(0);t:do{if((A|0)==64){u=V;s=pe[u>>2]|0;u=pe[u+4>>2]|0;l=d&32;if(!((s|0)==0&(u|0)==0)){a=I;do{a=a+-1|0;de[a>>0]=ve[5823+(s&15)>>0]|l;s=Kr(s|0,u|0,4)|0;u=re}while(!((s|0)==0&(u|0)==0));A=V;if((h&8|0)==0|(pe[A>>2]|0)==0&(pe[A+4>>2]|0)==0){s=h;h=0;l=5839;A=77}else{s=h;h=2;l=5839+(d>>4)|0;A=77}}else{a=I;s=h;h=0;l=5839;A=77}}else if((A|0)==76){a=Br(a,s,I)|0;s=M;h=u;A=77}else if((A|0)==82){A=0;M=Rr(a,0,f)|0;E=(M|0)==0;v=a;s=E?f:M-a|0;h=0;d=5839;a=E?a+f|0:M}else if((A|0)==86){A=0;s=0;a=0;l=pe[V>>2]|0;while(1){u=pe[l>>2]|0;if(!u)break;a=vr(J,u)|0;if((a|0)<0|a>>>0>(f-s|0)>>>0)break;s=a+s|0;if(f>>>0>s>>>0)l=l+4|0;else break}if((a|0)<0){o=-1;break e}Nr(e,32,P,s,M);if(!s){a=0;A=98}else{u=0;f=pe[V>>2]|0;while(1){a=pe[f>>2]|0;if(!a){a=s;A=98;break t}a=vr(J,a)|0;u=a+u|0;if((u|0)>(s|0)){a=s;A=98;break t}if(!(pe[e>>2]&32))gr(J,a,e)|0;if(u>>>0>=s>>>0){a=s;A=98;break}else f=f+4|0}}}}while(0);if((A|0)==98){A=0;Nr(e,32,P,a,M^8192);v=C;a=(P|0)>(a|0)?P:a;continue}if((A|0)==77){A=0;u=(f|0)>-1?s&-65537:s;s=V;s=(pe[s>>2]|0)!=0|(pe[s+4>>2]|0)!=0;if((f|0)!=0|s){s=(s&1^1)+(B-a)|0;v=a;s=(f|0)>(s|0)?f:s;d=l;a=I}else{v=I;s=0;d=l;a=I}}l=a-v|0;s=(s|0)<(l|0)?l:s;f=h+s|0;a=(P|0)<(f|0)?f:P;Nr(e,32,a,f,u);if(!(pe[e>>2]&32))gr(d,h,e)|0;Nr(e,48,a,f,u^65536);Nr(e,48,s,l,0);if(!(pe[e>>2]&32))gr(v,l,e)|0;Nr(e,32,a,f,u^8192);v=C}e:do{if((A|0)==245)if(!e)if(t){o=1;while(1){t=pe[n+(o<<2)>>2]|0;if(!t)break;Fr(i+(o<<3)|0,t,r);o=o+1|0;if((o|0)>=10){o=1;break e}}if((o|0)<10)while(1){if(pe[n+(o<<2)>>2]|0){o=-1;break e}o=o+1|0;if((o|0)>=10){o=1;break}}else o=1}else o=0}while(0);be=Q;return o|0}function Lr(e){e=e|0;if(!(pe[e+68>>2]|0))Er(e);return}function jr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;i=e+20|0;n=pe[i>>2]|0;e=(pe[e+16>>2]|0)-n|0;e=e>>>0>r>>>0?r:e;Qr(n|0,t|0,e|0)|0;pe[i>>2]=(pe[i>>2]|0)+e;return r|0}function Fr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0.0;e:do{if(t>>>0<=20)do{switch(t|0){case 9:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;pe[e>>2]=t;break e}case 10:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;i=e;pe[i>>2]=t;pe[i+4>>2]=((t|0)<0)<<31>>31;break e}case 11:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;i=e;pe[i>>2]=t;pe[i+4>>2]=0;break e}case 12:{i=(pe[r>>2]|0)+(8-1)&~(8-1);t=i;n=pe[t>>2]|0;t=pe[t+4>>2]|0;pe[r>>2]=i+8;i=e;pe[i>>2]=n;pe[i+4>>2]=t;break e}case 13:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;i=(i&65535)<<16>>16;n=e;pe[n>>2]=i;pe[n+4>>2]=((i|0)<0)<<31>>31;break e}case 14:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;n=e;pe[n>>2]=i&65535;pe[n+4>>2]=0;break e}case 15:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;i=(i&255)<<24>>24;n=e;pe[n>>2]=i;pe[n+4>>2]=((i|0)<0)<<31>>31;break e}case 16:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;n=e;pe[n>>2]=i&255;pe[n+4>>2]=0;break e}case 17:{n=(pe[r>>2]|0)+(8-1)&~(8-1);o=+ee[n>>3];pe[r>>2]=n+8;ee[e>>3]=o;break e}case 18:{n=(pe[r>>2]|0)+(8-1)&~(8-1);o=+ee[n>>3];pe[r>>2]=n+8;ee[e>>3]=o;break e}default:break e}}while(0)}while(0);return}function Br(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(t>>>0>0|(t|0)==0&e>>>0>4294967295)while(1){i=ai(e|0,t|0,10,0)|0;r=r+-1|0;de[r>>0]=i|48;i=oi(e|0,t|0,10,0)|0;if(t>>>0>9|(t|0)==9&e>>>0>4294967295){e=i;t=re}else{e=i;break}}if(e)while(1){r=r+-1|0;de[r>>0]=(e>>>0)%10|0|48;if(e>>>0<10)break;else e=(e>>>0)/10|0}return r|0}function Nr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0;s=be;be=be+256|0;a=s;do{if((r|0)>(i|0)&(n&73728|0)==0){n=r-i|0;Yr(a|0,t|0,(n>>>0>256?256:n)|0)|0;t=pe[e>>2]|0;o=(t&32|0)==0;if(n>>>0>255){i=r-i|0;do{if(o){gr(a,256,e)|0;t=pe[e>>2]|0}n=n+-256|0;o=(t&32|0)==0}while(n>>>0>255);if(o)n=i&255;else break}else if(!o)break;gr(a,n,e)|0}}while(0);be=s;return}function Ur(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,M=0,C=0,P=0,A=0,k=0,I=0,R=0,O=0,D=0,L=0,j=0,F=0;do{if(e>>>0<245){d=e>>>0<11?16:e+11&-8;e=d>>>3;s=pe[151]|0;r=s>>>e;if(r&3){e=(r&1^1)+e|0;i=e<<1;r=644+(i<<2)|0;i=644+(i+2<<2)|0;n=pe[i>>2]|0;o=n+8|0;a=pe[o>>2]|0;do{if((r|0)!=(a|0)){if(a>>>0<(pe[155]|0)>>>0)Xe();t=a+12|0;if((pe[t>>2]|0)==(n|0)){pe[t>>2]=r;pe[i>>2]=a;break}else Xe()}else pe[151]=s&~(1<>2]=F|3;F=n+(F|4)|0;pe[F>>2]=pe[F>>2]|1;F=o;return F|0}a=pe[153]|0;if(d>>>0>a>>>0){if(r){i=2<>>12&16;i=i>>>u;n=i>>>5&8;i=i>>>n;o=i>>>2&4;i=i>>>o;r=i>>>1&2;i=i>>>r;e=i>>>1&1;e=(n|u|o|r|e)+(i>>>e)|0;i=e<<1;r=644+(i<<2)|0;i=644+(i+2<<2)|0;o=pe[i>>2]|0;u=o+8|0;n=pe[u>>2]|0;do{if((r|0)!=(n|0)){if(n>>>0<(pe[155]|0)>>>0)Xe();t=n+12|0;if((pe[t>>2]|0)==(o|0)){pe[t>>2]=r;pe[i>>2]=n;c=pe[153]|0;break}else Xe()}else{pe[151]=s&~(1<>2]=d|3;s=o+d|0;pe[o+(d|4)>>2]=a|1;pe[o+F>>2]=a;if(c){n=pe[156]|0;r=c>>>3;t=r<<1;i=644+(t<<2)|0;e=pe[151]|0;r=1<>2]|0;if(t>>>0<(pe[155]|0)>>>0)Xe();else{f=e;l=t}}else{pe[151]=e|r;f=644+(t+2<<2)|0;l=i}pe[f>>2]=n;pe[l+12>>2]=n;pe[n+8>>2]=l;pe[n+12>>2]=i}pe[153]=a;pe[156]=s;F=u;return F|0}e=pe[152]|0;if(e){r=(e&0-e)+-1|0;j=r>>>12&16;r=r>>>j;L=r>>>5&8;r=r>>>L;F=r>>>2&4;r=r>>>F;e=r>>>1&2;r=r>>>e;i=r>>>1&1;i=pe[908+((L|j|F|e|i)+(r>>>i)<<2)>>2]|0;r=(pe[i+4>>2]&-8)-d|0;e=i;while(1){t=pe[e+16>>2]|0;if(!t){t=pe[e+20>>2]|0;if(!t){u=r;break}}e=(pe[t+4>>2]&-8)-d|0;F=e>>>0>>0;r=F?e:r;e=t;i=F?t:i}o=pe[155]|0;if(i>>>0>>0)Xe();s=i+d|0;if(i>>>0>=s>>>0)Xe();a=pe[i+24>>2]|0;r=pe[i+12>>2]|0;do{if((r|0)==(i|0)){e=i+20|0;t=pe[e>>2]|0;if(!t){e=i+16|0;t=pe[e>>2]|0;if(!t){h=0;break}}while(1){r=t+20|0;n=pe[r>>2]|0;if(n){t=n;e=r;continue}r=t+16|0;n=pe[r>>2]|0;if(!n)break;else{t=n;e=r}}if(e>>>0>>0)Xe();else{pe[e>>2]=0;h=t;break}}else{n=pe[i+8>>2]|0;if(n>>>0>>0)Xe();t=n+12|0;if((pe[t>>2]|0)!=(i|0))Xe();e=r+8|0;if((pe[e>>2]|0)==(i|0)){pe[t>>2]=r;pe[e>>2]=n;h=r;break}else Xe()}}while(0);do{if(a){t=pe[i+28>>2]|0;e=908+(t<<2)|0;if((i|0)==(pe[e>>2]|0)){pe[e>>2]=h;if(!h){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(i|0))pe[t>>2]=h;else pe[a+20>>2]=h;if(!h)break}e=pe[155]|0;if(h>>>0>>0)Xe();pe[h+24>>2]=a;t=pe[i+16>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[h+16>>2]=t;pe[t+24>>2]=h;break}}while(0);t=pe[i+20>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[h+20>>2]=t;pe[t+24>>2]=h;break}}}while(0);if(u>>>0<16){F=u+d|0;pe[i+4>>2]=F|3;F=i+(F+4)|0;pe[F>>2]=pe[F>>2]|1}else{pe[i+4>>2]=d|3;pe[i+(d|4)>>2]=u|1;pe[i+(u+d)>>2]=u;t=pe[153]|0;if(t){o=pe[156]|0;r=t>>>3;t=r<<1;n=644+(t<<2)|0;e=pe[151]|0;r=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{p=t;v=e}}else{pe[151]=e|r;p=644+(t+2<<2)|0;v=n}pe[p>>2]=o;pe[v+12>>2]=o;pe[o+8>>2]=v;pe[o+12>>2]=n}pe[153]=u;pe[156]=s}F=i+8|0;return F|0}else v=d}else v=d}else if(e>>>0<=4294967231){e=e+11|0;l=e&-8;f=pe[152]|0;if(f){r=0-l|0;e=e>>>8;if(e)if(l>>>0>16777215)c=31;else{v=(e+1048320|0)>>>16&8;_=e<>>16&4;_=_<>>16&2;c=14-(p|v|c)+(_<>>15)|0;c=l>>>(c+7|0)&1|c<<1}else c=0;e=pe[908+(c<<2)>>2]|0;e:do{if(!e){n=0;e=0;_=86}else{a=r;n=0;s=l<<((c|0)==31?0:25-(c>>>1)|0);u=e;e=0;while(1){o=pe[u+4>>2]&-8;r=o-l|0;if(r>>>0>>0)if((o|0)==(l|0)){o=u;e=u;_=90;break e}else e=u;else r=a;_=pe[u+20>>2]|0;u=pe[u+16+(s>>>31<<2)>>2]|0;n=(_|0)==0|(_|0)==(u|0)?n:_;if(!u){_=86;break}else{a=r;s=s<<1}}}}while(0);if((_|0)==86){if((n|0)==0&(e|0)==0){e=2<>>12&16;e=e>>>h;f=e>>>5&8;e=e>>>f;p=e>>>2&4;e=e>>>p;v=e>>>1&2;e=e>>>v;n=e>>>1&1;n=pe[908+((f|h|p|v|n)+(e>>>n)<<2)>>2]|0;e=0}if(!n){s=r;u=e}else{o=n;_=90}}if((_|0)==90)while(1){_=0;v=(pe[o+4>>2]&-8)-l|0;n=v>>>0>>0;r=n?v:r;e=n?o:e;n=pe[o+16>>2]|0;if(n){o=n;_=90;continue}o=pe[o+20>>2]|0;if(!o){s=r;u=e;break}else _=90}if((u|0)!=0?s>>>0<((pe[153]|0)-l|0)>>>0:0){n=pe[155]|0;if(u>>>0>>0)Xe();a=u+l|0;if(u>>>0>=a>>>0)Xe();o=pe[u+24>>2]|0;r=pe[u+12>>2]|0;do{if((r|0)==(u|0)){e=u+20|0;t=pe[e>>2]|0;if(!t){e=u+16|0;t=pe[e>>2]|0;if(!t){d=0;break}}while(1){r=t+20|0;i=pe[r>>2]|0;if(i){t=i;e=r;continue}r=t+16|0;i=pe[r>>2]|0;if(!i)break;else{t=i;e=r}}if(e>>>0>>0)Xe();else{pe[e>>2]=0;d=t;break}}else{i=pe[u+8>>2]|0;if(i>>>0>>0)Xe();t=i+12|0;if((pe[t>>2]|0)!=(u|0))Xe();e=r+8|0;if((pe[e>>2]|0)==(u|0)){pe[t>>2]=r;pe[e>>2]=i;d=r;break}else Xe()}}while(0);do{if(o){t=pe[u+28>>2]|0;e=908+(t<<2)|0;if((u|0)==(pe[e>>2]|0)){pe[e>>2]=d;if(!d){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=o+16|0;if((pe[t>>2]|0)==(u|0))pe[t>>2]=d;else pe[o+20>>2]=d;if(!d)break}e=pe[155]|0;if(d>>>0>>0)Xe();pe[d+24>>2]=o;t=pe[u+16>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[d+16>>2]=t;pe[t+24>>2]=d;break}}while(0);t=pe[u+20>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[d+20>>2]=t;pe[t+24>>2]=d;break}}}while(0);e:do{if(s>>>0>=16){pe[u+4>>2]=l|3;pe[u+(l|4)>>2]=s|1;pe[u+(s+l)>>2]=s;t=s>>>3;if(s>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{b=t;g=e}}else{pe[151]=r|t;b=644+(e+2<<2)|0;g=i}pe[b>>2]=a;pe[g+12>>2]=a;pe[u+(l+8)>>2]=g;pe[u+(l+12)>>2]=i;break}t=s>>>8;if(t)if(s>>>0>16777215)i=31;else{j=(t+1048320|0)>>>16&8;F=t<>>16&4;F=F<>>16&2;i=14-(L|j|i)+(F<>>15)|0;i=s>>>(i+7|0)&1|i<<1}else i=0;t=908+(i<<2)|0;pe[u+(l+28)>>2]=i;pe[u+(l+20)>>2]=0;pe[u+(l+16)>>2]=0;e=pe[152]|0;r=1<>2]=a;pe[u+(l+24)>>2]=t;pe[u+(l+12)>>2]=a;pe[u+(l+8)>>2]=a;break}t=pe[t>>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(s|0)){i=s<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(s|0)){T=r;break t}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=a;pe[u+(l+24)>>2]=t;pe[u+(l+12)>>2]=a;pe[u+(l+8)>>2]=a;break e}}else T=t}while(0);t=T+8|0;e=pe[t>>2]|0;F=pe[155]|0;if(e>>>0>=F>>>0&T>>>0>=F>>>0){pe[e+12>>2]=a;pe[t>>2]=a;pe[u+(l+8)>>2]=e;pe[u+(l+12)>>2]=T;pe[u+(l+24)>>2]=0;break}else Xe()}else{F=s+l|0;pe[u+4>>2]=F|3;F=u+(F+4)|0;pe[F>>2]=pe[F>>2]|1}}while(0);F=u+8|0;return F|0}else v=l}else v=l}else v=-1}while(0);r=pe[153]|0;if(r>>>0>=v>>>0){t=r-v|0;e=pe[156]|0;if(t>>>0>15){pe[156]=e+v;pe[153]=t;pe[e+(v+4)>>2]=t|1;pe[e+r>>2]=t;pe[e+4>>2]=v|3}else{pe[153]=0;pe[156]=0;pe[e+4>>2]=r|3;F=e+(r+4)|0;pe[F>>2]=pe[F>>2]|1}F=e+8|0;return F|0}e=pe[154]|0;if(e>>>0>v>>>0){j=e-v|0;pe[154]=j;F=pe[157]|0;pe[157]=F+v;pe[F+(v+4)>>2]=j|1;pe[F+4>>2]=v|3;F=F+8|0;return F|0}do{if(!(pe[269]|0)){e=Oe(30)|0;if(!(e+-1&e)){pe[271]=e;pe[270]=e;pe[272]=-1;pe[273]=-1;pe[274]=0;pe[262]=0;T=(Ge(0)|0)&-16^1431655768;pe[269]=T;break}else Xe()}}while(0);u=v+48|0;s=pe[271]|0;c=v+47|0;a=s+c|0;s=0-s|0;f=a&s;if(f>>>0<=v>>>0){F=0;return F|0}e=pe[261]|0;if((e|0)!=0?(g=pe[259]|0,T=g+f|0,T>>>0<=g>>>0|T>>>0>e>>>0):0){F=0;return F|0}e:do{if(!(pe[262]&4)){e=pe[157]|0;t:do{if(e){n=1052;while(1){r=pe[n>>2]|0;if(r>>>0<=e>>>0?(m=n+4|0,(r+(pe[m>>2]|0)|0)>>>0>e>>>0):0){o=n;e=m;break}n=pe[n+8>>2]|0;if(!n){_=174;break t}}r=a-(pe[154]|0)&s;if(r>>>0<2147483647){n=ke(r|0)|0;T=(n|0)==((pe[o>>2]|0)+(pe[e>>2]|0)|0);e=T?r:0;if(T){if((n|0)!=(-1|0)){w=n;p=e;_=194;break e}}else _=184}else e=0}else _=174}while(0);do{if((_|0)==174){o=ke(0)|0;if((o|0)!=(-1|0)){e=o;r=pe[270]|0;n=r+-1|0;if(!(n&e))r=f;else r=f-e+(n+e&0-r)|0;e=pe[259]|0;n=e+r|0;if(r>>>0>v>>>0&r>>>0<2147483647){T=pe[261]|0;if((T|0)!=0?n>>>0<=e>>>0|n>>>0>T>>>0:0){e=0;break}n=ke(r|0)|0;T=(n|0)==(o|0);e=T?r:0;if(T){w=o;p=e;_=194;break e}else _=184}else e=0}else e=0}}while(0);t:do{if((_|0)==184){o=0-r|0;do{if(u>>>0>r>>>0&(r>>>0<2147483647&(n|0)!=(-1|0))?(y=pe[271]|0,y=c-r+y&0-y,y>>>0<2147483647):0)if((ke(y|0)|0)==(-1|0)){ke(o|0)|0;break t}else{r=y+r|0;break}}while(0);if((n|0)!=(-1|0)){w=n;p=r;_=194;break e}}}while(0);pe[262]=pe[262]|4;_=191}else{e=0;_=191}}while(0);if((((_|0)==191?f>>>0<2147483647:0)?(w=ke(f|0)|0,x=ke(0)|0,w>>>0>>0&((w|0)!=(-1|0)&(x|0)!=(-1|0))):0)?(S=x-w|0,E=S>>>0>(v+40|0)>>>0,E):0){p=E?S:e;_=194}if((_|0)==194){e=(pe[259]|0)+p|0;pe[259]=e;if(e>>>0>(pe[260]|0)>>>0)pe[260]=e;a=pe[157]|0;e:do{if(a){o=1052;do{e=pe[o>>2]|0;r=o+4|0;n=pe[r>>2]|0;if((w|0)==(e+n|0)){M=e;C=r;P=n;A=o;_=204;break}o=pe[o+8>>2]|0}while((o|0)!=0);if(((_|0)==204?(pe[A+12>>2]&8|0)==0:0)?a>>>0>>0&a>>>0>=M>>>0:0){pe[C>>2]=P+p;F=(pe[154]|0)+p|0;j=a+8|0;j=(j&7|0)==0?0:0-j&7;L=F-j|0;pe[157]=a+j;pe[154]=L;pe[a+(j+4)>>2]=L|1;pe[a+(F+4)>>2]=40;pe[158]=pe[273];break}e=pe[155]|0;if(w>>>0>>0){pe[155]=w;e=w}r=w+p|0;o=1052;while(1){if((pe[o>>2]|0)==(r|0)){n=o;r=o;_=212;break}o=pe[o+8>>2]|0;if(!o){r=1052;break}}if((_|0)==212)if(!(pe[r+12>>2]&8)){pe[n>>2]=w;h=r+4|0;pe[h>>2]=(pe[h>>2]|0)+p;h=w+8|0;h=(h&7|0)==0?0:0-h&7;c=w+(p+8)|0;c=(c&7|0)==0?0:0-c&7;t=w+(c+p)|0;l=h+v|0;d=w+l|0;f=t-(w+h)-v|0;pe[w+(h+4)>>2]=v|3;t:do{if((t|0)!=(a|0)){if((t|0)==(pe[156]|0)){F=(pe[153]|0)+f|0;pe[153]=F;pe[156]=d;pe[w+(l+4)>>2]=F|1;pe[w+(F+l)>>2]=F;break}s=p+4|0;r=pe[w+(s+c)>>2]|0;if((r&3|0)==1){u=r&-8;o=r>>>3;r:do{if(r>>>0>=256){a=pe[w+((c|24)+p)>>2]|0;i=pe[w+(p+12+c)>>2]|0;do{if((i|0)==(t|0)){n=c|16;i=w+(s+n)|0;r=pe[i>>2]|0;if(!r){i=w+(n+p)|0;r=pe[i>>2]|0;if(!r){D=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;D=r;break}}else{n=pe[w+((c|8)+p)>>2]|0;if(n>>>0>>0)Xe();e=n+12|0;if((pe[e>>2]|0)!=(t|0))Xe();r=i+8|0;if((pe[r>>2]|0)==(t|0)){pe[e>>2]=i;pe[r>>2]=n;D=i;break}else Xe()}}while(0);if(!a)break;e=pe[w+(p+28+c)>>2]|0;r=908+(e<<2)|0;do{if((t|0)!=(pe[r>>2]|0)){if(a>>>0<(pe[155]|0)>>>0)Xe();e=a+16|0;if((pe[e>>2]|0)==(t|0))pe[e>>2]=D;else pe[a+20>>2]=D;if(!D)break r}else{pe[r>>2]=D;if(D)break;pe[152]=pe[152]&~(1<>>0>>0)Xe();pe[D+24>>2]=a;t=c|16;e=pe[w+(t+p)>>2]|0;do{if(e)if(e>>>0>>0)Xe();else{pe[D+16>>2]=e;pe[e+24>>2]=D;break}}while(0);t=pe[w+(s+t)>>2]|0;if(!t)break;if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[D+20>>2]=t;pe[t+24>>2]=D;break}}else{i=pe[w+((c|8)+p)>>2]|0;n=pe[w+(p+12+c)>>2]|0;r=644+(o<<1<<2)|0;do{if((i|0)!=(r|0)){if(i>>>0>>0)Xe();if((pe[i+12>>2]|0)==(t|0))break;Xe()}}while(0);if((n|0)==(i|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();e=n+8|0;if((pe[e>>2]|0)==(t|0)){k=e;break}Xe()}}while(0);pe[i+12>>2]=n;pe[k>>2]=i}}while(0);t=w+((u|c)+p)|0;n=u+f|0}else n=f;t=t+4|0;pe[t>>2]=pe[t>>2]&-2;pe[w+(l+4)>>2]=n|1;pe[w+(n+l)>>2]=n;t=n>>>3;if(n>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0>=(pe[155]|0)>>>0){L=t;j=e;break}Xe()}}while(0);pe[L>>2]=d;pe[j+12>>2]=d;pe[w+(l+8)>>2]=j;pe[w+(l+12)>>2]=i;break}t=n>>>8;do{if(!t)i=0;else{if(n>>>0>16777215){i=31;break}L=(t+1048320|0)>>>16&8;j=t<>>16&4;j=j<>>16&2;i=14-(D|L|i)+(j<>>15)|0;i=n>>>(i+7|0)&1|i<<1}}while(0);t=908+(i<<2)|0;pe[w+(l+28)>>2]=i;pe[w+(l+20)>>2]=0;pe[w+(l+16)>>2]=0;e=pe[152]|0;r=1<>2]=d;pe[w+(l+24)>>2]=t;pe[w+(l+12)>>2]=d;pe[w+(l+8)>>2]=d;break}t=pe[t>>2]|0;r:do{if((pe[t+4>>2]&-8|0)!=(n|0)){i=n<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(n|0)){F=r;break r}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=d;pe[w+(l+24)>>2]=t;pe[w+(l+12)>>2]=d;pe[w+(l+8)>>2]=d;break t}}else F=t}while(0);t=F+8|0;e=pe[t>>2]|0;j=pe[155]|0;if(e>>>0>=j>>>0&F>>>0>=j>>>0){pe[e+12>>2]=d;pe[t>>2]=d;pe[w+(l+8)>>2]=e;pe[w+(l+12)>>2]=F;pe[w+(l+24)>>2]=0;break}else Xe()}else{F=(pe[154]|0)+f|0;pe[154]=F;pe[157]=d;pe[w+(l+4)>>2]=F|1}}while(0);F=w+(h|8)|0;return F|0}else r=1052;while(1){e=pe[r>>2]|0;if(e>>>0<=a>>>0?(t=pe[r+4>>2]|0,i=e+t|0,i>>>0>a>>>0):0)break;r=pe[r+8>>2]|0}n=e+(t+-39)|0;e=e+(t+-47+((n&7|0)==0?0:0-n&7))|0;n=a+16|0;e=e>>>0>>0?a:e;t=e+8|0;r=w+8|0;r=(r&7|0)==0?0:0-r&7;F=p+-40-r|0;pe[157]=w+r;pe[154]=F;pe[w+(r+4)>>2]=F|1;pe[w+(p+-36)>>2]=40;pe[158]=pe[273];r=e+4|0;pe[r>>2]=27;pe[t>>2]=pe[263];pe[t+4>>2]=pe[264];pe[t+8>>2]=pe[265];pe[t+12>>2]=pe[266];pe[263]=w;pe[264]=p;pe[266]=0;pe[265]=t;t=e+28|0;pe[t>>2]=7;if((e+32|0)>>>0>>0)do{F=t;t=t+4|0;pe[t>>2]=7}while((F+8|0)>>>0>>0);if((e|0)!=(a|0)){o=e-a|0;pe[r>>2]=pe[r>>2]&-2;pe[a+4>>2]=o|1;pe[e>>2]=o;t=o>>>3;if(o>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{I=t;R=e}}else{pe[151]=r|t;I=644+(e+2<<2)|0;R=i}pe[I>>2]=a;pe[R+12>>2]=a;pe[a+8>>2]=R;pe[a+12>>2]=i;break}t=o>>>8;if(t)if(o>>>0>16777215)i=31;else{j=(t+1048320|0)>>>16&8;F=t<>>16&4;F=F<>>16&2;i=14-(L|j|i)+(F<>>15)|0;i=o>>>(i+7|0)&1|i<<1}else i=0;r=908+(i<<2)|0;pe[a+28>>2]=i;pe[a+20>>2]=0;pe[n>>2]=0;t=pe[152]|0;e=1<>2]=a;pe[a+24>>2]=r;pe[a+12>>2]=a;pe[a+8>>2]=a;break}t=pe[r>>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(o|0)){i=o<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(o|0)){O=r;break t}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=a;pe[a+24>>2]=t;pe[a+12>>2]=a;pe[a+8>>2]=a;break e}}else O=t}while(0);t=O+8|0;e=pe[t>>2]|0;F=pe[155]|0;if(e>>>0>=F>>>0&O>>>0>=F>>>0){pe[e+12>>2]=a;pe[t>>2]=a;pe[a+8>>2]=e;pe[a+12>>2]=O;pe[a+24>>2]=0;break}else Xe()}}else{F=pe[155]|0;if((F|0)==0|w>>>0>>0)pe[155]=w;pe[263]=w;pe[264]=p;pe[266]=0;pe[160]=pe[269];pe[159]=-1;t=0;do{F=t<<1;j=644+(F<<2)|0;pe[644+(F+3<<2)>>2]=j;pe[644+(F+2<<2)>>2]=j;t=t+1|0}while((t|0)!=32);F=w+8|0;F=(F&7|0)==0?0:0-F&7;j=p+-40-F|0;pe[157]=w+F;pe[154]=j;pe[w+(F+4)>>2]=j|1;pe[w+(p+-36)>>2]=40;pe[158]=pe[273]}}while(0);t=pe[154]|0;if(t>>>0>v>>>0){j=t-v|0;pe[154]=j;F=pe[157]|0;pe[157]=F+v;pe[F+(v+4)>>2]=j|1;pe[F+4>>2]=v|3;F=F+8|0;return F|0}}F=fr()|0;pe[F>>2]=12;F=0;return F|0}function zr(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0,y=0;if(!e)return;t=e+-8|0;s=pe[155]|0;if(t>>>0>>0)Xe();r=pe[e+-4>>2]|0;i=r&3;if((i|0)==1)Xe();d=r&-8;v=e+(d+-8)|0;do{if(!(r&1)){t=pe[t>>2]|0;if(!i)return;u=-8-t|0;f=e+u|0;l=t+d|0;if(f>>>0>>0)Xe();if((f|0)==(pe[156]|0)){t=e+(d+-4)|0;r=pe[t>>2]|0;if((r&3|0)!=3){y=f;o=l;break}pe[153]=l;pe[t>>2]=r&-2;pe[e+(u+4)>>2]=l|1;pe[v>>2]=l;return}n=t>>>3;if(t>>>0<256){i=pe[e+(u+8)>>2]|0;r=pe[e+(u+12)>>2]|0;t=644+(n<<1<<2)|0;if((i|0)!=(t|0)){if(i>>>0>>0)Xe();if((pe[i+12>>2]|0)!=(f|0))Xe()}if((r|0)==(i|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();t=r+8|0;if((pe[t>>2]|0)==(f|0))a=t;else Xe()}else a=r+8|0;pe[i+12>>2]=r;pe[a>>2]=i;y=f;o=l;break}a=pe[e+(u+24)>>2]|0;i=pe[e+(u+12)>>2]|0;do{if((i|0)==(f|0)){r=e+(u+20)|0;t=pe[r>>2]|0;if(!t){r=e+(u+16)|0;t=pe[r>>2]|0;if(!t){c=0;break}}while(1){i=t+20|0;n=pe[i>>2]|0;if(n){t=n;r=i;continue}i=t+16|0;n=pe[i>>2]|0;if(!n)break;else{t=n;r=i}}if(r>>>0>>0)Xe();else{pe[r>>2]=0;c=t;break}}else{n=pe[e+(u+8)>>2]|0;if(n>>>0>>0)Xe();t=n+12|0;if((pe[t>>2]|0)!=(f|0))Xe();r=i+8|0;if((pe[r>>2]|0)==(f|0)){pe[t>>2]=i;pe[r>>2]=n;c=i;break}else Xe()}}while(0);if(a){t=pe[e+(u+28)>>2]|0;r=908+(t<<2)|0;if((f|0)==(pe[r>>2]|0)){pe[r>>2]=c;if(!c){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(f|0))pe[t>>2]=c;else pe[a+20>>2]=c;if(!c){y=f;o=l;break}}r=pe[155]|0;if(c>>>0>>0)Xe();pe[c+24>>2]=a;t=pe[e+(u+16)>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[c+16>>2]=t;pe[t+24>>2]=c;break}}while(0);t=pe[e+(u+20)>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[c+20>>2]=t;pe[t+24>>2]=c;y=f;o=l;break}else{y=f;o=l}}else{y=f;o=l}}else{y=t;o=d}}while(0);if(y>>>0>=v>>>0)Xe();t=e+(d+-4)|0;r=pe[t>>2]|0;if(!(r&1))Xe();if(!(r&2)){if((v|0)==(pe[157]|0)){g=(pe[154]|0)+o|0;pe[154]=g;pe[157]=y;pe[y+4>>2]=g|1;if((y|0)!=(pe[156]|0))return;pe[156]=0;pe[153]=0;return}if((v|0)==(pe[156]|0)){g=(pe[153]|0)+o|0;pe[153]=g;pe[156]=y;pe[y+4>>2]=g|1;pe[y+g>>2]=g;return}o=(r&-8)+o|0;n=r>>>3;do{if(r>>>0>=256){a=pe[e+(d+16)>>2]|0;t=pe[e+(d|4)>>2]|0;do{if((t|0)==(v|0)){r=e+(d+12)|0;t=pe[r>>2]|0;if(!t){r=e+(d+8)|0;t=pe[r>>2]|0;if(!t){p=0;break}}while(1){i=t+20|0;n=pe[i>>2]|0;if(n){t=n;r=i;continue}i=t+16|0;n=pe[i>>2]|0;if(!n)break;else{t=n;r=i}}if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[r>>2]=0;p=t;break}}else{r=pe[e+d>>2]|0;if(r>>>0<(pe[155]|0)>>>0)Xe();i=r+12|0;if((pe[i>>2]|0)!=(v|0))Xe();n=t+8|0;if((pe[n>>2]|0)==(v|0)){pe[i>>2]=t;pe[n>>2]=r;p=t;break}else Xe()}}while(0);if(a){t=pe[e+(d+20)>>2]|0;r=908+(t<<2)|0;if((v|0)==(pe[r>>2]|0)){pe[r>>2]=p;if(!p){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(v|0))pe[t>>2]=p;else pe[a+20>>2]=p;if(!p)break}r=pe[155]|0;if(p>>>0>>0)Xe();pe[p+24>>2]=a;t=pe[e+(d+8)>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[p+16>>2]=t;pe[t+24>>2]=p;break}}while(0);t=pe[e+(d+12)>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[p+20>>2]=t;pe[t+24>>2]=p;break}}}else{i=pe[e+d>>2]|0;r=pe[e+(d|4)>>2]|0;t=644+(n<<1<<2)|0;if((i|0)!=(t|0)){if(i>>>0<(pe[155]|0)>>>0)Xe();if((pe[i+12>>2]|0)!=(v|0))Xe()}if((r|0)==(i|0)){pe[151]=pe[151]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=r+8|0;if((pe[t>>2]|0)==(v|0))h=t;else Xe()}else h=r+8|0;pe[i+12>>2]=r;pe[h>>2]=i}}while(0);pe[y+4>>2]=o|1;pe[y+o>>2]=o;if((y|0)==(pe[156]|0)){pe[153]=o;return}}else{pe[t>>2]=r&-2;pe[y+4>>2]=o|1;pe[y+o>>2]=o}t=o>>>3;if(o>>>0<256){r=t<<1;n=644+(r<<2)|0;i=pe[151]|0;t=1<>2]|0;if(r>>>0<(pe[155]|0)>>>0)Xe();else{m=t;b=r}}else{pe[151]=i|t;m=644+(r+2<<2)|0;b=n}pe[m>>2]=y;pe[b+12>>2]=y;pe[y+8>>2]=b;pe[y+12>>2]=n;return}t=o>>>8;if(t)if(o>>>0>16777215)n=31;else{m=(t+1048320|0)>>>16&8;b=t<>>16&4;b=b<>>16&2;n=14-(v|m|n)+(b<>>15)|0;n=o>>>(n+7|0)&1|n<<1}else n=0;t=908+(n<<2)|0;pe[y+28>>2]=n;pe[y+20>>2]=0;pe[y+16>>2]=0;r=pe[152]|0;i=1<>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(o|0)){n=o<<((n|0)==31?0:25-(n>>>1)|0);while(1){r=t+16+(n>>>31<<2)|0;i=pe[r>>2]|0;if(!i)break;if((pe[i+4>>2]&-8|0)==(o|0)){g=i;break t}else{n=n<<1;t=i}}if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[r>>2]=y;pe[y+24>>2]=t;pe[y+12>>2]=y;pe[y+8>>2]=y;break e}}else g=t}while(0);t=g+8|0;r=pe[t>>2]|0;b=pe[155]|0;if(r>>>0>=b>>>0&g>>>0>=b>>>0){pe[r+12>>2]=y;pe[t>>2]=y;pe[y+8>>2]=r;pe[y+12>>2]=g;pe[y+24>>2]=0;break}else Xe()}else{pe[152]=r|i;pe[t>>2]=y;pe[y+24>>2]=t;pe[y+12>>2]=y;pe[y+8>>2]=y}}while(0);y=(pe[159]|0)+-1|0;pe[159]=y;if(!y)t=1060;else return;while(1){t=pe[t>>2]|0;if(!t)break;else t=t+8|0}pe[159]=-1;return}function Xr(e,t){e=e|0;t=t|0;var r=0,i=0;if(!e){e=Ur(t)|0;return e|0}if(t>>>0>4294967231){e=fr()|0;pe[e>>2]=12;e=0;return e|0}r=Gr(e+-8|0,t>>>0<11?16:t+11&-8)|0;if(r){e=r+8|0;return e|0}r=Ur(t)|0;if(!r){e=0;return e|0}i=pe[e+-4>>2]|0;i=(i&-8)-((i&3|0)==0?8:4)|0;Qr(r|0,e|0,(i>>>0>>0?i:t)|0)|0;zr(e);e=r;return e|0}function qr(e){e=e|0;var t=0;if(!e){t=0;return t|0}e=pe[e+-4>>2]|0;t=e&3;if((t|0)==1){t=0;return t|0}t=(e&-8)-((t|0)==0?8:4)|0;return t|0}function Gr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;d=e+4|0;p=pe[d>>2]|0;u=p&-8;f=e+u|0;s=pe[155]|0;r=p&3;if(!((r|0)!=1&e>>>0>=s>>>0&e>>>0>>0))Xe();i=e+(u|4)|0;n=pe[i>>2]|0;if(!(n&1))Xe();if(!r){if(t>>>0<256){e=0;return e|0}if(u>>>0>=(t+4|0)>>>0?(u-t|0)>>>0<=pe[271]<<1>>>0:0)return e|0;e=0;return e|0}if(u>>>0>=t>>>0){r=u-t|0;if(r>>>0<=15)return e|0;pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=r|3;pe[i>>2]=pe[i>>2]|1;Hr(e+t|0,r);return e|0}if((f|0)==(pe[157]|0)){r=(pe[154]|0)+u|0;if(r>>>0<=t>>>0){e=0;return e|0}h=r-t|0;pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=h|1;pe[157]=e+t;pe[154]=h;return e|0}if((f|0)==(pe[156]|0)){i=(pe[153]|0)+u|0;if(i>>>0>>0){e=0;return e|0}r=i-t|0;if(r>>>0>15){pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=r|1;pe[e+i>>2]=r;i=e+(i+4)|0;pe[i>>2]=pe[i>>2]&-2;i=e+t|0}else{pe[d>>2]=p&1|i|2;i=e+(i+4)|0;pe[i>>2]=pe[i>>2]|1;i=0;r=0}pe[153]=r;pe[156]=i;return e|0}if(n&2){e=0;return e|0}l=(n&-8)+u|0;if(l>>>0>>0){e=0;return e|0}h=l-t|0;o=n>>>3;do{if(n>>>0>=256){a=pe[e+(u+24)>>2]|0;o=pe[e+(u+12)>>2]|0;do{if((o|0)==(f|0)){i=e+(u+20)|0;r=pe[i>>2]|0;if(!r){i=e+(u+16)|0;r=pe[i>>2]|0;if(!r){c=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;c=r;break}}else{n=pe[e+(u+8)>>2]|0;if(n>>>0>>0)Xe();r=n+12|0;if((pe[r>>2]|0)!=(f|0))Xe();i=o+8|0;if((pe[i>>2]|0)==(f|0)){pe[r>>2]=o;pe[i>>2]=n;c=o;break}else Xe()}}while(0);if(a){r=pe[e+(u+28)>>2]|0;i=908+(r<<2)|0;if((f|0)==(pe[i>>2]|0)){pe[i>>2]=c;if(!c){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=a+16|0;if((pe[r>>2]|0)==(f|0))pe[r>>2]=c;else pe[a+20>>2]=c;if(!c)break}i=pe[155]|0;if(c>>>0>>0)Xe();pe[c+24>>2]=a;r=pe[e+(u+16)>>2]|0;do{if(r)if(r>>>0>>0)Xe();else{pe[c+16>>2]=r;pe[r+24>>2]=c;break}}while(0);r=pe[e+(u+20)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[c+20>>2]=r;pe[r+24>>2]=c;break}}}else{n=pe[e+(u+8)>>2]|0;i=pe[e+(u+12)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(f|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(f|0))a=r;else Xe()}else a=i+8|0;pe[n+12>>2]=i;pe[a>>2]=n}}while(0);if(h>>>0<16){pe[d>>2]=l|p&1|2;t=e+(l|4)|0;pe[t>>2]=pe[t>>2]|1;return e|0}else{pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=h|3;p=e+(l|4)|0;pe[p>>2]=pe[p>>2]|1;Hr(e+t|0,h);return e|0}return 0}function Hr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0,v=0,m=0,b=0,g=0;v=e+t|0;r=pe[e+4>>2]|0;do{if(!(r&1)){c=pe[e>>2]|0;if(!(r&3))return;h=e+(0-c)|0;l=c+t|0;u=pe[155]|0;if(h>>>0>>0)Xe();if((h|0)==(pe[156]|0)){i=e+(t+4)|0;r=pe[i>>2]|0;if((r&3|0)!=3){g=h;a=l;break}pe[153]=l;pe[i>>2]=r&-2;pe[e+(4-c)>>2]=l|1;pe[v>>2]=l;return}o=c>>>3;if(c>>>0<256){n=pe[e+(8-c)>>2]|0;i=pe[e+(12-c)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(h|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(h|0))s=r;else Xe()}else s=i+8|0;pe[n+12>>2]=i;pe[s>>2]=n;g=h;a=l;break}s=pe[e+(24-c)>>2]|0;n=pe[e+(12-c)>>2]|0;do{if((n|0)==(h|0)){n=16-c|0;i=e+(n+4)|0;r=pe[i>>2]|0;if(!r){i=e+n|0;r=pe[i>>2]|0;if(!r){f=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;f=r;break}}else{o=pe[e+(8-c)>>2]|0;if(o>>>0>>0)Xe();r=o+12|0;if((pe[r>>2]|0)!=(h|0))Xe();i=n+8|0;if((pe[i>>2]|0)==(h|0)){pe[r>>2]=n;pe[i>>2]=o;f=n;break}else Xe()}}while(0);if(s){r=pe[e+(28-c)>>2]|0;i=908+(r<<2)|0;if((h|0)==(pe[i>>2]|0)){pe[i>>2]=f;if(!f){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=s+16|0;if((pe[r>>2]|0)==(h|0))pe[r>>2]=f;else pe[s+20>>2]=f;if(!f){g=h;a=l;break}}n=pe[155]|0;if(f>>>0>>0)Xe();pe[f+24>>2]=s;r=16-c|0;i=pe[e+r>>2]|0;do{if(i)if(i>>>0>>0)Xe();else{pe[f+16>>2]=i;pe[i+24>>2]=f;break}}while(0);r=pe[e+(r+4)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[f+20>>2]=r;pe[r+24>>2]=f;g=h;a=l;break}else{g=h;a=l}}else{g=h;a=l}}else{g=e;a=t}}while(0);u=pe[155]|0;if(v>>>0>>0)Xe();r=e+(t+4)|0;i=pe[r>>2]|0;if(!(i&2)){if((v|0)==(pe[157]|0)){b=(pe[154]|0)+a|0;pe[154]=b;pe[157]=g;pe[g+4>>2]=b|1;if((g|0)!=(pe[156]|0))return;pe[156]=0;pe[153]=0;return}if((v|0)==(pe[156]|0)){b=(pe[153]|0)+a|0;pe[153]=b;pe[156]=g;pe[g+4>>2]=b|1;pe[g+b>>2]=b;return}a=(i&-8)+a|0;o=i>>>3;do{if(i>>>0>=256){s=pe[e+(t+24)>>2]|0;n=pe[e+(t+12)>>2]|0;do{if((n|0)==(v|0)){i=e+(t+20)|0;r=pe[i>>2]|0;if(!r){i=e+(t+16)|0;r=pe[i>>2]|0;if(!r){p=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;p=r;break}}else{o=pe[e+(t+8)>>2]|0;if(o>>>0>>0)Xe();r=o+12|0;if((pe[r>>2]|0)!=(v|0))Xe();i=n+8|0;if((pe[i>>2]|0)==(v|0)){pe[r>>2]=n;pe[i>>2]=o;p=n;break}else Xe()}}while(0);if(s){r=pe[e+(t+28)>>2]|0;i=908+(r<<2)|0;if((v|0)==(pe[i>>2]|0)){pe[i>>2]=p;if(!p){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=s+16|0;if((pe[r>>2]|0)==(v|0))pe[r>>2]=p;else pe[s+20>>2]=p;if(!p)break}i=pe[155]|0;if(p>>>0>>0)Xe();pe[p+24>>2]=s;r=pe[e+(t+16)>>2]|0;do{if(r)if(r>>>0>>0)Xe();else{pe[p+16>>2]=r;pe[r+24>>2]=p;break}}while(0);r=pe[e+(t+20)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[p+20>>2]=r;pe[r+24>>2]=p;break}}}else{n=pe[e+(t+8)>>2]|0;i=pe[e+(t+12)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(v|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(v|0))d=r;else Xe()}else d=i+8|0;pe[n+12>>2]=i;pe[d>>2]=n}}while(0);pe[g+4>>2]=a|1;pe[g+a>>2]=a;if((g|0)==(pe[156]|0)){pe[153]=a;return}}else{pe[r>>2]=i&-2;pe[g+4>>2]=a|1;pe[g+a>>2]=a}r=a>>>3;if(a>>>0<256){i=r<<1;o=644+(i<<2)|0;n=pe[151]|0;r=1<>2]|0;if(i>>>0<(pe[155]|0)>>>0)Xe();else{m=r;b=i}}else{pe[151]=n|r;m=644+(i+2<<2)|0;b=o}pe[m>>2]=g;pe[b+12>>2]=g;pe[g+8>>2]=b;pe[g+12>>2]=o;return}r=a>>>8;if(r)if(a>>>0>16777215)o=31;else{m=(r+1048320|0)>>>16&8;b=r<>>16&4;b=b<>>16&2;o=14-(v|m|o)+(b<>>15)|0;o=a>>>(o+7|0)&1|o<<1}else o=0;r=908+(o<<2)|0;pe[g+28>>2]=o;pe[g+20>>2]=0;pe[g+16>>2]=0;i=pe[152]|0;n=1<>2]=g;pe[g+24>>2]=r;pe[g+12>>2]=g;pe[g+8>>2]=g;return}r=pe[r>>2]|0;e:do{if((pe[r+4>>2]&-8|0)!=(a|0)){o=a<<((o|0)==31?0:25-(o>>>1)|0);while(1){i=r+16+(o>>>31<<2)|0;n=pe[i>>2]|0;if(!n)break;if((pe[n+4>>2]&-8|0)==(a|0)){r=n;break e}else{o=o<<1;r=n}}if(i>>>0<(pe[155]|0)>>>0)Xe();pe[i>>2]=g;pe[g+24>>2]=r;pe[g+12>>2]=g;pe[g+8>>2]=g;return}}while(0);i=r+8|0;n=pe[i>>2]|0;b=pe[155]|0;if(!(n>>>0>=b>>>0&r>>>0>=b>>>0))Xe();pe[n+12>>2]=g;pe[i>>2]=g;pe[g+8>>2]=n;pe[g+12>>2]=r;pe[g+24>>2]=0;return}function Vr(){}function Wr(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;i=t-i-(r>>>0>e>>>0|0)>>>0;return(re=i,e-r>>>0|0)|0}function Yr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;i=e+r|0;if((r|0)>=20){t=t&255;o=e&3;a=t|t<<8|t<<16|t<<24;n=i&~3;if(o){o=e+4-o|0;while((e|0)<(o|0)){de[e>>0]=t;e=e+1|0}}while((e|0)<(n|0)){pe[e>>2]=a;e=e+4|0}}while((e|0)<(i|0)){de[e>>0]=t;e=e+1|0}return e-r|0}function Kr(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t>>>r;return e>>>r|(t&(1<>>r-32|0}function Jr(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t<>>32-r;return e<>>0;return(re=t+i+(r>>>0>>0|0)>>>0,r|0)|0}function Qr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if((r|0)>=4096)return Re(e|0,t|0,r|0)|0;i=e|0;if((e&3)==(t&3)){while(e&3){if(!r)return i|0;de[e>>0]=de[t>>0]|0;e=e+1|0;t=t+1|0;r=r-1|0}while((r|0)>=4){pe[e>>2]=pe[t>>2];e=e+4|0;t=t+4|0;r=r-4|0}}while((r|0)>0){de[e>>0]=de[t>>0]|0;e=e+1|0;t=t+1|0;r=r-1|0}return i|0}function $r(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t>>r;return e>>>r|(t&(1<>r-32|0}function ei(e){e=e|0;var t=0;t=de[m+(e&255)>>0]|0;if((t|0)<8)return t|0;t=de[m+(e>>8&255)>>0]|0;if((t|0)<8)return t+8|0;t=de[m+(e>>16&255)>>0]|0;if((t|0)<8)return t+16|0;return(de[m+(e>>>24)>>0]|0)+24|0}function ti(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0;o=e&65535;n=t&65535;r=ge(n,o)|0;i=e>>>16;e=(r>>>16)+(ge(n,i)|0)|0;n=t>>>16;t=ge(n,o)|0;return(re=(e>>>16)+(ge(n,i)|0)+(((e&65535)+t|0)>>>16)|0,e+t<<16|r&65535|0)|0}function ri(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0;c=t>>31|((t|0)<0?-1:0)<<1;u=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1;o=i>>31|((i|0)<0?-1:0)<<1;n=((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1;s=Wr(c^e,u^t,c,u)|0;a=re;e=o^c;t=n^u;return Wr((si(s,a,Wr(o^r,n^i,o,n)|0,re,0)|0)^e,re^t,e,t)|0}function ii(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,c=0;n=be;be=be+16|0;s=n|0;a=t>>31|((t|0)<0?-1:0)<<1;o=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1;c=i>>31|((i|0)<0?-1:0)<<1;u=((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1;e=Wr(a^e,o^t,a,o)|0;t=re;si(e,t,Wr(c^r,u^i,c,u)|0,re,s)|0;i=Wr(pe[s>>2]^a,pe[s+4>>2]^o,a,o)|0;r=re;be=n;return(re=r,i)|0}function ni(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0;n=e;o=r;r=ti(n,o)|0;e=re;return(re=(ge(t,o)|0)+(ge(i,n)|0)+e|e&0,r|0|0)|0}function oi(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;return si(e,t,r,i,0)|0}function ai(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0;o=be;be=be+16|0;n=o|0;si(e,t,r,i,n)|0;be=o;return(re=pe[n+4>>2]|0,pe[n>>2]|0)|0}function si(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,c=0,f=0,l=0,h=0,d=0,p=0;f=e;u=t;c=u;a=r;h=i;s=h;if(!c){o=(n|0)!=0;if(!s){if(o){pe[n>>2]=(f>>>0)%(a>>>0);pe[n+4>>2]=0}h=0;n=(f>>>0)/(a>>>0)>>>0;return(re=h,n)|0}else{if(!o){h=0;n=0;return(re=h,n)|0}pe[n>>2]=e|0;pe[n+4>>2]=t&0;h=0;n=0;return(re=h,n)|0}}o=(s|0)==0;do{if(a){if(!o){o=(ae(s|0)|0)-(ae(c|0)|0)|0;if(o>>>0<=31){l=o+1|0;s=31-o|0;t=o-31>>31;a=l;e=f>>>(l>>>0)&t|c<>>(l>>>0)&t;o=0;s=f<>2]=e|0;pe[n+4>>2]=u|t&0;h=0;n=0;return(re=h,n)|0}o=a-1|0;if(o&a){s=(ae(a|0)|0)+33-(ae(c|0)|0)|0;p=64-s|0;l=32-s|0;u=l>>31;d=s-32|0;t=d>>31;a=s;e=l-1>>31&c>>>(d>>>0)|(c<>>(s>>>0))&t;t=t&c>>>(s>>>0);o=f<>>(d>>>0))&u|f<>31;break}if(n){pe[n>>2]=o&f;pe[n+4>>2]=0}if((a|0)==1){d=u|t&0;p=e|0|0;return(re=d,p)|0}else{p=ei(a|0)|0;d=c>>>(p>>>0)|0;p=c<<32-p|f>>>(p>>>0)|0;return(re=d,p)|0}}else{if(o){if(n){pe[n>>2]=(c>>>0)%(a>>>0);pe[n+4>>2]=0}d=0;p=(c>>>0)/(a>>>0)>>>0;return(re=d,p)|0}if(!f){if(n){pe[n>>2]=0;pe[n+4>>2]=(c>>>0)%(s>>>0)}d=0;p=(c>>>0)/(s>>>0)>>>0;return(re=d,p)|0}o=s-1|0;if(!(o&s)){if(n){pe[n>>2]=e|0;pe[n+4>>2]=o&c|t&0}d=0;p=c>>>((ei(s|0)|0)>>>0);return(re=d,p)|0}o=(ae(s|0)|0)-(ae(c|0)|0)|0;if(o>>>0<=30){t=o+1|0;s=31-o|0;a=t;e=c<>>(t>>>0);t=c>>>(t>>>0);o=0;s=f<>2]=e|0;pe[n+4>>2]=u|t&0;d=0;p=0;return(re=d,p)|0}}while(0);if(!a){c=s;u=0;s=0}else{l=r|0|0;f=h|i&0;c=Zr(l|0,f|0,-1,-1)|0;r=re;u=s;s=0;do{i=u;u=o>>>31|u<<1;o=s|o<<1;i=e<<1|i>>>31|0;h=e>>>31|t<<1|0;Wr(c,r,i,h)|0;p=re;d=p>>31|((p|0)<0?-1:0)<<1;s=d&1;e=Wr(i,h,d&l,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&f)|0;t=re;a=a-1|0}while((a|0)!=0);c=u;u=0}a=0;if(n){pe[n>>2]=e;pe[n+4>>2]=t}d=(o|0)>>>31|(c|a)<<1|(a<<1|o>>>31)&0|u;p=(o<<1|0>>>31)&-2|s;return(re=d,p)|0}function ui(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;return Mi[e&7](t|0,r|0,i|0)|0}function ci(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;Ci[e&3](t|0,r|0,i|0,n|0,o|0)}function fi(e,t){e=e|0;t=t|0;Pi[e&7](t|0)}function li(e,t){e=e|0;t=t|0;return Ai[e&1](t|0)|0}function hi(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;ki[e&0](t|0,r|0,i|0)}function di(e){e=e|0;Ii[e&3]()}function pi(e,t,r,i,n,o,a){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;Ri[e&3](t|0,r|0,i|0,n|0,o|0,a|0)}function vi(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;return Oi[e&1](t|0,r|0,i|0,n|0,o|0)|0}function mi(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;Di[e&3](t|0,r|0,i|0,n|0)}function bi(e,t,r){e=e|0;t=t|0;r=r|0;se(0);return 0}function gi(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;se(1)}function yi(e){e=e|0;se(2)}function _i(e){e=e|0;se(3);return 0}function wi(e,t,r){e=e|0;t=t|0;r=r|0;se(4)}function xi(){se(5)}function Ti(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;se(6)}function Si(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;se(7);return 0}function Ei(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;se(8)}var Mi=[bi,Yt,jr,Ar,Pr,kr,bi,bi];var Ci=[gi,tr,er,gi];var Pi=[yi,qt,Vt,Gt,Ht,Wt,ur,Lr];var Ai=[_i,Cr];var ki=[wi];var Ii=[xi,ar,sr,xi];var Ri=[Ti,ir,rr,Ti];var Oi=[Si,ut];var Di=[Ei,Jt,Zt,Ei];return{___cxa_can_catch:nr,_crn_get_levels:Tt,_crn_get_uncompressed_size:Et,_crn_decompress:Mt,_i64Add:Zr,_crn_get_width:wt,___cxa_is_pointer_type:or,_i64Subtract:Wr,_memset:Yr,_malloc:Ur,_free:zr,_memcpy:Qr,_bitshift64Lshr:Kr,_fflush:mr,_bitshift64Shl:Jr,_crn_get_height:xt,___errno_location:fr,_crn_get_dxt_format:St,runPostSets:Vr,_emscripten_replace_memory:Ye,stackAlloc:Ke,stackSave:Je,stackRestore:Ze,establishStackSpace:Qe,setThrew:$e,setTempRet0:rt,getTempRet0:it,dynCall_iiii:ui,dynCall_viiiii:ci,dynCall_vi:fi,dynCall_ii:li,dynCall_viii:hi,dynCall_v:di,dynCall_viiiiii:pi,dynCall_iiiiii:vi,dynCall_viiii:mi}}(e.Ya,e.Za,buffer);e.___cxa_can_catch=Z.___cxa_can_catch,e._crn_get_levels=Z._crn_get_levels,e.runPostSets=Z.runPostSets,e._crn_get_uncompressed_size=Z._crn_get_uncompressed_size,e._crn_decompress=Z._crn_decompress;var zc=e._i64Add=Z._i64Add;e._crn_get_height=Z._crn_get_height,e.___cxa_is_pointer_type=Z.___cxa_is_pointer_type;var nb=e._i64Subtract=Z._i64Subtract,qb=e._memset=Z._memset,Ea=e._malloc=Z._malloc,Bc=e._memcpy=Z._memcpy,Xa=e._emscripten_replace_memory=Z._emscripten_replace_memory;e._crn_get_dxt_format=Z._crn_get_dxt_format;var rb=e._bitshift64Lshr=Z._bitshift64Lshr,Na=e._free=Z._free;e._fflush=Z._fflush,e._crn_get_width=Z._crn_get_width,e.___errno_location=Z.___errno_location;var sb=e._bitshift64Shl=Z._bitshift64Shl;function ia(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}e.dynCall_iiii=Z.dynCall_iiii,e.dynCall_viiiii=Z.dynCall_viiiii,e.dynCall_vi=Z.dynCall_vi,e.dynCall_ii=Z.dynCall_ii,e.dynCall_viii=Z.dynCall_viii,e.dynCall_v=Z.dynCall_v,e.dynCall_viiiiii=Z.dynCall_viiiiii,e.dynCall_iiiiii=Z.dynCall_iiiiii,e.dynCall_viiii=Z.dynCall_viiii,n.aa=Z.stackAlloc,n.ua=Z.stackSave,n.ba=Z.stackRestore,n.Cd=Z.establishStackSpace,n.rb=Z.setTempRet0,n.fb=Z.getTempRet0,ia.prototype=Error(),ia.prototype.constructor=ia;var rd=null,jb=function t(){e.calledRun||td(),e.calledRun||(jb=t)};function td(t){function r(){if(!e.calledRun&&(e.calledRun=!0,!na)){if(Ha||(Ha=!0,ab(cb)),ab(db),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e._main&&vd&&e.callMain(t),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)gb(e.postRun.shift());ab(eb)}}if(t=t||e.arguments,null===rd&&(rd=Date.now()),!(0>6],n=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:i,primitive:n,tag:r,tagStr:s.tag[r]}}function l(e,t,r){var i=e.readUInt8(r);if(e.isError(i))return i;if(!t&&128===i)return null;if(0==(128&i))return i;var n=127&i;if(4>=8)a++;(n=new c(2+a))[0]=o,n[1]=128|a;s=1+a;for(var u=i.length;0>=8)n[s]=255&u;return this._createEncoderBuffer([n,i])},s.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"!==t)return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)?this._createEncoderBuffer(e):"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported");for(var r=new c(2*e.length),i=0;i>=7)n++}var a=new c(n),s=a.length-1;for(i=e.length-1;0<=i;i--){o=e[i];for(a[s--]=127&o;0<(o>>=7);)a[s--]=128|127&o}return this._createEncoderBuffer(a)},s.prototype._encodeTime=function(e,t){var r,i=new Date(e);return"gentime"===t?r=[u(i.getFullYear()),u(i.getUTCMonth()+1),u(i.getUTCDate()),u(i.getUTCHours()),u(i.getUTCMinutes()),u(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[u(i.getFullYear()%100),u(i.getUTCMonth()+1),u(i.getUTCDate()),u(i.getUTCHours()),u(i.getUTCMinutes()),u(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},s.prototype._encodeNull=function(){return this._createEncoderBuffer("")},s.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!c.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new c(r)}if(c.isBuffer(e)){var i=e.length;0===e.length&&i++;var n=new c(i);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);i=1;for(var o=e;256<=o;o>>=8)i++;for(o=(n=new Array(i)).length-1;0<=o;o--)n[o]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(new c(n))},s.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},s.prototype._skipDefault=function(e,t,r){var i,n=this._baseState;if(null===n.default)return!1;var o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i>16&255,o[s++]=i>>8&255,o[s++]=255&i;2===n?(i=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,o[s++]=255&i):1===n&&(i=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,o[s++]=i>>8&255,o[s++]=255&i);return o},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,n="",o=[],a=0,s=r-i;a>2],n+=u[t<<4&63],n+="=="):2==i&&(t=(e[r-2]<<8)+e[r-1],n+=u[t>>10],n+=u[t>>4&63],n+=u[t<<2&63],n+="=");return o.push(n),o.join("")};for(var u=[],c=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,o=i.length;n>18&63]+u[n>>12&63]+u[n>>6&63]+u[63&n]);return o.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],17:[function(T,e,t){!function(e,t){"use strict";function m(e,t){if(!e)throw new Error(t||"Assertion failed")}function r(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function b(e,t,r){if(b.isBN(e))return e;this.negative=0,this.words=null,this.length=0,(this.red=null)!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var i;"object"==typeof e?e.exports=b:t.BN=b,(b.BN=b).wordSize=26;try{i=T("buffer").Buffer}catch(e){}function a(e,t,r){for(var i=0,n=Math.min(e.length,r),o=t;o>>26-a&67108863,26<=(a+=24)&&(a-=26,n++);else if("le"===r)for(n=i=0;i>>26-a&67108863,26<=(a+=24)&&(a-=26,n++);return this.strip()},b.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r>>26-o&4194303,26<=(o+=24)&&(o-=26,i++);r+6!==t&&(n=a(e,t,r+6),this.words[i]|=n<>>26-o&4194303),this.strip()},b.prototype._parseBase=function(e,t,r){this.words=[0];for(var i=0,n=this.length=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var o=e.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,c=r;c"};var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function n(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;i=(r.length=i)-1|0;var n=0|e.words[0],o=0|t.words[0],a=n*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,l=67108863&u,h=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=h;d++){var p=c-d|0;f+=(a=(n=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[c]=0|l,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}b.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,n=0,o=0;o>>24-i&16777215)||o!==this.length-1?h[6-s.length]+s+r:s+r,26<=(i+=2)&&(i-=26,o--)}for(0!==n&&(r=n.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&2<=e&&e<=36){var u=d[e],c=p[e];r="";var f=this.clone();for(f.negative=0;!f.isZero();){var l=f.modn(c).toString(e);r=(f=f.idivn(c)).isZero()?l+r:h[u-l.length]+l+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}m(!1,"Base should be between 2 and 36")},b.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:2>>=13),64<=t&&(r+=7,t>>>=7),8<=t&&(r+=4,t>>>=4),2<=t&&(r+=2,t>>>=2),r+t},b.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},b.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},b.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},b.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},b.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},b.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},b.prototype.iuxor=function(e){var t,r;r=this.length>e.length?(t=this,e):(t=e,this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},b.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},b.prototype.inotn=function(e){m("number"==typeof e&&0<=e);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),0>26-r),this.strip()},b.prototype.notn=function(e){return this.clone().inotn(e)},b.prototype.setn=function(e,t){m("number"==typeof e&&0<=e);var r=e/26|0,i=e%26;return this._expand(1+r),this.words[r]=t?this.words[r]|1<e.length?(r=this,e):(r=e,this);for(var n=0,o=0;o>>26;for(;0!==n&&o>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},b.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;i=0>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,v=d>>>13,m=0|a[2],b=8191&m,g=m>>>13,y=0|a[3],_=8191&y,w=y>>>13,x=0|a[4],T=8191&x,S=x>>>13,E=0|a[5],M=8191&E,C=E>>>13,P=0|a[6],A=8191&P,k=P>>>13,I=0|a[7],R=8191&I,O=I>>>13,D=0|a[8],L=8191&D,j=D>>>13,F=0|a[9],B=8191&F,N=F>>>13,U=0|s[0],z=8191&U,X=U>>>13,q=0|s[1],G=8191&q,H=q>>>13,V=0|s[2],W=8191&V,Y=V>>>13,K=0|s[3],J=8191&K,Z=K>>>13,Q=0|s[4],$=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ie=te>>>13,ne=0|s[6],oe=8191&ne,ae=ne>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],le=8191&fe,he=fe>>>13,de=0|s[9],pe=8191&de,ve=de>>>13;r.negative=e.negative^t.negative,r.length=19;var me=(c+(i=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,X))+Math.imul(h,z)|0))<<13)|0;c=((o=Math.imul(h,X))+(n>>>13)|0)+(me>>>26)|0,me&=67108863,i=Math.imul(p,z),n=(n=Math.imul(p,X))+Math.imul(v,z)|0,o=Math.imul(v,X);var be=(c+(i=i+Math.imul(l,G)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(h,G)|0))<<13)|0;c=((o=o+Math.imul(h,H)|0)+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(b,z),n=(n=Math.imul(b,X))+Math.imul(g,z)|0,o=Math.imul(g,X),i=i+Math.imul(p,G)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,H)|0;var ge=(c+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,Y)|0)+Math.imul(h,W)|0))<<13)|0;c=((o=o+Math.imul(h,Y)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(_,z),n=(n=Math.imul(_,X))+Math.imul(w,z)|0,o=Math.imul(w,X),i=i+Math.imul(b,G)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,H)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,Y)|0;var ye=(c+(i=i+Math.imul(l,J)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(h,J)|0))<<13)|0;c=((o=o+Math.imul(h,Z)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(T,z),n=(n=Math.imul(T,X))+Math.imul(S,z)|0,o=Math.imul(S,X),i=i+Math.imul(_,G)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(w,G)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(g,W)|0,o=o+Math.imul(g,Y)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0;var _e=(c+(i=i+Math.imul(l,$)|0)|0)+((8191&(n=(n=n+Math.imul(l,ee)|0)+Math.imul(h,$)|0))<<13)|0;c=((o=o+Math.imul(h,ee)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(M,z),n=(n=Math.imul(M,X))+Math.imul(C,z)|0,o=Math.imul(C,X),i=i+Math.imul(T,G)|0,n=(n=n+Math.imul(T,H)|0)+Math.imul(S,G)|0,o=o+Math.imul(S,H)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(b,J)|0,n=(n=n+Math.imul(b,Z)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(v,$)|0,o=o+Math.imul(v,ee)|0;var we=(c+(i=i+Math.imul(l,re)|0)|0)+((8191&(n=(n=n+Math.imul(l,ie)|0)+Math.imul(h,re)|0))<<13)|0;c=((o=o+Math.imul(h,ie)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(A,z),n=(n=Math.imul(A,X))+Math.imul(k,z)|0,o=Math.imul(k,X),i=i+Math.imul(M,G)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,H)|0,i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,Y)|0)+Math.imul(S,W)|0,o=o+Math.imul(S,Y)|0,i=i+Math.imul(_,J)|0,n=(n=n+Math.imul(_,Z)|0)+Math.imul(w,J)|0,o=o+Math.imul(w,Z)|0,i=i+Math.imul(b,$)|0,n=(n=n+Math.imul(b,ee)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ie)|0;var xe=(c+(i=i+Math.imul(l,oe)|0)|0)+((8191&(n=(n=n+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;c=((o=o+Math.imul(h,ae)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(R,z),n=(n=Math.imul(R,X))+Math.imul(O,z)|0,o=Math.imul(O,X),i=i+Math.imul(A,G)|0,n=(n=n+Math.imul(A,H)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(M,W)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(C,W)|0,o=o+Math.imul(C,Y)|0,i=i+Math.imul(T,J)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(S,J)|0,o=o+Math.imul(S,Z)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,ee)|0)+Math.imul(w,$)|0,o=o+Math.imul(w,ee)|0,i=i+Math.imul(b,re)|0,n=(n=n+Math.imul(b,ie)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ie)|0,i=i+Math.imul(p,oe)|0,n=(n=n+Math.imul(p,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0;var Te=(c+(i=i+Math.imul(l,ue)|0)|0)+((8191&(n=(n=n+Math.imul(l,ce)|0)+Math.imul(h,ue)|0))<<13)|0;c=((o=o+Math.imul(h,ce)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(L,z),n=(n=Math.imul(L,X))+Math.imul(j,z)|0,o=Math.imul(j,X),i=i+Math.imul(R,G)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(O,G)|0,o=o+Math.imul(O,H)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,Z)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,Z)|0,i=i+Math.imul(T,$)|0,n=(n=n+Math.imul(T,ee)|0)+Math.imul(S,$)|0,o=o+Math.imul(S,ee)|0,i=i+Math.imul(_,re)|0,n=(n=n+Math.imul(_,ie)|0)+Math.imul(w,re)|0,o=o+Math.imul(w,ie)|0,i=i+Math.imul(b,oe)|0,n=(n=n+Math.imul(b,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0,i=i+Math.imul(p,ue)|0,n=(n=n+Math.imul(p,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0;var Se=(c+(i=i+Math.imul(l,le)|0)|0)+((8191&(n=(n=n+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;c=((o=o+Math.imul(h,he)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(B,z),n=(n=Math.imul(B,X))+Math.imul(N,z)|0,o=Math.imul(N,X),i=i+Math.imul(L,G)|0,n=(n=n+Math.imul(L,H)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,H)|0,i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(O,W)|0,o=o+Math.imul(O,Y)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,i=i+Math.imul(M,$)|0,n=(n=n+Math.imul(M,ee)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,ee)|0,i=i+Math.imul(T,re)|0,n=(n=n+Math.imul(T,ie)|0)+Math.imul(S,re)|0,o=o+Math.imul(S,ie)|0,i=i+Math.imul(_,oe)|0,n=(n=n+Math.imul(_,ae)|0)+Math.imul(w,oe)|0,o=o+Math.imul(w,ae)|0,i=i+Math.imul(b,ue)|0,n=(n=n+Math.imul(b,ce)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,ce)|0,i=i+Math.imul(p,le)|0,n=(n=n+Math.imul(p,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Ee=(c+(i=i+Math.imul(l,pe)|0)|0)+((8191&(n=(n=n+Math.imul(l,ve)|0)+Math.imul(h,pe)|0))<<13)|0;c=((o=o+Math.imul(h,ve)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(B,G),n=(n=Math.imul(B,H))+Math.imul(N,G)|0,o=Math.imul(N,H),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,Y)|0)+Math.imul(j,W)|0,o=o+Math.imul(j,Y)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,ee)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,ee)|0,i=i+Math.imul(M,re)|0,n=(n=n+Math.imul(M,ie)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ie)|0,i=i+Math.imul(T,oe)|0,n=(n=n+Math.imul(T,ae)|0)+Math.imul(S,oe)|0,o=o+Math.imul(S,ae)|0,i=i+Math.imul(_,ue)|0,n=(n=n+Math.imul(_,ce)|0)+Math.imul(w,ue)|0,o=o+Math.imul(w,ce)|0,i=i+Math.imul(b,le)|0,n=(n=n+Math.imul(b,he)|0)+Math.imul(g,le)|0,o=o+Math.imul(g,he)|0;var Me=(c+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,ve)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,ve)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(B,W),n=(n=Math.imul(B,Y))+Math.imul(N,W)|0,o=Math.imul(N,Y),i=i+Math.imul(L,J)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,ee)|0)+Math.imul(O,$)|0,o=o+Math.imul(O,ee)|0,i=i+Math.imul(A,re)|0,n=(n=n+Math.imul(A,ie)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ie)|0,i=i+Math.imul(M,oe)|0,n=(n=n+Math.imul(M,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,i=i+Math.imul(T,ue)|0,n=(n=n+Math.imul(T,ce)|0)+Math.imul(S,ue)|0,o=o+Math.imul(S,ce)|0,i=i+Math.imul(_,le)|0,n=(n=n+Math.imul(_,he)|0)+Math.imul(w,le)|0,o=o+Math.imul(w,he)|0;var Ce=(c+(i=i+Math.imul(b,pe)|0)|0)+((8191&(n=(n=n+Math.imul(b,ve)|0)+Math.imul(g,pe)|0))<<13)|0;c=((o=o+Math.imul(g,ve)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(B,J),n=(n=Math.imul(B,Z))+Math.imul(N,J)|0,o=Math.imul(N,Z),i=i+Math.imul(L,$)|0,n=(n=n+Math.imul(L,ee)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,ee)|0,i=i+Math.imul(R,re)|0,n=(n=n+Math.imul(R,ie)|0)+Math.imul(O,re)|0,o=o+Math.imul(O,ie)|0,i=i+Math.imul(A,oe)|0,n=(n=n+Math.imul(A,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,i=i+Math.imul(M,ue)|0,n=(n=n+Math.imul(M,ce)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,ce)|0,i=i+Math.imul(T,le)|0,n=(n=n+Math.imul(T,he)|0)+Math.imul(S,le)|0,o=o+Math.imul(S,he)|0;var Pe=(c+(i=i+Math.imul(_,pe)|0)|0)+((8191&(n=(n=n+Math.imul(_,ve)|0)+Math.imul(w,pe)|0))<<13)|0;c=((o=o+Math.imul(w,ve)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(B,$),n=(n=Math.imul(B,ee))+Math.imul(N,$)|0,o=Math.imul(N,ee),i=i+Math.imul(L,re)|0,n=(n=n+Math.imul(L,ie)|0)+Math.imul(j,re)|0,o=o+Math.imul(j,ie)|0,i=i+Math.imul(R,oe)|0,n=(n=n+Math.imul(R,ae)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,ae)|0,i=i+Math.imul(A,ue)|0,n=(n=n+Math.imul(A,ce)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,ce)|0,i=i+Math.imul(M,le)|0,n=(n=n+Math.imul(M,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var Ae=(c+(i=i+Math.imul(T,pe)|0)|0)+((8191&(n=(n=n+Math.imul(T,ve)|0)+Math.imul(S,pe)|0))<<13)|0;c=((o=o+Math.imul(S,ve)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(B,re),n=(n=Math.imul(B,ie))+Math.imul(N,re)|0,o=Math.imul(N,ie),i=i+Math.imul(L,oe)|0,n=(n=n+Math.imul(L,ae)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,ae)|0,i=i+Math.imul(R,ue)|0,n=(n=n+Math.imul(R,ce)|0)+Math.imul(O,ue)|0,o=o+Math.imul(O,ce)|0,i=i+Math.imul(A,le)|0,n=(n=n+Math.imul(A,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var ke=(c+(i=i+Math.imul(M,pe)|0)|0)+((8191&(n=(n=n+Math.imul(M,ve)|0)+Math.imul(C,pe)|0))<<13)|0;c=((o=o+Math.imul(C,ve)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(B,oe),n=(n=Math.imul(B,ae))+Math.imul(N,oe)|0,o=Math.imul(N,ae),i=i+Math.imul(L,ue)|0,n=(n=n+Math.imul(L,ce)|0)+Math.imul(j,ue)|0,o=o+Math.imul(j,ce)|0,i=i+Math.imul(R,le)|0,n=(n=n+Math.imul(R,he)|0)+Math.imul(O,le)|0,o=o+Math.imul(O,he)|0;var Ie=(c+(i=i+Math.imul(A,pe)|0)|0)+((8191&(n=(n=n+Math.imul(A,ve)|0)+Math.imul(k,pe)|0))<<13)|0;c=((o=o+Math.imul(k,ve)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(B,ue),n=(n=Math.imul(B,ce))+Math.imul(N,ue)|0,o=Math.imul(N,ce),i=i+Math.imul(L,le)|0,n=(n=n+Math.imul(L,he)|0)+Math.imul(j,le)|0,o=o+Math.imul(j,he)|0;var Re=(c+(i=i+Math.imul(R,pe)|0)|0)+((8191&(n=(n=n+Math.imul(R,ve)|0)+Math.imul(O,pe)|0))<<13)|0;c=((o=o+Math.imul(O,ve)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(B,le),n=(n=Math.imul(B,he))+Math.imul(N,le)|0,o=Math.imul(N,he);var Oe=(c+(i=i+Math.imul(L,pe)|0)|0)+((8191&(n=(n=n+Math.imul(L,ve)|0)+Math.imul(j,pe)|0))<<13)|0;c=((o=o+Math.imul(j,ve)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863;var De=(c+(i=Math.imul(B,pe))|0)+((8191&(n=(n=Math.imul(B,ve))+Math.imul(N,pe)|0))<<13)|0;return c=((o=Math.imul(N,ve))+(n>>>13)|0)+(De>>>26)|0,De&=67108863,u[0]=me,u[1]=be,u[2]=ge,u[3]=ye,u[4]=_e,u[5]=we,u[6]=xe,u[7]=Te,u[8]=Se,u[9]=Ee,u[10]=Me,u[11]=Ce,u[12]=Pe,u[13]=Ae,u[14]=ke,u[15]=Ie,u[16]=Re,u[17]=Oe,u[18]=De,0!==c&&(u[19]=c,r.length++),r};function s(e,t,r){return(new u).mulp(e,t,r)}function u(e,t){this.x=e,this.y=t}Math.imul||(o=n),b.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?o(this,e,t):r<63?n(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r.strip()}(this,e,t):s(this,e,t)},u.prototype.makeRBT=function(e){for(var t=new Array(e),r=b.prototype._countBits(e)-1,i=0;i>=1;return i},u.prototype.permute=function(e,t,r,i,n,o){for(var a=0;a>>=1)n++;return 1<>>=13,r[2*o+1]=8191&n,n>>>=13;for(o=2*t;o>=26,t+=i/67108864|0,t+=n>>>26,this.words[r]=67108863&n}return 0!==t&&(this.words[r]=t,this.length++),this},b.prototype.muln=function(e){return this.clone().imuln(e)},b.prototype.sqr=function(){return this.mul(this)},b.prototype.isqr=function(){return this.imul(this.clone())},b.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>n}return t}(e);if(0===t.length)return new b(1);for(var r=this,i=0;i>>26-r<<26-r;if(0!=r){var o=0;for(t=0;t>>26-r}o&&(this.words[t]=o,this.length++)}if(0!=i){for(t=this.length-1;0<=t;t--)this.words[t+i]=this.words[t];for(t=0;t>>n<o)for(this.length-=o,u=0;u>>n,c=f&a}return s&&0!==c&&(s.words[s.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},b.prototype.ishrn=function(e,t,r){return m(0===this.negative),this.iushrn(e,t,r)},b.prototype.shln=function(e){return this.clone().ishln(e)},b.prototype.ushln=function(e){return this.clone().iushln(e)},b.prototype.shrn=function(e){return this.clone().ishrn(e)},b.prototype.ushrn=function(e){return this.clone().iushrn(e)},b.prototype.testn=function(e){m("number"==typeof e&&0<=e);var t=e%26,r=(e-t)/26,i=1<>>t<>26)-(s/67108864|0),this.words[i+r]=67108863&n}for(;i>26,this.words[i+r]=67108863&n;if(0===a)return this.strip();for(m(-1===a),i=a=0;i>26,this.words[i]=67108863&n;return this.negative=1,this.strip()},b.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,s=i.length-n.length;if("mod"!==t){(a=new b(null)).length=1+s,a.words=new Array(a.length);for(var u=0;uthis.length||this.cmp(e)<0?{div:new b(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new b(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new b(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,n,o},b.prototype.div=function(e){return this.divmod(e,"div",!1).div},b.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},b.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},b.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},b.prototype.modn=function(e){m(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;0<=i;i--)r=(t*r+(0|this.words[i]))%e;return r},b.prototype.idivn=function(e){m(e<=67108863);for(var t=0,r=this.length-1;0<=r;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},b.prototype.divn=function(e){return this.clone().idivn(e)},b.prototype.egcd=function(e){m(0===e.negative),m(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new b(1),n=new b(0),o=new b(0),a=new b(1),s=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++s;for(var u=r.clone(),c=t.clone();!t.isZero();){for(var f=0,l=1;0==(t.words[0]&l)&&f<26;++f,l<<=1);if(0>>26,a&=67108863,this.words[o]=a}return 0!==n&&(this.words[o]=n,this.length++),this},b.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},b.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),1e.length)return 1;if(this.lengththis.n;);var i=t>>22,n=o}n>>>=22,0===(e.words[i-10]=n)&&10>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},b._prime=function(e){if(c[e])return c[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new y;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return c[e]=t},w.prototype._verify1=function(e){m(0===e.negative,"red works only with positives"),m(e.red,"red works only with red numbers")},w.prototype._verify2=function(e,t){m(0==(e.negative|t.negative),"red works only with positives"),m(e.red&&e.red===t.red,"red works only with red numbers")},w.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},w.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},w.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r},w.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},w.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},w.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},w.prototype.isqr=function(e){return this.imul(e,e.clone())},w.prototype.sqr=function(e){return this.mul(e,e)},w.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(m(t%2==1),3===t){var r=this.m.add(new b(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);m(!i.isZero());var o=new b(1).toRed(this),a=o.redNeg(),s=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new b(2*u*u).toRed(this);0!==this.pow(u,s).cmp(a);)u.redIAdd(a);for(var c=this.pow(u,i),f=this.pow(e,i.addn(1).iushrn(1)),l=this.pow(e,i),h=n;0!==l.cmp(o);){for(var d=l,p=0;0!==d.cmp(o);p++)d=d.redSqr();m(p>c&1;n!==r[0]&&(n=this.sqr(n)),0!=f||0!==o?(o<<=1,o|=f,(4===++a||0===i&&0===c)&&(n=this.mul(n,r[o]),o=a=0)):a=0}s=26}return n},w.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},w.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},b.mont=function(e){return new x(e)},r(x,w),x.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},x.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},x.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return 0<=n.cmp(this.m)?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new b(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return 0<=n.cmp(this.m)?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},x.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:19}],18:[function(e,t,r){var i;function n(e){this.rand=e}if(t.exports=function(e){return i||(i=new n(null)),i.generate(e)},(t.exports.Rand=n).prototype.generate=function(e){return this._rand(e)},n.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^f[p>>>16&255]^l[v>>>8&255]^h[255&m]^t[b++],a=c[p>>>24]^f[v>>>16&255]^l[m>>>8&255]^h[255&d]^t[b++],s=c[v>>>24]^f[m>>>16&255]^l[d>>>8&255]^h[255&p]^t[b++],u=c[m>>>24]^f[d>>>16&255]^l[p>>>8&255]^h[255&v]^t[b++],d=o,p=a,v=s,m=u;return o=(i[d>>>24]<<24|i[p>>>16&255]<<16|i[v>>>8&255]<<8|i[255&m])^t[b++],a=(i[p>>>24]<<24|i[v>>>16&255]<<16|i[m>>>8&255]<<8|i[255&d])^t[b++],s=(i[v>>>24]<<24|i[m>>>16&255]<<16|i[d>>>8&255]<<8|i[255&p])^t[b++],u=(i[m>>>24]<<24|i[d>>>16&255]<<16|i[p>>>8&255]<<8|i[255&v])^t[b++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var l=[0,1,2,4,8,16,32,64,128,27,54],h=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],i=[],n=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99;var f=e[i[r[a]=c]=a],l=e[f],h=e[l],d=257*e[c]^16843008*c;n[0][a]=d<<24|d>>>8,n[1][a]=d<<16|d>>>16,n[2][a]=d<<8|d>>>24,n[3][a]=d,d=16843009*h^65537*l^257*f^16843008*a,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===a?a=s=1:(a=f^e[e[e[h^f]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:i,SUB_MIX:n,INV_SUB_MIX:o}}();function s(e){this._key=o(e),this._reset()}s.blockSize=16,s.keySize=32,s.prototype.blockSize=s.blockSize,s.prototype.keySize=s.keySize,s.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,i=4*(r+1),n=[],o=0;o>>24,a=h.SBOX[a>>>24]<<24|h.SBOX[a>>>16&255]<<16|h.SBOX[a>>>8&255]<<8|h.SBOX[255&a],a^=l[o/t|0]<<24):6>>24]<<24|h.SBOX[a>>>16&255]<<16|h.SBOX[a>>>8&255]<<8|h.SBOX[255&a]),n[o]=n[o-t]^a}for(var s=[],u=0;u>>24]]^h.INV_SUB_MIX[1][h.SBOX[f>>>16&255]]^h.INV_SUB_MIX[2][h.SBOX[f>>>8&255]]^h.INV_SUB_MIX[3][h.SBOX[255&f]]}this._nRounds=r,this._keySchedule=n,this._invKeySchedule=s},s.prototype.encryptBlockRaw=function(e){return a(e=o(e),this._keySchedule,h.SUB_MIX,h.SBOX,this._nRounds)},s.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},s.prototype.decryptBlock=function(e){var t=(e=o(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,h.INV_SUB_MIX,h.INV_SBOX,this._nRounds),i=n.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},s.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},t.exports.AES=s},{"safe-buffer":143}],21:[function(e,t,r){var a=e("./aes"),c=e("safe-buffer").Buffer,s=e("cipher-base"),i=e("inherits"),f=e("./ghash"),n=e("buffer-xor"),l=e("./incr32");function o(e,t,r,i){s.call(this);var n=c.alloc(4,0);this._cipher=new a.AES(t);var o=this._cipher.encryptBlock(n);this._ghash=new f(o),r=function(e,t,r){if(12===t.length)return e._finID=c.concat([t,c.from([0,0,0,1])]),c.concat([t,c.from([0,0,0,2])]);var i=new f(r),n=t.length,o=n%16;i.update(t),o&&(o=16-o,i.update(c.alloc(o,0))),i.update(c.alloc(8,0));var a=8*n,s=c.alloc(8);s.writeUIntBE(a,0,8),i.update(s),e._finID=i.state;var u=c.from(e._finID);return l(u),u}(this,r,o),this._prev=c.from(r),this._cache=c.allocUnsafe(0),this._secCache=c.allocUnsafe(0),this._decrypt=i,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}i(o,s),o.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=c.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},o.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=n(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var i=Math.min(e.length,t.length),n=0;n>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=i.alloc(16,0),this.cache=i.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t>>1|(1&r[e-1])<<31;r[0]=r[0]>>>1,t&&(r[0]=r[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=i.concat([this.cache,e]);16<=this.cache.length;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(i.concat([this.cache,n],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":143}],26:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],27:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":48}],28:[function(e,t,r){var o=e("safe-buffer").Buffer,a=e("buffer-xor");function s(e,t,r){var i=t.length,n=a(t,e._cache);return e._cache=e._cache.slice(i),e._prev=o.concat([e._prev,r?t:n]),n}r.encrypt=function(e,t,r){for(var i,n=o.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=o.allocUnsafe(0)),!(e._cache.length<=t.length)){n=o.concat([n,s(e,t,r)]);break}i=e._cache.length,n=o.concat([n,s(e,t.slice(0,i),r)]),t=t.slice(i)}return n}},{"buffer-xor":48,"safe-buffer":143}],29:[function(e,t,r){var a=e("safe-buffer").Buffer;function s(e,t,r){for(var i,n,o=-1,a=0;++o<8;)i=t&1<<7-o?128:0,a+=(128&(n=e._cipher.encryptBlock(e._prev)[0]^i))>>o%8,e._prev=u(e._prev,r?i:n);return a}function u(e,t){var r=e.length,i=-1,n=a.allocUnsafe(e.length);for(e=a.concat([e,a.from([t])]);++i>7;return n}r.encrypt=function(e,t,r){for(var i=t.length,n=a.allocUnsafe(i),o=-1;++o=t)throw new Error("invalid sig")}t.exports=function(e,t,r,i,n){var o=v(r);if("ec"===o.type){if("ecdsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong public key type");return function(e,t,r){var i=m[r.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var n=new p(i),o=r.data.subjectPrivateKey.data;return n.verify(t,e,o)}(e,t,o)}if("dsa"===o.type){if("dsa"!==i)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,n=r.data.q,o=r.data.g,a=r.data.pub_key,s=v.signature.decode(e,"der"),u=s.s,c=s.r;b(u,n),b(c,n);var f=d.mont(i),l=u.invm(n);return 0===o.toRed(f).redPow(new d(t).mul(l).mod(n)).fromRed().mul(a.toRed(f).redPow(c.mul(l).mod(n)).fromRed()).mod(i).mod(n).cmp(c)}(e,t,o)}if("rsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong public key type");t=h.concat([n,t]);for(var a=o.modulus.byteLength(),s=[1],u=0;t.length+s.length+2=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function d(e,t){if(l.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return D(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return L(e).length;default:if(i)return D(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function v(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):2147483647=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=l.from(t,i)),l.isBuffer(t))return 0===t.length?-1:m(e,t,r,i,n);if("number"==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,i,n){var o,a=1,s=e.length,u=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s/=a=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(n){var f=-1;for(o=r;o>>10&1023|55296),f=56320|1023&f),i.push(f),n+=l}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);var r="",i=0;for(;ithis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return S(this,t,r);case"utf8":case"utf-8":return _(this,t,r);case"ascii":return x(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return y(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}.apply(this,arguments)},l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.prototype.inspect=function(){var e="",t=B.INSPECT_MAX_BYTES;return 0t&&(e+=" ... ")),""},l.prototype.compare=function(e,t,r,i,n){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(n<=i&&r<=t)return 0;if(n<=i)return-1;if(r<=t)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(i,n),c=e.slice(t,r),f=0;fthis.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o,a,s,u,c,f,l,h,d,p=!1;;)switch(i){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return h=t,d=r,j(D(e,(l=this).length-h),l,h,d);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return g(this,e,t,r);case"base64":return u=this,c=t,f=r,j(L(e),u,c,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=t,s=r,j(function(e,t){for(var r,i,n,o=[],a=0;a>8,n=r%256,o.push(n),o.push(i);return o}(e,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),p=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function x(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;ne.length)throw new RangeError("Index out of range")}function P(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,o=Math.min(e.length-r,2);n>>8*(i?n:1-n)}function A(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,o=Math.min(e.length-r,4);n>>8*(i?n:3-n)&255}function k(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(e,t,r,i,n){return n||k(e,0,r,4),o.write(e,t,r,i,23,4),r+4}function R(e,t,r,i,n){return n||k(e,0,r,8),o.write(e,t,r,i,52,8),r+8}l.prototype.slice=function(e,t){var r,i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):i>>8):P(this,e,t,!0),t+2},l.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},l.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):A(this,e,t,!0),t+4},l.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):A(this,e,t,!1),t+4},l.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*r-1);C(this,e,t,r,n-1,-n)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},l.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*r-1);C(this,e,t,r,n-1,-n)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;0<=--o&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},l.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},l.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},l.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):A(this,e,t,!0),t+4},l.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):A(this,e,t,!1),t+4},l.prototype.writeFloatLE=function(e,t,r){return I(this,e,t,!0,r)},l.prototype.writeFloatBE=function(e,t,r){return I(this,e,t,!1,r)},l.prototype.writeDoubleLE=function(e,t,r){return R(this,e,t,!0,r)},l.prototype.writeDoubleBE=function(e,t,r){return R(this,e,t,!1,r)},l.prototype.copy=function(e,t,r,i){if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),0=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function L(e){return i.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(t,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function j(e,t,r,i){for(var n=0;n=t.length||n>=e.length);++n)t[n+r]=e[n];return n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":16,ieee754:101,isarray:105}],50:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){i=e}finally{r(i)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var i=this._decoder.write(e);return r&&(i+=this._decoder.end()),i},t.exports=a},{inherits:103,"safe-buffer":143,stream:152,string_decoder:153}],51:[function(e,t,r){(function(e){function t(e){return Object.prototype.toString.call(e)}r.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===t(e)},r.isBoolean=function(e){return"boolean"==typeof e},r.isNull=function(e){return null===e},r.isNullOrUndefined=function(e){return null==e},r.isNumber=function(e){return"number"==typeof e},r.isString=function(e){return"string"==typeof e},r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=function(e){return void 0===e},r.isRegExp=function(e){return"[object RegExp]"===t(e)},r.isObject=function(e){return"object"==typeof e&&null!==e},r.isDate=function(e){return"[object Date]"===t(e)},r.isError=function(e){return"[object Error]"===t(e)||e instanceof Error},r.isFunction=function(e){return"function"==typeof e},r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":104}],52:[function(e,s,t){(function(o){var t=e("elliptic"),i=e("bn.js");s.exports=function(e){return new n(e)};var r={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function n(e){this.curveType=r[e],this.curveType||(this.curveType={name:e}),this.curve=new t.ec(this.curveType.name),this.keys=void 0}function a(e,t,r){Array.isArray(e)||(e=e.toArray());var i=new o(e);if(r&&i.length>>2),i=0,n=0;i>5]|=128<>>9<<4)]=t;for(var r=1732584193,i=-271733879,n=-1732584194,o=271733878,a=0;a>>32-t}(v(v(t,e),v(i,o)),n),r)}function l(e,t,r,i,n,o,a){return s(t&r|~t&i,e,t,n,o,a)}function h(e,t,r,i,n,o,a){return s(t&i|r&~i,e,t,n,o,a)}function d(e,t,r,i,n,o,a){return s(t^r^i,e,t,n,o,a)}function p(e,t,r,i,n,o,a){return s(r^(t|~i),e,t,n,o,a)}function v(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return i(e,n)}},{"./make-hash":54}],56:[function(e,t,r){"use strict";var i=e("inherits"),n=e("./legacy"),a=e("cipher-base"),s=e("safe-buffer").Buffer,o=e("create-hash/md5"),u=e("ripemd160"),c=e("sha.js"),f=s.alloc(128);function l(e,t){a.call(this,"digest"),"string"==typeof t&&(t=s.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,(this._key=t).length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.length>>1];r=h.r28shl(r,o),i=h.r28shl(i,o),h.pc2(r,i,e.keys,n)}},u.prototype._update=function(e,t,r,i){var n=this._desState,o=h.readUInt32BE(e,t),a=h.readUInt32BE(e,t+4);h.ip(o,a,n.tmp,0),o=n.tmp[0],a=n.tmp[1],"encrypt"===this.type?this._encrypt(n,o,a,n.tmp,0):this._decrypt(n,o,a,n.tmp,0),o=n.tmp[0],a=n.tmp[1],h.writeUInt32BE(r,o,i),h.writeUInt32BE(r,a,i+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,i=t;i>>0,o=l}h.rip(a,o,i,n)},u.prototype._decrypt=function(e,t,r,i,n){for(var o=r,a=t,s=e.keys.length-2;0<=s;s-=2){var u=e.keys[s],c=e.keys[s+1];h.expand(o,e.tmp,0),u^=e.tmp[0],c^=e.tmp[1];var f=h.substitute(u,c),l=o;o=(a^h.permute(f))>>>0,a=l}h.rip(o,a,i,n)}},{"../des":59,inherits:103,"minimalistic-assert":109}],63:[function(e,t,r){"use strict";var o=e("minimalistic-assert"),i=e("inherits"),n=e("../des"),a=n.Cipher,s=n.DES;function u(e,t){o.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),n=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:n})]:[s.create({type:"decrypt",key:n}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}function c(e){a.call(this,e);var t=new u(this.type,this.options.key);this._edeState=t}i(c,a),(t.exports=c).create=function(e){return new c(e)},c.prototype._update=function(e,t,r,i){var n=this._edeState;n.ciphers[0]._update(e,t,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},c.prototype._pad=s.prototype._pad,c.prototype._unpad=s.prototype._unpad},{"../des":59,inherits:103,"minimalistic-assert":109}],64:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,i){for(var n=0,o=0,a=6;0<=a;a-=2){for(var s=0;s<=24;s+=8)n<<=1,n|=t>>>s+a&1;for(s=0;s<=24;s+=8)n<<=1,n|=e>>>s+a&1}for(a=6;0<=a;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[i+0]=n>>>0,r[i+1]=o>>>0},r.rip=function(e,t,r,i){for(var n=0,o=0,a=0;a<4;a++)for(var s=24;0<=s;s-=8)n<<=1,n|=t>>>s+a&1,n<<=1,n|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;0<=s;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[i+0]=n>>>0,r[i+1]=o>>>0},r.pc1=function(e,t,r,i){for(var n=0,o=0,a=7;5<=a;a--){for(var s=0;s<=24;s+=8)n<<=1,n|=t>>s+a&1;for(s=0;s<=24;s+=8)n<<=1,n|=e>>s+a&1}for(s=0;s<=24;s+=8)n<<=1,n|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[i+0]=n>>>0,r[i+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var u=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var n=0,o=0,a=u.length>>>1,s=0;s>>u[s]&1;for(s=a;s>>u[s]&1;r[i+0]=n>>>0,r[i+1]=o>>>0},r.expand=function(e,t,r){var i=0,n=0;i=(1&e)<<5|e>>>27;for(var o=23;15<=o;o-=4)i<<=6,i|=e>>>o&63;for(o=11;3<=o;o-=4)n|=e>>>o&63,n<<=6;n|=(31&e)<<1|e>>>31,t[r+0]=i>>>0,t[r+1]=n>>>0};var n=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,i=0;i<4;i++){r<<=4,r|=n[64*i+(e>>>18-6*i&63)]}for(i=0;i<4;i++){r<<=4,r|=n[256+64*i+(t>>>18-6*i&63)]}return r>>>0};var i=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>i[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var i=e.toString(2);i.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(u),r.testn(1)||r.iadd(c),t.cmp(c)){if(!t.cmp(f))for(;r.mod(l).cmp(h);)r.iadd(p)}else for(;r.mod(a).cmp(d);)r.iadd(p);if(m(i=r.shrn(1))&&m(r)&&b(i)&&b(r)&&s.test(i)&&s.test(r))return r}}},{"bn.js":17,"miller-rabin":108,randombytes:130}],68:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],69:[function(e,t,r){"use strict";var i=r;i.version=e("../package.json").version,i.utils=e("./elliptic/utils"),i.rand=e("brorand"),i.curve=e("./elliptic/curve"),i.curves=e("./elliptic/curves"),i.ec=e("./elliptic/ec"),i.eddsa=e("./elliptic/eddsa")},{"../package.json":84,"./elliptic/curve":72,"./elliptic/curves":75,"./elliptic/ec":76,"./elliptic/eddsa":79,"./elliptic/utils":83,brorand:18}],70:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../../elliptic").utils,E=n.getNAF,M=n.getJSF,l=n.assert;function o(e,t){this.type=e,this.p=new i(t.p,16),this.red=t.prime?i.red(t.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=t.n&&new i(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||0>1]):a.mixedAdd(n[-u-1>>1].neg()):0>1]):a.add(n[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},o.prototype._wnafMulAdd=function(e,t,r,i,n){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,c=0;c>1]:S<0&&(T=a[m][-S-1>>1].neg()),y="affine"===T.type?y.mixedAdd(T):y.add(T))}}for(c=0;c=Math.ceil((e.bitLength()+1)/t.step)},a.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(e),n=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=i.redAdd(t),a=o.redSub(r),s=i.redSub(t),u=n.redMul(a),c=o.redMul(s),f=n.redMul(s),l=a.redMul(o);return this.curve.point(u,c,l,f)},f.prototype._projDbl=function(){var e,t,r,i=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(n)).redAdd(o);if(this.zOne)e=i.redSub(n).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=i.redSub(n).redISub(o).redMul(u),t=a.redMul(c.redSub(o)),r=a.redMul(u)}}else{var c=n.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(s).redSub(s);e=this.curve._mulC(i.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(n.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),n=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=n.redSub(i),s=n.redAdd(i),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),l=o.redMul(u),h=a.redMul(s);return this.curve.point(c,f,h,l)},f.prototype._projAdd=function(e){var t,r,i=this.z.redMul(e.z),n=i.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=n.redSub(s),c=n.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),l=i.redMul(u).redMul(f);return r=this.curve.twisted?(t=i.redMul(c).redMul(a.redSub(this.curve._mulA(o))),u.redMul(c)):(t=i.redMul(c).redMul(a.redSub(o)),this.curve._mulC(u).redMul(c)),this.curve.point(l,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),0<=r.cmp(this.curve.p))return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},{"../../elliptic":69,"../curve":72,"bn.js":17,inherits:103}],72:[function(e,t,r){"use strict";var i=r;i.base=e("./base"),i.short=e("./short"),i.mont=e("./mont"),i.edwards=e("./edwards")},{"./base":70,"./edwards":71,"./mont":73,"./short":74}],73:[function(e,t,r){"use strict";var i=e("../curve"),n=e("bn.js"),o=e("inherits"),a=i.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),(t.exports=u).prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),i=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===i.redSqrt().redSqr().cmp(i)},o(c,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),i=e.redMul(t),n=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=n.redMul(i),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,i=this.curve.point(null,null),n=[];0!==t.cmpn(0);t.iushrn(1))n.push(t.andln(1));for(var o=n.length-1;0<=o;o--)0===n[o]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":69,"../curve":72,"bn.js":17,inherits:103}],74:[function(e,t,r){"use strict";var i=e("../curve"),n=e("../../elliptic"),w=e("bn.js"),o=e("inherits"),a=i.base,s=n.utils.assert;function u(e){a.call(this,"short",e),this.a=new w(e.a,16).toRed(this.red),this.b=new w(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function c(e,t,r,i){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new w(t,16),this.y=new w(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,i){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new w(0)):(this.x=new w(t,16),this.y=new w(r,16),this.z=new w(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,a),(t.exports=u).prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new w(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=(t=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(e.lambda)r=new w(e.lambda,16);else{var n=this._getEndoRoots(this.n);0===this.g.mul(n[0]).x.cmp(this.g.x.redMul(t))?r=n[0]:(r=n[1],s(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new w(e.a,16),b:new w(e.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:w.mont(e),r=new w(2).toRed(t).redInvm(),i=r.redNeg(),n=new w(3).toRed(t).redNeg().redSqrt().redMul(r);return[i.redAdd(n).fromRed(),i.redSub(n).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,i,n,o,a,s,u,c,f=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,h=this.n.clone(),d=new w(1),p=new w(0),v=new w(0),m=new w(1),b=0;0!==l.cmpn(0);){var g=h.div(l);u=h.sub(g.mul(l)),c=v.sub(g.mul(d));var y=m.sub(g.mul(p));if(!i&&u.cmp(f)<0)t=s.neg(),r=d,i=u.neg(),n=c;else if(i&&2==++b)break;h=l,l=s=u,v=d,d=c,m=p,p=y}o=u.neg(),a=c;var _=i.sqr().add(n.sqr());return 0<=o.sqr().add(a.sqr()).cmp(_)&&(o=t,a=r),i.negative&&(i=i.neg(),n=n.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:n},{a:o,b:a}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],n=i.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=n.mul(r.a),s=o.mul(i.a),u=n.mul(r.b),c=o.mul(i.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},u.prototype.pointFromX=function(e,t){(e=new w(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(t&&!n||!t&&n)&&(i=i.redNeg()),this.point(e,i)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,o=0;o":""},c.prototype.isInfinity=function(){return this.inf},c.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},c.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),o=n.redSqr().redISub(this.x.redAdd(this.x)),a=n.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},c.prototype.getX=function(){return this.x.fromRed()},c.prototype.getY=function(){return this.y.fromRed()},c.prototype.mul=function(e){return e=new w(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},c.prototype.jmulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},c.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},c.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t},c.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),n=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=i.redSub(n),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),l=i.redMul(c),h=u.redSqr().redIAdd(f).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),n=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(i),s=n.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),l=s.redSqr().redIAdd(c).redISub(f).redISub(f),h=s.redMul(f.redISub(l)).redISub(n.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":69,"../curve":72,"bn.js":17,inherits:103}],75:[function(e,t,r){"use strict";var i,n=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(t,r){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var e=new u(r);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:e}),e}})}n.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=e("./precomputed/secp256k1")}catch(e){i=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},{"../elliptic":69,"./precomputed/secp256k1":82,"hash.js":88}],76:[function(e,t,r){"use strict";var m=e("bn.js"),b=e("hmac-drbg"),o=e("../../elliptic"),d=o.utils.assert,i=e("./key"),g=e("./signature");function n(e){if(!(this instanceof n))return new n(e);"string"==typeof e&&(d(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}(t.exports=n).prototype.keyPair=function(e){return new i(this,e)},n.prototype.keyFromPrivate=function(e,t){return i.fromPrivate(this,e,t)},n.prototype.keyFromPublic=function(e,t){return i.fromPublic(this,e,t)},n.prototype.genKeyPair=function(e){e||(e={});for(var t=new b({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new m(2));;){var n=new m(t.generate(r));if(!(0>1;if(0<=a.cmp(this.curve.p.umod(this.curve.n))&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),u):this.curve.pointFromX(a,u);var f=t.r.invm(n),l=n.sub(o).mul(f).umod(n),h=s.mul(f).umod(n);return this.g.mulAdd(l,a,h)},n.prototype.getKeyRecoveryParam=function(e,t,r,i){if(null!==(t=new g(t,i)).recoveryParam)return t.recoveryParam;for(var n=0;n<4;n++){var o;try{o=this.recoverPubKey(e,t,n)}catch(e){continue}if(o.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":69,"./key":77,"./signature":78,"bn.js":17,"hmac-drbg":100}],77:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}(t.exports=o).fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new i(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?n(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||n(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":69,"bn.js":17}],78:[function(e,t,r){"use strict";var s=e("bn.js"),u=e("../../elliptic").utils,i=u.assert;function n(e,t){if(e instanceof n)return e;this._importDER(e,t)||(i(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function c(){this.place=0}function f(e,t){var r=e[t.place++];if(!(128&r))return r;for(var i=15&r,n=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}(t.exports=n).prototype._importDER=function(e,t){e=u.toArray(e,t);var r=new c;if(48!==e[r.place++])return!1;if(f(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var i=f(e,r),n=e.slice(r.place,i+r.place);if(r.place+=i,2!==e[r.place++])return!1;var o=f(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===n[0]&&128&n[1]&&(n=n.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(n),this.s=new s(a),!(this.recoveryParam=null)},n.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=a(t),r=a(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];l(i,t.length),(i=i.concat(t)).push(2),l(i,r.length);var n=i.concat(r),o=[48];return l(o,n.length),o=o.concat(n),u.encode(o,e)}},{"../../elliptic":69,"bn.js":17}],79:[function(e,t,r){"use strict";var i=e("hash.js"),n=e("../../elliptic"),o=n.utils,a=o.assert,u=o.parseBytes,s=e("./key"),c=e("./signature");function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=n.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=i.sha512}(t.exports=f).prototype.sign=function(e,t){e=u(e);var r=this.keyFromSecret(t),i=this.hashInt(r.messagePrefix(),e),n=this.g.mul(i),o=this.encodePoint(n),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),s=i.add(a).umod(this.curve.n);return this.makeSignature({R:n,S:s,Rencoded:o})},f.prototype.verify=function(e,t,r){e=u(e),t=this.makeSignature(t);var i=this.keyFromPublic(r),n=this.hashInt(t.Rencoded(),i.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(i.pub().mul(n)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t>1)-1>1)-a:a,n.isubn(o)}else o=0;r.push(o);for(var s=0!==n.cmpn(0)&&0===n.andln(i-1)?t+1:1,u=1;ur&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},i.prototype.once=function(e,t){if(!u(t))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(e,i),r||(r=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},i.prototype.removeListener=function(e,t){var r,i,n,o;if(!u(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=(r=this._events[e]).length,i=-1,r===t||u(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(c(r)){for(o=n;0=this._blockSize;){for(var n=this._blockOffset;n=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,i[n++]=e>>>16&255,i[n++]=e>>>8&255,i[n++]=255&e}else for(i[n++]=255&e,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),n(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return i(e,17)^i(e,19)^e>>>10}},{"../utils":99}],99:[function(e,t,r){"use strict";var c=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function n(e){return 1===e.length?"0"+e:e}function a(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>8,a=255&n;o?r.push(o,a):r.push(a)}else for(i=0;i>>0}return o},r.split32=function(e,t){for(var r=new Array(4*e.length),i=0,n=0;i>>24,r[n+1]=o>>>16&255,r[n+2]=o>>>8&255,r[n+3]=255&o):(r[n+3]=o>>>24,r[n+2]=o>>>16&255,r[n+1]=o>>>8&255,r[n]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,i){return e+t+r+i>>>0},r.sum32_5=function(e,t,r,i,n){return e+t+r+i+n>>>0},r.sum64=function(e,t,r,i){var n=e[t],o=i+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,i){return(t+i>>>0>>0},r.sum64_lo=function(e,t,r,i){return t+i>>>0},r.sum64_4_hi=function(e,t,r,i,n,o,a,s){var u=0,c=t;return u+=(c=c+i>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,i,n,o,a,s){return t+i+o+s>>>0},r.sum64_5_hi=function(e,t,r,i,n,o,a,s,u,c){var f=0,l=t;return f+=(l=l+i>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,i,n,o,a,s,u,c){return t+i+o+s+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:103,"minimalistic-assert":109}],100:[function(e,t,r){"use strict";var i=e("hash.js"),a=e("minimalistic-crypto-utils"),n=e("minimalistic-assert");function o(e){if(!(this instanceof o))return new o(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=a.toArray(e.entropy,e.entropyEnc||"hex"),r=a.toArray(e.nonce,e.nonceEnc||"hex"),i=a.toArray(e.pers,e.persEnc||"hex");n(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,i)}(t.exports=o).prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},o.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=r,r=t,t=null),r&&(r=a.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length>1,f=-7,l=r?n-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-f)-1,d>>=-f,f+=s;0>=-f,f+=i;0>1,h=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:o-1,p=i?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(t+=1<=a+l?h/u:h*Math.pow(2,1-l))*u&&(a++,u/=2),f<=a+l?(s=0,a=f):1<=a+l?(s=(t*u-1)*Math.pow(2,n),a+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,n),a=0));8<=n;e[r+d]=255&s,d+=p,s/=256,n-=8);for(a=a<>>32-t}function u(e,t,r,i,n,o,a){return s(e+(t&r|~t&i)+n+o|0,a)+t|0}function c(e,t,r,i,n,o,a){return s(e+(t&i|r&~i)+n+o|0,a)+t|0}function f(e,t,r,i,n,o,a){return s(e+(t^r^i)+n+o|0,a)+t|0}function l(e,t,r,i,n,o,a){return s(e+(r^(t|~i))+n+o|0,a)+t|0}e(i,r),i.prototype._update=function(){for(var e=a,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,i=this._b,n=this._c,o=this._d;i=l(i=l(i=l(i=l(i=f(i=f(i=f(i=f(i=c(i=c(i=c(i=c(i=u(i=u(i=u(i=u(i,n=u(n,o=u(o,r=u(r,i,n,o,e[0],3614090360,7),i,n,e[1],3905402710,12),r,i,e[2],606105819,17),o,r,e[3],3250441966,22),n=u(n,o=u(o,r=u(r,i,n,o,e[4],4118548399,7),i,n,e[5],1200080426,12),r,i,e[6],2821735955,17),o,r,e[7],4249261313,22),n=u(n,o=u(o,r=u(r,i,n,o,e[8],1770035416,7),i,n,e[9],2336552879,12),r,i,e[10],4294925233,17),o,r,e[11],2304563134,22),n=u(n,o=u(o,r=u(r,i,n,o,e[12],1804603682,7),i,n,e[13],4254626195,12),r,i,e[14],2792965006,17),o,r,e[15],1236535329,22),n=c(n,o=c(o,r=c(r,i,n,o,e[1],4129170786,5),i,n,e[6],3225465664,9),r,i,e[11],643717713,14),o,r,e[0],3921069994,20),n=c(n,o=c(o,r=c(r,i,n,o,e[5],3593408605,5),i,n,e[10],38016083,9),r,i,e[15],3634488961,14),o,r,e[4],3889429448,20),n=c(n,o=c(o,r=c(r,i,n,o,e[9],568446438,5),i,n,e[14],3275163606,9),r,i,e[3],4107603335,14),o,r,e[8],1163531501,20),n=c(n,o=c(o,r=c(r,i,n,o,e[13],2850285829,5),i,n,e[2],4243563512,9),r,i,e[7],1735328473,14),o,r,e[12],2368359562,20),n=f(n,o=f(o,r=f(r,i,n,o,e[5],4294588738,4),i,n,e[8],2272392833,11),r,i,e[11],1839030562,16),o,r,e[14],4259657740,23),n=f(n,o=f(o,r=f(r,i,n,o,e[1],2763975236,4),i,n,e[4],1272893353,11),r,i,e[7],4139469664,16),o,r,e[10],3200236656,23),n=f(n,o=f(o,r=f(r,i,n,o,e[13],681279174,4),i,n,e[0],3936430074,11),r,i,e[3],3572445317,16),o,r,e[6],76029189,23),n=f(n,o=f(o,r=f(r,i,n,o,e[9],3654602809,4),i,n,e[12],3873151461,11),r,i,e[15],530742520,16),o,r,e[2],3299628645,23),n=l(n,o=l(o,r=l(r,i,n,o,e[0],4096336452,6),i,n,e[7],1126891415,10),r,i,e[14],2878612391,15),o,r,e[5],4237533241,21),n=l(n,o=l(o,r=l(r,i,n,o,e[12],1700485571,6),i,n,e[3],2399980690,10),r,i,e[10],4293915773,15),o,r,e[1],2240044497,21),n=l(n,o=l(o,r=l(r,i,n,o,e[8],1873313359,6),i,n,e[15],4264355552,10),r,i,e[6],2734768916,15),o,r,e[13],1309151649,21),n=l(n,o=l(o,r=l(r,i,n,o,e[4],4149444226,6),i,n,e[11],3174756917,10),r,i,e[2],718787259,15),o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+o|0},i.prototype._digest=function(){this._block[this._blockOffset++]=128,56=this._blockSize;){for(var n=this._blockOffset;n>8,a=255&n;o?r.push(o,a):r.push(a)}return r},i.zero2=n,i.toHex=o,i.encode=function(e,t){return"hex"===t?o(e):e}},{}],111:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],112:[function(e,t,r){"use strict";var i=e("asn1.js");r.certificate=e("./certificate");var n=i.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=n;var o=i.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=i.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=i.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=i.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var c=i.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=c;var f=i.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=f,r.DSAparam=i.define("DSAparam",function(){this.int()});var l=i.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(h),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=l;var h=i.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=i.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":113,"asn1.js":2}],113:[function(e,t,r){"use strict";var i=e("asn1.js"),n=i.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=i.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=i.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=i.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=i.define("RelativeDistinguishedName",function(){this.setof(o)}),c=i.define("RDNSequence",function(){this.seqof(u)}),f=i.define("Name",function(){this.choice({rdnSequence:this.use(c)})}),l=i.define("Validity",function(){this.seq().obj(this.key("notBefore").use(n),this.key("notAfter").use(n))}),h=i.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=i.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(l),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(h).optional())}),p=i.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":2}],114:[function(e,t,r){(function(h){var d=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,p=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,v=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,m=e("evp_bytestokey"),b=e("browserify-aes");t.exports=function(e,t){var r,i=e.toString(),n=i.match(d);if(n){var o="aes"+n[1],a=new h(n[2],"hex"),s=new h(n[3].replace(/\r?\n/g,""),"base64"),u=m(t,a.slice(0,8),parseInt(n[1],10)).key,c=[],f=b.createDecipheriv(o,u,a);c.push(f.update(s)),c.push(f.final()),r=h.concat(c)}else{var l=i.match(v);r=new h(l[2].replace(/\r?\n/g,""),"base64")}return{tag:i.match(p)[1],data:r}}}).call(this,e("buffer").Buffer)},{"browserify-aes":22,buffer:49,evp_bytestokey:86}],115:[function(t,r,e){(function(l){var s=t("./asn1"),h=t("./aesid.json"),u=t("./fixProc"),d=t("browserify-aes"),p=t("pbkdf2");function e(e){var t;"object"!=typeof e||l.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new l(e));var r,i,n=u(e,t),o=n.tag,a=n.data;switch(o){case"CERTIFICATE":i=s.certificate.decode(a,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(i||(i=s.PublicKey.decode(a,"der")),r=i.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPublicKey.decode(i.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return i.subjectPrivateKey=i.subjectPublicKey,{type:"ec",data:i};case"1.2.840.10040.4.1":return i.algorithm.params.pub_key=s.DSAparam.decode(i.subjectPublicKey.data,"der"),{type:"dsa",data:i.algorithm.params};default:throw new Error("unknown key id "+r)}throw new Error("unknown key type "+o);case"ENCRYPTED PRIVATE KEY":a=function(e,t){var r=e.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),n=h[e.algorithm.decrypt.cipher.algo.join(".")],o=e.algorithm.decrypt.cipher.iv,a=e.subjectPrivateKey,s=parseInt(n.split("-")[1],10)/8,u=p.pbkdf2Sync(t,r,i,s),c=d.createDecipheriv(n,u,o),f=[];return f.push(c.update(a)),f.push(c.final()),l.concat(f)}(a=s.EncryptedPrivateKey.decode(a,"der"),t);case"PRIVATE KEY":switch(r=(i=s.PrivateKey.decode(a,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPrivateKey.decode(i.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:i.algorithm.curve,privateKey:s.ECPrivateKey.decode(i.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return i.algorithm.params.priv_key=s.DSAparam.decode(i.subjectPrivateKey,"der"),{type:"dsa",params:i.algorithm.params};default:throw new Error("unknown key id "+r)}throw new Error("unknown key type "+o);case"RSA PUBLIC KEY":return s.RSAPublicKey.decode(a,"der");case"RSA PRIVATE KEY":return s.RSAPrivateKey.decode(a,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:s.DSAPrivateKey.decode(a,"der")};case"EC PRIVATE KEY":return{curve:(a=s.ECPrivateKey.decode(a,"der")).parameters.value,privateKey:a.privateKey};default:throw new Error("unknown key type "+o)}}(r.exports=e).signature=s.signature}).call(this,t("buffer").Buffer)},{"./aesid.json":111,"./asn1":112,"./fixProc":114,"browserify-aes":22,buffer:49,pbkdf2:117}],116:[function(e,t,c){(function(n){function o(e,t){for(var r=0,i=e.length-1;0<=i;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,a=function(e){return t.exec(e).slice(1)};function s(e,t){if(e.filter)return e.filter(t);for(var r=[],i=0;in?t=i(t):t.lengtha||0<=new c(t).cmp(o.modulus))throw new Error("decryption error");n=r?v(new c(t),o):d(t,o);var s=new f(a-n.length);if(s.fill(0),n=f.concat([s,n],a),4===i)return function(e,t){e.modulus;var r=e.modulus.byteLength(),i=(t.length,p("sha1").update(new f("")).digest()),n=i.length;if(0!==t[0])throw new Error("decryption error");var o=t.slice(1,n+1),a=t.slice(n+1),s=h(o,l(a,n)),u=h(a,l(s,r-n-1));if(function(e,t){e=new f(e),t=new f(t);var r=0,i=e.length;e.length!==t.length&&(r++,i=Math.min(e.length,t.length));var n=-1;for(;++n=t.length){o++;break}var a=t.slice(2,n-1);t.slice(n-1,n);("0002"!==i.toString("hex")&&!r||"0001"!==i.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(n)}(0,n,r);if(3===i)return n;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":125,"./withPublic":128,"./xor":129,"bn.js":17,"browserify-rsa":40,buffer:49,"create-hash":53,"parse-asn1":115}],127:[function(e,t,r){(function(h){var a=e("parse-asn1"),d=e("randombytes"),p=e("create-hash"),v=e("./mgf"),m=e("./xor"),b=e("bn.js"),s=e("./withPublic"),u=e("browserify-rsa");t.exports=function(e,t,r){var i;i=e.padding?e.padding:r?1:4;var n,o=a(e);if(4===i)n=function(e,t){var r=e.modulus.byteLength(),i=t.length,n=p("sha1").update(new h("")).digest(),o=n.length,a=2*o;if(r-a-2t.highWaterMark&&(t.highWaterMark=function(e){return u<=e?e=u:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function f(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(y("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?m(l,e):l(e))}function l(e){y("emit readable"),e.emit("readable"),w(e)}function d(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.highWaterMark||t.ended))return y("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?T(this):f(this),null;if(0===(e=c(e,t))&&t.ended)return 0===t.length&&T(this),null;var i,n=t.needReadable;return y("need readable",n),(0===t.length||t.length-e>>32-t}function p(e,t,r,i,n,o,a,s){return d(e+(t^r^i)+o+a|0,s)+n|0}function v(e,t,r,i,n,o,a,s){return d(e+(t&r|~t&i)+o+a|0,s)+n|0}function m(e,t,r,i,n,o,a,s){return d(e+((t|~r)^i)+o+a|0,s)+n|0}function b(e,t,r,i,n,o,a,s){return d(e+(t&i|r&~i)+o+a|0,s)+n|0}function g(e,t,r,i,n,o,a,s){return d(e+(t^(r|~i))+o+a|0,s)+n|0}e(i,r),i.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,i=this._b,n=this._c,o=this._d,a=this._e;a=p(a,r=p(r,i,n,o,a,e[0],0,11),i,n=d(n,10),o,e[1],0,14),i=p(i=d(i,10),n=p(n,o=p(o,a,r,i,n,e[2],0,15),a,r=d(r,10),i,e[3],0,12),o,a=d(a,10),r,e[4],0,5),o=p(o=d(o,10),a=p(a,r=p(r,i,n,o,a,e[5],0,8),i,n=d(n,10),o,e[6],0,7),r,i=d(i,10),n,e[7],0,9),r=p(r=d(r,10),i=p(i,n=p(n,o,a,r,i,e[8],0,11),o,a=d(a,10),r,e[9],0,13),n,o=d(o,10),a,e[10],0,14),n=p(n=d(n,10),o=p(o,a=p(a,r,i,n,o,e[11],0,15),r,i=d(i,10),n,e[12],0,6),a,r=d(r,10),i,e[13],0,7),a=v(a=d(a,10),r=p(r,i=p(i,n,o,a,r,e[14],0,9),n,o=d(o,10),a,e[15],0,8),i,n=d(n,10),o,e[7],1518500249,7),i=v(i=d(i,10),n=v(n,o=v(o,a,r,i,n,e[4],1518500249,6),a,r=d(r,10),i,e[13],1518500249,8),o,a=d(a,10),r,e[1],1518500249,13),o=v(o=d(o,10),a=v(a,r=v(r,i,n,o,a,e[10],1518500249,11),i,n=d(n,10),o,e[6],1518500249,9),r,i=d(i,10),n,e[15],1518500249,7),r=v(r=d(r,10),i=v(i,n=v(n,o,a,r,i,e[3],1518500249,15),o,a=d(a,10),r,e[12],1518500249,7),n,o=d(o,10),a,e[0],1518500249,12),n=v(n=d(n,10),o=v(o,a=v(a,r,i,n,o,e[9],1518500249,15),r,i=d(i,10),n,e[5],1518500249,9),a,r=d(r,10),i,e[2],1518500249,11),a=v(a=d(a,10),r=v(r,i=v(i,n,o,a,r,e[14],1518500249,7),n,o=d(o,10),a,e[11],1518500249,13),i,n=d(n,10),o,e[8],1518500249,12),i=m(i=d(i,10),n=m(n,o=m(o,a,r,i,n,e[3],1859775393,11),a,r=d(r,10),i,e[10],1859775393,13),o,a=d(a,10),r,e[14],1859775393,6),o=m(o=d(o,10),a=m(a,r=m(r,i,n,o,a,e[4],1859775393,7),i,n=d(n,10),o,e[9],1859775393,14),r,i=d(i,10),n,e[15],1859775393,9),r=m(r=d(r,10),i=m(i,n=m(n,o,a,r,i,e[8],1859775393,13),o,a=d(a,10),r,e[1],1859775393,15),n,o=d(o,10),a,e[2],1859775393,14),n=m(n=d(n,10),o=m(o,a=m(a,r,i,n,o,e[7],1859775393,8),r,i=d(i,10),n,e[0],1859775393,13),a,r=d(r,10),i,e[6],1859775393,6),a=m(a=d(a,10),r=m(r,i=m(i,n,o,a,r,e[13],1859775393,5),n,o=d(o,10),a,e[11],1859775393,12),i,n=d(n,10),o,e[5],1859775393,7),i=b(i=d(i,10),n=b(n,o=m(o,a,r,i,n,e[12],1859775393,5),a,r=d(r,10),i,e[1],2400959708,11),o,a=d(a,10),r,e[9],2400959708,12),o=b(o=d(o,10),a=b(a,r=b(r,i,n,o,a,e[11],2400959708,14),i,n=d(n,10),o,e[10],2400959708,15),r,i=d(i,10),n,e[0],2400959708,14),r=b(r=d(r,10),i=b(i,n=b(n,o,a,r,i,e[8],2400959708,15),o,a=d(a,10),r,e[12],2400959708,9),n,o=d(o,10),a,e[4],2400959708,8),n=b(n=d(n,10),o=b(o,a=b(a,r,i,n,o,e[13],2400959708,9),r,i=d(i,10),n,e[3],2400959708,14),a,r=d(r,10),i,e[7],2400959708,5),a=b(a=d(a,10),r=b(r,i=b(i,n,o,a,r,e[15],2400959708,6),n,o=d(o,10),a,e[14],2400959708,8),i,n=d(n,10),o,e[5],2400959708,6),i=g(i=d(i,10),n=b(n,o=b(o,a,r,i,n,e[6],2400959708,5),a,r=d(r,10),i,e[2],2400959708,12),o,a=d(a,10),r,e[4],2840853838,9),o=g(o=d(o,10),a=g(a,r=g(r,i,n,o,a,e[0],2840853838,15),i,n=d(n,10),o,e[5],2840853838,5),r,i=d(i,10),n,e[9],2840853838,11),r=g(r=d(r,10),i=g(i,n=g(n,o,a,r,i,e[7],2840853838,6),o,a=d(a,10),r,e[12],2840853838,8),n,o=d(o,10),a,e[2],2840853838,13),n=g(n=d(n,10),o=g(o,a=g(a,r,i,n,o,e[10],2840853838,12),r,i=d(i,10),n,e[14],2840853838,5),a,r=d(r,10),i,e[1],2840853838,12),a=g(a=d(a,10),r=g(r,i=g(i,n,o,a,r,e[3],2840853838,13),n,o=d(o,10),a,e[8],2840853838,14),i,n=d(n,10),o,e[11],2840853838,11),i=g(i=d(i,10),n=g(n,o=g(o,a,r,i,n,e[6],2840853838,8),a,r=d(r,10),i,e[15],2840853838,5),o,a=d(a,10),r,e[13],2840853838,6),o=d(o,10);var s=this._a,u=this._b,c=this._c,f=this._d,l=this._e;l=g(l,s=g(s,u,c,f,l,e[5],1352829926,8),u,c=d(c,10),f,e[14],1352829926,9),u=g(u=d(u,10),c=g(c,f=g(f,l,s,u,c,e[7],1352829926,9),l,s=d(s,10),u,e[0],1352829926,11),f,l=d(l,10),s,e[9],1352829926,13),f=g(f=d(f,10),l=g(l,s=g(s,u,c,f,l,e[2],1352829926,15),u,c=d(c,10),f,e[11],1352829926,15),s,u=d(u,10),c,e[4],1352829926,5),s=g(s=d(s,10),u=g(u,c=g(c,f,l,s,u,e[13],1352829926,7),f,l=d(l,10),s,e[6],1352829926,7),c,f=d(f,10),l,e[15],1352829926,8),c=g(c=d(c,10),f=g(f,l=g(l,s,u,c,f,e[8],1352829926,11),s,u=d(u,10),c,e[1],1352829926,14),l,s=d(s,10),u,e[10],1352829926,14),l=b(l=d(l,10),s=g(s,u=g(u,c,f,l,s,e[3],1352829926,12),c,f=d(f,10),l,e[12],1352829926,6),u,c=d(c,10),f,e[6],1548603684,9),u=b(u=d(u,10),c=b(c,f=b(f,l,s,u,c,e[11],1548603684,13),l,s=d(s,10),u,e[3],1548603684,15),f,l=d(l,10),s,e[7],1548603684,7),f=b(f=d(f,10),l=b(l,s=b(s,u,c,f,l,e[0],1548603684,12),u,c=d(c,10),f,e[13],1548603684,8),s,u=d(u,10),c,e[5],1548603684,9),s=b(s=d(s,10),u=b(u,c=b(c,f,l,s,u,e[10],1548603684,11),f,l=d(l,10),s,e[14],1548603684,7),c,f=d(f,10),l,e[15],1548603684,7),c=b(c=d(c,10),f=b(f,l=b(l,s,u,c,f,e[8],1548603684,12),s,u=d(u,10),c,e[12],1548603684,7),l,s=d(s,10),u,e[4],1548603684,6),l=b(l=d(l,10),s=b(s,u=b(u,c,f,l,s,e[9],1548603684,15),c,f=d(f,10),l,e[1],1548603684,13),u,c=d(c,10),f,e[2],1548603684,11),u=m(u=d(u,10),c=m(c,f=m(f,l,s,u,c,e[15],1836072691,9),l,s=d(s,10),u,e[5],1836072691,7),f,l=d(l,10),s,e[1],1836072691,15),f=m(f=d(f,10),l=m(l,s=m(s,u,c,f,l,e[3],1836072691,11),u,c=d(c,10),f,e[7],1836072691,8),s,u=d(u,10),c,e[14],1836072691,6),s=m(s=d(s,10),u=m(u,c=m(c,f,l,s,u,e[6],1836072691,6),f,l=d(l,10),s,e[9],1836072691,14),c,f=d(f,10),l,e[11],1836072691,12),c=m(c=d(c,10),f=m(f,l=m(l,s,u,c,f,e[8],1836072691,13),s,u=d(u,10),c,e[12],1836072691,5),l,s=d(s,10),u,e[2],1836072691,14),l=m(l=d(l,10),s=m(s,u=m(u,c,f,l,s,e[10],1836072691,13),c,f=d(f,10),l,e[0],1836072691,13),u,c=d(c,10),f,e[4],1836072691,7),u=v(u=d(u,10),c=v(c,f=m(f,l,s,u,c,e[13],1836072691,5),l,s=d(s,10),u,e[8],2053994217,15),f,l=d(l,10),s,e[6],2053994217,5),f=v(f=d(f,10),l=v(l,s=v(s,u,c,f,l,e[4],2053994217,8),u,c=d(c,10),f,e[1],2053994217,11),s,u=d(u,10),c,e[3],2053994217,14),s=v(s=d(s,10),u=v(u,c=v(c,f,l,s,u,e[11],2053994217,14),f,l=d(l,10),s,e[15],2053994217,6),c,f=d(f,10),l,e[0],2053994217,14),c=v(c=d(c,10),f=v(f,l=v(l,s,u,c,f,e[5],2053994217,6),s,u=d(u,10),c,e[12],2053994217,9),l,s=d(s,10),u,e[2],2053994217,12),l=v(l=d(l,10),s=v(s,u=v(u,c,f,l,s,e[13],2053994217,9),c,f=d(f,10),l,e[9],2053994217,12),u,c=d(c,10),f,e[7],2053994217,5),u=p(u=d(u,10),c=v(c,f=v(f,l,s,u,c,e[10],2053994217,15),l,s=d(s,10),u,e[14],2053994217,8),f,l=d(l,10),s,e[12],0,8),f=p(f=d(f,10),l=p(l,s=p(s,u,c,f,l,e[15],0,5),u,c=d(c,10),f,e[10],0,12),s,u=d(u,10),c,e[4],0,9),s=p(s=d(s,10),u=p(u,c=p(c,f,l,s,u,e[1],0,12),f,l=d(l,10),s,e[5],0,5),c,f=d(f,10),l,e[8],0,14),c=p(c=d(c,10),f=p(f,l=p(l,s,u,c,f,e[7],0,6),s,u=d(u,10),c,e[6],0,8),l,s=d(s,10),u,e[2],0,13),l=p(l=d(l,10),s=p(s,u=p(u,c,f,l,s,e[13],0,6),c,f=d(f,10),l,e[14],0,5),u,c=d(c,10),f,e[0],0,15),u=p(u=d(u,10),c=p(c,f=p(f,l,s,u,c,e[3],0,13),l,s=d(s,10),u,e[9],0,11),f,l=d(l,10),s,e[11],0,11),f=d(f,10);var h=this._b+n+f|0;this._b=this._c+o+l|0,this._c=this._d+a+s|0,this._d=this._e+r+u|0,this._e=this._a+i+c|0,this._a=h},i.prototype._digest=function(){this._block[this._blockOffset++]=128,56=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=4294967295&r,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":143}],145:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":146,"./sha1":147,"./sha224":148,"./sha256":149,"./sha384":150,"./sha512":151}],146:[function(e,t,r){var i=e("inherits"),n=e("./hash"),o=e("safe-buffer").Buffer,b=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function s(){this.init(),this._w=a,n.call(this,64,56)}i(s,n),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,r,i,n,o,a,s=this._w,u=0|this._a,c=0|this._b,f=0|this._c,l=0|this._d,h=0|this._e,d=0;d<16;++d)s[d]=e.readInt32BE(4*d);for(;d<80;++d)s[d]=s[d-3]^s[d-8]^s[d-14]^s[d-16];for(var p=0;p<80;++p){var v=~~(p/20),m=0|((a=u)<<5|a>>>27)+(i=c,n=f,o=l,0===(r=v)?i&n|~i&o:2===r?i&n|i&o|n&o:i^n^o)+h+s[p]+b[v];h=l,l=f,f=(t=c)<<30|t>>>2,c=u,u=m}this._a=u+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=l+this._d|0,this._e=h+this._e|0},s.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=s},{"./hash":144,inherits:103,"safe-buffer":143}],147:[function(e,t,r){var i=e("inherits"),n=e("./hash"),o=e("safe-buffer").Buffer,g=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function s(){this.init(),this._w=a,n.call(this,64,56)}i(s,n),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,r,i,n,o,a,s,u=this._w,c=0|this._a,f=0|this._b,l=0|this._c,h=0|this._d,d=0|this._e,p=0;p<16;++p)u[p]=e.readInt32BE(4*p);for(;p<80;++p)u[p]=(t=u[p-3]^u[p-8]^u[p-14]^u[p-16])<<1|t>>>31;for(var v=0;v<80;++v){var m=~~(v/20),b=0|((s=c)<<5|s>>>27)+(n=f,o=l,a=h,0===(i=m)?n&o|~n&a:2===i?n&o|n&a|o&a:n^o^a)+d+u[v]+g[m];d=h,h=l,l=(r=f)<<30|r>>>2,f=c,c=b}this._a=c+this._a|0,this._b=f+this._b|0,this._c=l+this._c|0,this._d=h+this._d|0,this._e=d+this._e|0},s.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=s},{"./hash":144,inherits:103,"safe-buffer":143}],148:[function(e,t,r){var i=e("inherits"),n=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}i(u,n),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":144,"./sha256":149,inherits:103,"safe-buffer":143}],149:[function(e,t,r){var i=e("inherits"),n=e("./hash"),o=e("safe-buffer").Buffer,w=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function s(){this.init(),this._w=a,n.call(this,64,56)}i(s,n),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(e){for(var t,r,i,n,o,a,s,u=this._w,c=0|this._a,f=0|this._b,l=0|this._c,h=0|this._d,d=0|this._e,p=0|this._f,v=0|this._g,m=0|this._h,b=0;b<16;++b)u[b]=e.readInt32BE(4*b);for(;b<64;++b)u[b]=0|(((r=u[b-2])>>>17|r<<15)^(r>>>19|r<<13)^r>>>10)+u[b-7]+(((t=u[b-15])>>>7|t<<25)^(t>>>18|t<<14)^t>>>3)+u[b-16];for(var g=0;g<64;++g){var y=m+(((s=d)>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7))+((a=v)^d&(p^a))+w[g]+u[g]|0,_=0|(((o=c)>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10))+((i=c)&(n=f)|l&(i|n));m=v,v=p,p=d,d=h+y|0,h=l,l=f,f=c,c=y+_|0}this._a=c+this._a|0,this._b=f+this._b|0,this._c=l+this._c|0,this._d=h+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=v+this._g|0,this._h=m+this._h|0},s.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=s},{"./hash":144,inherits:103,"safe-buffer":143}],150:[function(e,t,r){var i=e("inherits"),n=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}i(u,n),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var i=a.allocUnsafe(48);function e(e,t,r){i.writeInt32BE(e,r),i.writeInt32BE(t,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),i},t.exports=u},{"./hash":144,"./sha512":151,inherits:103,"safe-buffer":143}],151:[function(e,t,r){var i=e("inherits"),n=e("./hash"),o=e("safe-buffer").Buffer,ee=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function s(){this.init(),this._w=a,n.call(this,128,112)}function te(e,t,r){return r^e&(t^r)}function re(e,t,r){return e&t|r&(e|t)}function ie(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function ne(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function oe(e,t){return e>>>0>>0?1:0}i(s,n),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(e){for(var t,r,i,n,o,a,s,u,c=this._w,f=0|this._ah,l=0|this._bh,h=0|this._ch,d=0|this._dh,p=0|this._eh,v=0|this._fh,m=0|this._gh,b=0|this._hh,g=0|this._al,y=0|this._bl,_=0|this._cl,w=0|this._dl,x=0|this._el,T=0|this._fl,S=0|this._gl,E=0|this._hl,M=0;M<32;M+=2)c[M]=e.readInt32BE(4*M),c[M+1]=e.readInt32BE(4*M+4);for(;M<160;M+=2){var C=c[M-30],P=c[M-30+1],A=((s=C)>>>1|(u=P)<<31)^(s>>>8|u<<24)^s>>>7,k=((o=P)>>>1|(a=C)<<31)^(o>>>8|a<<24)^(o>>>7|a<<25);C=c[M-4],P=c[M-4+1];var I=((i=C)>>>19|(n=P)<<13)^(n>>>29|i<<3)^i>>>6,R=((t=P)>>>19|(r=C)<<13)^(r>>>29|t<<3)^(t>>>6|r<<26),O=c[M-14],D=c[M-14+1],L=c[M-32],j=c[M-32+1],F=k+D|0,B=A+O+oe(F,k)|0;B=(B=B+I+oe(F=F+R|0,R)|0)+L+oe(F=F+j|0,j)|0,c[M]=B,c[M+1]=F}for(var N=0;N<160;N+=2){B=c[N],F=c[N+1];var U=re(f,l,h),z=re(g,y,_),X=ie(f,g),q=ie(g,f),G=ne(p,x),H=ne(x,p),V=ee[N],W=ee[N+1],Y=te(p,v,m),K=te(x,T,S),J=E+H|0,Z=b+G+oe(J,E)|0;Z=(Z=(Z=Z+Y+oe(J=J+K|0,K)|0)+V+oe(J=J+W|0,W)|0)+B+oe(J=J+F|0,F)|0;var Q=q+z|0,$=X+U+oe(Q,q)|0;b=m,E=S,m=v,S=T,v=p,T=x,p=d+Z+oe(x=w+J|0,w)|0,d=h,w=_,h=l,_=y,l=f,y=g,f=Z+$+oe(g=J+Q|0,J)|0}this._al=this._al+g|0,this._bl=this._bl+y|0,this._cl=this._cl+_|0,this._dl=this._dl+w|0,this._el=this._el+x|0,this._fl=this._fl+T|0,this._gl=this._gl+S|0,this._hl=this._hl+E|0,this._ah=this._ah+f+oe(this._al,g)|0,this._bh=this._bh+l+oe(this._bl,y)|0,this._ch=this._ch+h+oe(this._cl,_)|0,this._dh=this._dh+d+oe(this._dl,w)|0,this._eh=this._eh+p+oe(this._el,x)|0,this._fh=this._fh+v+oe(this._fl,T)|0,this._gh=this._gh+m+oe(this._gl,S)|0,this._hh=this._hh+b+oe(this._hl,E)|0},s.prototype._hash=function(){var i=o.allocUnsafe(64);function e(e,t,r){i.writeInt32BE(e,r),i.writeInt32BE(t,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),i},t.exports=s},{"./hash":144,inherits:103,"safe-buffer":143}],152:[function(e,t,r){t.exports=i;var f=e("events").EventEmitter;function i(){f.call(this)}e("inherits")(i,f),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),(i.Stream=i).prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function n(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",n),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",s));var o=!1;function a(){o||(o=!0,t.end())}function s(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function u(e){if(c(),0===f.listenerCount(this,"error"))throw e}function c(){r.removeListener("data",i),t.removeListener("drain",n),r.removeListener("end",a),r.removeListener("close",s),r.removeListener("error",u),t.removeListener("error",u),r.removeListener("end",c),r.removeListener("close",c),t.removeListener("close",c)}return r.on("error",u),t.on("error",u),r.on("end",c),r.on("close",c),t.on("close",c),t.emit("pipe",r),t}},{events:85,inherits:103,"readable-stream/duplex.js":132,"readable-stream/passthrough.js":138,"readable-stream/readable.js":139,"readable-stream/transform.js":140,"readable-stream/writable.js":141}],153:[function(e,t,r){var i=e("buffer").Buffer,n=i.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};var o=r.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!n(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=s;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=u;break;default:return void(this.write=a)}this.charBuffer=new i(6),this.charReceived=0,this.charLength=0};function a(e){return e.toString(this.encoding)}function s(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function u(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}o.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},o.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,i=this.charBuffer,n=this.encoding;t+=i.slice(0,r).toString(n)}return t}},{buffer:49}],154:[function(e,t,r){(function(r){function i(e){try{if(!r.localStorage)return!1}catch(e){return!1}var t=r.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}t.exports=function(e,t){if(i("noDeprecation"))return e;var r=!1;return function(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],155:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r>2)*(r+3>>2)*8;case p:case v:case f:case m:return(t+3>>2)*(r+3>>2)*16;case ne:case ae:return Math.floor((Math.max(t,8)*Math.max(r,8)*4+7)/8);case oe:case se:return Math.floor((Math.max(t,16)*Math.max(r,8)*2+7)/8);case b:case n:return Math.floor((t+3)/4)*Math.floor((r+3)/4)*16;case g:case o:return Math.floor((t+4)/5)*Math.floor((r+3)/4)*16;case y:case a:return Math.floor((t+4)/5)*Math.floor((r+4)/5)*16;case _:case s:return Math.floor((t+5)/6)*Math.floor((r+4)/5)*16;case w:case u:return Math.floor((t+5)/6)*Math.floor((r+5)/6)*16;case x:case I:return Math.floor((t+7)/8)*Math.floor((r+4)/5)*16;case T:case R:return Math.floor((t+7)/8)*Math.floor((r+5)/6)*16;case S:case O:return Math.floor((t+7)/8)*Math.floor((r+7)/8)*16;case E:case D:return Math.floor((t+9)/10)*Math.floor((r+4)/5)*16;case M:case L:return Math.floor((t+9)/10)*Math.floor((r+5)/6)*16;case C:case j:return Math.floor((t+9)/10)*Math.floor((r+7)/8)*16;case P:case F:return Math.floor((t+9)/10)*Math.floor((r+9)/10)*16;case A:case B:return Math.floor((t+11)/12)*Math.floor((r+9)/10)*16;case k:case N:return Math.floor((t+11)/12)*Math.floor((r+11)/12)*16;default:return 0}}(t.exports=l).prototype.init=function(e,t,r,i,n,o,a,s){this.src=e,this.width=i,this.height=n,this.data=t,this.type=r,this.levels=o,this.internalFormat=a,this.isCompressedImage=!0,this.crunch=s,this.preserveSource=!0;var u=this.complete;return this.complete=!!t,!u&&this.complete&&this.onload&&this.onload({target:this}),this},l.prototype.dispose=function(){this.data=null},l.prototype.generateWebGLTexture=function(e){if(null===this.data)throw"Trying to create a second (or more) webgl texture from the same CompressedImage : "+this.src;for(var t=this.width,r=this.height,i=this.levels,n=0,o=0;o>=1)<1&&(t=1),(r>>=1)<1&&(r=1),n+=a}1>8&255,e>>16&255,e>>24&255)}(i)}var n=1;t[V]&z&&(n=Math.max(1,t[K]));var o=t[Y],a=t[W],s=t[H]+4,u=new Uint8Array(e,s);return this.init(this.src,u,"DDS",o,a,n,r)},l.prototype._loadASTC=function(e){var t=new Int8Array(e,0,Ee);if(new Uint32Array(e.slice(0,4))!=Me)throw"Invalid magic number in ASTC header";for(var r=[b,g,y,_,w,x,T,S,E,M,C,P,A,k],i=e.byteLength-Ee,n=new Uint8Array([t[7],t[8],t[9],0]),o=new Uint8Array([t[10],t[11],t[12],0]),a=new Uint32Array(n.buffer)[0],s=new Uint32Array(o.buffer)[0],u=0,c=0;c 0.0) {\n c.rgb /= c.a;\n\n vec3 rgb = pow(c.rgb, vec3(1. / gamma));\n rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast);\n rgb.r *= red;\n rgb.g *= green;\n rgb.b *= blue;\n c.rgb = rgb * brightness;\n\n c.rgb *= c.a;\n }\n\n gl_FragColor = c * alpha;\n}\n"),Object.assign(this,{gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},e)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.gamma=Math.max(this.gamma,1e-4),this.uniforms.saturation=this.saturation,this.uniforms.contrast=this.contrast,this.uniforms.brightness=this.brightness,this.uniforms.red=this.red,this.uniforms.green=this.green,this.uniforms.blue=this.blue,this.uniforms.alpha=this.alpha,e.applyFilter(this,t,r,i)},e}(h.Filter),d=function(i){function e(e,t,r){void 0===e&&(e=4),void 0===t&&(t=3),void 0===r&&(r=!1),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r?"\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 uOffset;\nuniform vec4 filterClamp;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample top right pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample bottom right pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample bottom left pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Average\n color *= 0.25;\n\n gl_FragColor = color;\n}\n":"\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 uOffset;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample top right pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample bottom right pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Sample bottom left pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Average\n color *= 0.25;\n\n gl_FragColor = color;\n}"),this.uniforms.uOffset=new Float32Array(2),this._pixelSize=new h.Point,this.pixelSize=1,this._clamp=r,this._kernels=null,Array.isArray(e)?this.kernels=e:(this._blur=e,this.quality=t)}i&&(e.__proto__=i);var t={kernels:{configurable:!0},clamp:{configurable:!0},pixelSize:{configurable:!0},quality:{configurable:!0},blur:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){var n,o=this.pixelSize.x/t.size.width,a=this.pixelSize.y/t.size.height;if(1===this._quality||0===this._blur)n=this._kernels[0]+.5,this.uniforms.uOffset[0]=n*o,this.uniforms.uOffset[1]=n*a,e.applyFilter(this,t,r,i);else{for(var s,u=e.getRenderTarget(!0),c=t,f=u,l=this._quality-1,h=0;h threshold) {\n gl_FragColor = color;\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n}\n"),this.threshold=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={threshold:{configurable:!0}};return r.threshold.get=function(){return this.uniforms.threshold},r.threshold.set=function(e){this.uniforms.threshold=e},Object.defineProperties(e.prototype,r),e}(h.Filter),i=function(a){function e(e){a.call(this,s,"uniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D bloomTexture;\nuniform float bloomScale;\nuniform float brightness;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n color.rgb *= brightness;\n vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0);\n bloomColor.rgb *= bloomScale;\n gl_FragColor = color + bloomColor;\n}\n"),"number"==typeof e&&(e={threshold:e}),e=Object.assign({threshold:.5,bloomScale:1,brightness:1,kernels:null,blur:8,quality:4,pixelSize:1,resolution:h.settings.RESOLUTION},e),this.bloomScale=e.bloomScale,this.brightness=e.brightness;var t=e.kernels,r=e.blur,i=e.quality,n=e.pixelSize,o=e.resolution;this._extractFilter=new u(e.threshold),this._extractFilter.resolution=o,this._blurFilter=t?new d(t):new d(r,i),this.pixelSize=n,this.resolution=o}a&&(e.__proto__=a);var t={resolution:{configurable:!0},threshold:{configurable:!0},kernels:{configurable:!0},blur:{configurable:!0},quality:{configurable:!0},pixelSize:{configurable:!0}};return((e.prototype=Object.create(a&&a.prototype)).constructor=e).prototype.apply=function(e,t,r,i,n){var o=e.getRenderTarget(!0);this._extractFilter.apply(e,t,o,!0,n);var a=e.getRenderTarget(!0);this._blurFilter.apply(e,o,a,!0,n),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=a,e.applyFilter(this,t,r,i),e.returnRenderTarget(a),e.returnRenderTarget(o)},t.resolution.get=function(){return this._resolution},t.resolution.set=function(e){this._resolution=e,this._extractFilter&&(this._extractFilter.resolution=e),this._blurFilter&&(this._blurFilter.resolution=e)},t.threshold.get=function(){return this._extractFilter.threshold},t.threshold.set=function(e){this._extractFilter.threshold=e},t.kernels.get=function(){return this._blurFilter.kernels},t.kernels.set=function(e){this._blurFilter.kernels=e},t.blur.get=function(){return this._blurFilter.blur},t.blur.set=function(e){this._blurFilter.blur=e},t.quality.get=function(){return this._blurFilter.quality},t.quality.set=function(e){this._blurFilter.quality=e},t.pixelSize.get=function(){return this._blurFilter.pixelSize},t.pixelSize.set=function(e){this._blurFilter.pixelSize=e},Object.defineProperties(e.prototype,t),e}(h.Filter),n=function(t){function e(e){void 0===e&&(e=8),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\n\nuniform vec4 filterArea;\nuniform float pixelSize;\nuniform sampler2D uSampler;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 pixelate(vec2 coord, vec2 size)\n{\n return floor( coord / size ) * size;\n}\n\nvec2 getMod(vec2 coord, vec2 size)\n{\n return mod( coord , size) / size;\n}\n\nfloat character(float n, vec2 p)\n{\n p = floor(p*vec2(4.0, -4.0) + 2.5);\n\n if (clamp(p.x, 0.0, 4.0) == p.x)\n {\n if (clamp(p.y, 0.0, 4.0) == p.y)\n {\n if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0;\n }\n }\n return 0.0;\n}\n\nvoid main()\n{\n vec2 coord = mapCoord(vTextureCoord);\n\n // get the rounded color..\n vec2 pixCoord = pixelate(coord, vec2(pixelSize));\n pixCoord = unmapCoord(pixCoord);\n\n vec4 color = texture2D(uSampler, pixCoord);\n\n // determine the character to use\n float gray = (color.r + color.g + color.b) / 3.0;\n\n float n = 65536.0; // .\n if (gray > 0.2) n = 65600.0; // :\n if (gray > 0.3) n = 332772.0; // *\n if (gray > 0.4) n = 15255086.0; // o\n if (gray > 0.5) n = 23385164.0; // &\n if (gray > 0.6) n = 15252014.0; // 8\n if (gray > 0.7) n = 13199452.0; // @\n if (gray > 0.8) n = 11512810.0; // #\n\n // get the mod..\n vec2 modd = getMod(coord, vec2(pixelSize));\n\n gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0);\n\n}\n"),this.size=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={size:{configurable:!0}};return r.size.get=function(){return this.uniforms.pixelSize},r.size.set=function(e){this.uniforms.pixelSize=e},Object.defineProperties(e.prototype,r),e}(h.Filter),o=function(t){function e(e){void 0===e&&(e={}),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform float transformX;\nuniform float transformY;\nuniform vec3 lightColor;\nuniform float lightAlpha;\nuniform vec3 shadowColor;\nuniform float shadowAlpha;\n\nvoid main(void) {\n vec2 transform = vec2(1.0 / filterArea) * vec2(transformX, transformY);\n vec4 color = texture2D(uSampler, vTextureCoord);\n float light = texture2D(uSampler, vTextureCoord - transform).a;\n float shadow = texture2D(uSampler, vTextureCoord + transform).a;\n\n color.rgb = mix(color.rgb, lightColor, clamp((color.a - light) * lightAlpha, 0.0, 1.0));\n color.rgb = mix(color.rgb, shadowColor, clamp((color.a - shadow) * shadowAlpha, 0.0, 1.0));\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"),this.uniforms.lightColor=new Float32Array(3),this.uniforms.shadowColor=new Float32Array(3),e=Object.assign({rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7},e),this.rotation=e.rotation,this.thickness=e.thickness,this.lightColor=e.lightColor,this.lightAlpha=e.lightAlpha,this.shadowColor=e.shadowColor,this.shadowAlpha=e.shadowAlpha}t&&(e.__proto__=t);var r={rotation:{configurable:!0},thickness:{configurable:!0},lightColor:{configurable:!0},lightAlpha:{configurable:!0},shadowColor:{configurable:!0},shadowAlpha:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._updateTransform=function(){this.uniforms.transformX=this._thickness*Math.cos(this._angle),this.uniforms.transformY=this._thickness*Math.sin(this._angle)},r.rotation.get=function(){return this._angle/h.DEG_TO_RAD},r.rotation.set=function(e){this._angle=e*h.DEG_TO_RAD,this._updateTransform()},r.thickness.get=function(){return this._thickness},r.thickness.set=function(e){this._thickness=e,this._updateTransform()},r.lightColor.get=function(){return h.utils.rgb2hex(this.uniforms.lightColor)},r.lightColor.set=function(e){h.utils.hex2rgb(e,this.uniforms.lightColor)},r.lightAlpha.get=function(){return this.uniforms.lightAlpha},r.lightAlpha.set=function(e){this.uniforms.lightAlpha=e},r.shadowColor.get=function(){return h.utils.rgb2hex(this.uniforms.shadowColor)},r.shadowColor.set=function(e){h.utils.hex2rgb(e,this.uniforms.shadowColor)},r.shadowAlpha.get=function(){return this.uniforms.shadowAlpha},r.shadowAlpha.set=function(e){this.uniforms.shadowAlpha=e},Object.defineProperties(e.prototype,r),e}(h.Filter),a=h.filters,c=a.BlurXFilter,f=a.BlurYFilter,l=a.AlphaFilter,p=function(a){function e(e,t,r,i){var n,o;void 0===e&&(e=2),void 0===t&&(t=4),void 0===r&&(r=h.settings.RESOLUTION),void 0===i&&(i=5),a.call(this),"number"==typeof e?o=n=e:e instanceof h.Point?(n=e.x,o=e.y):Array.isArray(e)&&(n=e[0],o=e[1]),this.blurXFilter=new c(n,t,r,i),this.blurYFilter=new f(o,t,r,i),this.blurYFilter.blendMode=h.BLEND_MODES.SCREEN,this.defaultFilter=new l}a&&(e.__proto__=a);var t={blur:{configurable:!0},blurX:{configurable:!0},blurY:{configurable:!0}};return((e.prototype=Object.create(a&&a.prototype)).constructor=e).prototype.apply=function(e,t,r){var i=e.getRenderTarget(!0);this.defaultFilter.apply(e,t,r),this.blurXFilter.apply(e,t,i),this.blurYFilter.apply(e,i,r),e.returnRenderTarget(i)},t.blur.get=function(){return this.blurXFilter.blur},t.blur.set=function(e){this.blurXFilter.blur=this.blurYFilter.blur=e},t.blurX.get=function(){return this.blurXFilter.blur},t.blurX.set=function(e){this.blurXFilter.blur=e},t.blurY.get=function(){return this.blurYFilter.blur},t.blurY.set=function(e){this.blurYFilter.blur=e},Object.defineProperties(e.prototype,t),e}(h.Filter),v=function(i){function e(e,t,r){i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","uniform float radius;\nuniform float strength;\nuniform vec2 center;\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\n\nvoid main()\n{\n vec2 coord = vTextureCoord * filterArea.xy;\n coord -= center * dimensions.xy;\n float distance = length(coord);\n if (distance < radius) {\n float percent = distance / radius;\n if (strength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);\n }\n }\n coord += center * dimensions.xy;\n coord /= filterArea.xy;\n vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw);\n vec4 color = texture2D(uSampler, clampedCoord);\n if (coord != clampedCoord) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n gl_FragColor = color;\n}\n"),this.uniforms.dimensions=new Float32Array(2),this.center=e||[.5,.5],this.radius="number"==typeof t?t:100,this.strength="number"==typeof r?r:1}i&&(e.__proto__=i);var t={radius:{configurable:!0},strength:{configurable:!0},center:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,e.applyFilter(this,t,r,i)},t.radius.get=function(){return this.uniforms.radius},t.radius.set=function(e){this.uniforms.radius=e},t.strength.get=function(){return this.uniforms.strength},t.strength.set=function(e){this.uniforms.strength=e},t.center.get=function(){return this.uniforms.center},t.center.set=function(e){this.uniforms.center=e},Object.defineProperties(e.prototype,t),e}(h.Filter),m=function(i){function e(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=1),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform sampler2D colorMap;\nuniform float _mix;\nuniform float _size;\nuniform float _sliceSize;\nuniform float _slicePixelSize;\nuniform float _sliceInnerSize;\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord.xy);\n\n vec4 adjusted;\n if (color.a > 0.0) {\n color.rgb /= color.a;\n float innerWidth = _size - 1.0;\n float zSlice0 = min(floor(color.b * innerWidth), innerWidth);\n float zSlice1 = min(zSlice0 + 1.0, innerWidth);\n float xOffset = _slicePixelSize * 0.5 + color.r * _sliceInnerSize;\n float s0 = xOffset + (zSlice0 * _sliceSize);\n float s1 = xOffset + (zSlice1 * _sliceSize);\n float yOffset = _sliceSize * 0.5 + color.g * (1.0 - _sliceSize);\n vec4 slice0Color = texture2D(colorMap, vec2(s0,yOffset));\n vec4 slice1Color = texture2D(colorMap, vec2(s1,yOffset));\n float zOffset = fract(color.b * innerWidth);\n adjusted = mix(slice0Color, slice1Color, zOffset);\n\n color.rgb *= color.a;\n }\n gl_FragColor = vec4(mix(color, adjusted, _mix).rgb, color.a);\n\n}"),this._size=0,this._sliceSize=0,this._slicePixelSize=0,this._sliceInnerSize=0,this._scaleMode=null,this._nearest=!1,this.nearest=t,this.mix=r,this.colorMap=e}i&&(e.__proto__=i);var t={colorSize:{configurable:!0},colorMap:{configurable:!0},nearest:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms._mix=this.mix,e.applyFilter(this,t,r,i)},t.colorSize.get=function(){return this._size},t.colorMap.get=function(){return this._colorMap},t.colorMap.set=function(e){e instanceof h.Texture||(e=h.Texture.from(e)),e&&e.baseTexture&&(e.baseTexture.scaleMode=this._scaleMode,e.baseTexture.mipmap=!1,this._size=e.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms._size=this._size,this.uniforms._sliceSize=this._sliceSize,this.uniforms._slicePixelSize=this._slicePixelSize,this.uniforms._sliceInnerSize=this._sliceInnerSize,this.uniforms.colorMap=e),this._colorMap=e},t.nearest.get=function(){return this._nearest},t.nearest.set=function(e){this._nearest=e,this._scaleMode=e?h.SCALE_MODES.NEAREST:h.SCALE_MODES.LINEAR;var t=this._colorMap;t&&t.baseTexture&&(t.baseTexture._glTextures={},t.baseTexture.scaleMode=this._scaleMode,t.baseTexture.mipmap=!1,t._updateID++,t.baseTexture.emit("update",t.baseTexture))},e.prototype.updateColorMap=function(){var e=this._colorMap;e&&e.baseTexture&&(e._updateID++,e.baseTexture.emit("update",e.baseTexture),this.colorMap=e)},e.prototype.destroy=function(e){this._colorMap&&this._colorMap.destroy(e),i.prototype.destroy.call(this)},Object.defineProperties(e.prototype,t),e}(h.Filter),b=function(i){function e(e,t,r){void 0===e&&(e=16711680),void 0===t&&(t=0),void 0===r&&(r=.4),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec3 originalColor;\nuniform vec3 newColor;\nuniform float epsilon;\nvoid main(void) {\n vec4 currentColor = texture2D(uSampler, vTextureCoord);\n vec3 colorDiff = originalColor - (currentColor.rgb / max(currentColor.a, 0.0000000001));\n float colorDistance = length(colorDiff);\n float doReplace = step(colorDistance, epsilon);\n gl_FragColor = vec4(mix(currentColor.rgb, (newColor + colorDiff) * currentColor.a, doReplace), currentColor.a);\n}\n"),this.uniforms.originalColor=new Float32Array(3),this.uniforms.newColor=new Float32Array(3),this.originalColor=e,this.newColor=t,this.epsilon=r}i&&(e.__proto__=i),(e.prototype=Object.create(i&&i.prototype)).constructor=e;var t={originalColor:{configurable:!0},newColor:{configurable:!0},epsilon:{configurable:!0}};return t.originalColor.set=function(e){var t=this.uniforms.originalColor;"number"==typeof e?(h.utils.hex2rgb(e,t),this._originalColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._originalColor=h.utils.rgb2hex(t))},t.originalColor.get=function(){return this._originalColor},t.newColor.set=function(e){var t=this.uniforms.newColor;"number"==typeof e?(h.utils.hex2rgb(e,t),this._newColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._newColor=h.utils.rgb2hex(t))},t.newColor.get=function(){return this._newColor},t.epsilon.set=function(e){this.uniforms.epsilon=e},t.epsilon.get=function(){return this.uniforms.epsilon},Object.defineProperties(e.prototype,t),e}(h.Filter),g=function(i){function e(e,t,r){void 0===t&&(t=200),void 0===r&&(r=200),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying mediump vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec2 texelSize;\nuniform float matrix[9];\n\nvoid main(void)\n{\n vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left\n vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center\n vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right\n\n vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left\n vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center\n vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right\n\n vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left\n vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center\n vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right\n\n gl_FragColor =\n c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] +\n c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] +\n c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8];\n\n gl_FragColor.a = c22.a;\n}\n"),this.uniforms.texelSize=new Float32Array(2),this.uniforms.matrix=new Float32Array(9),void 0!==e&&(this.matrix=e),this.width=t,this.height=r}i&&(e.__proto__=i),(e.prototype=Object.create(i&&i.prototype)).constructor=e;var t={matrix:{configurable:!0},width:{configurable:!0},height:{configurable:!0}};return t.matrix.get=function(){return this.uniforms.matrix},t.matrix.set=function(e){var r=this;e.forEach(function(e,t){return r.uniforms.matrix[t]=e})},t.width.get=function(){return 1/this.uniforms.texelSize[0]},t.width.set=function(e){this.uniforms.texelSize[0]=1/e},t.height.get=function(){return 1/this.uniforms.texelSize[1]},t.height.set=function(e){this.uniforms.texelSize[1]=1/e},Object.defineProperties(e.prototype,t),e}(h.Filter),y=function(e){function t(){e.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);\n\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n\n if (lum < 1.00)\n {\n if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.75)\n {\n if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.50)\n {\n if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.3)\n {\n if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n}\n")}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t}(h.Filter),_=function(t){function e(e){t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec2 dimensions;\n\nconst float SQRT_2 = 1.414213;\n\nconst float light = 1.0;\n\nuniform float curvature;\nuniform float lineWidth;\nuniform float lineContrast;\nuniform bool verticalLine;\nuniform float noise;\nuniform float noiseSize;\n\nuniform float vignetting;\nuniform float vignettingAlpha;\nuniform float vignettingBlur;\n\nuniform float seed;\nuniform float time;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main(void)\n{\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n vec2 coord = pixelCoord / dimensions;\n\n vec2 dir = vec2(coord - vec2(0.5, 0.5));\n\n float _c = curvature > 0. ? curvature : 1.;\n float k = curvature > 0. ?(length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.;\n vec2 uv = dir * k;\n\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n vec3 rgb = gl_FragColor.rgb;\n\n\n if (noise > 0.0 && noiseSize > 0.0)\n {\n pixelCoord.x = floor(pixelCoord.x / noiseSize);\n pixelCoord.y = floor(pixelCoord.y / noiseSize);\n float _noise = rand(pixelCoord * noiseSize * seed) - 0.5;\n rgb += _noise * noise;\n }\n\n if (lineWidth > 0.0) {\n float v = (verticalLine ? uv.x * dimensions.x : uv.y * dimensions.y) * min(1.0, 2.0 / lineWidth ) / _c;\n float j = 1. + cos(v * 1.2 - time) * 0.5 * lineContrast;\n rgb *= j;\n float segment = verticalLine ? mod((dir.x + .5) * dimensions.x, 4.) : mod((dir.y + .5) * dimensions.y, 4.);\n rgb *= 0.99 + ceil(segment) * 0.015;\n }\n\n if (vignetting > 0.0)\n {\n float outter = SQRT_2 - vignetting * SQRT_2;\n float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0);\n rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha);\n }\n\n gl_FragColor.rgb = rgb;\n}\n"),this.uniforms.dimensions=new Float32Array(2),this.time=0,this.seed=0,Object.assign(this,{curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,seed:0,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0},e)}t&&(e.__proto__=t);var r={curvature:{configurable:!0},lineWidth:{configurable:!0},lineContrast:{configurable:!0},verticalLine:{configurable:!0},noise:{configurable:!0},noiseSize:{configurable:!0},vignetting:{configurable:!0},vignettingAlpha:{configurable:!0},vignettingBlur:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,this.uniforms.seed=this.seed,this.uniforms.time=this.time,e.applyFilter(this,t,r,i)},r.curvature.set=function(e){this.uniforms.curvature=e},r.curvature.get=function(){return this.uniforms.curvature},r.lineWidth.set=function(e){this.uniforms.lineWidth=e},r.lineWidth.get=function(){return this.uniforms.lineWidth},r.lineContrast.set=function(e){this.uniforms.lineContrast=e},r.lineContrast.get=function(){return this.uniforms.lineContrast},r.verticalLine.set=function(e){this.uniforms.verticalLine=e},r.verticalLine.get=function(){return this.uniforms.verticalLine},r.noise.set=function(e){this.uniforms.noise=e},r.noise.get=function(){return this.uniforms.noise},r.noiseSize.set=function(e){this.uniforms.noiseSize=e},r.noiseSize.get=function(){return this.uniforms.noiseSize},r.vignetting.set=function(e){this.uniforms.vignetting=e},r.vignetting.get=function(){return this.uniforms.vignetting},r.vignettingAlpha.set=function(e){this.uniforms.vignettingAlpha=e},r.vignettingAlpha.get=function(){return this.uniforms.vignettingAlpha},r.vignettingBlur.set=function(e){this.uniforms.vignettingBlur=e},r.vignettingBlur.get=function(){return this.uniforms.vignettingBlur},Object.defineProperties(e.prototype,r),e}(h.Filter),w=function(r){function e(e,t){void 0===e&&(e=1),void 0===t&&(t=5),r.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec4 filterArea;\nuniform sampler2D uSampler;\n\nuniform float angle;\nuniform float scale;\n\nfloat pattern()\n{\n float s = sin(angle), c = cos(angle);\n vec2 tex = vTextureCoord * filterArea.xy;\n vec2 point = vec2(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float average = (color.r + color.g + color.b) / 3.0;\n gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);\n}\n"),this.scale=e,this.angle=t}r&&(e.__proto__=r),(e.prototype=Object.create(r&&r.prototype)).constructor=e;var t={scale:{configurable:!0},angle:{configurable:!0}};return t.scale.get=function(){return this.uniforms.scale},t.scale.set=function(e){this.uniforms.scale=e},t.angle.get=function(){return this.uniforms.angle},t.angle.set=function(e){this.uniforms.angle=e},Object.defineProperties(e.prototype,t),e}(h.Filter),x=function(l){function e(e){e&&e.constructor!==Object&&(console.warn("DropShadowFilter now uses options instead of (rotation, distance, blur, color, alpha)"),e={rotation:e},void 0!==arguments[1]&&(e.distance=arguments[1]),void 0!==arguments[2]&&(e.blur=arguments[2]),void 0!==arguments[3]&&(e.color=arguments[3]),void 0!==arguments[4]&&(e.alpha=arguments[4])),e=Object.assign({rotation:45,distance:5,color:0,alpha:.5,shadowOnly:!1,kernels:null,blur:2,quality:3,pixelSize:1,resolution:h.settings.RESOLUTION},e),l.call(this);var t=e.kernels,r=e.blur,i=e.quality,n=e.pixelSize,o=e.resolution;this._tintFilter=new h.Filter("attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform vec3 color;\nvoid main(void){\n vec4 sample = texture2D(uSampler, vTextureCoord);\n\n // Un-premultiply alpha before applying the color\n if (sample.a > 0.0) {\n sample.rgb /= sample.a;\n }\n\n // Premultiply alpha again\n sample.rgb = color.rgb * sample.a;\n\n // alpha user alpha\n sample *= alpha;\n\n gl_FragColor = sample;\n}"),this._tintFilter.uniforms.color=new Float32Array(4),this._tintFilter.resolution=o,this._blurFilter=t?new d(t):new d(r,i),this.pixelSize=n,this.resolution=o,this.targetTransform=new h.Matrix;var a=e.shadowOnly,s=e.rotation,u=e.distance,c=e.alpha,f=e.color;this.shadowOnly=a,this.rotation=s,this.distance=u,this.alpha=c,this.color=f,this._updatePadding()}l&&(e.__proto__=l);var t={resolution:{configurable:!0},distance:{configurable:!0},rotation:{configurable:!0},alpha:{configurable:!0},color:{configurable:!0},kernels:{configurable:!0},blur:{configurable:!0},quality:{configurable:!0},pixelSize:{configurable:!0}};return((e.prototype=Object.create(l&&l.prototype)).constructor=e).prototype.apply=function(e,t,r,i){var n=e.getRenderTarget();n.transform=this.targetTransform,this._tintFilter.apply(e,t,n,!0),n.transform=null,this._blurFilter.apply(e,n,r,i),!0!==this.shadowOnly&&e.applyFilter(this,t,r,!1),e.returnRenderTarget(n)},e.prototype._updatePadding=function(){this.padding=this.distance+2*this.blur},e.prototype._updateTargetTransform=function(){this.targetTransform.tx=this.distance*Math.cos(this.angle),this.targetTransform.ty=this.distance*Math.sin(this.angle)},t.resolution.get=function(){return this._resolution},t.resolution.set=function(e){this._resolution=e,this._tintFilter&&(this._tintFilter.resolution=e),this._blurFilter&&(this._blurFilter.resolution=e)},t.distance.get=function(){return this._distance},t.distance.set=function(e){this._distance=e,this._updatePadding(),this._updateTargetTransform()},t.rotation.get=function(){return this.angle/h.DEG_TO_RAD},t.rotation.set=function(e){this.angle=e*h.DEG_TO_RAD,this._updateTargetTransform()},t.alpha.get=function(){return this._tintFilter.uniforms.alpha},t.alpha.set=function(e){this._tintFilter.uniforms.alpha=e},t.color.get=function(){return h.utils.rgb2hex(this._tintFilter.uniforms.color)},t.color.set=function(e){h.utils.hex2rgb(e,this._tintFilter.uniforms.color)},t.kernels.get=function(){return this._blurFilter.kernels},t.kernels.set=function(e){this._blurFilter.kernels=e},t.blur.get=function(){return this._blurFilter.blur},t.blur.set=function(e){this._blurFilter.blur=e,this._updatePadding()},t.quality.get=function(){return this._blurFilter.quality},t.quality.set=function(e){this._blurFilter.quality=e},t.pixelSize.get=function(){return this._blurFilter.pixelSize},t.pixelSize.set=function(e){this._blurFilter.pixelSize=e},Object.defineProperties(e.prototype,t),e}(h.Filter),T=function(t){function e(e){void 0===e&&(e=5),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float strength;\nuniform vec4 filterArea;\n\n\nvoid main(void)\n{\n\tvec2 onePixel = vec2(1.0 / filterArea);\n\n\tvec4 color;\n\n\tcolor.rgb = vec3(0.5);\n\n\tcolor -= texture2D(uSampler, vTextureCoord - onePixel) * strength;\n\tcolor += texture2D(uSampler, vTextureCoord + onePixel) * strength;\n\n\tcolor.rgb = vec3((color.r + color.g + color.b) / 3.0);\n\n\tfloat alpha = texture2D(uSampler, vTextureCoord).a;\n\n\tgl_FragColor = vec4(color.rgb * alpha, alpha);\n}\n"),this.strength=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={strength:{configurable:!0}};return r.strength.get=function(){return this.uniforms.strength},r.strength.set=function(e){this.uniforms.strength=e},Object.defineProperties(e.prototype,r),e}(h.Filter),S=function(t){function e(e){void 0===e&&(e={}),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","// precision highp float;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\nuniform float aspect;\n\nuniform sampler2D displacementMap;\nuniform float offset;\nuniform float sinDir;\nuniform float cosDir;\nuniform int fillMode;\n\nuniform float seed;\nuniform vec2 red;\nuniform vec2 green;\nuniform vec2 blue;\n\nconst int TRANSPARENT = 0;\nconst int ORIGINAL = 1;\nconst int LOOP = 2;\nconst int CLAMP = 3;\nconst int MIRROR = 4;\n\nvoid main(void)\n{\n vec2 coord = (vTextureCoord * filterArea.xy) / dimensions;\n\n if (coord.x > 1.0 || coord.y > 1.0) {\n return;\n }\n\n float cx = coord.x - 0.5;\n float cy = (coord.y - 0.5) * aspect;\n float ny = (-sinDir * cx + cosDir * cy) / aspect + 0.5;\n\n // displacementMap: repeat\n // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny);\n\n // displacementMap: mirror\n ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny);\n\n vec4 dc = texture2D(displacementMap, vec2(0.5, ny));\n\n float displacement = (dc.r - dc.g) * (offset / filterArea.x);\n\n coord = vTextureCoord + vec2(cosDir * displacement, sinDir * displacement * aspect);\n\n if (fillMode == CLAMP) {\n coord = clamp(coord, filterClamp.xy, filterClamp.zw);\n } else {\n if( coord.x > filterClamp.z ) {\n if (fillMode == ORIGINAL) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n } else if (fillMode == LOOP) {\n coord.x -= filterClamp.z;\n } else if (fillMode == MIRROR) {\n coord.x = filterClamp.z * 2.0 - coord.x;\n } else {\n gl_FragColor = vec4(0., 0., 0., 0.);\n return;\n }\n } else if( coord.x < filterClamp.x ) {\n if (fillMode == ORIGINAL) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n } else if (fillMode == LOOP) {\n coord.x += filterClamp.z;\n } else if (fillMode == MIRROR) {\n coord.x *= -filterClamp.z;\n } else {\n gl_FragColor = vec4(0., 0., 0., 0.);\n return;\n }\n }\n\n if( coord.y > filterClamp.w ) {\n if (fillMode == ORIGINAL) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n } else if (fillMode == LOOP) {\n coord.y -= filterClamp.w;\n } else if (fillMode == MIRROR) {\n coord.y = filterClamp.w * 2.0 - coord.y;\n } else {\n gl_FragColor = vec4(0., 0., 0., 0.);\n return;\n }\n } else if( coord.y < filterClamp.y ) {\n if (fillMode == ORIGINAL) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n } else if (fillMode == LOOP) {\n coord.y += filterClamp.w;\n } else if (fillMode == MIRROR) {\n coord.y *= -filterClamp.w;\n } else {\n gl_FragColor = vec4(0., 0., 0., 0.);\n return;\n }\n }\n }\n\n gl_FragColor.r = texture2D(uSampler, coord + red * (1.0 - seed * 0.4) / filterArea.xy).r;\n gl_FragColor.g = texture2D(uSampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g;\n gl_FragColor.b = texture2D(uSampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b;\n gl_FragColor.a = texture2D(uSampler, coord).a;\n}\n"),this.uniforms.dimensions=new Float32Array(2),e=Object.assign({slices:5,offset:100,direction:0,fillMode:0,average:!1,seed:0,red:[0,0],green:[0,0],blue:[0,0],minSize:8,sampleSize:512},e),this.direction=e.direction,this.red=e.red,this.green=e.green,this.blue=e.blue,this.offset=e.offset,this.fillMode=e.fillMode,this.average=e.average,this.seed=e.seed,this.minSize=e.minSize,this.sampleSize=e.sampleSize,this._canvas=document.createElement("canvas"),this._canvas.width=4,this._canvas.height=this.sampleSize,this.texture=h.Texture.fromCanvas(this._canvas,h.SCALE_MODES.NEAREST),this._slices=0,this.slices=e.slices}t&&(e.__proto__=t);var r={sizes:{configurable:!0},offsets:{configurable:!0},slices:{configurable:!0},direction:{configurable:!0},red:{configurable:!0},green:{configurable:!0},blue:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.apply=function(e,t,r,i){var n=t.sourceFrame.width,o=t.sourceFrame.height;this.uniforms.dimensions[0]=n,this.uniforms.dimensions[1]=o,this.uniforms.aspect=o/n,this.uniforms.seed=this.seed,this.uniforms.offset=this.offset,this.uniforms.fillMode=this.fillMode,e.applyFilter(this,t,r,i)},e.prototype._randomizeSizes=function(){var e=this._sizes,t=this._slices-1,r=this.sampleSize,i=Math.min(this.minSize/r,.9/this._slices);if(this.average){for(var n=this._slices,o=1,a=0;a>0,i=e[t];e[t]=e[r],e[r]=i}},e.prototype._randomizeOffsets=function(){for(var e=0;e>0,t,1+a>>0),n+=a}r.baseTexture.update(),this.uniforms.displacementMap=r},r.sizes.set=function(e){for(var t=Math.min(this._slices,e.length),r=0;rthis._maxColors)throw"Length of replacements ("+i+") exceeds the maximum colors length ("+this._maxColors+")";t[3*i]=-1;for(var n=0;n 0.5) then: 1 - 2 * (1 - dst) * (1 - src)\n return vec3((dst.x <= 0.5) ? (2.0 * src.x * dst.x) : (1.0 - 2.0 * (1.0 - dst.x) * (1.0 - src.x)),\n (dst.y <= 0.5) ? (2.0 * src.y * dst.y) : (1.0 - 2.0 * (1.0 - dst.y) * (1.0 - src.y)),\n (dst.z <= 0.5) ? (2.0 * src.z * dst.z) : (1.0 - 2.0 * (1.0 - dst.z) * (1.0 - src.z)));\n}\n\n\nvoid main()\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n vec3 color = gl_FragColor.rgb;\n\n if (sepia > 0.0)\n {\n float gray = (color.x + color.y + color.z) / 3.0;\n vec3 grayscale = vec3(gray);\n\n color = Overlay(SEPIA_RGB, grayscale);\n\n color = grayscale + sepia * (color - grayscale);\n }\n\n vec2 coord = vTextureCoord * filterArea.xy / dimensions.xy;\n\n if (vignetting > 0.0)\n {\n float outter = SQRT_2 - vignetting * SQRT_2;\n vec2 dir = vec2(vec2(0.5, 0.5) - coord);\n dir.y *= dimensions.y / dimensions.x;\n float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0);\n color.rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha);\n }\n\n if (scratchDensity > seed && scratch != 0.0)\n {\n float phase = seed * 256.0;\n float s = mod(floor(phase), 2.0);\n float dist = 1.0 / scratchDensity;\n float d = distance(coord, vec2(seed * dist, abs(s - seed * dist)));\n if (d < seed * 0.6 + 0.4)\n {\n highp float period = scratchDensity * 10.0;\n\n float xx = coord.x * period + phase;\n float aa = abs(mod(xx, 0.5) * 4.0);\n float bb = mod(floor(xx / 0.5), 2.0);\n float yy = (1.0 - bb) * aa + bb * (2.0 - aa);\n\n float kk = 2.0 * period;\n float dw = scratchWidth / dimensions.x * (0.75 + seed);\n float dh = dw * kk;\n\n float tine = (yy - (2.0 - dh));\n\n if (tine > 0.0) {\n float _sign = sign(scratch);\n\n tine = s * tine / period + scratch + 0.1;\n tine = clamp(tine + 1.0, 0.5 + _sign * 0.5, 1.5 + _sign * 0.5);\n\n color.rgb *= tine;\n }\n }\n }\n\n if (noise > 0.0 && noiseSize > 0.0)\n {\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n pixelCoord.x = floor(pixelCoord.x / noiseSize);\n pixelCoord.y = floor(pixelCoord.y / noiseSize);\n // vec2 d = pixelCoord * noiseSize * vec2(1024.0 + seed * 512.0, 1024.0 - seed * 512.0);\n // float _noise = snoise(d) * 0.5;\n float _noise = rand(pixelCoord * noiseSize * seed) - 0.5;\n color += _noise * noise;\n }\n\n gl_FragColor.rgb = color;\n}\n"),this.uniforms.dimensions=new Float32Array(2),"number"==typeof e?(this.seed=e,e=null):this.seed=t,Object.assign(this,{sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3},e)}r&&(e.__proto__=r);var t={sepia:{configurable:!0},noise:{configurable:!0},noiseSize:{configurable:!0},scratch:{configurable:!0},scratchDensity:{configurable:!0},scratchWidth:{configurable:!0},vignetting:{configurable:!0},vignettingAlpha:{configurable:!0},vignettingBlur:{configurable:!0}};return((e.prototype=Object.create(r&&r.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,this.uniforms.seed=this.seed,e.applyFilter(this,t,r,i)},t.sepia.set=function(e){this.uniforms.sepia=e},t.sepia.get=function(){return this.uniforms.sepia},t.noise.set=function(e){this.uniforms.noise=e},t.noise.get=function(){return this.uniforms.noise},t.noiseSize.set=function(e){this.uniforms.noiseSize=e},t.noiseSize.get=function(){return this.uniforms.noiseSize},t.scratch.set=function(e){this.uniforms.scratch=e},t.scratch.get=function(){return this.uniforms.scratch},t.scratchDensity.set=function(e){this.uniforms.scratchDensity=e},t.scratchDensity.get=function(){return this.uniforms.scratchDensity},t.scratchWidth.set=function(e){this.uniforms.scratchWidth=e},t.scratchWidth.get=function(){return this.uniforms.scratchWidth},t.vignetting.set=function(e){this.uniforms.vignetting=e},t.vignetting.get=function(){return this.uniforms.vignetting},t.vignettingAlpha.set=function(e){this.uniforms.vignettingAlpha=e},t.vignettingAlpha.get=function(){return this.uniforms.vignettingAlpha},t.vignettingBlur.set=function(e){this.uniforms.vignettingBlur=e},t.vignettingBlur.get=function(){return this.uniforms.vignettingBlur},Object.defineProperties(e.prototype,t),e}(h.Filter),k=function(o){function a(e,t,r){void 0===e&&(e=1),void 0===t&&(t=0),void 0===r&&(r=.1);var i=Math.max(r*a.MAX_SAMPLES,a.MIN_SAMPLES),n=(2*Math.PI/i).toFixed(7);o.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 thickness;\nuniform vec4 outlineColor;\nuniform vec4 filterClamp;\n\nconst float DOUBLE_PI = 3.14159265358979323846264 * 2.;\n\nvoid main(void) {\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\n vec4 curColor;\n float maxAlpha = 0.;\n vec2 displaced;\n for (float angle = 0.; angle <= DOUBLE_PI; angle += ${angleStep}) {\n displaced.x = vTextureCoord.x + thickness.x * cos(angle);\n displaced.y = vTextureCoord.y + thickness.y * sin(angle);\n curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw));\n maxAlpha = max(maxAlpha, curColor.a);\n }\n float resultAlpha = max(maxAlpha, ownColor.a);\n gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha);\n}\n".replace(/\$\{angleStep\}/,n)),this.uniforms.thickness=new Float32Array([0,0]),this.thickness=e,this.uniforms.outlineColor=new Float32Array([0,0,0,1]),this.color=t,this.quality=r}o&&(a.__proto__=o);var e={color:{configurable:!0}};return((a.prototype=Object.create(o&&o.prototype)).constructor=a).prototype.apply=function(e,t,r,i){this.uniforms.thickness[0]=this.thickness/t.size.width,this.uniforms.thickness[1]=this.thickness/t.size.height,e.applyFilter(this,t,r,i)},e.color.get=function(){return h.utils.rgb2hex(this.uniforms.outlineColor)},e.color.set=function(e){h.utils.hex2rgb(e,this.uniforms.outlineColor)},Object.defineProperties(a.prototype,e),a}(h.Filter);k.MIN_SAMPLES=1,k.MAX_SAMPLES=100;var I=function(t){function e(e){void 0===e&&(e=10),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform vec2 size;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 pixelate(vec2 coord, vec2 size)\n{\n\treturn floor( coord / size ) * size;\n}\n\nvoid main(void)\n{\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = pixelate(coord, size);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord);\n}\n"),this.size=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={size:{configurable:!0}};return r.size.get=function(){return this.uniforms.size},r.size.set=function(e){"number"==typeof e&&(e=[e,e]),this.uniforms.size=e},Object.defineProperties(e.prototype,r),e}(h.Filter),R=function(n){function e(e,t,r,i){void 0===e&&(e=0),void 0===t&&(t=[0,0]),void 0===r&&(r=5),void 0===i&&(i=-1),n.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform float uRadian;\nuniform vec2 uCenter;\nuniform float uRadius;\nuniform int uKernelSize;\n\nconst int MAX_KERNEL_SIZE = 2048;\n\nvoid main(void)\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n if (uKernelSize == 0)\n {\n gl_FragColor = color;\n return;\n }\n\n float aspect = filterArea.y / filterArea.x;\n vec2 center = uCenter.xy / filterArea.xy;\n float gradient = uRadius / filterArea.x * 0.3;\n float radius = uRadius / filterArea.x - gradient * 0.5;\n int k = uKernelSize - 1;\n\n vec2 coord = vTextureCoord;\n vec2 dir = vec2(center - coord);\n float dist = length(vec2(dir.x, dir.y * aspect));\n\n float radianStep = uRadian;\n if (radius >= 0.0 && dist > radius) {\n float delta = dist - radius;\n float gap = gradient;\n float scale = 1.0 - abs(delta / gap);\n if (scale <= 0.0) {\n gl_FragColor = color;\n return;\n }\n radianStep *= scale;\n }\n radianStep /= float(k);\n\n float s = sin(radianStep);\n float c = cos(radianStep);\n mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c));\n\n for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) {\n if (i == k) {\n break;\n }\n\n coord -= center;\n coord.y *= aspect;\n coord = rotationMatrix * coord;\n coord.y /= aspect;\n coord += center;\n\n vec4 sample = texture2D(uSampler, coord);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample;\n }\n\n gl_FragColor = color / float(uKernelSize);\n}\n"),this._angle=0,this.angle=e,this.center=t,this.kernelSize=r,this.radius=i}n&&(e.__proto__=n);var t={angle:{configurable:!0},center:{configurable:!0},radius:{configurable:!0}};return((e.prototype=Object.create(n&&n.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.uKernelSize=0!==this._angle?this.kernelSize:0,e.applyFilter(this,t,r,i)},t.angle.set=function(e){this._angle=e,this.uniforms.uRadian=e*Math.PI/180},t.angle.get=function(){return this._angle},t.center.get=function(){return this.uniforms.uCenter},t.center.set=function(e){this.uniforms.uCenter=e},t.radius.get=function(){return this.uniforms.uRadius},t.radius.set=function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},Object.defineProperties(e.prototype,t),e}(h.Filter),O=function(t){function e(e){t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\n\nuniform bool mirror;\nuniform float boundary;\nuniform vec2 amplitude;\nuniform vec2 waveLength;\nuniform vec2 alpha;\nuniform float time;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main(void)\n{\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n vec2 coord = pixelCoord / dimensions;\n\n if (coord.y < boundary) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n\n float k = (coord.y - boundary) / (1. - boundary + 0.0001);\n float areaY = boundary * dimensions.y / filterArea.y;\n float v = areaY + areaY - vTextureCoord.y;\n float y = mirror ? v : vTextureCoord.y;\n\n float _amplitude = ((amplitude.y - amplitude.x) * k + amplitude.x ) / filterArea.x;\n float _waveLength = ((waveLength.y - waveLength.x) * k + waveLength.x) / filterArea.y;\n float _alpha = (alpha.y - alpha.x) * k + alpha.x;\n\n float x = vTextureCoord.x + cos(v * 6.28 / _waveLength - time) * _amplitude;\n x = clamp(x, filterClamp.x, filterClamp.z);\n\n vec4 color = texture2D(uSampler, vec2(x, y));\n\n gl_FragColor = color * _alpha;\n}\n"),this.uniforms.amplitude=new Float32Array(2),this.uniforms.waveLength=new Float32Array(2),this.uniforms.alpha=new Float32Array(2),this.uniforms.dimensions=new Float32Array(2),Object.assign(this,{mirror:!0,boundary:.5,amplitude:[0,20],waveLength:[30,100],alpha:[1,1],time:0},e)}t&&(e.__proto__=t);var r={mirror:{configurable:!0},boundary:{configurable:!0},amplitude:{configurable:!0},waveLength:{configurable:!0},alpha:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,this.uniforms.time=this.time,e.applyFilter(this,t,r,i)},r.mirror.set=function(e){this.uniforms.mirror=e},r.mirror.get=function(){return this.uniforms.mirror},r.boundary.set=function(e){this.uniforms.boundary=e},r.boundary.get=function(){return this.uniforms.boundary},r.amplitude.set=function(e){this.uniforms.amplitude[0]=e[0],this.uniforms.amplitude[1]=e[1]},r.amplitude.get=function(){return this.uniforms.amplitude},r.waveLength.set=function(e){this.uniforms.waveLength[0]=e[0],this.uniforms.waveLength[1]=e[1]},r.waveLength.get=function(){return this.uniforms.waveLength},r.alpha.set=function(e){this.uniforms.alpha[0]=e[0],this.uniforms.alpha[1]=e[1]},r.alpha.get=function(){return this.uniforms.alpha},Object.defineProperties(e.prototype,r),e}(h.Filter),D=function(i){function e(e,t,r){void 0===e&&(e=[-10,0]),void 0===t&&(t=[0,10]),void 0===r&&(r=[0,0]),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\nuniform vec2 red;\nuniform vec2 green;\nuniform vec2 blue;\n\nvoid main(void)\n{\n gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r;\n gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g;\n gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b;\n gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;\n}\n"),this.red=e,this.green=t,this.blue=r}i&&(e.__proto__=i),(e.prototype=Object.create(i&&i.prototype)).constructor=e;var t={red:{configurable:!0},green:{configurable:!0},blue:{configurable:!0}};return t.red.get=function(){return this.uniforms.red},t.red.set=function(e){this.uniforms.red=e},t.green.get=function(){return this.uniforms.green},t.green.set=function(e){this.uniforms.green=e},t.blue.get=function(){return this.uniforms.blue},t.blue.set=function(e){this.uniforms.blue=e},Object.defineProperties(e.prototype,t),e}(h.Filter),L=function(i){function e(e,t,r){void 0===e&&(e=[0,0]),void 0===t&&(t={}),void 0===r&&(r=0),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\n\nuniform vec2 center;\n\nuniform float amplitude;\nuniform float wavelength;\n// uniform float power;\nuniform float brightness;\nuniform float speed;\nuniform float radius;\n\nuniform float time;\n\nconst float PI = 3.14159;\n\nvoid main()\n{\n float halfWavelength = wavelength * 0.5 / filterArea.x;\n float maxRadius = radius / filterArea.x;\n float currentRadius = time * speed / filterArea.x;\n\n float fade = 1.0;\n\n if (maxRadius > 0.0) {\n if (currentRadius > maxRadius) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n fade = 1.0 - pow(currentRadius / maxRadius, 2.0);\n }\n\n vec2 dir = vec2(vTextureCoord - center / filterArea.xy);\n dir.y *= filterArea.y / filterArea.x;\n float dist = length(dir);\n\n if (dist <= 0.0 || dist < currentRadius - halfWavelength || dist > currentRadius + halfWavelength) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n\n vec2 diffUV = normalize(dir);\n\n float diff = (dist - currentRadius) / halfWavelength;\n\n float p = 1.0 - pow(abs(diff), 2.0);\n\n // float powDiff = diff * pow(p, 2.0) * ( amplitude * fade );\n float powDiff = 1.25 * sin(diff * PI) * p * ( amplitude * fade );\n\n vec2 offset = diffUV * powDiff / filterArea.xy;\n\n // Do clamp :\n vec2 coord = vTextureCoord + offset;\n vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw);\n vec4 color = texture2D(uSampler, clampedCoord);\n if (coord != clampedCoord) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n // No clamp :\n // gl_FragColor = texture2D(uSampler, vTextureCoord + offset);\n\n color.rgb *= 1.0 + (brightness - 1.0) * p * fade;\n\n gl_FragColor = color;\n}\n"),this.center=e,Array.isArray(t)&&(console.warn("Deprecated Warning: ShockwaveFilter params Array has been changed to options Object."),t={}),t=Object.assign({amplitude:30,wavelength:160,brightness:1,speed:500,radius:-1},t),this.amplitude=t.amplitude,this.wavelength=t.wavelength,this.brightness=t.brightness,this.speed=t.speed,this.radius=t.radius,this.time=r}i&&(e.__proto__=i);var t={center:{configurable:!0},amplitude:{configurable:!0},wavelength:{configurable:!0},brightness:{configurable:!0},speed:{configurable:!0},radius:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.time=this.time,e.applyFilter(this,t,r,i)},t.center.get=function(){return this.uniforms.center},t.center.set=function(e){this.uniforms.center=e},t.amplitude.get=function(){return this.uniforms.amplitude},t.amplitude.set=function(e){this.uniforms.amplitude=e},t.wavelength.get=function(){return this.uniforms.wavelength},t.wavelength.set=function(e){this.uniforms.wavelength=e},t.brightness.get=function(){return this.uniforms.brightness},t.brightness.set=function(e){this.uniforms.brightness=e},t.speed.get=function(){return this.uniforms.speed},t.speed.set=function(e){this.uniforms.speed=e},t.radius.get=function(){return this.uniforms.radius},t.radius.set=function(e){this.uniforms.radius=e},Object.defineProperties(e.prototype,t),e}(h.Filter),j=function(i){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=1),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform sampler2D uLightmap;\nuniform vec4 filterArea;\nuniform vec2 dimensions;\nuniform vec4 ambientColor;\nvoid main() {\n vec4 diffuseColor = texture2D(uSampler, vTextureCoord);\n vec2 lightCoord = (vTextureCoord * filterArea.xy) / dimensions;\n vec4 light = texture2D(uLightmap, lightCoord);\n vec3 ambient = ambientColor.rgb * ambientColor.a;\n vec3 intensity = ambient + light.rgb;\n vec3 finalColor = diffuseColor.rgb * intensity;\n gl_FragColor = vec4(finalColor, diffuseColor.a);\n}\n"),this.uniforms.dimensions=new Float32Array(2),this.uniforms.ambientColor=new Float32Array([0,0,0,r]),this.texture=e,this.color=t}i&&(e.__proto__=i);var t={texture:{configurable:!0},color:{configurable:!0},alpha:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,e.applyFilter(this,t,r,i)},t.texture.get=function(){return this.uniforms.uLightmap},t.texture.set=function(e){this.uniforms.uLightmap=e},t.color.set=function(e){var t=this.uniforms.ambientColor;"number"==typeof e?(h.utils.hex2rgb(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._color=h.utils.rgb2hex(t))},t.color.get=function(){return this._color},t.alpha.get=function(){return this.uniforms.ambientColor[3]},t.alpha.set=function(e){this.uniforms.ambientColor[3]=e},Object.defineProperties(e.prototype,t),e}(h.Filter),F=function(n){function e(e,t,r,i){void 0===e&&(e=100),void 0===t&&(t=600),void 0===r&&(r=null),void 0===i&&(i=null),n.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float blur;\nuniform float gradientBlur;\nuniform vec2 start;\nuniform vec2 end;\nuniform vec2 delta;\nuniform vec2 texSize;\n\nfloat random(vec3 scale, float seed)\n{\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur;\n\n for (float t = -30.0; t <= 30.0; t++)\n {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius);\n sample.rgb *= sample.a;\n color += sample * weight;\n total += weight;\n }\n\n color /= total;\n color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n"),this.uniforms.blur=e,this.uniforms.gradientBlur=t,this.uniforms.start=r||new h.Point(0,window.innerHeight/2),this.uniforms.end=i||new h.Point(600,window.innerHeight/2),this.uniforms.delta=new h.Point(30,30),this.uniforms.texSize=new h.Point(window.innerWidth,window.innerHeight),this.updateDelta()}n&&(e.__proto__=n);var t={blur:{configurable:!0},gradientBlur:{configurable:!0},start:{configurable:!0},end:{configurable:!0}};return((e.prototype=Object.create(n&&n.prototype)).constructor=e).prototype.updateDelta=function(){this.uniforms.delta.x=0,this.uniforms.delta.y=0},t.blur.get=function(){return this.uniforms.blur},t.blur.set=function(e){this.uniforms.blur=e},t.gradientBlur.get=function(){return this.uniforms.gradientBlur},t.gradientBlur.set=function(e){this.uniforms.gradientBlur=e},t.start.get=function(){return this.uniforms.start},t.start.set=function(e){this.uniforms.start=e,this.updateDelta()},t.end.get=function(){return this.uniforms.end},t.end.set=function(e){this.uniforms.end=e,this.updateDelta()},Object.defineProperties(e.prototype,t),e}(h.Filter),B=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,r=Math.sqrt(e*e+t*t);this.uniforms.delta.x=e/r,this.uniforms.delta.y=t/r},t}(F),N=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,r=Math.sqrt(e*e+t*t);this.uniforms.delta.x=-t/r,this.uniforms.delta.y=e/r},t}(F),U=function(n){function e(e,t,r,i){void 0===e&&(e=100),void 0===t&&(t=600),void 0===r&&(r=null),void 0===i&&(i=null),n.call(this),this.tiltShiftXFilter=new B(e,t,r,i),this.tiltShiftYFilter=new N(e,t,r,i)}n&&(e.__proto__=n);var t={blur:{configurable:!0},gradientBlur:{configurable:!0},start:{configurable:!0},end:{configurable:!0}};return((e.prototype=Object.create(n&&n.prototype)).constructor=e).prototype.apply=function(e,t,r){var i=e.getRenderTarget(!0);this.tiltShiftXFilter.apply(e,t,i),this.tiltShiftYFilter.apply(e,i,r),e.returnRenderTarget(i)},t.blur.get=function(){return this.tiltShiftXFilter.blur},t.blur.set=function(e){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=e},t.gradientBlur.get=function(){return this.tiltShiftXFilter.gradientBlur},t.gradientBlur.set=function(e){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=e},t.start.get=function(){return this.tiltShiftXFilter.start},t.start.set=function(e){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=e},t.end.get=function(){return this.tiltShiftXFilter.end},t.end.set=function(e){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=e},Object.defineProperties(e.prototype,t),e}(h.Filter),z=function(i){function e(e,t,r){void 0===e&&(e=200),void 0===t&&(t=4),void 0===r&&(r=20),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 twist(vec2 coord)\n{\n coord -= offset;\n\n float dist = length(coord);\n\n if (dist < radius)\n {\n float ratioDist = (radius - dist) / radius;\n float angleMod = ratioDist * ratioDist * angle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n coord += offset;\n\n return coord;\n}\n\nvoid main(void)\n{\n\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = twist(coord);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord );\n\n}\n"),this.radius=e,this.angle=t,this.padding=r}i&&(e.__proto__=i),(e.prototype=Object.create(i&&i.prototype)).constructor=e;var t={offset:{configurable:!0},radius:{configurable:!0},angle:{configurable:!0}};return t.offset.get=function(){return this.uniforms.offset},t.offset.set=function(e){this.uniforms.offset=e},t.radius.get=function(){return this.uniforms.radius},t.radius.set=function(e){this.uniforms.radius=e},t.angle.get=function(){return this.uniforms.angle},t.angle.set=function(e){this.uniforms.angle=e},Object.defineProperties(e.prototype,t),e}(h.Filter),X=function(n){function e(e,t,r,i){void 0===e&&(e=.1),void 0===t&&(t=[0,0]),void 0===r&&(r=0),void 0===i&&(i=-1),n.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform vec2 uCenter;\nuniform float uStrength;\nuniform float uInnerRadius;\nuniform float uRadius;\n\nconst float MAX_KERNEL_SIZE = 32.0;\n\n// author: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand(vec2 co, float seed) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);\n return fract(sin(sn) * c + seed);\n}\n\nvoid main() {\n\n float minGradient = uInnerRadius * 0.3;\n float innerRadius = (uInnerRadius + minGradient * 0.5) / filterArea.x;\n\n float gradient = uRadius * 0.3;\n float radius = (uRadius - gradient * 0.5) / filterArea.x;\n\n float countLimit = MAX_KERNEL_SIZE;\n\n vec2 dir = vec2(uCenter.xy / filterArea.xy - vTextureCoord);\n float dist = length(vec2(dir.x, dir.y * filterArea.y / filterArea.x));\n\n float strength = uStrength;\n\n float delta = 0.0;\n float gap;\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (radius >= 0.0 && dist > radius) { // radius < 0 means it's infinity\n delta = dist - radius;\n gap = gradient;\n }\n\n if (delta > 0.0) {\n float normalCount = gap / filterArea.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n if (countLimit < 1.0)\n {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n float offset = rand(vTextureCoord, 0.0);\n\n float total = 0.0;\n vec4 color = vec4(0.0);\n\n dir *= strength;\n\n for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {\n float percent = (t + offset) / MAX_KERNEL_SIZE;\n float weight = 4.0 * (percent - percent * percent);\n vec2 p = vTextureCoord + dir * percent;\n vec4 sample = texture2D(uSampler, p);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n\n if (t > countLimit){\n break;\n }\n }\n\n color /= total;\n // switch back from pre-multiplied alpha\n // color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n"),this.center=t,this.strength=e,this.innerRadius=r,this.radius=i}n&&(e.__proto__=n),(e.prototype=Object.create(n&&n.prototype)).constructor=e;var t={center:{configurable:!0},strength:{configurable:!0},innerRadius:{configurable:!0},radius:{configurable:!0}};return t.center.get=function(){return this.uniforms.uCenter},t.center.set=function(e){this.uniforms.uCenter=e},t.strength.get=function(){return this.uniforms.uStrength},t.strength.set=function(e){this.uniforms.uStrength=e},t.innerRadius.get=function(){return this.uniforms.uInnerRadius},t.innerRadius.set=function(e){this.uniforms.uInnerRadius=e},t.radius.get=function(){return this.uniforms.uRadius},t.radius.set=function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},Object.defineProperties(e.prototype,t),e}(h.Filter);return e.AdjustmentFilter=t,e.AdvancedBloomFilter=i,e.AsciiFilter=n,e.BevelFilter=o,e.BloomFilter=p,e.BulgePinchFilter=v,e.ColorMapFilter=m,e.ColorReplaceFilter=b,e.ConvolutionFilter=g,e.CrossHatchFilter=y,e.CRTFilter=_,e.DotFilter=w,e.DropShadowFilter=x,e.EmbossFilter=T,e.GlitchFilter=S,e.GlowFilter=E,e.GodrayFilter=M,e.KawaseBlurFilter=d,e.MotionBlurFilter=C,e.MultiColorReplaceFilter=P,e.OldFilmFilter=A,e.OutlineFilter=k,e.PixelateFilter=I,e.RadialBlurFilter=R,e.ReflectionFilter=O,e.RGBSplitFilter=D,e.ShockwaveFilter=L,e.SimpleLightmapFilter=j,e.TiltShiftFilter=U,e.TiltShiftAxisFilter=F,e.TiltShiftXFilter=B,e.TiltShiftYFilter=N,e.TwistFilter=z,e.ZoomBlurFilter=X,e}({},PIXI),pixi_projection,pixi_projection;Object.assign(PIXI.filters,this?this.__filters:__filters),this.PIXI=this.PIXI||{},function(d,m){"use strict";var h,p=function(){function h(e,t,r){this.value=e,this.time=t,this.next=null,this.isStepped=!1,this.ease=r?"function"==typeof r?r:d.ParticleUtils.generateEase(r):null}return h.createList=function(e){if("list"in e){var t=e.list,r=void 0,i=void 0,n=t[0],o=n.value,a=n.time;if(i=r=new h("string"==typeof o?d.ParticleUtils.hexToRGB(o):o,a,e.ease),2a.time;)n=a,a=e[++o];u=(u-n.time)/(a.time-n.time);var c=h.hexToRGB(n.value),f=h.hexToRGB(a.value),l={r:(f.r-c.r)*u+c.r,g:(f.g-c.g)*u+c.g,b:(f.b-c.b)*u+c.b};i.next=new p(l,s/t),i=i.next}return r};var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function t(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var n=function(){function e(e){void 0===e&&(e=!1),this.current=null,this.next=null,this.isColor=!!e,this.interpolate=null,this.ease=null}return e.prototype.reset=function(e){this.current=e,this.next=e.next,this.next&&1<=this.next.time?this.interpolate=this.isColor?o:r:e.isStepped?this.interpolate=this.isColor?c:u:this.interpolate=this.isColor?s:a,this.ease=this.current.ease},e}();function r(e){return this.ease&&(e=this.ease(e)),(this.next.value-this.current.value)*e+this.current.value}function o(e){this.ease&&(e=this.ease(e));var t=this.current.value,r=this.next.value,i=(r.r-t.r)*e+t.r,n=(r.g-t.g)*e+t.g,o=(r.b-t.b)*e+t.b;return d.ParticleUtils.combineRGBComponents(i,n,o)}function a(e){for(this.ease&&(e=this.ease(e));e>this.next.time;)this.current=this.next,this.next=this.next.next;return e=(e-this.current.time)/(this.next.time-this.current.time),(this.next.value-this.current.value)*e+this.current.value}function s(e){for(this.ease&&(e=this.ease(e));e>this.next.time;)this.current=this.next,this.next=this.next.next;e=(e-this.current.time)/(this.next.time-this.current.time);var t=this.current.value,r=this.next.value,i=(r.r-t.r)*e+t.r,n=(r.g-t.g)*e+t.g,o=(r.b-t.b)*e+t.b;return d.ParticleUtils.combineRGBComponents(i,n,o)}function u(e){for(this.ease&&(e=this.ease(e));this.next&&e>this.next.time;)this.current=this.next,this.next=this.next.next;return this.current.value}function c(e){for(this.ease&&(e=this.ease(e));this.next&&e>this.next.time;)this.current=this.next,this.next=this.next.next;var t=this.current.value;return d.ParticleUtils.combineRGBComponents(t.r,t.g,t.b)}var f,l=function(r){function i(e){var t=r.call(this)||this;return t.emitter=e,t.anchor.x=t.anchor.y=.5,t.velocity=new m.Point,t.rotationSpeed=0,t.rotationAcceleration=0,t.maxLife=0,t.age=0,t.ease=null,t.extraData=null,t.alphaList=new n,t.speedList=new n,t.speedMultiplier=1,t.acceleration=new m.Point,t.maxSpeed=NaN,t.scaleList=new n,t.scaleMultiplier=1,t.colorList=new n(!0),t._doAlpha=!1,t._doScale=!1,t._doSpeed=!1,t._doAcceleration=!1,t._doColor=!1,t._doNormalMovement=!1,t._oneOverLife=0,t.next=null,t.prev=null,t.init=t.init,t.Particle_init=i.prototype.init,t.update=t.update,t.Particle_update=i.prototype.update,t.Sprite_destroy=r.prototype.destroy,t.Particle_destroy=i.prototype.destroy,t.applyArt=t.applyArt,t.kill=t.kill,t}return t(i,r),i.prototype.init=function(){this.age=0,this.velocity.x=this.speedList.current.value*this.speedMultiplier,this.velocity.y=0,d.ParticleUtils.rotatePoint(this.rotation,this.velocity),this.noRotation?this.rotation=0:this.rotation*=d.ParticleUtils.DEG_TO_RADS,this.rotationSpeed*=d.ParticleUtils.DEG_TO_RADS,this.rotationAcceleration*=d.ParticleUtils.DEG_TO_RADS,this.alpha=this.alphaList.current.value,this.scale.x=this.scale.y=this.scaleList.current.value,this._doAlpha=!!this.alphaList.current.next,this._doSpeed=!!this.speedList.current.next,this._doScale=!!this.scaleList.current.next,this._doColor=!!this.colorList.current.next,this._doAcceleration=0!==this.acceleration.x||0!==this.acceleration.y,this._doNormalMovement=this._doSpeed||0!==this.speedList.current.value||this._doAcceleration,this._oneOverLife=1/this.maxLife;var e=this.colorList.current.value;this.tint=d.ParticleUtils.combineRGBComponents(e.r,e.g,e.b),this.visible=!0},i.prototype.applyArt=function(e){this.texture=e||m.Texture.EMPTY},i.prototype.update=function(e){if(this.age+=e,this.age>=this.maxLife||this.age<0)return this.kill(),-1;var t=this.age*this._oneOverLife;if(this.ease&&(t=4==this.ease.length?this.ease(t,0,1,1):this.ease(t)),this._doAlpha&&(this.alpha=this.alphaList.interpolate(t)),this._doScale){var r=this.scaleList.interpolate(t)*this.scaleMultiplier;this.scale.x=this.scale.y=r}if(this._doNormalMovement){var i=void 0,n=void 0;if(this._doSpeed){var o=this.speedList.interpolate(t)*this.speedMultiplier;d.ParticleUtils.normalize(this.velocity),d.ParticleUtils.scaleBy(this.velocity,o),i=this.velocity.x*e,n=this.velocity.y*e}else if(this._doAcceleration){var a=this.velocity.x,s=this.velocity.y;if(this.velocity.x+=this.acceleration.x*e,this.velocity.y+=this.acceleration.y*e,this.maxSpeed){var u=d.ParticleUtils.length(this.velocity);u>this.maxSpeed&&d.ParticleUtils.scaleBy(this.velocity,this.maxSpeed/u)}i=(a+this.velocity.x)/2*e,n=(s+this.velocity.y)/2*e}else i=this.velocity.x*e,n=this.velocity.y*e;this.position.x+=i,this.position.y+=n}if(this._doColor&&(this.tint=this.colorList.interpolate(t)),0!==this.rotationAcceleration){var c=this.rotationSpeed+this.rotationAcceleration*e;this.rotation+=(this.rotationSpeed+c)/2*e,this.rotationSpeed=c}else 0!==this.rotationSpeed?this.rotation+=this.rotationSpeed*e:this.acceleration&&!this.noRotation&&(this.rotation=Math.atan2(this.velocity.y,this.velocity.x));return t},i.prototype.kill=function(){this.emitter.recycle(this)},i.prototype.destroy=function(){this.parent&&this.parent.removeChild(this),this.Sprite_destroy(),this.emitter=this.velocity=this.colorList=this.scaleList=this.alphaList=this.speedList=this.ease=this.next=this.prev=null},i.parseArt=function(e){var t;for(t=e.length;0<=t;--t)"string"==typeof e[t]&&(e[t]=m.Texture.fromImage(e[t]));if(d.ParticleUtils.verbose)for(t=e.length-1;0=this.maxParticles)this._spawnTimer+=this._frequency;else{var u=void 0;if(u=this.minLifetime==this.maxLifetime?this.minLifetime:Math.random()*(this.maxLifetime-this.minLifetime)+this.minLifetime,-this._spawnTimer=this.spawnChance)){var d=void 0;if(this._poolFirst?(d=this._poolFirst,this._poolFirst=this._poolFirst.next,d.next=null):d=new this.particleConstructor(this),1this.duration&&(this.loop?this.elapsed=this.elapsed%this.duration:this.elapsed=this.duration-1e-6);var r=this.elapsed*this.framerate+1e-7|0;this.texture=this.textures[r]||m.Texture.EMPTY}return t},e.prototype.destroy=function(){this.Particle_destroy(),this.textures=null},e.parseArt=function(e){for(var t,r,i,n,o,a=[],s=0;s>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,1+(e|=e>>>16)},t.log2=function(e){var t,r;return t=+(65535>>=t))<<3,t|=r=+(15<(e>>>=r))<<2,(t|=r=+(3<(e>>>=r))<<1)|(e>>>=r)>>1},t.getIntersectionFactor=function(e,t,r,i,n){var o=t.x-e.x,a=r.x-i.x,s=r.x-e.x,u=t.y-e.y,c=r.y-i.y,f=r.y-e.y,l=o*c-u*a;if(Math.abs(l)<1e-7)return n.x=o,n.y=u,0;var h=(s*c-f*a)/l,d=(o*f-u*s)/l;return d<1e-6||-1e-6=this.size&&this.flush(),e._texture._uvs&&e._texture.baseTexture&&(this.sprites[this.currentIndex++]=e)},e.prototype.flush=function(){if(0!==this.currentIndex){var e,t,r,i=this.renderer.gl,n=this.MAX_TEXTURES,o=O.utils.nextPow2(this.currentIndex),a=O.utils.log2(o),s=this.buffers[a],u=this.sprites,c=this.groups,f=s.float32View,l=s.uint32View,h=0,d=null,p=1,v=0,m=c[0],b=I[u[0]._texture.baseTexture.premultipliedAlpha?1:0][u[0].blendMode];for(m.textureCount=0,m.start=0,m.blend=b,R++,r=0;rt[s]&&(i=t[s]),ot[s+1]&&(n=t[s+1]),ah[c]){u=l[s];l[s]=l[c],l[c]=u;var f=h[s];h[s]=h[c],h[c]=f}if(t[0]=l[0].x,t[1]=l[0].y,t[2]=l[1].x,t[3]=l[1].y,t[4]=l[2].x,t[5]=l[2].y,t[6]=l[3].x,t[7]=l[3].y,(l[3].x-l[2].x)*(l[1].y-l[2].y)-(l[1].x-l[2].x)*(l[3].y-l[2].y)<0)return t[4]=l[3].x,void(t[5]=l[3].y)}},e}();e.Surface=t}(pixi_projection||(pixi_projection={})),function(e){var S=new PIXI.Matrix,n=new PIXI.Rectangle,E=new PIXI.Point,t=function(t){function e(){var e=t.call(this)||this;return e.distortion=new PIXI.Point,e}return __extends(e,t),e.prototype.clear=function(){this.distortion.set(0,0)},e.prototype.apply=function(e,t){t=t||new PIXI.Point;var r=this.distortion,i=e.x*e.y;return t.x=e.x+r.x*i,t.y=e.y+r.y*i,t},e.prototype.applyInverse=function(e,t){t=t||new PIXI.Point;var r=e.x,i=e.y,n=this.distortion.x,o=this.distortion.y;if(0==n)t.x=r,t.y=i/(1+o*r);else if(0==o)t.y=i,t.x=r/(1+n*i);else{var a=.5*(i*n-r*o+1)/o,s=a*a+r/o;if(s<=1e-5)return void t.set(NaN,NaN);t.x=0 vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n uv.x = vTrans1.x * surface2.x + vTrans1.y * surface2.y + vTrans1.z;\n uv.y = vTrans2.x * surface2.x + vTrans2.y * surface2.y + vTrans2.z;\n pixels = uv * samplerSize[0];\n \n if (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n discard;\n }\n}\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = 1.0; //edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\nvec4 color;\nvec2 textureCoord = uv;\n%forloop%\ngl_FragColor = color * rColor;\n}",e.defUniforms={worldTransform:new Float32Array([1,0,0,0,1,0,0,0,1]),distortion:new Float32Array([0,0])},e}return __extends(e,t),e.prototype.getUniforms=function(e){var t=e.proj;this.shader;return null!==t.surface?t.uniforms:null!==t._activeProjection?t._activeProjection.uniforms:this.defUniforms},e.prototype.createVao=function(e){var t=this.shader.attributes;this.vertSize=14,this.vertByteSize=4*this.vertSize;var r=this.renderer.gl,i=this.renderer.createVao().addIndex(this.indexBuffer).addAttribute(e,t.aVertexPosition,r.FLOAT,!1,this.vertByteSize,0).addAttribute(e,t.aTrans1,r.FLOAT,!1,this.vertByteSize,8).addAttribute(e,t.aTrans2,r.FLOAT,!1,this.vertByteSize,20).addAttribute(e,t.aFrame,r.FLOAT,!1,this.vertByteSize,32).addAttribute(e,t.aColor,r.UNSIGNED_BYTE,!0,this.vertByteSize,48);return t.aTextureId&&i.addAttribute(e,t.aTextureId,r.FLOAT,!1,this.vertByteSize,52),i},e.prototype.fillVertices=function(e,t,r,i,n,o){for(var a=i.vertexData,s=i._texture,u=(s.orig.width,s.orig.height,i._anchor._x,i._anchor._y,s._frame),c=i.aTrans,f=0;f<4;f++)e[r]=a[2*f],e[r+1]=a[2*f+1],e[r+2]=c.a,e[r+3]=c.c,e[r+4]=c.tx,e[r+5]=c.b,e[r+6]=c.d,e[r+7]=c.ty,e[r+8]=u.x,e[r+9]=u.y,e[r+10]=u.x+u.width,e[r+11]=u.y+u.height,t[r+12]=n,e[r+13]=o,r+=14},e}((pixi_projection||(pixi_projection={})).webgl.MultiTextureSpriteRenderer);PIXI.WebGLRenderer.registerPlugin("sprite_bilinear",t)}(),function(e){var t=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.size=100,e.MAX_TEXTURES_LOCAL=1,e.shaderVert="precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec3 aTrans1;\nattribute vec3 aTrans2;\nattribute vec4 aFrame;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 worldTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * worldTransform * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n \n vTextureCoord = aVertexPosition;\n vTrans1 = aTrans1;\n vTrans2 = aTrans2;\n vTextureId = aTextureId;\n vColor = aColor;\n vFrame = aFrame;\n}\n",e.shaderFrag="precision highp float;\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nuniform sampler2D uSamplers[%count%];\nuniform vec2 samplerSize[%count%]; \nuniform vec4 params;\n\nvoid main(void){\nvec2 surface;\n\nfloat vx = vTextureCoord.x;\nfloat vy = vTextureCoord.y;\nfloat aleph = params.x;\nfloat bet = params.y;\nfloat A = params.z;\nfloat B = params.w;\n\nif (aleph == 0.0) {\n\tsurface.y = vy / (1.0 + vx * bet);\n\tsurface.x = vx;\n}\nelse if (bet == 0.0) {\n\tsurface.x = vx / (1.0 + vy * aleph);\n\tsurface.y = vy;\n} else {\n\tsurface.x = vx * (bet + 1.0) / (bet + 1.0 + vy * aleph);\n\tsurface.y = vy * (aleph + 1.0) / (aleph + 1.0 + vx * bet);\n}\n\nvec2 uv;\nuv.x = vTrans1.x * surface.x + vTrans1.y * surface.y + vTrans1.z;\nuv.y = vTrans2.x * surface.x + vTrans2.y * surface.y + vTrans2.z;\n\nvec2 pixels = uv * samplerSize[0];\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\nvec4 color;\nvec2 textureCoord = uv;\n%forloop%\ngl_FragColor = color * rColor;\n}",e.defUniforms={worldTransform:new Float32Array([1,0,0,0,1,0,0,0,1]),distortion:new Float32Array([0,0])},e}return __extends(e,t),e.prototype.getUniforms=function(e){var t=e.proj;this.shader;return null!==t.surface?t.uniforms:null!==t._activeProjection?t._activeProjection.uniforms:this.defUniforms},e.prototype.createVao=function(e){var t=this.shader.attributes;this.vertSize=14,this.vertByteSize=4*this.vertSize;var r=this.renderer.gl,i=this.renderer.createVao().addIndex(this.indexBuffer).addAttribute(e,t.aVertexPosition,r.FLOAT,!1,this.vertByteSize,0).addAttribute(e,t.aTrans1,r.FLOAT,!1,this.vertByteSize,8).addAttribute(e,t.aTrans2,r.FLOAT,!1,this.vertByteSize,20).addAttribute(e,t.aFrame,r.FLOAT,!1,this.vertByteSize,32).addAttribute(e,t.aColor,r.UNSIGNED_BYTE,!0,this.vertByteSize,48);return t.aTextureId&&i.addAttribute(e,t.aTextureId,r.FLOAT,!1,this.vertByteSize,52),i},e.prototype.fillVertices=function(e,t,r,i,n,o){for(var a=i.vertexData,s=i._texture,u=(s.orig.width,s.orig.height,i._anchor._x,i._anchor._y,s._frame),c=i.aTrans,f=0;f<4;f++)e[r]=a[2*f],e[r+1]=a[2*f+1],e[r+2]=c.a,e[r+3]=c.c,e[r+4]=c.tx,e[r+5]=c.b,e[r+6]=c.d,e[r+7]=c.ty,e[r+8]=u.x,e[r+9]=u.y,e[r+10]=u.x+u.width,e[r+11]=u.y+u.height,t[r+12]=n,e[r+13]=o,r+=14},e}((pixi_projection||(pixi_projection={})).webgl.MultiTextureSpriteRenderer);PIXI.WebGLRenderer.registerPlugin("sprite_strange",t)}(),function(e){var S=new PIXI.Matrix,n=new PIXI.Rectangle,E=new PIXI.Point,t=function(t){function e(){var e=t.call(this)||this;return e.params=[0,0,NaN,NaN],e}return __extends(e,t),e.prototype.clear=function(){var e=this.params;e[0]=0,e[1]=0,e[2]=NaN,e[3]=NaN},e.prototype.setAxisX=function(e,t,r){var i=e.x,n=e.y,o=Math.sqrt(i*i+n*n),a=r.rotation;0!==a&&(r.skew._x-=a,r.skew._y+=a,r.rotation=0),r.skew.y=Math.atan2(n,i);var s=this.params;s[2]=0!==t?-o*t:NaN,this._calc01()},e.prototype.setAxisY=function(e,t,r){var i=e.x,n=e.y,o=Math.sqrt(i*i+n*n),a=r.rotation;0!==a&&(r.skew._x-=a,r.skew._y+=a,r.rotation=0),r.skew.x=-Math.atan2(n,i)+Math.PI/2;var s=this.params;s[3]=0!==t?-o*t:NaN,this._calc01()},e.prototype._calc01=function(){var e=this.params;if(isNaN(e[2]))e[1]=0,isNaN(e[3])?e[0]=0:e[0]=1/e[3];else if(isNaN(e[3]))e[0]=0,e[1]=1/e[2];else{var t=1-e[2]*e[3];e[0]=(1-e[2])/t,e[1]=(1-e[3])/t}},e.prototype.apply=function(e,t){t=t||new PIXI.Point;var r=this.params[0],i=this.params[1],n=this.params[2],o=this.params[3],a=e.x,s=e.y;if(0===r)t.y=s*(1+a*i),t.x=a;else if(0===i)t.x=a*(1+s*r),t.y=s;else{var u=n*o-s*a;t.x=n*a*(o+s)/u,t.y=o*s*(n+a)/u}return t},e.prototype.applyInverse=function(e,t){t=t||new PIXI.Point;var r=this.params[0],i=this.params[1],n=(this.params[2],this.params[3],e.x),o=e.y;return 0===r?(t.y=o/(1+n*i),t.x=n):0===i?(t.x=n*(1+o*r),t.y=o):(t.x=n*(i+1)/(i+1+o*r),t.y=o*(r+1)/(r+1+n*i)),t},e.prototype.mapSprite=function(e,t,r){var i=e.texture;return n.x=-e.anchor.x*i.orig.width,n.y=-e.anchor.y*i.orig.height,n.width=i.orig.width,n.height=i.orig.height,this.mapQuad(n,t,r||e.transform)},e.prototype.mapQuad=function(e,t,r){var i=-e.x/e.width,n=-e.y/e.height,o=(1-e.x)/e.width,a=(1-e.y)/e.height,s=t[0].x*(1-i)+t[1].x*i,u=t[0].y*(1-i)+t[1].y*i,c=t[0].x*(1-o)+t[1].x*o,f=t[0].y*(1-o)+t[1].y*o,l=t[3].x*(1-i)+t[2].x*i,h=t[3].y*(1-i)+t[2].y*i,d=t[3].x*(1-o)+t[2].x*o,p=t[3].y*(1-o)+t[2].y*o,v=s*(1-n)+l*n,m=u*(1-n)+h*n,b=c*(1-n)+d*n,g=f*(1-n)+p*n,y=s*(1-a)+l*a,_=u*(1-a)+h*a,w=c*(1-a)+d*a,x=f*(1-a)+p*a,T=S;return T.tx=v,T.ty=m,T.a=b-v,T.b=g-m,T.c=y-v,T.d=_-m,E.set(w,x),T.applyInverse(E,E),r.setFromMatrix(T),this},e.prototype.fillUniforms=function(e){var t=this.params,r=e.params||new Float32Array([0,0,0,0]);(e.params=r)[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3]},e}(e.Surface);e.StrangeSurface=t}(pixi_projection||(pixi_projection={})),function(e){PIXI.Sprite.prototype.convertTo2s=function(){this.proj||(this.pluginName="sprite_bilinear",this.aTrans=new PIXI.Matrix,this.calculateVertices=e.Sprite2s.prototype.calculateVertices,this.calculateTrimmedVertices=e.Sprite2s.prototype.calculateTrimmedVertices,this._calculateBounds=e.Sprite2s.prototype._calculateBounds,PIXI.Container.prototype.convertTo2s.call(this))},PIXI.Container.prototype.convertTo2s=function(){this.proj||(this.proj=new e.Projection2d(this.transform),Object.defineProperty(this,"worldTransform",{get:function(){return this.proj},enumerable:!0,configurable:!0}))},PIXI.Container.prototype.convertSubtreeTo2s=function(){this.convertTo2s();for(var e=0;e=o.TRANSFORM_STEP.PROJ?(i||this.displayObjectUpdateTransform(),this.proj.affine?this.transform.worldTransform.applyInverse(e,r):this.proj.world.applyInverse(e,r)):(this.parent?r=this.parent.worldTransform.applyInverse(e,r):r.copy(e),n===o.TRANSFORM_STEP.NONE?r:this.transform.localTransform.applyInverse(r,r))},Object.defineProperty(e.prototype,"worldTransform",{get:function(){return this.proj.affine?this.transform.worldTransform:this.proj.world},enumerable:!0,configurable:!0}),e}(PIXI.Container);o.Container2d=e,o.container2dToLocal=e.prototype.toLocal}(pixi_projection||(pixi_projection={})),function(e){var u,t,b=PIXI.Point,r=[1,0,0,0,1,0,0,0,1];(t=u=e.AFFINE||(e.AFFINE={}))[t.NONE=0]="NONE",t[t.FREE=1]="FREE",t[t.AXIS_X=2]="AXIS_X",t[t.AXIS_Y=3]="AXIS_Y",t[t.POINT=4]="POINT",t[t.AXIS_XR=5]="AXIS_XR";var i=function(){function e(e){this.floatArray=null,this.mat3=new Float64Array(e||r)}return Object.defineProperty(e.prototype,"a",{get:function(){return this.mat3[0]/this.mat3[8]},set:function(e){this.mat3[0]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"b",{get:function(){return this.mat3[1]/this.mat3[8]},set:function(e){this.mat3[1]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"c",{get:function(){return this.mat3[3]/this.mat3[8]},set:function(e){this.mat3[3]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"d",{get:function(){return this.mat3[4]/this.mat3[8]},set:function(e){this.mat3[4]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tx",{get:function(){return this.mat3[6]/this.mat3[8]},set:function(e){this.mat3[6]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ty",{get:function(){return this.mat3[7]/this.mat3[8]},set:function(e){this.mat3[7]=e*this.mat3[8]},enumerable:!0,configurable:!0}),e.prototype.set=function(e,t,r,i,n,o){var a=this.mat3;return a[0]=e,a[1]=t,a[2]=0,a[3]=r,a[4]=i,a[5]=0,a[6]=n,a[7]=o,a[8]=1,this},e.prototype.toArray=function(e,t){this.floatArray||(this.floatArray=new Float32Array(9));var r=t||this.floatArray,i=this.mat3;return e?(r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7]):(r[0]=i[0],r[1]=i[3],r[2]=i[6],r[3]=i[1],r[4]=i[4],r[5]=i[7],r[6]=i[2],r[7]=i[5]),r[8]=i[8],r},e.prototype.apply=function(e,t){t=t||new PIXI.Point;var r=this.mat3,i=e.x,n=e.y,o=1/(r[2]*i+r[5]*n+r[8]);return t.x=o*(r[0]*i+r[3]*n+r[6]),t.y=o*(r[1]*i+r[4]*n+r[7]),t},e.prototype.translate=function(e,t){var r=this.mat3;return r[0]+=e*r[2],r[1]+=t*r[2],r[3]+=e*r[5],r[4]+=t*r[5],r[6]+=e*r[8],r[7]+=t*r[8],this},e.prototype.scale=function(e,t){var r=this.mat3;return r[0]*=e,r[1]*=t,r[3]*=e,r[4]*=t,r[6]*=e,r[7]*=t,this},e.prototype.scaleAndTranslate=function(e,t,r,i){var n=this.mat3;n[0]=e*n[0]+r*n[2],n[1]=t*n[1]+i*n[2],n[3]=e*n[3]+r*n[5],n[4]=t*n[4]+i*n[5],n[6]=e*n[6]+r*n[8],n[7]=t*n[7]+i*n[8]},e.prototype.applyInverse=function(e,t){t=t||new b;var r=this.mat3,i=e.x,n=e.y,o=r[0],a=r[3],s=r[6],u=r[1],c=r[4],f=r[7],l=r[2],h=r[5],d=r[8],p=(d*c-f*h)*i+(-d*a+s*h)*n+(f*a-s*c),v=(-d*u+f*l)*i+(d*o-s*l)*n+(-f*o+s*u),m=(h*u-c*l)*i+(-h*o+a*l)*n+(c*o-a*u);return t.x=p/m,t.y=v/m,t},e.prototype.invert=function(){var e=this.mat3,t=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],s=e[6],u=e[7],c=e[8],f=c*o-a*u,l=-c*n+a*s,h=u*n-o*s,d=t*f+r*l+i*h;return d&&(d=1/d,e[0]=f*d,e[1]=(-c*r+i*u)*d,e[2]=(a*r-i*o)*d,e[3]=l*d,e[4]=(c*t-i*s)*d,e[5]=(-a*t+i*n)*d,e[6]=h*d,e[7]=(-u*t+r*s)*d,e[8]=(o*t-r*n)*d),this},e.prototype.identity=function(){var e=this.mat3;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this},e.prototype.clone=function(){return new e(this.mat3)},e.prototype.copyTo=function(e){var t=this.mat3,r=e.mat3;return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],e},e.prototype.copyTo2dOr3d=function(e){return this.copyTo(e)},e.prototype.copy=function(e,t,r){var i=this.mat3,n=1/i[8],o=i[6]*n,a=i[7]*n;if(e.a=(i[0]-i[2]*o)*n,e.b=(i[1]-i[2]*a)*n,e.c=(i[3]-i[5]*o)*n,e.d=(i[4]-i[5]*a)*n,e.tx=o,e.ty=a,2<=t){var s=e.a*e.d-e.b*e.c;r||(s=Math.abs(s)),t===u.POINT?(s=0=r&&ethis._duration?this._duration:e,t)):this._time},n.totalTime=function(e,t,r){if(b||m.wake(),!arguments.length)return this._totalTime;if(this._timeline){if(e<0&&!r&&(e+=this.totalDuration()),this._timeline.smoothChildTiming){this._dirty&&this.totalDuration();var i=this._totalDuration,n=this._timeline;if(io;)n=n._prev;return n?(e._next=n._next,n._next=e):(e._next=this._first,this._first=e),e._next?e._next._prev=e:this._last=e,e._prev=n,this._recent=e,this._timeline&&this._uncache(!0),this},n._remove=function(e,t){return e.timeline===this&&(t||e._enabled(!1,!0),e._prev?e._prev._next=e._next:this._first===e&&(this._first=e._next),e._next?e._next._prev=e._prev:this._last===e&&(this._last=e._prev),e._next=e._prev=e.timeline=null,e===this._recent&&(this._recent=this._last),this._timeline&&this._uncache(!0)),this},n.render=function(e,t,r){var i,n=this._first;for(this._totalTime=this._time=this._rawPrevTime=e;n;)i=n._next,(n._active||e>=n._startTime&&!n._paused&&!n._gc)&&(n._reversed?n.render((n._dirty?n.totalDuration():n._totalDuration)-(e-n._startTime)*n._timeScale,t,r):n.render((e-n._startTime)*n._timeScale,t,r)),n=i},n.rawTime=function(){return b||m.wake(),this._totalTime};var L=S("TweenLite",function(e,t,r){if(R.call(this,t,r),this.render=L.prototype.render,null==e)throw"Cannot tween a null target.";this.target=e="string"!=typeof e?e:L.selector(e)||e;var i,n,o,a=e.jquery||e.length&&e!==h&&e[0]&&(e[0]===h||e[0].nodeType&&e[0].style&&!e.nodeType),s=this.vars.overwrite;if(this._overwrite=s=null==s?J[L.defaultOverwrite]:"number"==typeof s?s>>0:J[s],(a||e instanceof Array||e.push&&w(e))&&"number"!=typeof e[0])for(this._targets=o=u(e),this._propLookup=[],this._siblings=[],i=0;i=$){for(r in $=m.frame+(parseInt(L.autoSleep,10)||120),W){for(e=(t=W[r].tweens).length;-1<--e;)t[e]._gc&&t.splice(e,1);0===t.length&&delete W[r]}if((!(r=Q._first)||r._paused)&&L.autoSleep&&!Z._first&&1===m._listeners.tick.length){for(;r&&r._paused;)r=r._next;r||m.sleep()}}},m.addEventListener("tick",R._updateRoot);var te=function(e,t,r){var i,n,o=e._gsTweenID;if(W[o||(e._gsTweenID=o="t"+Y++)]||(W[o]={target:e,tweens:[]}),t&&((i=W[o].tweens)[n=i.length]=t,r))for(;-1<--n;)i[n]===t&&i.splice(n,1);return W[o].tweens},re=function(e,t,r,i){var n,o,a=e.vars.onOverwrite;return a&&(n=a(e,t,r,i)),(a=L.onOverwrite)&&(o=a(e,t,r,i)),!1!==n&&!1!==o},ie=function(e,t,r,i,n){var o,a,s,u;if(1===i||4<=i){for(u=n.length,o=0;of&&((d||!s._initted)&&f-s._startTime<=2e-8||(l[h++]=s)));for(o=h;-1<--o;)if(u=(s=l[o])._firstPT,2===i&&s._kill(r,e,t)&&(a=!0),2!==i||!s._firstPT&&s._initted&&u){if(2!==i&&!re(s,t))continue;s._enabled(!1,!1)&&(a=!0)}return a},ne=function(e,t,r){for(var i=e._timeline,n=i._timeScale,o=e._startTime;i._timeline;){if(o+=i._startTime,n*=i._timeScale,i._paused)return-100;i=i._timeline}return t<(o/=n)?o-t:r&&o===t||!e._initted&&o-t<2e-8?y:(o+=e.totalDuration()/e._timeScale/n)>t+y?0:o-t-y};n._init=function(){var e,t,r,i,n,o,a=this.vars,s=this._overwrittenProps,u=this._duration,c=!!a.immediateRender,f=a.ease,l=this._startAt;if(a.startAt){for(i in l&&(l.render(-1,!0),l.kill()),n={},a.startAt)n[i]=a.startAt[i];if(n.data="isStart",n.overwrite=!1,n.immediateRender=!0,n.lazy=c&&!1!==a.lazy,n.startAt=n.delay=null,n.onUpdate=a.onUpdate,n.onUpdateParams=a.onUpdateParams,n.onUpdateScope=a.onUpdateScope||a.callbackScope||this,this._startAt=L.to(this.target||{},0,n),c)if(0s.pr;)i=i._next;(s._prev=i?i._prev:o)?s._prev._next=s:n=s,(s._next=i)?i._prev=s:o=s,s=a}s=t._firstPT=n}for(;s;)s.pg&&"function"==typeof s.t[e]&&s.t[e]()&&(r=!0),s=s._next;return r},oe.activate=function(e){for(var t=e.length;-1<--t;)e[t].API===oe.API&&(V[(new e[t])._propName]=e[t]);return!0},s.plugin=function(e){if(!(e&&e.propName&&e.init&&e.API))throw"illegal plugin definition.";var t,r=e.propName,i=e.priority||0,n=e.overwriteProps,o={init:"_onInitTween",set:"setRatio",kill:"_kill",round:"_mod",mod:"_mod",initAll:"_onInitAllProps"},a=S("plugins."+r.charAt(0).toUpperCase()+r.substr(1)+"Plugin",function(){oe.call(this,r,i),this._overwriteProps=n||[]},!0===e.global),s=a.prototype=new oe(r);for(t in(s.constructor=a).API=e.API,o)"function"==typeof e[t]&&(s[o[t]]=e[t]);return a.version=e.version,oe.activate([a]),a},t=h._gsQueue){for(r=0;r@~]/g,"\\$&").replace(/\n/g,"A")}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getCommonAncestor=function(e){var t=(1 /g,">").split(/\s+(?=(?:(?:[^"]*"){2})*[^"]*$)/);if(i.length<2)return l("",e,"",t);var n=[i.pop()];for(;1/g,"> ").trim()};var i,n=r(3),c=(i=n)&&i.__esModule?i:{default:i},f=r(0);function l(r,i,n,o){if(r.length&&(r+=" "),n.length&&(n=" "+n),/\[*\]/.test(i)){var e=i.replace(/=.*$/,"]"),a=""+r+e+n;if(v(document.querySelectorAll(a),o))i=e;else for(var s=document.querySelectorAll(""+r+e),t=function(){var t=s[u];if(o.some(function(e){return t.contains(e)})){var e=t.tagName.toLowerCase();return a=""+r+e+n,v(document.querySelectorAll(a),o)&&(i=e),"break"}},u=0,h=s.length;u/.test(i)){var c=i.replace(/>/,"");a=""+r+c+n;v(document.querySelectorAll(a),o)&&(i=c)}if(/:nth-child/.test(i)){var f=i.replace(/nth-child/g,"nth-of-type");a=""+r+f+n;v(document.querySelectorAll(a),o)&&(i=f)}if(/\.\S+\.\S+/.test(i)){for(var l=i.trim().split(".").slice(1).map(function(e){return"."+e}).sort(function(e,t){return e.length-t.length});l.length;){var d=i.replace(l.shift(),"").trim();if(!(a=(""+r+d+n).trim()).length||">"===a.charAt(0)||">"===a.charAt(a.length-1))break;v(document.querySelectorAll(a),o)&&(i=d)}if((l=i&&i.match(/\./g))&&2/.test(s):h=function(t){return function(e){return e(t.parent)&&t.parent}};break;case/^\./.test(s):var r=s.substr(1).split(".");u=function(e){var t=e.attribs.class;return t&&r.every(function(e){return-1)(\S)/g,"$1 $2").trim()),t=i.shift(),n=i.length;return t(this).filter(function(e){for(var t=0;t\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=o.console&&(o.console.warn||o.console.log);return r&&r.call(o.console,n,t),i.apply(this,arguments)}}a="function"!=typeof Object.assign?function(e){if(e===f||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;rt[r]}):i.sort()),i}function C(e,t){for(var r,i,n=t[0].toUpperCase()+t.slice(1),o=0;ol(h.y)?h.x:h.y,t.scale=a?function(e,t){return ie(t[0],t[1],K)/ie(e[0],e[1],K)}(a.pointers,i):1,t.rotation=a?function(e,t){return ne(t[1],t[0],K)+ne(e[1],e[0],K)}(a.pointers,i):0,t.maxPointers=r.prevInput?t.pointers.length>r.prevInput.maxPointers?t.pointers.length:r.prevInput.maxPointers:t.pointers.length,function(e,t){var r,i,n,o,a=e.lastInterval||t,s=t.timeStamp-a.timeStamp;if(t.eventType!=U&&(jl(c.y)?c.x:c.y,o=re(u,h),e.lastInterval=t}else r=a.velocity,i=a.velocityX,n=a.velocityY,o=a.direction;t.velocity=r,t.velocityX=i,t.velocityY=n,t.direction=o}(r,t);var c=e.element;T(t.srcEvent.target,c)&&(c=t.srcEvent.target);t.target=c}(e,r),e.emit("hammer.input",r),e.recognize(r),e.session.prevInput=r}function $(e){for(var t=[],r=0;r=l(t)?e<0?X:q:t<0?H:G}function ie(e,t,r){r||(r=J);var i=t[r[0]]-e[r[0]],n=t[r[1]]-e[r[1]];return Math.sqrt(i*i+n*n)}function ne(e,t,r){r||(r=J);var i=t[r[0]]-e[r[0]],n=t[r[1]]-e[r[1]];return 180*Math.atan2(n,i)/Math.PI}Z.prototype={handler:function(){},init:function(){this.evEl&&w(this.element,this.evEl,this.domHandler),this.evTarget&&w(this.target,this.evTarget,this.domHandler),this.evWin&&w(I(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(I(this.element),this.evWin,this.domHandler)}};var oe={mousedown:B,mousemove:2,mouseup:N},ae="mousedown",se="mousemove mouseup";function ue(){this.evEl=ae,this.evWin=se,this.pressed=!1,Z.apply(this,arguments)}b(ue,Z,{handler:function(e){var t=oe[e.type];t&B&&0===e.button&&(this.pressed=!0),2&t&&1!==e.which&&(t=N),this.pressed&&(t&N&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:F,srcEvent:e}))}});var he={pointerdown:B,pointermove:2,pointerup:N,pointercancel:U,pointerout:U},ce={2:L,3:"pen",4:F,5:"kinect"},fe="pointerdown",le="pointermove pointerup pointercancel";function de(){this.evEl=fe,this.evWin=le,Z.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}o.MSPointerEvent&&!o.PointerEvent&&(fe="MSPointerDown",le="MSPointerMove MSPointerUp MSPointerCancel"),b(de,Z,{handler:function(e){var t=this.store,r=!1,i=e.type.toLowerCase().replace("ms",""),n=he[i],o=ce[e.pointerType]||e.pointerType,a=o==L,s=A(t,e.pointerId,"pointerId");n&B&&(0===e.button||a)?s<0&&(t.push(e),s=t.length-1):n&(N|U)&&(r=!0),s<0||(t[s]=e,this.callback(this.manager,n,{pointers:t,changedPointers:[e],pointerType:o,srcEvent:e}),r&&t.splice(s,1))}});var pe={touchstart:B,touchmove:2,touchend:N,touchcancel:U};function me(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Z.apply(this,arguments)}b(me,Z,{handler:function(e){var t=pe[e.type];if(t===B&&(this.started=!0),this.started){var r=function(e,t){var r=P(e.touches),i=P(e.changedTouches);t&(N|U)&&(r=M(r.concat(i),"identifier",!0));return[r,i]}.call(this,e,t);t&(N|U)&&r[0].length-r[1].length==0&&(this.started=!1),this.callback(this.manager,t,{pointers:r[0],changedPointers:r[1],pointerType:L,srcEvent:e})}}});var ve={touchstart:B,touchmove:2,touchend:N,touchcancel:U},be="touchstart touchmove touchend touchcancel";function ge(){this.evTarget=be,this.targetIds={},Z.apply(this,arguments)}b(ge,Z,{handler:function(e){var t=ve[e.type],r=function(e,t){var r=P(e.touches),i=this.targetIds;if(t&(2|B)&&1===r.length)return i[r[0].identifier]=!0,[r,r];var n,o,a=P(e.changedTouches),s=[],u=this.target;if(o=r.filter(function(e){return T(e.target,u)}),t===B)for(n=0;nt.threshold&&n&t.direction},attrTest:function(e){return Fe.prototype.attrTest.call(this,e)&&(2&this.state||!(2&this.state)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=De(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}}),b(Be,Fe,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Ae]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||2&this.state)},emit:function(e){if(1!==e.scale){var t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}}),b(Ne,Re,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return["auto"]},process:function(e){var t=this.options,r=e.pointers.length===t.pointers,i=e.distancet.time;if(this._input=e,!i||!r||e.eventType&(N|U)&&!n)this.reset();else if(e.eventType&B)this.reset(),this._timer=h(function(){this.state=8,this.tryEmit()},t.time,this);else if(e.eventType&N)return 8;return 32},reset:function(){clearTimeout(this._timer)},emit:function(e){8===this.state&&(e&&e.eventType&N?this.manager.emit(this.options.event+"up",e):(this._input.timeStamp=d(),this.manager.emit(this.options.event,this._input)))}}),b(Ue,Fe,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Ae]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||2&this.state)}}),b(ze,Fe,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:V|Y,pointers:1},getTouchAction:function(){return je.prototype.getTouchAction.call(this)},attrTest:function(e){var t,r=this.options.direction;return r&(V|Y)?t=e.overallVelocity:r&V?t=e.overallVelocityX:r&Y&&(t=e.overallVelocityY),this._super.attrTest.call(this,e)&&r&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&l(t)>this.options.velocity&&e.eventType&N},emit:function(e){var t=De(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}}),b(Xe,Re,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Ee]},process:function(e){var t=this.options,r=e.pointers.length===t.pointers,i=e.distance]+>|\t|)+|(?:\n)))/gm,y="",_={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};function w(e){return e.replace(/&/g,"&").replace(//g,">")}function l(e){return e.nodeName.toLowerCase()}function x(e,t){var r=e&&e.exec(t);return r&&0===r.index}function c(e){return t.test(e)}function d(e){var t,r={},i=Array.prototype.slice.call(arguments,1);for(t in e)r[t]=e[t];return i.forEach(function(e){for(t in e)r[t]=e[t]}),r}function p(e){var n=[];return function e(t,r){for(var i=t.firstChild;i;i=i.nextSibling)3===i.nodeType?r+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:r,node:i}),r=e(i,r),l(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:r,node:i}));return r}(e,0),n}function o(e){if(r&&!e.langApiRestored){for(var t in e.langApiRestored=!0,r)e[t]&&(e[r[t]]=e[t]);(e.contains||[]).concat(e.variants||[]).forEach(o)}}function T(a){function h(e){return e&&e.source||e}function s(e,t){return new RegExp(h(e),"m"+(a.case_insensitive?"i":"")+(t?"g":""))}!function t(r,e){if(!r.compiled){if(r.compiled=!0,r.keywords=r.keywords||r.beginKeywords,r.keywords){var i={},n=function(r,e){a.case_insensitive&&(e=e.toLowerCase()),e.split(" ").forEach(function(e){var t=e.split("|");i[t[0]]=[r,t[1]?Number(t[1]):1]})};"string"==typeof r.keywords?n("keyword",r.keywords):u(r.keywords).forEach(function(e){n(e,r.keywords[e])}),r.keywords=i}r.lexemesRe=s(r.lexemes||/\w+/,!0),e&&(r.beginKeywords&&(r.begin="\\b("+r.beginKeywords.split(" ").join("|")+")\\b"),r.begin||(r.begin=/\B|\b/),r.beginRe=s(r.begin),r.endSameAsBegin&&(r.end=r.begin),r.end||r.endsWithParent||(r.end=/\B|\b/),r.end&&(r.endRe=s(r.end)),r.terminator_end=h(r.end)||"",r.endsWithParent&&e.terminator_end&&(r.terminator_end+=(r.end?"|":"")+e.terminator_end)),r.illegal&&(r.illegalRe=s(r.illegal)),null==r.relevance&&(r.relevance=1),r.contains||(r.contains=[]),r.contains=Array.prototype.concat.apply([],r.contains.map(function(e){return function(t){return t.variants&&!t.cached_variants&&(t.cached_variants=t.variants.map(function(e){return d(t,{variants:null},e)})),t.cached_variants||t.endsWithParent&&[d(t)]||[t]}("self"===e?r:e)})),r.contains.forEach(function(e){t(e,r)}),r.starts&&t(r.starts,e);var o=r.contains.map(function(e){return e.beginKeywords?"\\.?(?:"+e.begin+")\\.?":e.begin}).concat([r.terminator_end,r.illegal]).map(h).filter(Boolean);r.terminators=o.length?s(function(e,t){for(var r=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,i=0,n="",o=0;o')+t+(r?"":y)}function a(){l+=null!=c.subLanguage?function(){var e="string"==typeof c.subLanguage;if(e&&!g[c.subLanguage])return w(d);var t=e?S(c.subLanguage,d,!0,f[c.subLanguage]):E(d,c.subLanguage.length?c.subLanguage:void 0);return 0")+'"');return d+=t,t.length||1}var h=A(e);if(!h)throw new Error('Unknown language: "'+e+'"');T(h);var n,c=r||h,f={},l="";for(n=c;n!==h;n=n.parent)n.className&&(l=s(n.className,"",!0)+l);var d="",p=0;try{for(var m,v,b=0;c.terminators.lastIndex=b,m=c.terminators.exec(t);)v=i(t.substring(b,m.index),m[0]),b=m.index+v;for(i(t.substr(b)),n=c;n.parent;n=n.parent)n.className&&(l+=y);return{relevance:p,value:l,language:e,top:c}}catch(e){if(e.message&&-1!==e.message.indexOf("Illegal"))return{relevance:0,value:w(t)};throw e}}function E(r,e){e=e||_.languages||u(g);var i={relevance:0,value:w(r)},n=i;return e.filter(A).filter(b).forEach(function(e){var t=S(e,r,!1);t.language=e,t.relevance>n.relevance&&(n=t),t.relevance>i.relevance&&(n=i,i=t)}),n.language&&(i.second_best=n),i}function m(e){return _.tabReplace||_.useBR?e.replace(i,function(e,t){return _.useBR&&"\n"===e?"
":_.tabReplace?t.replace(/\t/g,_.tabReplace):""}):e}function a(e){var t,r,i,n,o,a=function(e){var t,r,i,n,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",r=h.exec(o))return A(r[1])?r[1]:"no-highlight";for(t=0,i=(o=o.split(/\s+/)).length;t/g,"\n"):t=e,o=t.textContent,i=a?S(a,o,!0):E(o),(r=p(t)).length&&((n=document.createElementNS("http://www.w3.org/1999/xhtml","div")).innerHTML=i.value,i.value=function(e,t,r){var i=0,n="",o=[];function a(){return e.length&&t.length?e[0].offset!==t[0].offset?e[0].offset"}function u(e){n+=""}function h(e){("start"===e.event?s:u)(e.node)}for(;e.length||t.length;){var c=a();if(n+=w(r.substring(i,c[0].offset)),i=c[0].offset,c===e){for(o.reverse().forEach(u);h(c.splice(0,1)[0]),(c=a())===e&&c.length&&c[0].offset===i;);o.reverse().forEach(s)}else"start"===c[0].event?o.push(c[0].node):o.pop(),h(c.splice(0,1)[0])}return n+w(r.substr(i))}(r,p(n),o)),i.value=m(i.value),e.innerHTML=i.value,e.className=function(e,t,r){var i=t?s[t]:r,n=[e.trim()];return e.match(/\bhljs\b/)||n.push("hljs"),-1===e.indexOf(i)&&n.push(i),n.join(" ").trim()}(e.className,a,i.language),e.result={language:i.language,re:i.relevance},i.second_best&&(e.second_best={language:i.second_best.language,re:i.second_best.relevance}))}function v(){if(!v.called){v.called=!0;var e=document.querySelectorAll("pre code");f.forEach.call(e,a)}}function A(e){return e=(e||"").toLowerCase(),g[e]||g[s[e]]}function b(e){var t=A(e);return t&&!t.disableAutodetect}return n.highlight=S,n.highlightAuto=E,n.fixMarkup=m,n.highlightBlock=a,n.configure=function(e){_=d(_,e)},n.initHighlighting=v,n.initHighlightingOnLoad=function(){addEventListener("DOMContentLoaded",v,!1),addEventListener("load",v,!1)},n.registerLanguage=function(t,e){var r=g[t]=e(n);o(r),r.aliases&&r.aliases.forEach(function(e){s[e]=t})},n.listLanguages=function(){return u(g)},n.getLanguage=A,n.autoDetection=b,n.inherit=d,n.IDENT_RE="[a-zA-Z]\\w*",n.UNDERSCORE_IDENT_RE="[a-zA-Z_]\\w*",n.NUMBER_RE="\\b\\d+(\\.\\d+)?",n.C_NUMBER_RE="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",n.BINARY_NUMBER_RE="\\b(0b[01]+)",n.RE_STARTERS_RE="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",n.BACKSLASH_ESCAPE={begin:"\\\\[\\s\\S]",relevance:0},n.APOS_STRING_MODE={className:"string",begin:"'",end:"'",illegal:"\\n",contains:[n.BACKSLASH_ESCAPE]},n.QUOTE_STRING_MODE={className:"string",begin:'"',end:'"',illegal:"\\n",contains:[n.BACKSLASH_ESCAPE]},n.PHRASAL_WORDS_MODE={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},n.COMMENT=function(e,t,r){var i=n.inherit({className:"comment",begin:e,end:t,contains:[]},r||{});return i.contains.push(n.PHRASAL_WORDS_MODE),i.contains.push({className:"doctag",begin:"(?:TODO|FIXME|NOTE|BUG|XXX):",relevance:0}),i},n.C_LINE_COMMENT_MODE=n.COMMENT("//","$"),n.C_BLOCK_COMMENT_MODE=n.COMMENT("/\\*","\\*/"),n.HASH_COMMENT_MODE=n.COMMENT("#","$"),n.NUMBER_MODE={className:"number",begin:n.NUMBER_RE,relevance:0},n.C_NUMBER_MODE={className:"number",begin:n.C_NUMBER_RE,relevance:0},n.BINARY_NUMBER_MODE={className:"number",begin:n.BINARY_NUMBER_RE,relevance:0},n.CSS_NUMBER_MODE={className:"number",begin:n.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},n.REGEXP_MODE={className:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[n.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[n.BACKSLASH_ESCAPE]}]},n.TITLE_MODE={className:"title",begin:n.IDENT_RE,relevance:0},n.UNDERSCORE_TITLE_MODE={className:"title",begin:n.UNDERSCORE_IDENT_RE,relevance:0},n.METHOD_GUARD={begin:"\\.\\s*"+n.UNDERSCORE_IDENT_RE,relevance:0},n});var PIXI=function(e){"use strict";var O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e,t){return e(t={exports:{}},t.exports),t.exports}var i=r(function(e,S){!function(e){var t,r=e.Promise,i=r&&"resolve"in r&&"reject"in r&&"all"in r&&"race"in r&&(new r(function(e){t=e}),"function"==typeof t);S?(S.Promise=i?r:T,S.Polyfill=T):i||(e.Promise=T);var n="pending",o="sealed",a="fulfilled",s="rejected",u=function(){};function h(e){return"[object Array]"===Object.prototype.toString.call(e)}var c,f="undefined"!=typeof setImmediate?setImmediate:setTimeout,l=[];function d(){for(var e=0;e80*r){i=o=e[0],n=a=e[1];for(var p=r;po.x?n.x>a.x?n.x:a.x:o.x>a.x?o.x:a.x,c=n.y>o.y?n.y>a.y?n.y:a.y:o.y>a.y?o.y:a.y,f=k(s,u,t,r,i),l=k(h,c,t,r,i),d=e.prevZ,p=e.nextZ;d&&d.z>=f&&p&&p.z<=l;){if(d!==e.prev&&d!==e.next&&R(n.x,n.y,o.x,o.y,a.x,a.y,d.x,d.y)&&0<=D(d.prev,d,d.next))return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&&R(n.x,n.y,o.x,o.y,a.x,a.y,p.x,p.y)&&0<=D(p.prev,p,p.next))return!1;p=p.nextZ}for(;d&&d.z>=f;){if(d!==e.prev&&d!==e.next&&R(n.x,n.y,o.x,o.y,a.x,a.y,d.x,d.y)&&0<=D(d.prev,d,d.next))return!1;d=d.prevZ}for(;p&&p.z<=l;){if(p!==e.prev&&p!==e.next&&R(n.x,n.y,o.x,o.y,a.x,a.y,p.x,p.y)&&0<=D(p.prev,p,p.next))return!1;p=p.nextZ}return!0}function E(e,t,r){var i=e;do{var n=i.prev,o=i.next.next;!L(n,o)&&F(n,i,i.next,o)&&j(n,o)&&j(o,n)&&(t.push(n.i/r),t.push(i.i/r),t.push(o.i/r),U(i),U(i.next),i=e=o),i=i.next}while(i!==e);return i}function P(e,t,r,i,n,o){var a,s,u=e;do{for(var h=u.next.next;h!==u.prev;){if(u.i!==h.i&&(s=h,(a=u).next.i!==s.i&&a.prev.i!==s.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&F(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(a,s)&&j(a,s)&&j(s,a)&&function(e,t){var r=e,i=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;for(;r.y>o!=r.next.y>o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next,r!==e;);return i}(a,s))){var c=B(u,h);return u=w(u,u.next),c=w(c,c.next),x(u,t,r,i,n,o),void x(c,t,r,i,n,o)}h=h.next}u=u.next}while(u!==e)}function M(e,t){return e.x-t.x}function C(e,t){if(t=function(e,t){var r,i=t,n=e.x,o=e.y,a=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var s=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=n&&a=i.x&&i.x>=c&&n!==i.x&&R(or.x)&&j(i,e)&&(r=i,l=u),i=i.next;return r}(e,t)){var r=B(t,e);w(r,r.next)}}function k(e,t,r,i,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function I(e){for(var t=e,r=e;(t.x= 0x80 (not a basic code point)","invalid-input":"Invalid input"},l=g-y,S=Math.floor,E=String.fromCharCode;function A(e){throw RangeError(f[e])}function d(e,t){for(var r=e.length,i=[];r--;)i[r]=t(e[r]);return i}function p(e,t){var r=e.split("@"),i="";return 1>>10&1023|55296),e=56320|1023&e),t+=E(e)}).join("")}function C(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function k(e,t,r){var i=0;for(e=r?S(e/s):e>>1,e+=S(e/t);l*_>>1S((b-p)/a))&&A("overflow"),p+=u*a,!(u<(h=s<=v?y:v+_<=s?_:s-v));s+=g)a>S(b/(c=g-h))&&A("overflow"),a*=c;v=k(p-o,t=l.length+1,0==o),S(p/t)>b-m&&A("overflow"),m+=S(p/t),p%=t,l.splice(p++,0,m)}return M(l)}function v(e){var t,r,i,n,o,a,s,u,h,c,f,l,d,p,m,v=[];for(l=(e=P(e)).length,t=x,o=w,a=r=0;aS((b-r)/(d=i+1))&&A("overflow"),r+=(s-t)*d,t=s,a=0;ab&&A("overflow"),f==t){for(u=r,h=g;!(u<(c=h<=o?y:o+_<=h?_:h-o));h+=g)m=u-c,p=g-c,v.push(E(C(c+m%p,0))),u=S(m/p);v.push(E(C(u,0))),o=k(r,d,i==n),r=0,++i}++r,++t}return v.join("")}if(n={version:"1.3.2",ucs2:{decode:P,encode:M},decode:m,encode:v,toASCII:function(e){return p(e,function(e){return h.test(e)?"xn--"+v(e):e})},toUnicode:function(e){return p(e,function(e){return u.test(e)?m(e.slice(4).toLowerCase()):e})}},t&&r)if(I.exports==t)r.exports=n;else for(o in n)n.hasOwnProperty(o)&&(t[o]=n[o]);else e.punycode=n}(O)}),H={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}};H.isString,H.isObject,H.isNull,H.isNullOrUndefined;var G=function(e,t,r,i){t=t||"&",r=r||"=";var n={};if("string"!=typeof e||0===e.length)return n;var o=/\+/g;e=e.split(t);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var s,u,h=e.length;0",'"',"`"," ","\r","\n","\t"]),oe=["'"].concat(ne),ae=["%","/","?",";","#"].concat(oe),se=["/","?","#"],ue=/^[+a-z0-9A-Z_-]{0,63}$/,he=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,ce={javascript:!0,"javascript:":!0},fe={javascript:!0,"javascript:":!0},le={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function de(e,t,r){if(e&&H.isObject(e)&&e instanceof ee)return e;var i=new ee;return i.parse(e,t,r),i}ee.prototype.parse=function(e,t,r){if(!H.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),n=-1!==i&&i>16&255)/255,t[1]=(e>>8&255)/255,t[2]=(255&e)/255,t}function Oe(e){return e=e.toString(16),"#"+(e="000000".substr(0,6-e.length)+e)}function De(e){return"string"==typeof e&&"#"===e[0]&&(e=e.substr(1)),parseInt(e,16)}var Le=function(){for(var e=[],t=[],r=0;r<32;r++)t[e[r]=r]=r;e[ge.NORMAL_NPM]=ge.NORMAL,e[ge.ADD_NPM]=ge.ADD,e[ge.SCREEN_NPM]=ge.SCREEN,t[ge.NORMAL]=ge.NORMAL_NPM,t[ge.ADD]=ge.ADD_NPM,t[ge.SCREEN]=ge.SCREEN_NPM;var i=[];return i.push(t),i.push(e),i}();function Fe(e,t){return Le[t?1:0][e]}function je(e,t,r,i){return r=r||new Float32Array(4),i||void 0===i?(r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t):(r[0]=e[0],r[1]=e[1],r[2]=e[2]),r[3]=t,r}function Be(e,t){if(1===t)return(255*t<<24)+e;if(0===t)return 0;var r=e>>16&255,i=e>>8&255,n=255&e;return(255*t<<24)+((r=r*t+.5|0)<<16)+((i=i*t+.5|0)<<8)+(n=n*t+.5|0)}function Ne(e,t,r,i){return(r=r||new Float32Array(4))[0]=(e>>16&255)/255,r[1]=(e>>8&255)/255,r[2]=(255&e)/255,(i||void 0===i)&&(r[0]*=t,r[1]*=t,r[2]*=t),r[3]=t,r}function Ue(e){for(var t=6*e,r=new Uint16Array(t),i=0,n=0;i>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)+1}function Ve(e){return!(e&e-1||!e)}function Ye(e){var t=(65535>>=t))<<3;return t|=r,t|=r=(15<(e>>>=r))<<2,(t|=r=(3<(e>>>=r))<<1)|(e>>>=r)>>1}var We={},Je=Object.create(null),Ke=Object.create(null);function Ze(e){var t,r,i,n=e.width,o=e.height,a=e.getContext("2d"),s=a.getImageData(0,0,n,o).data,u=s.length,h={top:null,left:null,right:null,bottom:null},c=null;for(t=0;t=this.x&&e=this.y&&t=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){if(t>=this.y+this.radius&&t<=this.y+this.height-this.radius||e>=this.x+this.radius&&e<=this.x+this.width-this.radius)return!0;var r=e-(this.x+this.radius),i=t-(this.y+this.radius),n=this.radius*this.radius;if(r*r+i*i<=n)return!0;if((r=e-(this.x+this.width-this.radius))*r+i*i<=n)return!0;if(r*r+(i=t-(this.y+this.height-this.radius))*i<=n)return!0;if((r=e-(this.x+this.radius))*r+i*i<=n)return!0}return!1},A.SORTABLE_CHILDREN=!1;var Dt=function(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null};Dt.prototype.isEmpty=function(){return this.minX>this.maxX||this.minY>this.maxY},Dt.prototype.clear=function(){this.updateID++,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0},Dt.prototype.getRectangle=function(e){return this.minX>this.maxX||this.minY>this.maxY?Pt.EMPTY:((e=e||new Pt(0,0,1,1)).x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)},Dt.prototype.addPoint=function(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)},Dt.prototype.addQuad=function(e){var t=this.minX,r=this.minY,i=this.maxX,n=this.maxY,o=e[0],a=e[1];t=oi?e.maxX:i,this.maxY=e.maxY>n?e.maxY:n},Dt.prototype.addBoundsMask=function(e,t){var r=e.minX>t.minX?e.minX:t.minX,i=e.minY>t.minY?e.minY:t.minY,n=e.maxXt.x?e.minX:t.x,i=e.minY>t.y?e.minY:t.y,n=e.maxXthis.children.length)throw new Error(e+"addChildAt: The index "+t+" supplied is out of bounds "+this.children.length);return e.parent&&e.parent.removeChild(e),(e.parent=this).sortDirty=!0,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit("added",this),this.emit("childAdded",e,this,t),e},e.prototype.swapChildren=function(e,t){if(e!==t){var r=this.getChildIndex(e),i=this.getChildIndex(t);this.children[r]=t,this.children[i]=e,this.onChildrenChange(r=this.children.length)throw new Error("The index "+t+" supplied is out of bounds "+this.children.length);var r=this.getChildIndex(e);ze(this.children,r,1),this.children.splice(t,0,e),this.onChildrenChange(t)},e.prototype.getChildAt=function(e){if(e<0||e>=this.children.length)throw new Error("getChildAt: Index ("+e+") does not exist.");return this.children[e]},e.prototype.removeChild=function(e){var t=arguments,r=arguments.length;if(1this.renderer.width&&(e.width=this.renderer.width-e.x),e.y+e.height>this.renderer.height&&(e.height=this.renderer.height-e.y)},Nt.prototype.addChild=function(e){var t=this.pool.pop();t||((t=document.createElement("button")).style.width="100px",t.style.height="100px",t.style.backgroundColor=this.debug?"rgba(255,0,0,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=2,t.style.borderStyle="none",-1t.priority){e.connect(r);break}t=(r=t).next}e.previous||e.connect(r)}else e.connect(r);return this._startIfPossible(),this},Gt.prototype.remove=function(e,t){for(var r=this._head.next;r;)r=r.match(e,t)?r.destroy():r.next;return this._head.next||this._cancelIfNeeded(),this},Gt.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},Gt.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},Gt.prototype.destroy=function(){if(!this._protected){this.stop();for(var e=this._head.next;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}},Gt.prototype.update=function(e){var t;if(void 0===e&&(e=performance.now()),e>this.lastTime){if((t=this.elapsedMS=e-this.lastTime)>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS&&t+1=A.TARGET_FPMS)this._minElapsedMS=0;else{var t=Math.max(this.minFPS,e),r=Math.min(Math.max(1,t)/1e3,A.TARGET_FPMS);this._minElapsedMS=1/r}},Yt.shared.get=function(){if(!Gt._shared){var e=Gt._shared=new Gt;e.autoStart=!0,e._protected=!0}return Gt._shared},Yt.system.get=function(){if(!Gt._system){var e=Gt._system=new Gt;e.autoStart=!0,e._protected=!0}return Gt._system},Object.defineProperties(Gt.prototype,Vt),Object.defineProperties(Gt,Yt);var Wt=function(){};Wt.init=function(e){var t=this;e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set:function(e){this._ticker&&this._ticker.remove(this.render,this),(this._ticker=e)&&e.add(this.render,this,qt.LOW)},get:function(){return this._ticker}}),this.stop=function(){t._ticker.stop()},this.start=function(){t._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Gt.shared:new Gt,e.autoStart&&this.start()},Wt.destroy=function(){if(this._ticker){var e=this._ticker;this.ticker=null,e.destroy()}};var Jt=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._width=e,this._height=t,this.destroyed=!1,this.internal=!1,this.onResize=new zt("setRealSize",2),this.onUpdate=new zt("update")},Kt={valid:{configurable:!0},width:{configurable:!0},height:{configurable:!0}};Jt.prototype.bind=function(e){this.onResize.add(e),this.onUpdate.add(e),(this._width||this._height)&&this.onResize.run(this._width,this._height)},Jt.prototype.unbind=function(e){this.onResize.remove(e),this.onUpdate.remove(e)},Jt.prototype.resize=function(e,t){e===this._width&&t===this._height||(this._width=e,this._height=t,this.onResize.run(e,t))},Kt.valid.get=function(){return!!this._width&&!!this._height},Jt.prototype.update=function(){this.destroyed||this.onUpdate.run()},Jt.prototype.load=function(){return Promise.resolve()},Kt.width.get=function(){return this._width},Kt.height.get=function(){return this._height},Jt.prototype.upload=function(e,t,r){return!1},Jt.prototype.style=function(e,t,r){return!1},Jt.prototype.dispose=function(){},Jt.prototype.destroy=function(){this.destroyed||(this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null,this.destroyed=!0,this.dispose())},Object.defineProperties(Jt.prototype,Kt);var Zt=function(t){function e(e){t.call(this,e.width,e.height),this.source=e}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).crossOrigin=function(e,t,r){void 0===r&&0!==t.indexOf("data:")?e.crossOrigin=it(t):!1!==r&&(e.crossOrigin="string"==typeof r?r:"anonymous")},e.prototype.upload=function(e,t,r,i){var n=e.gl,o=t.realWidth,a=t.realHeight;return i=i||this.source,n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),t.target===n.TEXTURE_2D&&r.width===o&&r.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.format,t.type,i):(r.width=o,r.height=a,n.texImage2D(t.target,0,t.format,t.format,t.type,i)),!0},e.prototype.dispose=function(){this.source=null},e}(Jt),Qt=function(a){function e(e,t){if(t=t||{},!(e instanceof HTMLImageElement)){var r=new Image;a.crossOrigin(r,e,t.crossorigin),r.src=e,e=r}a.call(this,e),this.url=e.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=!1!==t.createBitmap&&A.CREATE_IMAGE_BITMAP&&!!window.createImageBitmap,this.premultiplyAlpha=!1!==t.premultiplyAlpha,this.bitmap=null,this._load=null,!1!==t.autoLoad&&this.load()}return a&&(e.__proto__=a),((e.prototype=Object.create(a&&a.prototype)).constructor=e).prototype.load=function(e){var i=this;return void 0!==e&&(this.createBitmap=e),this._load||(this._load=new Promise(function(e){i.url=i.source.src;var t=i.source,r=function(){i.destroyed||(t.onload=null,t.onerror=null,i.resize(t.width,t.height),i._load=null,i.createBitmap?e(i.process()):e(i))};t.complete&&t.src?r():t.onload=r})),this._load},e.prototype.process=function(){var t=this;return null!==this._process?this._process:null===this.bitmap&&window.createImageBitmap?(this._process=window.createImageBitmap(this.source,0,0,this.source.width,this.source.height,{premultiplyAlpha:this.premultiplyAlpha?"premultiply":"none"}).then(function(e){return t.destroyed?Promise.reject():(t.bitmap=e,t.update(),t._process=null,Promise.resolve(t))}),this._process):Promise.resolve(this)},e.prototype.upload=function(e,t,r){if(t.premultiplyAlpha=this.premultiplyAlpha,!this.createBitmap)return a.prototype.upload.call(this,e,t,r);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(a.prototype.upload.call(this,e,t,r,this.bitmap),!this.preserveBitmap){var i=!0;for(var n in t._glTextures){var o=t._glTextures[n];if(o!==r&&o.dirtyId!==t.dirtyId){i=!1;break}}i&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0},e.prototype.dispose=function(){a.prototype.dispose.call(this),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null},e}(Zt),$t=[];function er(e,t){if(!e)return null;var r="";if("string"==typeof e){var i=/\.(\w{3,4})(?:$|\?|#)/i.exec(e);i&&(r=i[1].toLowerCase())}for(var n=$t.length-1;0<=n;--n){var o=$t[n];if(o.test&&o.test(e,r))return new o(e,t)}return new Qt(e,t)}var tr=function(o){function e(e,t){var r=t||{},i=r.width,n=r.height;if(!i||!n)throw new Error("BufferResource width or height invalid");o.call(this,i,n),this.data=e}return o&&(e.__proto__=o),((e.prototype=Object.create(o&&o.prototype)).constructor=e).prototype.upload=function(e,t,r){var i=e.gl;if(i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.width===t.width&&r.height===t.height)i.texSubImage2D(t.target,0,0,0,t.width,t.height,t.format,t.type,this.data);else{r.width=t.width,r.height=t.height;var n=t.format;2===e.context.webGLVersion&&t.type===e.gl.FLOAT&&t.format===e.gl.RGBA&&(n=e.gl.RGBA32F),i.texImage2D(t.target,0,n,t.width,t.height,0,t.format,t.type,this.data)}return!0},e.prototype.dispose=function(){this.data=null},e.test=function(e){return e instanceof Float32Array||e instanceof Uint8Array||e instanceof Uint32Array},e}(Jt),rr={scaleMode:Te.NEAREST,format:_e.RGBA,premultiplyAlpha:!1},ir=function(d){function a(e,t){void 0===e&&(e=null),void 0===t&&(t=null),d.call(this);var r=(t=t||{}).premultiplyAlpha,i=t.mipmap,n=t.scaleMode,o=t.width,a=t.height,s=t.wrapMode,u=t.format,h=t.type,c=t.target,f=t.resolution,l=t.resourceOptions;!e||e instanceof Jt||((e=er(e,l)).internal=!0),this.width=o||0,this.height=a||0,this.resolution=f||A.RESOLUTION,this.mipmap=void 0!==i?i:A.MIPMAP_TEXTURES,this.wrapMode=s||A.WRAP_MODE,this.scaleMode=void 0!==n?n:A.SCALE_MODE,this.format=u||_e.RGBA,this.type=h||xe.UNSIGNED_BYTE,this.target=c||we.TEXTURE_2D,this.premultiplyAlpha=!1!==r,this.uid=qe(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=0]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var ur=function(c){function r(e,t){if(t=t||{},!(e instanceof HTMLVideoElement)){var r=document.createElement("video");r.setAttribute("webkit-playsinline",""),r.setAttribute("playsinline",""),"string"==typeof e&&(e=[e]),c.crossOrigin(r,e[0].src||e[0],t.crossorigin);for(var i=0;ithis.baseTexture.width,a=r+n>this.baseTexture.height;if(o||a){var s=o&&a?"and":"or",u="X: "+t+" + "+i+" = "+(t+i)+" > "+this.baseTexture.width,h="Y: "+r+" + "+n+" = "+(r+n)+" > "+this.baseTexture.height;throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: "+u+" "+s+" "+h)}this.valid=i&&n&&this.baseTexture.valid,this.trim||this.rotate||(this.orig=e),this.valid&&this.updateUvs()},e.rotate.get=function(){return this._rotate},e.rotate.set=function(e){this._rotate=e,this.valid&&this.updateUvs()},e.width.get=function(){return this.orig.width},e.height.get=function(){return this.orig.height},Object.defineProperties(s.prototype,e),s}(v);function gr(e){e.destroy=function(){},e.on=function(){},e.once=function(){},e.emit=function(){}}br.EMPTY=new br(new ir),gr(br.EMPTY),gr(br.EMPTY.baseTexture),br.WHITE=function(){var e=document.createElement("canvas");e.width=16,e.height=16;var t=e.getContext("2d");return t.fillStyle="white",t.fillRect(0,0,16,16),new br(new ir(new or(e)))}(),gr(br.WHITE),gr(br.WHITE.baseTexture);var yr=function(s){function t(e,t){var r=null;if(!(e instanceof pr)){var i=arguments[1],n=arguments[2],o=arguments[3],a=arguments[4];console.warn("Please use RenderTexture.create("+i+", "+n+") instead of the ctor directly."),r=arguments[0],t=null,e=new pr({width:i,height:n,scaleMode:o,resolution:a})}s.call(this,e,t),this.legacyRenderer=r,this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}return s&&(t.__proto__=s),((t.prototype=Object.create(s&&s.prototype)).constructor=t).prototype.resize=function(e,t,r){void 0===r&&(r=!0),e=Math.ceil(e),t=Math.ceil(t),this.valid=0=ve.WEBGL2&&(r=e.getContext("webgl2",t)),r)this.webGLVersion=2;else if(this.webGLVersion=1,!(r=e.getContext("webgl",t)||e.getContext("experimental-webgl",t)))throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=r,this.getExtensions(),r},e.prototype.getExtensions=function(){var e=this.gl;1===this.webGLVersion&&Object.assign(this.extensions,{drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBKIT_WEBGL_depth_texture"),floatTexture:e.getExtension("OES_texture_float"),loseContext:e.getExtension("WEBGL_lose_context"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object")})},e.prototype.handleContextLost=function(e){e.preventDefault()},e.prototype.handleContextRestored=function(){this.renderer.runners.contextChange.run(this.gl)},e.prototype.destroy=function(){var e=this.renderer.view;e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()},e.prototype.postrender=function(){this.gl.flush()},e.prototype.validateContext=function(e){e.getContextAttributes().stencil||console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly")},Object.defineProperties(e.prototype,r),e}(cr),Ur=function(t){function e(e){t.call(this,e),this.managedFramebuffers=[],this.unknownFramebuffer=new lr(10,10)}t&&(e.__proto__=t);var r={size:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.contextChange=function(){var e=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Pt,this.hasMRT=!0,this.writeDepthTexture=!0,this.disposeAll(!0),1===this.renderer.context.webGLVersion){var t=this.renderer.context.extensions.drawBuffers,r=this.renderer.context.extensions.depthTexture;A.PREFER_ENV===ve.WEBGL_LEGACY&&(r=t=null),t?e.drawBuffers=function(e){return t.drawBuffersWEBGL(e)}:(this.hasMRT=!1,e.drawBuffers=function(){}),r||(this.writeDepthTexture=!1)}},e.prototype.bind=function(e,t){var r=this.gl;if(e){var i=e.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(e);this.current!==e&&(this.current=e,r.bindFramebuffer(r.FRAMEBUFFER,i.framebuffer)),i.dirtyId!==e.dirtyId&&(i.dirtyId=e.dirtyId,i.dirtyFormat!==e.dirtyFormat?(i.dirtyFormat=e.dirtyFormat,this.updateFramebuffer(e)):i.dirtySize!==e.dirtySize&&(i.dirtySize=e.dirtySize,this.resizeFramebuffer(e)));for(var n=0;n=i.data.byteLength)t.bufferSubData(o,0,i.data);else{var a=i.static?t.STATIC_DRAW:t.DYNAMIC_DRAW;n.byteLength=i.data.byteLength,t.bufferData(o,i.data,a)}}}},e.prototype.checkCompatibility=function(e,t){var r=e.attributes,i=t.attributeData;for(var n in i)if(!r[n])throw new Error('shader and geometry incompatible, geometry missing the "'+n+'" attribute')},e.prototype.getSignature=function(e,t){var r=e.attributes,i=t.attributeData,n=["g",e.id];for(var o in r)i[o]&&n.push(o);return n.join("-")},e.prototype.initGeometryVao=function(e,t){this.checkCompatibility(e,t);var r=this.gl,i=this.CONTEXT_UID,n=this.getSignature(e,t),o=e.glVertexArrayObjects[this.CONTEXT_UID],a=o[n];if(a)return o[t.id]=a;var s=e.buffers,u=e.attributes,h={},c={};for(var f in s)h[f]=0,c[f]=0;for(var l in u)!u[l].size&&t.attributeData[l]?u[l].size=t.attributeData[l].size:u[l].size||console.warn("PIXI Geometry attribute '"+l+"' size cannot be determined (likely the bound shader does not have the attribute)"),h[u[l].buffer]+=u[l].size*Xr[u[l].type];for(var d in u){var p=u[d],m=p.size;void 0===p.stride&&(h[p.buffer]===m*Xr[p.type]?p.stride=0:p.stride=h[p.buffer]),void 0===p.start&&(p.start=c[p.buffer],c[p.buffer]+=m*Xr[p.type])}a=r.createVertexArray(),r.bindVertexArray(a);for(var v=0;v=ve.WEBGL2&&(e=t.getContext("webgl2",{})),!e){if(!(e=t.getContext("webgl",{})||t.getContext("experimental-webgl",{})))throw new Error("This browser does not support WebGL. Try using the canvas renderer");e.getExtension("WEBGL_draw_buffers")}return Jr=e}function Zr(e,t,r){if("precision"===e.substring(0,9))return r!==Pe.HIGH&&"precision highp"===e.substring(0,15)?e.replace("precision highp","precision mediump"):e;var i=t;return t===Pe.HIGH&&r!==Pe.HIGH&&(i=Pe.MEDIUM),"precision "+i+" float;\n"+e}var Qr={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};var $r=null,ei={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray"};function ti(e,t){if(!$r){var r=Object.keys(ei);$r={};for(var i=0;it.name?1:-1});for(var c=0;c>=1,r++;this.stateId=e.data}for(var i=0;ithis.checkCountMax&&(this.checkCount=0,this.run()))},e.prototype.run=function(){for(var e=this.renderer.texture,t=e.managedTextures,r=!1,i=0;ithis.maxIdle&&(e.destroyTexture(n,!0),r=!(t[i]=null))}if(r){for(var o=0,a=0;athis.size&&this.flush(),this.elements[this.currentIndex++]=e,this.currentSize+=e.vertexData.length/2,this.currentIndexSize+=e.indices.length)},e.prototype.getIndexBuffer=function(e){var t=Ge(Math.ceil(e/12)),r=Ye(t),i=12*t;this.iBuffers.length<=r&&(this.iBuffers.length=r+1);var n=this.iBuffers[r];return n||(this.iBuffers[r]=n=new Uint16Array(i)),n},e.prototype.getAttributeBuffer=function(e){var t=Ge(Math.ceil(e/8)),r=Ye(t),i=8*t;this.aBuffers.length<=r&&(this.iBuffers.length=r+1);var n=this.aBuffers[i];return n||(this.aBuffers[i]=n=new qi(i*this.vertByteSize)),n},e.prototype.flush=function(){if(0!==this.currentSize){var e,t,r=this.renderer.gl,i=this.MAX_TEXTURES,n=this.getAttributeBuffer(this.currentSize),o=this.getIndexBuffer(this.currentIndexSize),a=this.elements,s=this.groups,u=n.float32View,h=n.uint32View,c=this.renderer.textureGC.count,f=0,l=0,d=0,p=0,m=s[0],v=-1;m.textureCount=0,m.start=0,m.blend=v;var b,g=++ir._globalBatch;for(b=0;bthis.maxSegments&&(r=this.maxSegments),r}},hn=function(){this.reset()};hn.prototype.clone=function(){var e=new hn;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e},hn.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=br.WHITE,this.matrix=null,this.visible=!1},hn.prototype.destroy=function(){this.texture=null,this.matrix=null};var cn=function(e,t,r,i){void 0===t&&(t=null),void 0===r&&(r=null),void 0===i&&(i=null),this.shape=e,this.lineStyle=r,this.fillStyle=t,this.matrix=i,this.type=e.type,this.points=[],this.holes=[]};cn.prototype.clone=function(){return new cn(this.shape,this.fillStyle,this.lineStyle,this.matrix)},cn.prototype.destroy=function(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null};var fn={build:function(e){var t,r,i=e.shape,n=e.points,o=i.x,a=i.y;if(n.length=0,r=e.type===pt.CIRC?(t=i.radius,i.radius):(t=i.width,i.height),0!==t&&0!==r){var s=Math.floor(30*Math.sqrt(i.radius))||Math.floor(15*Math.sqrt(i.width+i.height));s/=2.3;for(var u=2*Math.PI/s,h=0;h>16)+(65280&t)+((255&t)<<16),r);0>16&255)/255*b,m.tint[1]=(v>>8&255)/255*b,m.tint[2]=(255&v)/255*b,m.tint[3]=b,e.shader.bind(this.shader),e.geometry.bind(t,this.shader),e.state.setState(this.state);for(var g=0;g>16)+(65280&n)+((255&n)<<16)}}},r.prototype.calculateVertices=function(){if(this._transformID!==this.transform._worldID){this._transformID=this.transform._worldID;for(var e=this.transform.worldTransform,t=e.a,r=e.b,i=e.c,n=e.d,o=e.tx,a=e.ty,s=this.geometry.points,u=this.vertexData,h=0,c=0;c=i&&kn.x=n&&kn.y>16)+(65280&e)+((255&e)<<16)},e.texture.get=function(){return this._texture},e.texture.set=function(e){this._texture!==e&&(this._texture=e||br.EMPTY,this.cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,e&&(e.baseTexture.valid?this._onTextureUpdate():e.once("update",this._onTextureUpdate,this)))},Object.defineProperties(i.prototype,e),i}(jt),On={LINEAR_VERTICAL:0,LINEAR_HORIZONTAL:1},Dn={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:On.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},Ln=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Fn=function(e){this.styleID=0,this.reset(),Un(this,e,e)},jn={align:{configurable:!0},breakWords:{configurable:!0},dropShadow:{configurable:!0},dropShadowAlpha:{configurable:!0},dropShadowAngle:{configurable:!0},dropShadowBlur:{configurable:!0},dropShadowColor:{configurable:!0},dropShadowDistance:{configurable:!0},fill:{configurable:!0},fillGradientType:{configurable:!0},fillGradientStops:{configurable:!0},fontFamily:{configurable:!0},fontSize:{configurable:!0},fontStyle:{configurable:!0},fontVariant:{configurable:!0},fontWeight:{configurable:!0},letterSpacing:{configurable:!0},lineHeight:{configurable:!0},leading:{configurable:!0},lineJoin:{configurable:!0},miterLimit:{configurable:!0},padding:{configurable:!0},stroke:{configurable:!0},strokeThickness:{configurable:!0},textBaseline:{configurable:!0},trim:{configurable:!0},whiteSpace:{configurable:!0},wordWrap:{configurable:!0},wordWrapWidth:{configurable:!0}};function Bn(e){return"number"==typeof e?Oe(e):("string"==typeof e&&0===e.indexOf("0x")&&(e=e.replace("0x","#")),e)}function Nn(e){if(Array.isArray(e)){for(var t=0;t>2,n[1]=(3&i[0])<<4|i[1]>>4,n[2]=(15&i[1])<<2|i[2]>>6,n[3]=63&i[2],r-(e.length-1)){case 2:n[3]=64,n[2]=64;break;case 1:n[3]=64}for(var a=0;a>2,n[1]=(3&i[0])<<4|i[1]>>4,n[2]=(15&i[1])<<2|i[2]>>6,n[3]=63&i[2],r-(e.length-1)){case 2:n[3]=64,n[2]=64;break;case 1:n[3]=64}for(var a=0;a=a.length){if(!e.autoResize)break;a.push(this._generateOneMoreBuffer(e))}var p=a[l];p.uploadDynamic(t,f,d);var m=e._bufferUpdateIDs[l]||0;(c=c||p._updateID=i&&Uo.x=n&&Uo.ys&&(ze(i,1+l-++p,1+v-l),v=l,l=-1,n.push(d),c=Math.max(c,d),f++,r.x=0,r.y+=e.lineHeight,u=null))}else n.push(h),c=Math.max(c,h),++f,++p,r.x=0,r.y+=e.lineHeight,u=null}var _=o.charAt(o.length-1);"\r"!==_&&"\n"!==_&&(/(?:\s)/.test(_)&&(h=d),n.push(h),c=Math.max(c,h));for(var w=[],x=0;x<=f;x++){var T=0;"right"===this._font.align?T=c-n[x]:"center"===this._font.align&&(T=(c-n[x])/2),w.push(T)}for(var S=i.length,E=this.tint,A=0;A 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n",e),this.alpha=1}t&&(e.__proto__=t);var r={matrix:{configurable:!0},alpha:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._loadMatrix=function(e,t){void 0===t&&(t=!1);var r=e;t&&(this._multiply(r,this.uniforms.m,e),r=this._colorMatrix(r)),this.uniforms.m=r},e.prototype._multiply=function(e,t,r){return e[0]=t[0]*r[0]+t[1]*r[5]+t[2]*r[10]+t[3]*r[15],e[1]=t[0]*r[1]+t[1]*r[6]+t[2]*r[11]+t[3]*r[16],e[2]=t[0]*r[2]+t[1]*r[7]+t[2]*r[12]+t[3]*r[17],e[3]=t[0]*r[3]+t[1]*r[8]+t[2]*r[13]+t[3]*r[18],e[4]=t[0]*r[4]+t[1]*r[9]+t[2]*r[14]+t[3]*r[19]+t[4],e[5]=t[5]*r[0]+t[6]*r[5]+t[7]*r[10]+t[8]*r[15],e[6]=t[5]*r[1]+t[6]*r[6]+t[7]*r[11]+t[8]*r[16],e[7]=t[5]*r[2]+t[6]*r[7]+t[7]*r[12]+t[8]*r[17],e[8]=t[5]*r[3]+t[6]*r[8]+t[7]*r[13]+t[8]*r[18],e[9]=t[5]*r[4]+t[6]*r[9]+t[7]*r[14]+t[8]*r[19]+t[9],e[10]=t[10]*r[0]+t[11]*r[5]+t[12]*r[10]+t[13]*r[15],e[11]=t[10]*r[1]+t[11]*r[6]+t[12]*r[11]+t[13]*r[16],e[12]=t[10]*r[2]+t[11]*r[7]+t[12]*r[12]+t[13]*r[17],e[13]=t[10]*r[3]+t[11]*r[8]+t[12]*r[13]+t[13]*r[18],e[14]=t[10]*r[4]+t[11]*r[9]+t[12]*r[14]+t[13]*r[19]+t[14],e[15]=t[15]*r[0]+t[16]*r[5]+t[17]*r[10]+t[18]*r[15],e[16]=t[15]*r[1]+t[16]*r[6]+t[17]*r[11]+t[18]*r[16],e[17]=t[15]*r[2]+t[16]*r[7]+t[17]*r[12]+t[18]*r[17],e[18]=t[15]*r[3]+t[16]*r[8]+t[17]*r[13]+t[18]*r[18],e[19]=t[15]*r[4]+t[16]*r[9]+t[17]*r[14]+t[18]*r[19]+t[19],e},e.prototype._colorMatrix=function(e){var t=new Float32Array(e);return t[4]/=255,t[9]/=255,t[14]/=255,t[19]/=255,t},e.prototype.brightness=function(e,t){var r=[e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0];this._loadMatrix(r,t)},e.prototype.greyscale=function(e,t){var r=[e,e,e,0,0,e,e,e,0,0,e,e,e,0,0,0,0,0,1,0];this._loadMatrix(r,t)},e.prototype.blackAndWhite=function(e){this._loadMatrix([.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],e)},e.prototype.hue=function(e,t){e=(e||0)/180*Math.PI;var r=Math.cos(e),i=Math.sin(e),n=(0,Math.sqrt)(1/3),o=[r+1/3*(1-r),1/3*(1-r)-n*i,1/3*(1-r)+n*i,0,0,1/3*(1-r)+n*i,r+1/3*(1-r),1/3*(1-r)-n*i,0,0,1/3*(1-r)-n*i,1/3*(1-r)+n*i,r+1/3*(1-r),0,0,0,0,0,1,0];this._loadMatrix(o,t)},e.prototype.contrast=function(e,t){var r=(e||0)+1,i=-.5*(r-1),n=[r,0,0,0,i,0,r,0,0,i,0,0,r,0,i,0,0,0,1,0];this._loadMatrix(n,t)},e.prototype.saturate=function(e,t){void 0===e&&(e=0);var r=2*e/3+1,i=-.5*(r-1),n=[r,i,i,0,0,i,r,i,0,0,i,i,r,0,0,0,0,0,1,0];this._loadMatrix(n,t)},e.prototype.desaturate=function(){this.saturate(-1)},e.prototype.negative=function(e){this._loadMatrix([-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],e)},e.prototype.sepia=function(e){this._loadMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],e)},e.prototype.technicolor=function(e){this._loadMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0],e)},e.prototype.polaroid=function(e){this._loadMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],e)},e.prototype.toBGR=function(e){this._loadMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],e)},e.prototype.kodachrome=function(e){this._loadMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0],e)},e.prototype.browni=function(e){this._loadMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],e)},e.prototype.vintage=function(e){this._loadMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],e)},e.prototype.colorTone=function(e,t,r,i,n){var o=((r=r||16770432)>>16&255)/255,a=(r>>8&255)/255,s=(255&r)/255,u=((i=i||3375104)>>16&255)/255,h=(i>>8&255)/255,c=(255&i)/255,f=[.3,.59,.11,0,0,o,a,s,e=e||.2,0,u,h,c,t=t||.15,0,o-u,a-h,s-c,0,0];this._loadMatrix(f,n)},e.prototype.night=function(e,t){var r=[-2*(e=e||.1),-e,0,0,0,-e,0,e,0,0,0,e,2*e,0,0,0,0,0,1,0];this._loadMatrix(r,t)},e.prototype.predator=function(e,t){var r=[11.224130630493164*e,-4.794486999511719*e,-2.8746118545532227*e,0*e,.40342438220977783*e,-3.6330697536468506*e,9.193157196044922*e,-2.951810836791992*e,0*e,-1.316135048866272*e,-3.2184197902679443*e,-4.2375030517578125*e,7.476448059082031*e,0*e,.8044459223747253*e,0,0,0,1,0];this._loadMatrix(r,t)},e.prototype.lsd=function(e){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],e)},e.prototype.reset=function(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!1)},r.matrix.get=function(){return this.uniforms.m},r.matrix.set=function(e){this.uniforms.m=e},r.alpha.get=function(){return this.uniforms.uAlpha},r.alpha.set=function(e){this.uniforms.uAlpha=e},Object.defineProperties(e.prototype,r),e}(vi);$o.prototype.grayscale=$o.prototype.greyscale;var ea=function(i){function e(e,t){var r=new mt;e.renderable=!1,i.call(this,"attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\nuniform mat3 filterMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vFilterCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n\tgl_Position = filterVertexPosition();\n\tvTextureCoord = filterTextureCoord();\n\tvFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;\n}\n","varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\nuniform mat2 rotation;\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform highp vec4 inputSize;\nuniform vec4 inputClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy = scale * inputSize.zw * (rotation * map.xy);\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));\n}\n",{mapSampler:e._texture,filterMatrix:r,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=e,this.maskMatrix=r,null==t&&(t=20),this.scale=new ut(t,t)}i&&(e.__proto__=i);var t={map:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.filterMatrix=e.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;var n=this.maskSprite.transform.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);0!==o&&0!==a&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),e.applyFilter(this,t,r,i)},t.map.get=function(){return this.uniforms.mapSampler},t.map.set=function(e){this.uniforms.mapSampler=e},Object.defineProperties(e.prototype,t),e}(vi),ta=function(e){function t(){e.call(this,"\nattribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vFragCoord;\n\nuniform vec4 inputPixel;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvoid texcoords(vec2 fragCoord, vec2 inverseVP,\n out vec2 v_rgbNW, out vec2 v_rgbNE,\n out vec2 v_rgbSW, out vec2 v_rgbSE,\n out vec2 v_rgbM) {\n v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\n v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\n v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\n v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\n v_rgbM = vec2(fragCoord * inverseVP);\n}\n\nvoid main(void) {\n\n gl_Position = filterVertexPosition();\n\n vFragCoord = aVertexPosition * outputFrame.zw;\n\n texcoords(vFragCoord, inputPixel.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}\n",'varying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vFragCoord;\nuniform sampler2D uSampler;\nuniform highp vec4 inputPixel;\n\n\n/**\n Basic FXAA implementation based on the code on geeks3d.com with the\n modification that the texture2DLod stuff was removed since it\'s\n unsupported by WebGL.\n\n --\n\n From:\n https://github.com/mitsuhiko/webgl-meincraft\n\n Copyright (c) 2011 by Armin Ronacher.\n\n Some rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are\n met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n\n * The names of the contributors may not be used to endorse or\n promote products derived from this software without specific\n prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef FXAA_REDUCE_MIN\n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n#define FXAA_SPAN_MAX 8.0\n#endif\n\n//optimized version for mobile, where dependent\n//texture reads can be a bottleneck\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,\n vec2 v_rgbNW, vec2 v_rgbNE,\n vec2 v_rgbSW, vec2 v_rgbSE,\n vec2 v_rgbM) {\n vec4 color;\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n\n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\nvoid main() {\n\n vec4 color;\n\n color = fxaa(uSampler, vFragCoord, inputPixel.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n gl_FragColor = color;\n}\n')}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t}(vi),ra=function(r){function e(e,t){void 0===e&&(e=.5),void 0===t&&(t=Math.random()),r.call(this,Ni,"precision highp float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform float uNoise;\nuniform float uSeed;\nuniform sampler2D uSampler;\n\nfloat rand(vec2 co)\n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float randomValue = rand(gl_FragCoord.xy * uSeed);\n float diff = (randomValue - 0.5) * uNoise;\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (color.a > 0.0) {\n color.rgb /= color.a;\n }\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n // Premultiply alpha again.\n color.rgb *= color.a;\n\n gl_FragColor = color;\n}\n",{uNoise:0,uSeed:0}),this.noise=e,this.seed=t}r&&(e.__proto__=r),(e.prototype=Object.create(r&&r.prototype)).constructor=e;var t={noise:{configurable:!0},seed:{configurable:!0}};return t.noise.get=function(){return this.uniforms.uNoise},t.noise.set=function(e){this.uniforms.uNoise=e},t.seed.get=function(){return this.uniforms.uSeed},t.seed.set=function(e){this.uniforms.uSeed=e},Object.defineProperties(e.prototype,t),e}(vi),ia=new mt;Lt.prototype._cacheAsBitmap=!1,Lt.prototype._cacheData=!1;var na=function(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalHitTest=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.sprite=null};Object.defineProperties(Lt.prototype,{cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(e){var t;this._cacheAsBitmap!==e&&((this._cacheAsBitmap=e)?(this._cacheData||(this._cacheData=new na),(t=this._cacheData).originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):((t=this._cacheData).sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea))}}}),Lt.prototype._renderCached=function(e){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(e),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(e))},Lt.prototype._initCachedDisplayObject=function(e){if(!this._cacheData||!this._cacheData.sprite){var t=this.alpha;this.alpha=1,e.batch.flush();var r=this.getLocalBounds().clone();if(this.filters){var i=this.filters[0].padding;r.pad(i)}r.ceil(A.RESOLUTION);var n=e._activeRenderTarget,o=yr.create(r.width,r.height),a="cacheAsBitmap_"+qe();this._cacheData.textureCacheId=a,ir.addToCache(o.baseTexture,a),br.addToCache(o,a);var s=ia;s.tx=-r.x,s.ty=-r.y,this.transform.worldTransform.identity(),this.render=this._cacheData.originalRender,e.render(this,o,!0,s,!0),e.renderTexture.bind(n),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var u=new Rn(o);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-r.x/r.width,u.anchor.y=-r.y/r.height,u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=e._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=u.containsPoint.bind(u)}},Lt.prototype._renderCachedCanvas=function(e){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(e),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(e))},Lt.prototype._initCachedDisplayObjectCanvas=function(e){if(!this._cacheData||!this._cacheData.sprite){var t=this.getLocalBounds(),r=this.alpha;this.alpha=1;var i=e.context;t.ceil(A.RESOLUTION);var n=yr.create(t.width,t.height),o="cacheAsBitmap_"+qe();this._cacheData.textureCacheId=o,ir.addToCache(n.baseTexture,o),br.addToCache(n,o);var a=ia;this.transform.localTransform.copyTo(a),a.invert(),a.tx-=t.x,a.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,e.render(this,n,!0,a,!1),e.context=i,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null;var s=new Rn(n);s.transform.worldTransform=this.transform.worldTransform,s.anchor.x=-t.x/t.width,s.anchor.y=-t.y/t.height,s.alpha=r,s._bounds=this._bounds,this._cacheData.sprite=s,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=e._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=s.containsPoint.bind(s)}},Lt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._lastBoundsID=this._boundsID},Lt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds()},Lt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,ir.removeFromCache(this._cacheData.textureCacheId),br.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Lt.prototype._cacheAsBitmapDestroy=function(e){this.cacheAsBitmap=!1,this.destroy(e)},Lt.prototype.name=null,jt.prototype.getChildByName=function(e){for(var t=0;t>16)+(65280&e)+((255&e)<<16),this._colorDirty=!0)},t.tint.get=function(){return this._tint},e.prototype.update=function(){if(this._colorDirty){this._colorDirty=!1;var e=this.texture.baseTexture;Ne(this._tint,this._alpha,this.uniforms.uColor,e.premultiplyAlpha)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)},Object.defineProperties(e.prototype,t),e}(li),fa=function(a){function e(e,t,r){a.call(this);var i=new xr(e),n=new xr(t,!0),o=new xr(r,!0,!0);this.addAttribute("aVertexPosition",i,2,!1,xe.FLOAT).addAttribute("aTextureCoord",n,2,!1,xe.FLOAT).addIndex(o),this._updateId=-1}a&&(e.__proto__=a),(e.prototype=Object.create(a&&a.prototype)).constructor=e;var t={vertexDirtyId:{configurable:!0}};return t.vertexDirtyId.get=function(){return this.buffers[0]._updateID},Object.defineProperties(e.prototype,t),e}(Mr),la=function(n){function e(e,t,r,i){void 0===e&&(e=100),void 0===t&&(t=100),void 0===r&&(r=10),void 0===i&&(i=10),n.call(this),this.segWidth=r,this.segHeight=i,this.width=e,this.height=t,this.build()}return n&&(e.__proto__=n),((e.prototype=Object.create(n&&n.prototype)).constructor=e).prototype.build=function(){for(var e=this.segWidth*this.segHeight,t=[],r=[],i=[],n=this.segWidth-1,o=this.segHeight-1,a=this.width/n,s=this.height/o,u=0;ut?1:this._height/t;e[9]=e[11]=e[13]=e[15]=this._topHeight*r,e[17]=e[19]=e[21]=e[23]=this._height-this._bottomHeight*r,e[25]=e[27]=e[29]=e[31]=this._height},e.prototype.updateVerticalVertices=function(){var e=this.vertices,t=this._leftWidth+this._rightWidth,r=this._width>t?1:this._width/t;e[2]=e[10]=e[18]=e[26]=this._leftWidth*r,e[4]=e[12]=e[20]=e[28]=this._width-this._rightWidth*r,e[6]=e[14]=e[22]=e[30]=this._width},t.width.get=function(){return this._width},t.width.set=function(e){this._width=e,this._refresh()},t.height.get=function(){return this._height},t.height.set=function(e){this._height=e,this._refresh()},t.leftWidth.get=function(){return this._leftWidth},t.leftWidth.set=function(e){this._leftWidth=e,this._refresh()},t.rightWidth.get=function(){return this._rightWidth},t.rightWidth.set=function(e){this._rightWidth=e,this._refresh()},t.topHeight.get=function(){return this._topHeight},t.topHeight.set=function(e){this._topHeight=e,this._refresh()},t.bottomHeight.get=function(){return this._bottomHeight},t.bottomHeight.set=function(e){this._bottomHeight=e,this._refresh()},e.prototype._refresh=function(){var e=this.texture,t=this.geometry.buffers[1].data;this._origWidth=e.orig.width,this._origHeight=e.orig.height;var r=1/this._origWidth,i=1/this._origHeight;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1,t[2]=t[10]=t[18]=t[26]=r*this._leftWidth,t[4]=t[12]=t[20]=t[28]=1-r*this._rightWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()},Object.defineProperties(e.prototype,t),e}(ma),ga=function(r){function i(e,t){r.call(this,e[0]instanceof br?e[0]:e[0].texture),this._textures=null,this._durations=null,this.textures=e,this._autoUpdate=!1!==t,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this.playing=!1}r&&(i.__proto__=r);var e={totalFrames:{configurable:!0},textures:{configurable:!0},currentFrame:{configurable:!0}};return((i.prototype=Object.create(r&&r.prototype)).constructor=i).prototype.stop=function(){this.playing&&(this.playing=!1,this._autoUpdate&&Gt.shared.remove(this.update,this))},i.prototype.play=function(){this.playing||(this.playing=!0,this._autoUpdate&&Gt.shared.add(this.update,this,qt.HIGH))},i.prototype.gotoAndStop=function(e){this.stop();var t=this.currentFrame;this._currentTime=e,t!==this.currentFrame&&this.updateTexture()},i.prototype.gotoAndPlay=function(e){var t=this.currentFrame;this._currentTime=e,t!==this.currentFrame&&this.updateTexture(),this.play()},i.prototype.update=function(e){var t=this.animationSpeed*e,r=this.currentFrame;if(null!==this._durations){var i=this._currentTime%1*this._durations[this.currentFrame];for(i+=t/60*1e3;i<0;)this._currentTime--,i+=this._durations[this.currentFrame];var n=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);i>=this._durations[this.currentFrame];)i-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=i/this._durations[this.currentFrame]}else this._currentTime+=t;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):r!==this.currentFrame&&(this.loop&&this.onLoop&&(0r&&this.onLoop()),this.updateTexture())},i.prototype.updateTexture=function(){this._texture=this._textures[this.currentFrame],this._textureID=-1,this._textureTrimmedID=-1,this.cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copy(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame)},i.prototype.destroy=function(e){this.stop(),r.prototype.destroy.call(this,e),this.onComplete=null,this.onFrameChange=null,this.onLoop=null},i.fromFrames=function(e){for(var t=[],r=0;r 0) var gc = undefined");else{if(!ba&&!ca)throw"Unknown runtime environment. Where are we?";e.read=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},"undefined"!=typeof arguments&&(e.arguments=arguments),"undefined"!=typeof console?(e.print||(e.print=function(e){console.log(e)}),e.printErr||(e.printErr=function(e){console.log(e)})):e.print||(e.print=function(){}),ca&&(e.load=importScripts),void 0===e.setWindowTitle&&(e.setWindowTitle=function(e){document.title=e})}function ha(e){eval.call(null,e)}for(k in!e.load&&e.read&&(e.load=function(t){ha(e.read(t))}),e.print||(e.print=function(){}),e.printErr||(e.printErr=e.print),e.arguments||(e.arguments=[]),e.thisProgram||(e.thisProgram="./this.program"),e.print=e.print,e.W=e.printErr,e.preRun=[],e.postRun=[],aa)aa.hasOwnProperty(k)&&(e[k]=aa[k]);var n={rb:function(e){ka=e},fb:function(){return ka},ua:function(){return m},ba:function(e){m=e},Ka:function(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:return"*"===e[e.length-1]?n.J:"i"===e[0]?(assert(0==(e=parseInt(e.substr(1)))%8),e/8):0}},eb:function(e){return Math.max(n.Ka(e),n.J)},ud:16,Qd:function(e,t){return"double"===t||"i64"===t?7&e&&(assert(4==(7&e)),e+=4):assert(0==(3&e)),e},Ed:function(e,t,r){return r||"i64"!=e&&"double"!=e?e?Math.min(t||(e?n.eb(e):0),n.J):Math.min(t,8):8},L:function(t,r,i){return i&&i.length?(i.splice||(i=Array.prototype.slice.call(i)),i.splice(0,0,r),e["dynCall_"+t].apply(null,i)):e["dynCall_"+t].call(null,r)},Z:[],Xa:function(e){for(var t=0;t>>0)+4294967296*+(t>>>0):+(e>>>0)+4294967296*+(0|t)},Ua:8,J:4,vd:0};e.Runtime=n,n.addFunction=n.Xa,n.removeFunction=n.nb;var na=!1,oa,pa,ka,ra,sa;function assert(e,t){e||x("Assertion failed: "+t)}function qa(a){var b=e["_"+a];if(!b)try{b=eval("_"+a)}catch(e){}return assert(b,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)"),b}function wa(e,t,r){switch("*"===(r=r||"i8").charAt(r.length-1)&&(r="i32"),r){case"i1":case"i8":y[e>>0]=t;break;case"i16":z[e>>1]=t;break;case"i32":C[e>>2]=t;break;case"i64":pa=[t>>>0,(oa=t,1<=+xa(oa)?0>>0:~~+Aa((oa-+(~~oa>>>0))/4294967296)>>>0:0)],C[e>>2]=pa[0],C[e+4>>2]=pa[1];break;case"float":Ba[e>>2]=t;break;case"double":Ca[e>>3]=t;break;default:x("invalid type for setValue: "+r)}}function Da(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return y[e>>0];case"i16":return z[e>>1];case"i32":case"i64":return C[e>>2];case"float":return Ba[e>>2];case"double":return Ca[e>>3];default:x("invalid type for setValue: "+t)}return null}function D(e,t,r,i){var o,a;a="number"==typeof e?(o=!0,e):(o=!1,e.length);var s,u,h="string"==typeof t?t:null;if(r=4==r?i:[Ea,n.aa,n.Ra,n.R][void 0===r?2:r](Math.max(a,h?1:t.length)),o){for(assert(0==(3&(i=r))),e=r+(-4&a);i>2]=0;for(e=r+a;i>0]=0;return r}if("i8"===h)return e.subarray||e.slice?E.set(e,r):E.set(new Uint8Array(e),r),r;for(i=0;i>0],0!=i||r)&&(o++,!r||o!=r););if(r||(r=o),i="",n<128){for(;0>10,56320|1023&r)))):s+=String.fromCharCode(r)}}function Ka(e,t,r,i){if(!(0>6}else{if(a<=65535){if(i<=r+2)break;t[r++]=224|a>>12}else{if(a<=2097151){if(i<=r+3)break;t[r++]=240|a>>18}else{if(a<=67108863){if(i<=r+4)break;t[r++]=248|a>>24}else{if(i<=r+5)break;t[r++]=252|a>>30,t[r++]=128|a>>24&63}t[r++]=128|a>>18&63}t[r++]=128|a>>12&63}t[r++]=128|a>>6&63}t[r++]=128|63&a}}return t[r]=0,r-n}function La(e){for(var t=0,r=0;r"):o=n;e:for(;f>0];if(!r)return t;t+=String.fromCharCode(r)}},e.stringToAscii=function(e,t){return Ia(e,t,!1)},e.UTF8ArrayToString=Ja,e.UTF8ToString=function(e){return Ja(E,e)},e.stringToUTF8Array=Ka,e.stringToUTF8=function(e,t,r){return Ka(e,E,t,r)},e.lengthBytesUTF8=La,e.UTF16ToString=function(e){for(var t=0,r="";;){var i=z[e+2*t>>1];if(0==i)return r;++t,r+=String.fromCharCode(i)}},e.stringToUTF16=function(e,t,r){if(void 0===r&&(r=2147483647),r<2)return 0;var i=t;r=(r-=2)<2*e.length?r/2:e.length;for(var n=0;n>1]=e.charCodeAt(n),t+=2;return z[t>>1]=0,t-i},e.lengthBytesUTF16=function(e){return 2*e.length},e.UTF32ToString=function(e){for(var t=0,r="";;){var i=C[e+4*t>>2];if(0==i)return r;++t,65536<=i?(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i)):r+=String.fromCharCode(i)}},e.stringToUTF32=function(e,t,r){if(void 0===r&&(r=2147483647),r<4)return 0;var i=t;r=i+r-4;for(var n=0;n>2]=o,r<(t+=4)+4)break}return C[t>>2]=0,t-i},e.lengthBytesUTF32=function(e){for(var t=0,r=0;r>0]=e[r],r+=1}function ta(e,t){for(var r=0;r>0]=e[r]}function Ia(e,t,r){for(var i=0;i>0]=e.charCodeAt(i);r||(y[t>>0]=0)}e.addOnPreRun=fb,e.addOnInit=function(e){cb.unshift(e)},e.addOnPreMain=function(e){db.unshift(e)},e.addOnExit=function(e){H.unshift(e)},e.addOnPostRun=gb,e.intArrayFromString=hb,e.intArrayToString=function(e){for(var t=[],r=0;r>>16)*i+r*(t>>>16)<<16)|0}),Math.Jd=Math.imul,Math.clz32||(Math.clz32=function(e){e>>>=0;for(var t=0;t<32;t++)if(e&1<<31-t)return t;return 32}),Math.Ad=Math.clz32;var xa=Math.abs,Aa=Math.ceil,za=Math.floor,ya=Math.min,I=0,ib=null,jb=null;function kb(){I++,e.monitorRunDependencies&&e.monitorRunDependencies(I)}function lb(){if(I--,e.monitorRunDependencies&&e.monitorRunDependencies(I),0==I&&(null!==ib&&(clearInterval(ib),ib=null),jb)){var t=jb;jb=null,t()}}e.addRunDependency=kb,e.removeRunDependency=lb,e.preloadedImages={},e.preloadedAudios={},Ta=8,la=Ta+5888,cb.push(),D([124,0,0,0,98,7,0,0,124,0,0,0,111,7,0,0,164,0,0,0,124,7,0,0,16,0,0,0,0,0,0,0,164,0,0,0,157,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,227,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,191,7,0,0,56,0,0,0,0,0,0,0,164,0,0,0,5,8,0,0,40,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,40,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,88,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,114,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,1,0,0,236,1,0,0,236,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,239,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,4,0,0,0,231,16,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,115,40,37,117,41,58,32,65,115,115,101,114,116,105,111,110,32,102,97,105,108,117,114,101,58,32,34,37,115,34,10,0,109,95,115,105,122,101,32,60,61,32,109,95,99,97,112,97,99,105,116,121,0,46,47,99,114,110,95,100,101,99,111,109,112,46,104,0,109,105,110,95,110,101,119,95,99,97,112,97,99,105,116,121,32,60,32,40,48,120,55,70,70,70,48,48,48,48,85,32,47,32,101,108,101,109,101,110,116,95,115,105,122,101,41,0,110,101,119,95,99,97,112,97,99,105,116,121,32,38,38,32,40,110,101,119,95,99,97,112,97,99,105,116,121,32,62,32,109,95,99,97,112,97,99,105,116,121,41,0,110,117,109,95,99,111,100,101,115,91,99,93,0,115,111,114,116,101,100,95,112,111,115,32,60,32,116,111,116,97,108,95,117,115,101,100,95,115,121,109,115,0,112,67,111,100,101,115,105,122,101,115,91,115,121,109,95,105,110,100,101,120,93,32,61,61,32,99,111,100,101,115,105,122,101,0,116,32,60,32,40,49,85,32,60,60,32,116,97,98,108,101,95,98,105,116,115,41,0,109,95,108,111,111,107,117,112,91,116,93,32,61,61,32,99,85,73,78,84,51,50,95,77,65,88,0,99,114,110,100,95,109,97,108,108,111,99,58,32,115,105,122,101,32,116,111,111,32,98,105,103,0,99,114,110,100,95,109,97,108,108,111,99,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,0,40,40,117,105,110,116,51,50,41,112,95,110,101,119,32,38,32,40,67,82,78,68,95,77,73,78,95,65,76,76,79,67,95,65,76,73,71,78,77,69,78,84,32,45,32,49,41,41,32,61,61,32,48,0,99,114,110,100,95,114,101,97,108,108,111,99,58,32,98,97,100,32,112,116,114,0,99,114,110,100,95,102,114,101,101,58,32,98,97,100,32,112,116,114,0,102,97,108,115,101,0,40,116,111,116,97,108,95,115,121,109,115,32,62,61,32,49,41,32,38,38,32,40,116,111,116,97,108,95,115,121,109,115,32,60,61,32,112,114,101,102,105,120,95,99,111,100,105,110,103,58,58,99,77,97,120,83,117,112,112,111,114,116,101,100,83,121,109,115,41,0,17,18,19,20,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,16,48,0,110,117,109,95,98,105,116,115,32,60,61,32,51,50,85,0,109,95,98,105,116,95,99,111,117,110,116,32,60,61,32,99,66,105,116,66,117,102,83,105,122,101,0,116,32,33,61,32,99,85,73,78,84,51,50,95,77,65,88,0,109,111,100,101,108,46,109,95,99,111,100,101,95,115,105,122,101,115,91,115,121,109,93,32,61,61,32,108,101,110,0,0,2,3,1,0,2,3,4,5,6,7,1,40,108,101,110,32,62,61,32,49,41,32,38,38,32,40,108,101,110,32,60,61,32,99,77,97,120,69,120,112,101,99,116,101,100,67,111,100,101,83,105,122,101,41,0,105,32,60,32,109,95,115,105,122,101,0,110,101,120,116,95,108,101,118,101,108,95,111,102,115,32,62,32,99,117,114,95,108,101,118,101,108,95,111,102,115,0,1,2,2,3,3,3,3,4,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,2,1,2,0,0,0,1,0,2,1,0,2,0,0,1,2,3,110,117,109,32,38,38,32,40,110,117,109,32,61,61,32,126,110,117,109,95,99,104,101,99,107,41,0,83,116,57,101,120,99,101,112,116,105,111,110,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,117,110,99,97,117,103,104,116,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0],"i8",4,n.Ua);var mb=n.ja(D(12,"i8",2),8);function ob(t){return e.___errno_location&&(C[e.___errno_location()>>2]=t),t}assert(0==mb%8),e._i64Subtract=nb;var J={I:1,F:2,ed:3,bc:4,H:5,Aa:6,vb:7,zc:8,ea:9,Jb:10,va:11,qd:11,Ta:12,da:13,Vb:14,Lc:15,fa:16,wa:17,rd:18,ha:19,ya:20,P:21,q:22,uc:23,Sa:24,Q:25,nd:26,Wb:27,Hc:28,ia:29,bd:30,nc:31,Vc:32,Sb:33,Zc:34,Dc:42,Zb:43,Kb:44,ec:45,fc:46,gc:47,mc:48,od:49,xc:50,dc:51,Pb:35,Ac:37,Bb:52,Eb:53,sd:54,vc:55,Fb:56,Gb:57,Qb:35,Hb:59,Jc:60,yc:61,kd:62,Ic:63,Ec:64,Fc:65,ad:66,Bc:67,yb:68,gd:69,Lb:70,Wc:71,pc:72,Tb:73,Db:74,Qc:76,Cb:77,$c:78,hc:79,ic:80,lc:81,kc:82,jc:83,Kc:38,za:39,qc:36,ga:40,Rc:95,Uc:96,Ob:104,wc:105,zb:97,Yc:91,Oc:88,Gc:92,cd:108,Nb:111,wb:98,Mb:103,tc:101,rc:100,ld:110,Xb:112,Yb:113,ac:115,Ab:114,Rb:89,oc:90,Xc:93,dd:94,xb:99,sc:102,cc:106,Mc:107,md:109,pd:87,Ub:122,hd:116,Pc:95,Cc:123,$b:84,Sc:75,Ib:125,Nc:131,Tc:130,jd:86};function pb(e,t){H.push(function(){n.L("vi",e,[t])}),pb.level=H.length}function tb(){return!!tb.p}e._memset=qb,e._bitshift64Lshr=rb,e._bitshift64Shl=sb;var ub=[],vb={};function wb(e,t){wb.p||(wb.p={}),e in wb.p||(n.L("v",t),wb.p[e]=1)}var xb={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};function yb(e,t){for(var r=0,i=e.length-1;0<=i;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function zb(e){var t="/"===e.charAt(0),r="/"===e.substr(-1);return(e=yb(e.split("/").filter(function(e){return!!e}),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function Ab(e){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."}function Bb(e){if("/"===e)return"/";var t=e.lastIndexOf("/");return-1===t?e:e.substr(t+1)}function Cb(){return zb(Array.prototype.slice.call(arguments,0).join("/"))}function K(e,t){return zb(e+"/"+t)}function Db(){for(var e="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=yb(e.split("/").filter(function(e){return!!e}),!t).join("/"))||"."}var Eb=[];function Fb(e,t){Eb[e]={input:[],output:[],N:t},Gb(e,Hb)}var Hb={open:function(e){var t=Eb[e.g.rdev];if(!t)throw new L(J.ha);e.tty=t,e.seekable=!1},close:function(e){e.tty.N.flush(e.tty)},flush:function(e){e.tty.N.flush(e.tty)},read:function(e,t,r,i){if(!e.tty||!e.tty.N.La)throw new L(J.Aa);for(var n=0,o=0;oe.e.length&&(e.e=M.cb(e),e.o=e.e.length),!e.e||e.e.subarray){var r=e.e?e.e.buffer.byteLength:0;t<=r||(t=Math.max(t,r*(r<1048576?2:1.125)|0),0!=r&&(t=Math.max(t,256)),r=e.e,e.e=new Uint8Array(t),0t)e.e.length=t;else for(;e.e.length=e.g.o)return 0;if(assert(0<=(e=Math.min(e.g.o-n,i))),8>1)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return t.mode},B:function(e){for(var t=[];e.parent!==e;)t.push(e.name),e=e.parent;return t.push(e.A.pa.root),t.reverse(),Cb.apply(null,t)},Ha:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},$a:function(e){if((e&=-32769)in P.Ha)return P.Ha[e];throw new L(J.q)},k:{D:function(e){var t;e=P.B(e);try{t=fs.lstatSync(e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return P.$&&!t.K&&(t.K=4096),P.$&&!t.blocks&&(t.blocks=(t.size+t.K-1)/t.K|0),{dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,K:t.K,blocks:t.blocks}},u:function(e,t){var r=P.B(e);try{void 0!==t.mode&&(fs.chmodSync(r,t.mode),e.mode=t.mode),void 0!==t.size&&fs.truncateSync(r,t.size)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},lookup:function(e,t){var r=K(P.B(e),t);r=P.Ja(r);return P.createNode(e,t,r)},T:function(e,t,r,i){e=P.createNode(e,t,r,i),t=P.B(e);try{N(e.mode)?fs.mkdirSync(t,e.mode):fs.writeFileSync(t,"",{mode:e.mode})}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return e},rename:function(e,t,r){e=P.B(e),t=K(P.B(t),r);try{fs.renameSync(e,t)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},unlink:function(e,t){var r=K(P.B(e),t);try{fs.unlinkSync(r)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},rmdir:function(e,t){var r=K(P.B(e),t);try{fs.rmdirSync(r)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},readdir:function(e){e=P.B(e);try{return fs.readdirSync(e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},symlink:function(e,t,r){e=K(P.B(e),t);try{fs.symlinkSync(r,e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},readlink:function(e){var t=P.B(e);try{return t=fs.readlinkSync(t),t=Ob.relative(Ob.resolve(e.A.pa.root),t)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}}},n:{open:function(e){var t=P.B(e.g);try{32768==(61440&e.g.mode)&&(e.V=fs.openSync(t,P.$a(e.flags)))}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},close:function(e){try{32768==(61440&e.g.mode)&&e.V&&fs.closeSync(e.V)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},read:function(e,t,r,i,n){if(0===i)return 0;var o,a=new Buffer(i);try{o=fs.readSync(e.V,a,0,i,n)}catch(e){throw new L(J[e.code])}if(0>>0)%Q.length}function Xb(e){var t=Wb(e.parent.id,e.name);e.M=Q[t],Q[t]=e}function Nb(e,t){var r;if(r=(r=Yb(e,"x"))?r:e.k.lookup?0:J.da)throw new L(r,e);for(r=Q[Wb(e.id,t)];r;r=r.M){var i=r.name;if(r.parent.id===e.id&&i===t)return r}return e.k.lookup(e,t)}function Lb(e,t,r,i){return Zb||((Zb=function(e,t,r,i){e||(e=this),this.parent=e,this.A=e.A,this.U=null,this.id=Sb++,this.name=t,this.mode=r,this.k={},this.n={},this.rdev=i}).prototype={},Object.defineProperties(Zb.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},kb:{get:function(){return N(this.mode)}},jb:{get:function(){return 8192==(61440&this.mode)}}})),Xb(e=new Zb(e,t,r,i)),e}function N(e){return 16384==(61440&e)}var $b={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Yb(e,t){return Tb?0:(-1===t.indexOf("r")||292&e.mode)&&(-1===t.indexOf("w")||146&e.mode)&&(-1===t.indexOf("x")||73&e.mode)?0:J.da}function ac(e,t){try{return Nb(e,t),J.wa}catch(e){}return Yb(e,"wx")}function bc(){for(var e=0;e<=4096;e++)if(!Rb[e])return e;throw new L(J.Sa)}function cc(e){dc||((dc=function(){}).prototype={},Object.defineProperties(dc.prototype,{object:{get:function(){return this.g},set:function(e){this.g=e}},Ld:{get:function(){return 1!=(2097155&this.flags)}},Md:{get:function(){return 0!=(2097155&this.flags)}},Kd:{get:function(){return 1024&this.flags}}}));var t,r=new dc;for(t in e)r[t]=e[t];return e=r,r=bc(),e.fd=r,Rb[r]=e}var Kb={open:function(e){e.n=Qb[e.g.rdev].n,e.n.open&&e.n.open(e)},G:function(){throw new L(J.ia)}},qc;function Gb(e,t){Qb[e]={n:t}}function ec(e,t){var r,i="/"===t,n=!t;if(i&&Pb)throw new L(J.fa);if(!i&&!n){if(t=(r=S(t,{Ia:!1})).path,(r=r.g).U)throw new L(J.fa);if(!N(r.mode))throw new L(J.ya)}n={type:e,pa:{},Oa:t,lb:[]};var o=e.A(n);(o.A=n).root=o,i?Pb=o:r&&(r.U=n,r.A&&r.A.lb.push(n))}function fc(e,t,r){var i=S(e,{parent:!0}).g;if(!(e=Bb(e))||"."===e||".."===e)throw new L(J.q);var n=ac(i,e);if(n)throw new L(n);if(!i.k.T)throw new L(J.I);return i.k.T(i,e,t,r)}function gc(e,t){return t=4095&(void 0!==t?t:438),fc(e,t|=32768,0)}function V(e,t){return t=1023&(void 0!==t?t:511),fc(e,t|=16384,0)}function hc(e,t,r){return void 0===r&&(r=t,t=438),fc(e,8192|t,r)}function ic(e,t){if(!Db(e))throw new L(J.F);var r=S(t,{parent:!0}).g;if(!r)throw new L(J.F);var i=Bb(t),n=ac(r,i);if(n)throw new L(n);if(!r.k.symlink)throw new L(J.I);return r.k.symlink(r,i,e)}function Vb(e){if(!(e=S(e).g))throw new L(J.F);if(!e.k.readlink)throw new L(J.q);return Db(T(e.parent),e.k.readlink(e))}function jc(e,t){var r;if(!(r="string"==typeof e?S(e,{la:!0}).g:e).k.u)throw new L(J.I);r.k.u(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})}function kc(t,r){var i,n,o;if(""===t)throw new L(J.F);if("string"==typeof r){if(void 0===(n=$b[r]))throw Error("Unknown file open mode: "+r)}else n=r;if(i=64&(r=n)?4095&(void 0===i?438:i)|32768:0,"object"==typeof t)o=t;else{t=zb(t);try{o=S(t,{la:!(131072&r)}).g}catch(e){}}if(n=!1,64&r)if(o){if(128&r)throw new L(J.wa)}else o=fc(t,i,0),n=!0;if(!o)throw new L(J.F);if(8192==(61440&o.mode)&&(r&=-513),65536&r&&!N(o.mode))throw new L(J.ya);if(!n&&(i=o?40960==(61440&o.mode)?J.ga:N(o.mode)&&(0!=(2097155&r)||512&r)?J.P:(i=["r","w","rw"][3&r],512&r&&(i+="w"),Yb(o,i)):J.F))throw new L(i);if(512&r){var a;if(!(a="string"==typeof(i=o)?S(i,{la:!0}).g:i).k.u)throw new L(J.I);if(N(a.mode))throw new L(J.P);if(32768!=(61440&a.mode))throw new L(J.q);if(i=Yb(a,"w"))throw new L(i);a.k.u(a,{size:0,timestamp:Date.now()})}r&=-641,(o=cc({g:o,path:T(o),flags:r,seekable:!0,position:0,n:o.n,tb:[],error:!1})).n.open&&o.n.open(o),!e.logReadFiles||1&r||(lc||(lc={}),t in lc||(lc[t]=1,e.printErr("read file: "+t)));try{R.onOpenFile&&(a=0,1!=(2097155&r)&&(a|=1),0!=(2097155&r)&&(a|=2),R.onOpenFile(t,a))}catch(e){console.log("FS.trackingDelegate['onOpenFile']('"+t+"', flags) threw an exception: "+e.message)}return o}function mc(e){e.na&&(e.na=null);try{e.n.close&&e.n.close(e)}catch(e){throw e}finally{Rb[e.fd]=null}}function nc(e,t,r){if(!e.seekable||!e.n.G)throw new L(J.ia);e.position=e.n.G(e,t,r),e.tb=[]}function oc(e,t,r,i,n,o){if(i<0||n<0)throw new L(J.q);if(0==(2097155&e.flags))throw new L(J.ea);if(N(e.g.mode))throw new L(J.P);if(!e.n.write)throw new L(J.q);1024&e.flags&&nc(e,0,2);var a=!0;if(void 0===n)n=e.position,a=!1;else if(!e.seekable)throw new L(J.ia);t=e.n.write(e,t,r,i,n,o),a||(e.position+=t);try{e.path&&R.onWriteToFile&&R.onWriteToFile(e.path)}catch(e){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+e.message)}return t}function pc(){L||((L=function(e,t){this.g=t,this.qb=function(e){for(var t in this.S=e,J)if(J[t]===e){this.code=t;break}},this.qb(e),this.message=xb[e]}).prototype=Error(),L.prototype.constructor=L,[J.F].forEach(function(e){Mb[e]=new L(e),Mb[e].stack=""}))}function rc(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}function sc(e,t,r,i){return gc(e=K("string"==typeof e?e:T(e),t),rc(r,i))}function tc(e,t,r,i,n,o){if(n=gc(e=t?K("string"==typeof e?e:T(e),t):e,i=rc(i,n)),r){if("string"==typeof r){e=Array(r.length),t=0;for(var a=r.length;t>2]}function xc(){var e;if(e=X(),!(e=Rb[e]))throw new L(J.ea);return e}var yc={};function Ga(e){Ga.p||(r=Qa(r),Ga.p=!0,assert(n.R),Ga.bb=n.R,n.R=function(){x("cannot dynamically allocate, sbrk now has control")});var t=r;return 0==e||Ga.bb(e)?t:4294967295}e._i64Add=zc;var Ac=1;function Cc(e,t){if(Dc=e,Ec=t,!Fc)return 1;if(0==e)Y=function(){setTimeout(Gc,t)},Hc="timeout";else if(1==e)Y=function(){Ic(Gc)},Hc="rAF";else if(2==e){if(!window.setImmediate){var r=[];window.addEventListener("message",function(e){e.source===window&&"__emcc"===e.data&&(e.stopPropagation(),r.shift()())},!0),window.setImmediate=function(e){r.push(e),window.postMessage("__emcc","*")}}Y=function(){window.setImmediate(Gc)},Hc="immediate"}return 0}function Jc(a,t,r,s,i){e.noExitRuntime=!0,assert(!Fc,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),Fc=a,Kc=s;var u=Lc;if(Gc=function(){if(!na)if(0>r-6&63;r=r-6,e=e+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[n]}2==r?(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&t)<<4],e+="=="):4==r&&(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&t)<<2],e+="="),h.src="data:audio/x-"+a.substr(-3)+";base64,"+e,s(h)}},h.src=n,ad(function(){s(h)})}});var r=e.canvas;r&&(r.sa=r.requestPointerLock||r.mozRequestPointerLock||r.webkitRequestPointerLock||r.msRequestPointerLock||function(){},r.Fa=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},r.Fa=r.Fa.bind(document),document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1),document.addEventListener("mspointerlockchange",t,!1),e.elementPointerLock&&r.addEventListener("click",function(e){!Tc&&r.sa&&(r.sa(),e.preventDefault())},!1))}}function bd(t,r,i,n){if(r&&e.ka&&t==e.canvas)return e.ka;var o,a;if(r){if(a={antialias:!1,alpha:!1},n)for(var s in n)a[s]=n[s];(a=GL.createContext(t,a))&&(o=GL.getContext(a).td),t.style.backgroundColor="black"}else o=t.getContext("2d");return o?(i&&(r||assert("undefined"==typeof GLctx,"cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),e.ka=o,r&&GL.Od(a),e.Td=r,Uc.forEach(function(e){e()}),Vc()),o):null}var cd=!1,dd=void 0,ed=void 0;function fd(t,r,i){function n(){Sc=!1;var t=o.parentNode;(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===t?(o.Da=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msExitFullscreen||document.exitFullscreen||function(){},o.Da=o.Da.bind(document),dd&&o.sa(),Sc=!0,ed&&gd()):(t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),ed&&hd()),e.onFullScreen&&e.onFullScreen(Sc),id(o)}void 0===(dd=t)&&(dd=!0),void 0===(ed=r)&&(ed=!1),void 0===(jd=i)&&(jd=null);var o=e.canvas;cd||(cd=!0,document.addEventListener("fullscreenchange",n,!1),document.addEventListener("mozfullscreenchange",n,!1),document.addEventListener("webkitfullscreenchange",n,!1),document.addEventListener("MSFullscreenChange",n,!1));var a=document.createElement("div");o.parentNode.insertBefore(a,o),a.appendChild(o),a.p=a.requestFullScreen||a.mozRequestFullScreen||a.msRequestFullscreen||(a.webkitRequestFullScreen?function(){a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),i?a.p({Ud:i}):a.p()}var kd=0;function ld(e){var t=Date.now();if(0===kd)kd=t+1e3/60;else for(;kd<=t+2;)kd+=1e3/60;t=Math.max(kd-t,0),setTimeout(e,t)}function Ic(e){"undefined"==typeof window?ld(e):(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||ld),window.requestAnimationFrame(e))}function ad(t){e.noExitRuntime=!0,setTimeout(function(){na||t()},1e4)}function $c(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]}function md(e,t,r){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)}function nd(t,r,e){md(t,function(e){assert(e,'Loading data file "'+t+'" failed (no arrayBuffer).'),r(new Uint8Array(e)),lb()},function(){if(!e)throw'Loading data file "'+t+'" failed.';e()}),kb()}var od=[],Wc,Xc,Yc,Zc,jd;function pd(){var t=e.canvas;od.forEach(function(e){e(t.width,t.height)})}function gd(){if("undefined"!=typeof SDL){var e=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=8388608|e}pd()}function hd(){if("undefined"!=typeof SDL){var e=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=-8388609&e}pd()}function id(t,r,i){r&&i?(t.ub=r,t.hb=i):(r=t.ub,i=t.hb);var n=r,o=i;if(e.forcedAspectRatio&&0this.length-1||e<0)){var t=e%this.chunkSize;return this.gb(e/this.chunkSize|0)[t]}},a.prototype.pb=function(e){this.gb=e},a.prototype.Ca=function(){var e=new XMLHttpRequest;if(e.open("HEAD",u,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw Error("Couldn't load "+u+". Status: "+e.status);var t,o=Number(e.getResponseHeader("Content-length")),a=1048576;(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t||(a=o);var s=this;s.pb(function(e){var t=e*a,r=(e+1)*a-1;r=Math.min(r,o-1);if(void 0===s.Y[e]){var i=s.Y;if(r=(e=e.g.e).length)return 0;if(assert(0<=(i=Math.min(e.length-n,i))),e.slice)for(var o=0;o>2]=0;case 21520:return r.tty?-J.q:-J.Q;case 21531:if(n=X(),!r.n.ib)throw new L(J.Q);return r.n.ib(r,i,n);default:x("bad ioctl syscall "+i)}}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},___syscall6:function(e,t){wc=t;try{return mc(xc()),0}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},_emscripten_set_main_loop_timing:Cc,__ZSt18uncaught_exceptionv:tb,___setErrNo:ob,_sbrk:Ga,___cxa_begin_catch:function(e){var t;tb.p--,ub.push(e);e:{if(e&&!vb[e])for(t in vb)if(vb[t].wd===e)break e;t=e}return t&&vb[t].Sd++,e},_emscripten_memcpy_big:function(e,t,r){return E.set(E.subarray(t,t+r),e),e},_sysconf:function(e){switch(e){case 30:return 4096;case 85:return F/4096;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return"object"==typeof navigator&&navigator.hardwareConcurrency||1}return ob(J.q),-1},_pthread_getspecific:function(e){return yc[e]||0},_pthread_self:function(){return 0},_pthread_once:wb,_pthread_key_create:function(e){return 0==e?J.q:(C[e>>2]=Ac,yc[Ac]=0,Ac++,0)},___unlock:function(){},_emscripten_set_main_loop:Jc,_pthread_setspecific:function(e,t){return e in yc?(yc[e]=t,0):J.q},___lock:function(){},_abort:function(){e.abort()},_pthread_cleanup_push:pb,_time:function(e){var t=Date.now()/1e3|0;return e&&(C[e>>2]=t),t},___syscall140:function(e,t){wc=t;try{var r=xc(),i=X(),n=X(),o=X(),a=X();return assert(0===i),nc(r,n,a),C[o>>2]=r.position,r.na&&0===n&&0===a&&(r.na=null),0}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},___syscall146:function(e,t){wc=t;try{var r,i=xc(),n=X();e:{for(var o=X(),a=0,s=0;s>2],C[n+(8*s+4)>>2],void 0);if(u<0){r=-1;break e}a+=u}r=a}return r}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},STACKTOP:m,STACK_MAX:Va,tempDoublePtr:mb,ABORT:na,cttz_i8:qd};var Z=function(e,t,r){"use asm";var i=e.Int8Array;var n=e.Int16Array;var o=e.Int32Array;var a=e.Uint8Array;var s=e.Uint16Array;var u=e.Uint32Array;var h=e.Float32Array;var c=e.Float64Array;var de=new i(r);var $=new n(r);var pe=new o(r);var me=new a(r);var ve=new s(r);var f=new u(r);var l=new h(r);var ee=new c(r);var d=e.byteLength;var be=t.STACKTOP|0;var p=t.STACK_MAX|0;var te=t.tempDoublePtr|0;var m=t.ABORT|0;var v=t.cttz_i8|0;var b=0;var g=0;var y=0;var _=0;var w=e.NaN,x=e.Infinity;var T=0,S=0,E=0,A=0,P=0.0,M=0,C=0,k=0,I=0.0;var re=0;var R=0;var O=0;var D=0;var L=0;var F=0;var j=0;var B=0;var N=0;var U=0;var z=e.Math.floor;var X=e.Math.abs;var q=e.Math.sqrt;var H=e.Math.pow;var G=e.Math.cos;var V=e.Math.sin;var Y=e.Math.tan;var W=e.Math.acos;var J=e.Math.asin;var K=e.Math.atan;var Z=e.Math.atan2;var Q=e.Math.exp;var ie=e.Math.log;var ne=e.Math.ceil;var ge=e.Math.imul;var oe=e.Math.min;var ae=e.Math.clz32;var se=t.abort;var ue=t.assert;var he=t.invoke_iiii;var ce=t.invoke_viiiii;var fe=t.invoke_vi;var le=t.invoke_ii;var ye=t.invoke_viii;var _e=t.invoke_v;var we=t.invoke_viiiiii;var xe=t.invoke_iiiiii;var Te=t.invoke_viiii;var Se=t._pthread_cleanup_pop;var Ee=t.___syscall54;var Ae=t.___syscall6;var Pe=t._emscripten_set_main_loop_timing;var Me=t.__ZSt18uncaught_exceptionv;var Ce=t.___setErrNo;var ke=t._sbrk;var Ie=t.___cxa_begin_catch;var Re=t._emscripten_memcpy_big;var Oe=t._sysconf;var De=t._pthread_getspecific;var Le=t._pthread_self;var Fe=t._pthread_once;var je=t._pthread_key_create;var Be=t.___unlock;var Ne=t._emscripten_set_main_loop;var Ue=t._pthread_setspecific;var ze=t.___lock;var Xe=t._abort;var qe=t._pthread_cleanup_push;var He=t._time;var Ge=t.___syscall140;var Ve=t.___syscall146;var Ye=0.0;function We(e){if(d(e)&16777215||d(e)<=16777215||d(e)>2147483648)return false;de=new i(e);$=new n(e);pe=new o(e);me=new a(e);ve=new s(e);f=new u(e);l=new h(e);ee=new c(e);r=e;return true}function Je(e){e=e|0;var t=0;t=be;be=be+e|0;be=be+15&-16;return t|0}function Ke(){return be|0}function Ze(e){e=e|0;be=e}function Qe(e,t){e=e|0;t=t|0;be=e;p=t}function $e(e,t){e=e|0;t=t|0;if(!b){b=e;g=t}}function et(e){e=e|0;de[te>>0]=de[e>>0];de[te+1>>0]=de[e+1>>0];de[te+2>>0]=de[e+2>>0];de[te+3>>0]=de[e+3>>0]}function tt(e){e=e|0;de[te>>0]=de[e>>0];de[te+1>>0]=de[e+1>>0];de[te+2>>0]=de[e+2>>0];de[te+3>>0]=de[e+3>>0];de[te+4>>0]=de[e+4>>0];de[te+5>>0]=de[e+5>>0];de[te+6>>0]=de[e+6>>0];de[te+7>>0]=de[e+7>>0]}function rt(e){e=e|0;re=e}function it(){return re|0}function nt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0;m=be;be=be+608|0;l=m+88|0;f=m+72|0;u=m+64|0;s=m+48|0;a=m+24|0;o=m;c=m+96|0;d=m+92|0;h=e+4|0;p=e+8|0;if((pe[h>>2]|0)>>>0>(pe[p>>2]|0)>>>0){pe[o>>2]=1154;pe[o+4>>2]=2120;pe[o+8>>2]=1133;_r(c,1100,o)|0;yr(c,m+16|0)|0}if((2147418112/(i>>>0)|0)>>>0<=t>>>0){pe[a>>2]=1154;pe[a+4>>2]=2121;pe[a+8>>2]=1169;_r(c,1100,a)|0;yr(c,m+40|0)|0}a=pe[p>>2]|0;if(a>>>0>=t>>>0){p=1;be=m;return p|0}do{if(r){if(t){o=t+-1|0;if(!(o&t)){o=11;break}else t=o}else t=-1;t=t>>>16|t;t=t>>>8|t;t=t>>>4|t;t=t>>>2|t;t=(t>>>1|t)+1|0;o=10}else o=10}while(0);if((o|0)==10)if(!t){t=0;o=12}else o=11;if((o|0)==11)if(t>>>0<=a>>>0)o=12;if((o|0)==12){pe[s>>2]=1154;pe[s+4>>2]=2130;pe[s+8>>2]=1217;_r(c,1100,s)|0;yr(c,u)|0}r=ge(t,i)|0;do{if(!n){o=ot(pe[e>>2]|0,r,d,1)|0;if(!o){p=0;be=m;return p|0}else{pe[e>>2]=o;break}}else{a=at(r,d)|0;if(!a){p=0;be=m;return p|0}ki[n&0](a,pe[e>>2]|0,pe[h>>2]|0);o=pe[e>>2]|0;do{if(o)if(!(o&7)){Oi[pe[104>>2]&1](o,0,0,1,pe[27]|0)|0;break}else{pe[f>>2]=1154;pe[f+4>>2]=2499;pe[f+8>>2]=1516;_r(c,1100,f)|0;yr(c,l)|0;break}}while(0);pe[e>>2]=a}}while(0);o=pe[d>>2]|0;if(o>>>0>r>>>0)t=(o>>>0)/(i>>>0)|0;pe[p>>2]=t;p=1;be=m;return p|0}function ot(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0;h=be;be=be+592|0;u=h+48|0;o=h+24|0;n=h;s=h+72|0;a=h+68|0;if(e&7){pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1494;_r(s,1100,n)|0;yr(s,h+16|0)|0;u=0;be=h;return u|0}if(t>>>0>2147418112){pe[o>>2]=1154;pe[o+4>>2]=2499;pe[o+8>>2]=1387;_r(s,1100,o)|0;yr(s,h+40|0)|0;u=0;be=h;return u|0}pe[a>>2]=t;i=Oi[pe[104>>2]&1](e,t,a,i,pe[27]|0)|0;if(r)pe[r>>2]=pe[a>>2];if(!(i&7)){u=i;be=h;return u|0}pe[u>>2]=1154;pe[u+4>>2]=2551;pe[u+8>>2]=1440;_r(s,1100,u)|0;yr(s,h+64|0)|0;u=i;be=h;return u|0}function at(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0;u=be;be=be+592|0;a=u+48|0;s=u+24|0;r=u;o=u+72|0;n=u+68|0;i=e+3&-4;i=(i|0)!=0?i:4;if(i>>>0>2147418112){pe[r>>2]=1154;pe[r+4>>2]=2499;pe[r+8>>2]=1387;_r(o,1100,r)|0;yr(o,u+16|0)|0;s=0;be=u;return s|0}pe[n>>2]=i;r=Oi[pe[104>>2]&1](0,i,n,1,pe[27]|0)|0;e=pe[n>>2]|0;if(t)pe[t>>2]=e;if((r|0)==0|e>>>0>>0){pe[s>>2]=1154;pe[s+4>>2]=2499;pe[s+8>>2]=1413;_r(o,1100,s)|0;yr(o,u+40|0)|0;s=0;be=u;return s|0}if(!(r&7)){s=r;be=u;return s|0}pe[a>>2]=1154;pe[a+4>>2]=2526;pe[a+8>>2]=1440;_r(o,1100,a)|0;yr(o,u+64|0)|0;s=r;be=u;return s|0}function st(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0;B=be;be=be+960|0;L=B+232|0;D=B+216|0;O=B+208|0;R=B+192|0;I=B+184|0;k=B+168|0;C=B+160|0;M=B+144|0;E=B+136|0;S=B+120|0;T=B+112|0;x=B+96|0;y=B+88|0;g=B+72|0;b=B+64|0;v=B+48|0;f=B+40|0;d=B+24|0;l=B+16|0;c=B;P=B+440|0;F=B+376|0;j=B+304|0;m=B+236|0;if((t|0)==0|i>>>0>11){e=0;be=B;return e|0}pe[e>>2]=t;n=j;o=n+68|0;do{pe[n>>2]=0;n=n+4|0}while((n|0)<(o|0));o=0;do{n=de[r+o>>0]|0;if(n<<24>>24){A=j+((n&255)<<2)|0;pe[A>>2]=(pe[A>>2]|0)+1}o=o+1|0}while((o|0)!=(t|0));o=0;h=1;a=0;s=-1;u=0;while(1){n=pe[j+(h<<2)>>2]|0;if(!n)pe[e+28+(h+-1<<2)>>2]=0;else{A=h+-1|0;pe[F+(A<<2)>>2]=o;o=n+o|0;w=16-h|0;pe[e+28+(A<<2)>>2]=(o+-1<>2]=u;pe[m+(h<<2)>>2]=u;a=a>>>0>h>>>0?a:h;s=s>>>0>>0?s:h;u=n+u|0}h=h+1|0;if((h|0)==17){A=a;break}else o=o<<1}pe[e+4>>2]=u;o=e+172|0;do{if(u>>>0>(pe[o>>2]|0)>>>0){pe[o>>2]=u;if(u){n=u+-1|0;if(n&u)p=14}else{n=-1;p=14}if((p|0)==14){w=n>>>16|n;w=w>>>8|w;w=w>>>4|w;w=w>>>2|w;w=(w>>>1|w)+1|0;pe[o>>2]=w>>>0>t>>>0?t:w}a=e+176|0;n=pe[a>>2]|0;do{if(n){w=pe[n+-4>>2]|0;n=n+-8|0;if(!((w|0)!=0?(w|0)==(~pe[n>>2]|0):0)){pe[c>>2]=1154;pe[c+4>>2]=644;pe[c+8>>2]=1863;_r(P,1100,c)|0;yr(P,l)|0}if(!(n&7)){Oi[pe[104>>2]&1](n,0,0,1,pe[27]|0)|0;break}else{pe[d>>2]=1154;pe[d+4>>2]=2499;pe[d+8>>2]=1516;_r(P,1100,d)|0;yr(P,f)|0;break}}}while(0);o=pe[o>>2]|0;o=(o|0)!=0?o:1;n=at((o<<1)+8|0,0)|0;if(!n){pe[a>>2]=0;n=0;break}else{pe[n+4>>2]=o;pe[n>>2]=~o;pe[a>>2]=n+8;p=25;break}}else p=25}while(0);e:do{if((p|0)==25){w=e+24|0;de[w>>0]=s;de[e+25>>0]=A;o=e+176|0;a=0;do{_=de[r+a>>0]|0;n=_&255;if(_<<24>>24){if(!(pe[j+(n<<2)>>2]|0)){pe[v>>2]=1154;pe[v+4>>2]=2273;pe[v+8>>2]=1261;_r(P,1100,v)|0;yr(P,b)|0}_=m+(n<<2)|0;n=pe[_>>2]|0;pe[_>>2]=n+1;if(n>>>0>=u>>>0){pe[g>>2]=1154;pe[g+4>>2]=2277;pe[g+8>>2]=1274;_r(P,1100,g)|0;yr(P,y)|0}$[(pe[o>>2]|0)+(n<<1)>>1]=a}a=a+1|0}while((a|0)!=(t|0));n=de[w>>0]|0;y=(n&255)>>>0>>0?i:0;_=e+8|0;pe[_>>2]=y;g=(y|0)!=0;if(g){b=1<>>0>(pe[n>>2]|0)>>>0){pe[n>>2]=b;a=e+168|0;n=pe[a>>2]|0;do{if(n){v=pe[n+-4>>2]|0;n=n+-8|0;if(!((v|0)!=0?(v|0)==(~pe[n>>2]|0):0)){pe[x>>2]=1154;pe[x+4>>2]=644;pe[x+8>>2]=1863;_r(P,1100,x)|0;yr(P,T)|0}if(!(n&7)){Oi[pe[104>>2]&1](n,0,0,1,pe[27]|0)|0;break}else{pe[S>>2]=1154;pe[S+4>>2]=2499;pe[S+8>>2]=1516;_r(P,1100,S)|0;yr(P,E)|0;break}}}while(0);n=b<<2;o=at(n+8|0,0)|0;if(!o){pe[a>>2]=0;n=0;break e}else{E=o+8|0;pe[o+4>>2]=b;pe[o>>2]=~b;pe[a>>2]=E;o=E;break}}else{o=e+168|0;n=b<<2;a=o;o=pe[o>>2]|0}}while(0);Wr(o|0,-1,n|0)|0;p=e+176|0;v=1;do{if(pe[j+(v<<2)>>2]|0){t=y-v|0;m=1<>2]|0;if(o>>>0>=16){pe[M>>2]=1154;pe[M+4>>2]=1953;pe[M+8>>2]=1737;_r(P,1100,M)|0;yr(P,C)|0}n=pe[e+28+(o<<2)>>2]|0;if(!n)d=-1;else d=(n+-1|0)>>>(16-v|0);if(s>>>0<=d>>>0){f=(pe[e+96+(o<<2)>>2]|0)-s|0;l=v<<16;do{n=ve[(pe[p>>2]|0)+(f+s<<1)>>1]|0;if((me[r+n>>0]|0|0)!=(v|0)){pe[k>>2]=1154;pe[k+4>>2]=2319;pe[k+8>>2]=1303;_r(P,1100,k)|0;yr(P,I)|0}c=s<>>0>=b>>>0){pe[R>>2]=1154;pe[R+4>>2]=2325;pe[R+8>>2]=1337;_r(P,1100,R)|0;yr(P,O)|0}n=pe[a>>2]|0;if((pe[n+(u<<2)>>2]|0)!=-1){pe[D>>2]=1154;pe[D+4>>2]=2327;pe[D+8>>2]=1360;_r(P,1100,D)|0;yr(P,L)|0;n=pe[a>>2]|0}pe[n+(u<<2)>>2]=o;h=h+1|0}while(h>>>0>>0);s=s+1|0}while(s>>>0<=d>>>0)}}v=v+1|0}while(y>>>0>=v>>>0);n=de[w>>0]|0}o=e+96|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F>>2]|0);o=e+100|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+4>>2]|0);o=e+104|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+8>>2]|0);o=e+108|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+12>>2]|0);o=e+112|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+16>>2]|0);o=e+116|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+20>>2]|0);o=e+120|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+24>>2]|0);o=e+124|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+28>>2]|0);o=e+128|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+32>>2]|0);o=e+132|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+36>>2]|0);o=e+136|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+40>>2]|0);o=e+140|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+44>>2]|0);o=e+144|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+48>>2]|0);o=e+148|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+52>>2]|0);o=e+152|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+56>>2]|0);o=e+156|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+60>>2]|0);o=e+16|0;pe[o>>2]=0;a=e+20|0;pe[a>>2]=n&255;t:do{if(g){while(1){if(!i)break t;n=i+-1|0;if(!(pe[j+(i<<2)>>2]|0))i=n;else break}pe[o>>2]=pe[e+28+(n<<2)>>2];n=y+1|0;pe[a>>2]=n;if(n>>>0<=A>>>0){while(1){if(pe[j+(n<<2)>>2]|0)break;n=n+1|0;if(n>>>0>A>>>0)break t}pe[a>>2]=n}}}while(0);pe[e+92>>2]=-1;pe[e+160>>2]=1048575;pe[e+12>>2]=32-(pe[_>>2]|0);n=1}}while(0);e=n;be=B;return e|0}function ut(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0;if(!e){n=Ur(t)|0;if(!r){r=n;return r|0}if(!n)o=0;else o=qr(n)|0;pe[r>>2]=o;r=n;return r|0}if(!t){zr(e);if(!r){r=0;return r|0}pe[r>>2]=0;r=0;return r|0}n=Xr(e,t)|0;o=(n|0)!=0;if(o|i^1)o=o?n:e;else{n=Xr(e,t)|0;o=(n|0)==0?e:n}if(!r){r=n;return r|0}t=qr(o)|0;pe[r>>2]=t;r=n;return r|0}function ht(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(!((e|0)!=0&t>>>0>73&(r|0)!=0)){r=0;return r|0}if((pe[r>>2]|0)!=40|t>>>0<74){r=0;return r|0}if(((me[e>>0]|0)<<8|(me[e+1>>0]|0)|0)!=18552){r=0;return r|0}if(((me[e+2>>0]|0)<<8|(me[e+3>>0]|0))>>>0<74){r=0;return r|0}if(((me[e+7>>0]|0)<<16|(me[e+6>>0]|0)<<24|(me[e+8>>0]|0)<<8|(me[e+9>>0]|0))>>>0>t>>>0){r=0;return r|0}pe[r+4>>2]=(me[e+12>>0]|0)<<8|(me[e+13>>0]|0);pe[r+8>>2]=(me[e+14>>0]|0)<<8|(me[e+15>>0]|0);pe[r+12>>2]=me[e+16>>0];pe[r+16>>2]=me[e+17>>0];t=e+18|0;i=r+32|0;pe[i>>2]=me[t>>0];pe[i+4>>2]=0;t=de[t>>0]|0;pe[r+20>>2]=t<<24>>24==0|t<<24>>24==9?8:16;pe[r+24>>2]=(me[e+26>>0]|0)<<16|(me[e+25>>0]|0)<<24|(me[e+27>>0]|0)<<8|(me[e+28>>0]|0);pe[r+28>>2]=(me[e+30>>0]|0)<<16|(me[e+29>>0]|0)<<24|(me[e+31>>0]|0)<<8|(me[e+32>>0]|0);r=1;return r|0}function ct(e){e=e|0;Ie(e|0)|0;zt()}function ft(e){e=e|0;var t=0,r=0,i=0,n=0,o=0;o=be;be=be+544|0;n=o;i=o+24|0;t=pe[e+20>>2]|0;if(t)lt(t);t=e+4|0;r=pe[t>>2]|0;if(!r){n=e+16|0;de[n>>0]=0;be=o;return}if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1516;_r(i,1100,n)|0;yr(i,o+16|0)|0}pe[t>>2]=0;pe[e+8>>2]=0;pe[e+12>>2]=0;n=e+16|0;de[n>>0]=0;be=o;return}function lt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;d=be;be=be+640|0;l=d+112|0;f=d+96|0;c=d+88|0;h=d+72|0;u=d+64|0;s=d+48|0;i=d+40|0;o=d+24|0;n=d+16|0;r=d;a=d+120|0;if(!e){be=d;return}t=pe[e+168>>2]|0;do{if(t){p=pe[t+-4>>2]|0;t=t+-8|0;if(!((p|0)!=0?(p|0)==(~pe[t>>2]|0):0)){pe[r>>2]=1154;pe[r+4>>2]=644;pe[r+8>>2]=1863;_r(a,1100,r)|0;yr(a,n)|0}if(!(t&7)){Oi[pe[104>>2]&1](t,0,0,1,pe[27]|0)|0;break}else{pe[o>>2]=1154;pe[o+4>>2]=2499;pe[o+8>>2]=1516;_r(a,1100,o)|0;yr(a,i)|0;break}}}while(0);t=pe[e+176>>2]|0;do{if(t){p=pe[t+-4>>2]|0;t=t+-8|0;if(!((p|0)!=0?(p|0)==(~pe[t>>2]|0):0)){pe[s>>2]=1154;pe[s+4>>2]=644;pe[s+8>>2]=1863;_r(a,1100,s)|0;yr(a,u)|0}if(!(t&7)){Oi[pe[104>>2]&1](t,0,0,1,pe[27]|0)|0;break}else{pe[h>>2]=1154;pe[h+4>>2]=2499;pe[h+8>>2]=1516;_r(a,1100,h)|0;yr(a,c)|0;break}}}while(0);if(!(e&7)){Oi[pe[104>>2]&1](e,0,0,1,pe[27]|0)|0;be=d;return}else{pe[f>>2]=1154;pe[f+4>>2]=2499;pe[f+8>>2]=1516;_r(a,1100,f)|0;yr(a,l)|0;be=d;return}}function dt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+560|0;a=c+40|0;s=c+24|0;t=c;o=c+48|0;n=e+8|0;r=pe[n>>2]|0;if((r+-1|0)>>>0>=8192){pe[t>>2]=1154;pe[t+4>>2]=2997;pe[t+8>>2]=1541;_r(o,1100,t)|0;yr(o,c+16|0)|0}pe[e>>2]=r;i=e+20|0;t=pe[i>>2]|0;if(!t){t=at(180,0)|0;if(!t)t=0;else{h=t+164|0;pe[h>>2]=0;pe[h+4>>2]=0;pe[h+8>>2]=0;pe[h+12>>2]=0}pe[i>>2]=t;h=t;u=pe[e>>2]|0}else{h=t;u=r}if(!(pe[n>>2]|0)){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(o,1100,s)|0;yr(o,a)|0;o=pe[e>>2]|0}else o=u;n=pe[e+4>>2]|0;if(o>>>0>16){r=o;t=0}else{e=0;h=st(h,u,n,e)|0;be=c;return h|0}while(1){i=t+1|0;if(r>>>0>3){r=r>>>1;t=i}else{r=i;break}}e=t+2+((r|0)!=32&1<>>0>>0&1)|0;e=e>>>0<11?e&255:11;h=st(h,u,n,e)|0;be=c;return h|0}function pt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0;L=be;be=be+800|0;k=L+256|0;C=L+240|0;M=L+232|0;P=L+216|0;A=L+208|0;E=L+192|0;S=L+184|0;T=L+168|0;x=L+160|0;w=L+144|0;_=L+136|0;y=L+120|0;g=L+112|0;b=L+96|0;v=L+88|0;m=L+72|0;f=L+64|0;c=L+48|0;s=L+40|0;u=L+24|0;o=L+16|0;n=L;O=L+288|0;D=L+264|0;I=mt(e,14)|0;if(!I){pe[t>>2]=0;r=t+4|0;i=pe[r>>2]|0;if(i){if(!(i&7))Oi[pe[104>>2]&1](i,0,0,1,pe[27]|0)|0;else{pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1516;_r(O,1100,n)|0;yr(O,o)|0}pe[r>>2]=0;pe[t+8>>2]=0;pe[t+12>>2]=0}de[t+16>>0]=0;r=t+20|0;i=pe[r>>2]|0;if(!i){t=1;be=L;return t|0}lt(i);pe[r>>2]=0;t=1;be=L;return t|0}d=t+4|0;p=t+8|0;r=pe[p>>2]|0;if((r|0)!=(I|0)){if(r>>>0<=I>>>0){do{if((pe[t+12>>2]|0)>>>0>>0){if(nt(d,I,(r+1|0)==(I|0),1,0)|0){r=pe[p>>2]|0;break}de[t+16>>0]=1;t=0;be=L;return t|0}}while(0);Wr((pe[d>>2]|0)+r|0,0,I-r|0)|0}pe[p>>2]=I}Wr(pe[d>>2]|0,0,I|0)|0;l=e+20|0;r=pe[l>>2]|0;if((r|0)<5){o=e+4|0;a=e+8|0;n=e+16|0;do{i=pe[o>>2]|0;if((i|0)==(pe[a>>2]|0))i=0;else{pe[o>>2]=i+1;i=me[i>>0]|0}r=r+8|0;pe[l>>2]=r;if((r|0)>=33){pe[u>>2]=1154;pe[u+4>>2]=3199;pe[u+8>>2]=1650;_r(O,1100,u)|0;yr(O,s)|0;r=pe[l>>2]|0}i=i<<32-r|pe[n>>2];pe[n>>2]=i}while((r|0)<5)}else{i=e+16|0;n=i;i=pe[i>>2]|0}h=i>>>27;pe[n>>2]=i<<5;pe[l>>2]=r+-5;if((h+-1|0)>>>0>20){t=0;be=L;return t|0}pe[D+20>>2]=0;pe[D>>2]=0;pe[D+4>>2]=0;pe[D+8>>2]=0;pe[D+12>>2]=0;de[D+16>>0]=0;r=D+4|0;i=D+8|0;e:do{if(nt(r,21,0,1,0)|0){s=pe[i>>2]|0;u=pe[r>>2]|0;Wr(u+s|0,0,21-s|0)|0;pe[i>>2]=21;if(h){n=e+4|0;o=e+8|0;a=e+16|0;s=0;do{r=pe[l>>2]|0;if((r|0)<3)do{i=pe[n>>2]|0;if((i|0)==(pe[o>>2]|0))i=0;else{pe[n>>2]=i+1;i=me[i>>0]|0}r=r+8|0;pe[l>>2]=r;if((r|0)>=33){pe[c>>2]=1154;pe[c+4>>2]=3199;pe[c+8>>2]=1650;_r(O,1100,c)|0;yr(O,f)|0;r=pe[l>>2]|0}i=i<<32-r|pe[a>>2];pe[a>>2]=i}while((r|0)<3);else i=pe[a>>2]|0;pe[a>>2]=i<<3;pe[l>>2]=r+-3;de[u+(me[1611+s>>0]|0)>>0]=i>>>29;s=s+1|0}while((s|0)!=(h|0))}if(dt(D)|0){s=e+4|0;u=e+8|0;h=e+16|0;i=0;t:while(1){a=I-i|0;r=vt(e,D)|0;r:do{if(r>>>0<17){if((pe[p>>2]|0)>>>0<=i>>>0){pe[m>>2]=1154;pe[m+4>>2]=903;pe[m+8>>2]=1781;_r(O,1100,m)|0;yr(O,v)|0}de[(pe[d>>2]|0)+i>>0]=r;r=i+1|0}else switch(r|0){case 17:{r=pe[l>>2]|0;if((r|0)<3)do{n=pe[s>>2]|0;if((n|0)==(pe[u>>2]|0))n=0;else{pe[s>>2]=n+1;n=me[n>>0]|0}r=r+8|0;pe[l>>2]=r;if((r|0)>=33){pe[b>>2]=1154;pe[b+4>>2]=3199;pe[b+8>>2]=1650;_r(O,1100,b)|0;yr(O,g)|0;r=pe[l>>2]|0}n=n<<32-r|pe[h>>2];pe[h>>2]=n}while((r|0)<3);else n=pe[h>>2]|0;pe[h>>2]=n<<3;pe[l>>2]=r+-3;r=(n>>>29)+3|0;if(r>>>0>a>>>0){r=0;break e}r=r+i|0;break r}case 18:{r=pe[l>>2]|0;if((r|0)<7)do{n=pe[s>>2]|0;if((n|0)==(pe[u>>2]|0))n=0;else{pe[s>>2]=n+1;n=me[n>>0]|0}r=r+8|0;pe[l>>2]=r;if((r|0)>=33){pe[y>>2]=1154;pe[y+4>>2]=3199;pe[y+8>>2]=1650;_r(O,1100,y)|0;yr(O,_)|0;r=pe[l>>2]|0}n=n<<32-r|pe[h>>2];pe[h>>2]=n}while((r|0)<7);else n=pe[h>>2]|0;pe[h>>2]=n<<7;pe[l>>2]=r+-7;r=(n>>>25)+11|0;if(r>>>0>a>>>0){r=0;break e}r=r+i|0;break r}default:{if((r+-19|0)>>>0>=2){R=90;break t}o=pe[l>>2]|0;if((r|0)==19){if((o|0)<2){n=o;while(1){r=pe[s>>2]|0;if((r|0)==(pe[u>>2]|0))o=0;else{pe[s>>2]=r+1;o=me[r>>0]|0}r=n+8|0;pe[l>>2]=r;if((r|0)>=33){pe[w>>2]=1154;pe[w+4>>2]=3199;pe[w+8>>2]=1650;_r(O,1100,w)|0;yr(O,x)|0;r=pe[l>>2]|0}n=o<<32-r|pe[h>>2];pe[h>>2]=n;if((r|0)<2)n=r;else break}}else{n=pe[h>>2]|0;r=o}pe[h>>2]=n<<2;pe[l>>2]=r+-2;o=(n>>>30)+3|0}else{if((o|0)<6){n=o;while(1){r=pe[s>>2]|0;if((r|0)==(pe[u>>2]|0))o=0;else{pe[s>>2]=r+1;o=me[r>>0]|0}r=n+8|0;pe[l>>2]=r;if((r|0)>=33){pe[T>>2]=1154;pe[T+4>>2]=3199;pe[T+8>>2]=1650;_r(O,1100,T)|0;yr(O,S)|0;r=pe[l>>2]|0}n=o<<32-r|pe[h>>2];pe[h>>2]=n;if((r|0)<6)n=r;else break}}else{n=pe[h>>2]|0;r=o}pe[h>>2]=n<<6;pe[l>>2]=r+-6;o=(n>>>26)+7|0}if((i|0)==0|o>>>0>a>>>0){r=0;break e}r=i+-1|0;if((pe[p>>2]|0)>>>0<=r>>>0){pe[E>>2]=1154;pe[E+4>>2]=903;pe[E+8>>2]=1781;_r(O,1100,E)|0;yr(O,A)|0}n=de[(pe[d>>2]|0)+r>>0]|0;if(!(n<<24>>24)){r=0;break e}r=o+i|0;if(i>>>0>=r>>>0){r=i;break r}do{if((pe[p>>2]|0)>>>0<=i>>>0){pe[P>>2]=1154;pe[P+4>>2]=903;pe[P+8>>2]=1781;_r(O,1100,P)|0;yr(O,M)|0}de[(pe[d>>2]|0)+i>>0]=n;i=i+1|0}while((i|0)!=(r|0))}}}while(0);if(I>>>0>r>>>0)i=r;else break}if((R|0)==90){pe[C>>2]=1154;pe[C+4>>2]=3140;pe[C+8>>2]=1632;_r(O,1100,C)|0;yr(O,k)|0;r=0;break}if((I|0)==(r|0))r=dt(t)|0;else r=0}else r=0}else{de[D+16>>0]=1;r=0}}while(0);ft(D);t=r;be=L;return t|0}function mt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+544|0;s=c+16|0;a=c;o=c+24|0;if(!t){h=0;be=c;return h|0}if(t>>>0<=16){h=bt(e,t)|0;be=c;return h|0}u=bt(e,t+-16|0)|0;h=e+20|0;t=pe[h>>2]|0;if((t|0)<16){i=e+4|0;n=e+8|0;r=e+16|0;do{e=pe[i>>2]|0;if((e|0)==(pe[n>>2]|0))e=0;else{pe[i>>2]=e+1;e=me[e>>0]|0}t=t+8|0;pe[h>>2]=t;if((t|0)>=33){pe[a>>2]=1154;pe[a+4>>2]=3199;pe[a+8>>2]=1650;_r(o,1100,a)|0;yr(o,s)|0;t=pe[h>>2]|0}e=e<<32-t|pe[r>>2];pe[r>>2]=e}while((t|0)<16)}else{e=e+16|0;r=e;e=pe[e>>2]|0}pe[r>>2]=e<<16;pe[h>>2]=t+-16;h=e>>>16|u<<16;be=c;return h|0}function vt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0;y=be;be=be+608|0;m=y+88|0;p=y+72|0;l=y+64|0;f=y+48|0;c=y+40|0;d=y+24|0;h=y+16|0;u=y;b=y+96|0;v=pe[t+20>>2]|0;g=e+20|0;s=pe[g>>2]|0;do{if((s|0)<24){a=e+4|0;i=pe[a>>2]|0;n=pe[e+8>>2]|0;r=i>>>0>>0;if((s|0)>=16){if(r){pe[a>>2]=i+1;r=me[i>>0]|0}else r=0;pe[g>>2]=s+8;a=e+16|0;o=r<<24-s|pe[a>>2];pe[a>>2]=o;break}if(r){o=(me[i>>0]|0)<<8;r=i+1|0}else{o=0;r=i}if(r>>>0>>0){i=me[r>>0]|0;r=r+1|0}else i=0;pe[a>>2]=r;pe[g>>2]=s+16;a=e+16|0;o=(i|o)<<16-s|pe[a>>2];pe[a>>2]=o}else{o=e+16|0;a=o;o=pe[o>>2]|0}}while(0);n=(o>>>16)+1|0;do{if(n>>>0<=(pe[v+16>>2]|0)>>>0){i=pe[(pe[v+168>>2]|0)+(o>>>(32-(pe[v+8>>2]|0)|0)<<2)>>2]|0;if((i|0)==-1){pe[u>>2]=1154;pe[u+4>>2]=3244;pe[u+8>>2]=1677;_r(b,1100,u)|0;yr(b,h)|0}r=i&65535;i=i>>>16;if((pe[t+8>>2]|0)>>>0<=r>>>0){pe[d>>2]=1154;pe[d+4>>2]=902;pe[d+8>>2]=1781;_r(b,1100,d)|0;yr(b,c)|0}if((me[(pe[t+4>>2]|0)+r>>0]|0|0)!=(i|0)){pe[f>>2]=1154;pe[f+4>>2]=3248;pe[f+8>>2]=1694;_r(b,1100,f)|0;yr(b,l)|0}}else{i=pe[v+20>>2]|0;while(1){r=i+-1|0;if(n>>>0>(pe[v+28+(r<<2)>>2]|0)>>>0)i=i+1|0;else break}r=(o>>>(32-i|0))+(pe[v+96+(r<<2)>>2]|0)|0;if(r>>>0<(pe[t>>2]|0)>>>0){r=ve[(pe[v+176>>2]|0)+(r<<1)>>1]|0;break}pe[p>>2]=1154;pe[p+4>>2]=3266;pe[p+8>>2]=1632;_r(b,1100,p)|0;yr(b,m)|0;g=0;be=y;return g|0}}while(0);pe[a>>2]=pe[a>>2]<>2]=(pe[g>>2]|0)-i;g=r;be=y;return g|0}function bt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+560|0;s=c+40|0;u=c+24|0;r=c;a=c+48|0;if(t>>>0>=33){pe[r>>2]=1154;pe[r+4>>2]=3190;pe[r+8>>2]=1634;_r(a,1100,r)|0;yr(a,c+16|0)|0}h=e+20|0;r=pe[h>>2]|0;if((r|0)>=(t|0)){o=e+16|0;a=o;o=pe[o>>2]|0;s=r;u=32-t|0;u=o>>>u;o=o<>2]=o;t=s-t|0;pe[h>>2]=t;be=c;return u|0}n=e+4|0;o=e+8|0;i=e+16|0;do{e=pe[n>>2]|0;if((e|0)==(pe[o>>2]|0))e=0;else{pe[n>>2]=e+1;e=me[e>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[u>>2]=1154;pe[u+4>>2]=3199;pe[u+8>>2]=1650;_r(a,1100,u)|0;yr(a,s)|0;r=pe[h>>2]|0}e=e<<32-r|pe[i>>2];pe[i>>2]=e}while((r|0)<(t|0));u=32-t|0;u=e>>>u;s=e<>2]=s;t=r-t|0;pe[h>>2]=t;be=c;return u|0}function gt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0;p=be;be=be+544|0;l=p+16|0;f=p;c=p+24|0;if((e|0)==0|t>>>0<62){d=0;be=p;return d|0}h=at(300,0)|0;if(!h){d=0;be=p;return d|0}pe[h>>2]=519686845;r=h+4|0;pe[r>>2]=0;i=h+8|0;pe[i>>2]=0;u=h+88|0;n=h+136|0;o=h+160|0;a=u;s=a+44|0;do{pe[a>>2]=0;a=a+4|0}while((a|0)<(s|0));de[u+44>>0]=0;m=h+184|0;a=h+208|0;s=h+232|0;v=h+252|0;pe[v>>2]=0;pe[v+4>>2]=0;pe[v+8>>2]=0;de[v+12>>0]=0;v=h+268|0;pe[v>>2]=0;pe[v+4>>2]=0;pe[v+8>>2]=0;de[v+12>>0]=0;v=h+284|0;pe[v>>2]=0;pe[v+4>>2]=0;pe[v+8>>2]=0;de[v+12>>0]=0;pe[n>>2]=0;pe[n+4>>2]=0;pe[n+8>>2]=0;pe[n+12>>2]=0;pe[n+16>>2]=0;de[n+20>>0]=0;pe[o>>2]=0;pe[o+4>>2]=0;pe[o+8>>2]=0;pe[o+12>>2]=0;pe[o+16>>2]=0;de[o+20>>0]=0;pe[m>>2]=0;pe[m+4>>2]=0;pe[m+8>>2]=0;pe[m+12>>2]=0;pe[m+16>>2]=0;de[m+20>>0]=0;pe[a>>2]=0;pe[a+4>>2]=0;pe[a+8>>2]=0;pe[a+12>>2]=0;pe[a+16>>2]=0;de[a+20>>0]=0;pe[s>>2]=0;pe[s+4>>2]=0;pe[s+8>>2]=0;pe[s+12>>2]=0;de[s+16>>0]=0;do{if(((t>>>0>=74?((me[e>>0]|0)<<8|(me[e+1>>0]|0)|0)==18552:0)?((me[e+2>>0]|0)<<8|(me[e+3>>0]|0))>>>0>=74:0)?((me[e+7>>0]|0)<<16|(me[e+6>>0]|0)<<24|(me[e+8>>0]|0)<<8|(me[e+9>>0]|0))>>>0<=t>>>0:0){pe[u>>2]=e;pe[r>>2]=e;pe[i>>2]=t;if(Pt(h)|0){r=pe[u>>2]|0;if((me[r+39>>0]|0)<<8|(me[r+40>>0]|0)){if(!(Mt(h)|0))break;if(!(Ct(h)|0))break;r=pe[u>>2]|0}if(!((me[r+55>>0]|0)<<8|(me[r+56>>0]|0))){v=h;be=p;return v|0}if(kt(h)|0?It(h)|0:0){v=h;be=p;return v|0}}}else d=7}while(0);if((d|0)==7)pe[u>>2]=0;Ft(h);if(!(h&7)){Oi[pe[104>>2]&1](h,0,0,1,pe[27]|0)|0;v=0;be=p;return v|0}else{pe[f>>2]=1154;pe[f+4>>2]=2499;pe[f+8>>2]=1516;_r(c,1100,f)|0;yr(c,l)|0;v=0;be=p;return v|0}return 0}function yt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+544|0;h=c;u=c+24|0;o=pe[e+88>>2]|0;s=(me[o+70+(n<<2)+1>>0]|0)<<16|(me[o+70+(n<<2)>>0]|0)<<24|(me[o+70+(n<<2)+2>>0]|0)<<8|(me[o+70+(n<<2)+3>>0]|0);a=n+1|0;if(a>>>0<(me[o+16>>0]|0)>>>0)o=(me[o+70+(a<<2)+1>>0]|0)<<16|(me[o+70+(a<<2)>>0]|0)<<24|(me[o+70+(a<<2)+2>>0]|0)<<8|(me[o+70+(a<<2)+3>>0]|0);else o=pe[e+8>>2]|0;if(o>>>0>s>>>0){u=e+4|0;u=pe[u>>2]|0;u=u+s|0;h=o-s|0;h=_t(e,u,h,t,r,i,n)|0;be=c;return h|0}pe[h>>2]=1154;pe[h+4>>2]=3704;pe[h+8>>2]=1792;_r(u,1100,h)|0;yr(u,c+16|0)|0;u=e+4|0;u=pe[u>>2]|0;u=u+s|0;h=o-s|0;h=_t(e,u,h,t,r,i,n)|0;be=c;return h|0}function _t(e,t,r,i,n,o,a){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;var s=0,u=0,h=0,c=0;c=pe[e+88>>2]|0;u=((me[c+12>>0]|0)<<8|(me[c+13>>0]|0))>>>a;h=((me[c+14>>0]|0)<<8|(me[c+15>>0]|0))>>>a;u=u>>>0>1?(u+3|0)>>>2:1;h=h>>>0>1?(h+3|0)>>>2:1;c=c+18|0;a=de[c>>0]|0;a=ge(a<<24>>24==0|a<<24>>24==9?8:16,u)|0;if(o)if((o&3|0)==0&a>>>0<=o>>>0)a=o;else{e=0;return e|0}if((ge(a,h)|0)>>>0>n>>>0){e=0;return e|0}o=(u+1|0)>>>1;s=(h+1|0)>>>1;if(!r){e=0;return e|0}pe[e+92>>2]=t;pe[e+96>>2]=t;pe[e+104>>2]=r;pe[e+100>>2]=t+r;pe[e+108>>2]=0;pe[e+112>>2]=0;switch(me[c>>0]|0|0){case 0:{Rt(e,i,n,a,u,h,o,s)|0;e=1;return e|0}case 4:case 6:case 5:case 3:case 2:{Ot(e,i,n,a,u,h,o,s)|0;e=1;return e|0}case 9:{Dt(e,i,n,a,u,h,o,s)|0;e=1;return e|0}case 8:case 7:{Lt(e,i,n,a,u,h,o,s)|0;e=1;return e|0}default:{e=0;return e|0}}return 0}function wt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ht(e,t,r)|0;be=i;return pe[r+4>>2]|0}function xt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ht(e,t,r)|0;be=i;return pe[r+8>>2]|0}function Tt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ht(e,t,r)|0;be=i;return pe[r+12>>2]|0}function St(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ht(e,t,r)|0;be=i;return pe[r+32>>2]|0}function Et(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,h=0;u=be;be=be+576|0;a=u+56|0;o=u+40|0;n=u+64|0;h=u;pe[h>>2]=40;ht(e,t,h)|0;i=(((pe[h+4>>2]|0)>>>r)+3|0)>>>2;t=(((pe[h+8>>2]|0)>>>r)+3|0)>>>2;r=h+32|0;e=pe[r+4>>2]|0;do{switch(pe[r>>2]|0){case 0:{if(!e)e=8;else s=13;break}case 1:{if(!e)s=12;else s=13;break}case 2:{if(!e)s=12;else s=13;break}case 3:{if(!e)s=12;else s=13;break}case 4:{if(!e)s=12;else s=13;break}case 5:{if(!e)s=12;else s=13;break}case 6:{if(!e)s=12;else s=13;break}case 7:{if(!e)s=12;else s=13;break}case 8:{if(!e)s=12;else s=13;break}case 9:{if(!e)e=8;else s=13;break}default:s=13}}while(0);if((s|0)==12)e=16;else if((s|0)==13){pe[o>>2]=1154;pe[o+4>>2]=2663;pe[o+8>>2]=1535;_r(n,1100,o)|0;yr(n,a)|0;e=0}h=ge(ge(t,i)|0,e)|0;be=u;return h|0}function At(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0;p=be;be=be+608|0;l=p+80|0;d=p+64|0;s=p+56|0;a=p+40|0;c=p+88|0;m=p;f=p+84|0;pe[m>>2]=40;ht(e,t,m)|0;u=(((pe[m+4>>2]|0)>>>n)+3|0)>>>2;m=m+32|0;o=pe[m+4>>2]|0;do{switch(pe[m>>2]|0){case 0:{if(!o)o=8;else h=13;break}case 1:{if(!o)h=12;else h=13;break}case 2:{if(!o)h=12;else h=13;break}case 3:{if(!o)h=12;else h=13;break}case 4:{if(!o)h=12;else h=13;break}case 5:{if(!o)h=12;else h=13;break}case 6:{if(!o)h=12;else h=13;break}case 7:{if(!o)h=12;else h=13;break}case 8:{if(!o)h=12;else h=13;break}case 9:{if(!o)o=8;else h=13;break}default:h=13}}while(0);if((h|0)==12)o=16;else if((h|0)==13){pe[a>>2]=1154;pe[a+4>>2]=2663;pe[a+8>>2]=1535;_r(c,1100,a)|0;yr(c,s)|0;o=0}s=ge(o,u)|0;a=gt(e,t)|0;pe[f>>2]=r;o=(a|0)==0;if(!(n>>>0>15|(i>>>0<8|o))?(pe[a>>2]|0)==519686845:0)yt(a,f,i,s,n)|0;if(o){be=p;return}if((pe[a>>2]|0)!=519686845){be=p;return}Ft(a);if(!(a&7)){Oi[pe[104>>2]&1](a,0,0,1,pe[27]|0)|0;be=p;return}else{pe[d>>2]=1154;pe[d+4>>2]=2499;pe[d+8>>2]=1516;_r(c,1100,d)|0;yr(c,l)|0;be=p;return}}function Pt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0;a=e+92|0;i=pe[e+4>>2]|0;o=e+88|0;n=pe[o>>2]|0;t=(me[n+68>>0]|0)<<8|(me[n+67>>0]|0)<<16|(me[n+69>>0]|0);r=i+t|0;n=(me[n+65>>0]|0)<<8|(me[n+66>>0]|0);if(!n){e=0;return e|0}pe[a>>2]=r;pe[e+96>>2]=r;pe[e+104>>2]=n;pe[e+100>>2]=i+(n+t);pe[e+108>>2]=0;pe[e+112>>2]=0;if(!(pt(a,e+116|0)|0)){e=0;return e|0}t=pe[o>>2]|0;do{if(!((me[t+39>>0]|0)<<8|(me[t+40>>0]|0))){if(!((me[t+55>>0]|0)<<8|(me[t+56>>0]|0))){e=0;return e|0}}else{if(!(pt(a,e+140|0)|0)){e=0;return e|0}if(pt(a,e+188|0)|0){t=pe[o>>2]|0;break}else{e=0;return e|0}}}while(0);if((me[t+55>>0]|0)<<8|(me[t+56>>0]|0)){if(!(pt(a,e+164|0)|0)){e=0;return e|0}if(!(pt(a,e+212|0)|0)){e=0;return e|0}}e=1;return e|0}function Mt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;p=be;be=be+592|0;u=p+16|0;s=p;a=p+72|0;d=p+24|0;i=e+88|0;t=pe[i>>2]|0;l=(me[t+39>>0]|0)<<8|(me[t+40>>0]|0);c=e+236|0;o=e+240|0;r=pe[o>>2]|0;if((r|0)!=(l|0)){if(r>>>0<=l>>>0){do{if((pe[e+244>>2]|0)>>>0>>0){if(nt(c,l,(r+1|0)==(l|0),4,0)|0){t=pe[o>>2]|0;break}de[e+248>>0]=1;d=0;be=p;return d|0}else t=r}while(0);Wr((pe[c>>2]|0)+(t<<2)|0,0,l-t<<2|0)|0;t=pe[i>>2]|0}pe[o>>2]=l}h=e+92|0;r=pe[e+4>>2]|0;i=(me[t+34>>0]|0)<<8|(me[t+33>>0]|0)<<16|(me[t+35>>0]|0);n=r+i|0;t=(me[t+37>>0]|0)<<8|(me[t+36>>0]|0)<<16|(me[t+38>>0]|0);if(!t){d=0;be=p;return d|0}pe[h>>2]=n;pe[e+96>>2]=n;pe[e+104>>2]=t;pe[e+100>>2]=r+(t+i);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[d+20>>2]=0;pe[d>>2]=0;pe[d+4>>2]=0;pe[d+8>>2]=0;pe[d+12>>2]=0;de[d+16>>0]=0;e=d+24|0;pe[d+44>>2]=0;pe[e>>2]=0;pe[e+4>>2]=0;pe[e+8>>2]=0;pe[e+12>>2]=0;de[e+16>>0]=0;if(pt(h,d)|0?(f=d+24|0,pt(h,f)|0):0){if(!(pe[o>>2]|0)){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(a,1100,s)|0;yr(a,u)|0}if(!l)t=1;else{i=0;n=0;o=0;t=0;a=0;e=0;s=0;r=pe[c>>2]|0;while(1){i=(vt(h,d)|0)+i&31;n=(vt(h,f)|0)+n&63;o=(vt(h,d)|0)+o&31;t=(vt(h,d)|0)+t|0;a=(vt(h,f)|0)+a&63;e=(vt(h,d)|0)+e&31;pe[r>>2]=n<<5|i<<11|o|t<<27|a<<21|e<<16;s=s+1|0;if((s|0)==(l|0)){t=1;break}else{t=t&31;r=r+4|0}}}}else t=0;ft(d+24|0);ft(d);d=t;be=p;return d|0}function Ct(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0;E=be;be=be+1024|0;s=E+16|0;a=E;o=E+504|0;S=E+480|0;x=E+284|0;T=E+88|0;w=E+24|0;n=pe[e+88>>2]|0;_=(me[n+47>>0]|0)<<8|(me[n+48>>0]|0);y=e+92|0;t=pe[e+4>>2]|0;r=(me[n+42>>0]|0)<<8|(me[n+41>>0]|0)<<16|(me[n+43>>0]|0);i=t+r|0;n=(me[n+45>>0]|0)<<8|(me[n+44>>0]|0)<<16|(me[n+46>>0]|0);if(!n){S=0;be=E;return S|0}pe[y>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[S+20>>2]=0;pe[S>>2]=0;pe[S+4>>2]=0;pe[S+8>>2]=0;pe[S+12>>2]=0;de[S+16>>0]=0;if(pt(y,S)|0){r=0;i=-3;n=-3;while(1){pe[x+(r<<2)>>2]=i;pe[T+(r<<2)>>2]=n;t=(i|0)>2;r=r+1|0;if((r|0)==49)break;else{i=t?-3:i+1|0;n=(t&1)+n|0}}t=w;r=t+64|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(r|0));g=e+252|0;r=e+256|0;t=pe[r>>2]|0;e:do{if((t|0)==(_|0))u=13;else{if(t>>>0<=_>>>0){do{if((pe[e+260>>2]|0)>>>0<_>>>0)if(nt(g,_,(t+1|0)==(_|0),4,0)|0){t=pe[r>>2]|0;break}else{de[e+264>>0]=1;t=0;break e}}while(0);Wr((pe[g>>2]|0)+(t<<2)|0,0,_-t<<2|0)|0}pe[r>>2]=_;u=13}}while(0);do{if((u|0)==13){if(!_){pe[a>>2]=1154;pe[a+4>>2]=903;pe[a+8>>2]=1781;_r(o,1100,a)|0;yr(o,s)|0;t=1;break}i=w+4|0;n=w+8|0;e=w+12|0;o=w+16|0;a=w+20|0;s=w+24|0;u=w+28|0;h=w+32|0;c=w+36|0;f=w+40|0;l=w+44|0;d=w+48|0;p=w+52|0;m=w+56|0;v=w+60|0;b=0;r=pe[g>>2]|0;while(1){t=0;do{A=vt(y,S)|0;g=t<<1;P=w+(g<<2)|0;pe[P>>2]=(pe[P>>2]|0)+(pe[x+(A<<2)>>2]|0)&3;g=w+((g|1)<<2)|0;pe[g>>2]=(pe[g>>2]|0)+(pe[T+(A<<2)>>2]|0)&3;t=t+1|0}while((t|0)!=8);pe[r>>2]=(me[1725+(pe[i>>2]|0)>>0]|0)<<2|(me[1725+(pe[w>>2]|0)>>0]|0)|(me[1725+(pe[n>>2]|0)>>0]|0)<<4|(me[1725+(pe[e>>2]|0)>>0]|0)<<6|(me[1725+(pe[o>>2]|0)>>0]|0)<<8|(me[1725+(pe[a>>2]|0)>>0]|0)<<10|(me[1725+(pe[s>>2]|0)>>0]|0)<<12|(me[1725+(pe[u>>2]|0)>>0]|0)<<14|(me[1725+(pe[h>>2]|0)>>0]|0)<<16|(me[1725+(pe[c>>2]|0)>>0]|0)<<18|(me[1725+(pe[f>>2]|0)>>0]|0)<<20|(me[1725+(pe[l>>2]|0)>>0]|0)<<22|(me[1725+(pe[d>>2]|0)>>0]|0)<<24|(me[1725+(pe[p>>2]|0)>>0]|0)<<26|(me[1725+(pe[m>>2]|0)>>0]|0)<<28|(me[1725+(pe[v>>2]|0)>>0]|0)<<30;b=b+1|0;if((b|0)==(_|0)){t=1;break}else r=r+4|0}}}while(0)}else t=0;ft(S);P=t;be=E;return P|0}function kt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0;l=be;be=be+560|0;u=l+16|0;s=l;a=l+48|0;f=l+24|0;n=pe[e+88>>2]|0;c=(me[n+55>>0]|0)<<8|(me[n+56>>0]|0);h=e+92|0;t=pe[e+4>>2]|0;r=(me[n+50>>0]|0)<<8|(me[n+49>>0]|0)<<16|(me[n+51>>0]|0);i=t+r|0;n=(me[n+53>>0]|0)<<8|(me[n+52>>0]|0)<<16|(me[n+54>>0]|0);if(!n){f=0;be=l;return f|0}pe[h>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[f+20>>2]=0;pe[f>>2]=0;pe[f+4>>2]=0;pe[f+8>>2]=0;pe[f+12>>2]=0;de[f+16>>0]=0;e:do{if(pt(h,f)|0){o=e+268|0;r=e+272|0;t=pe[r>>2]|0;if((t|0)!=(c|0)){if(t>>>0<=c>>>0){do{if((pe[e+276>>2]|0)>>>0>>0)if(nt(o,c,(t+1|0)==(c|0),2,0)|0){t=pe[r>>2]|0;break}else{de[e+280>>0]=1;t=0;break e}}while(0);Wr((pe[o>>2]|0)+(t<<1)|0,0,c-t<<1|0)|0}pe[r>>2]=c}if(!c){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(a,1100,s)|0;yr(a,u)|0;t=1;break}r=0;i=0;n=0;t=pe[o>>2]|0;while(1){u=vt(h,f)|0;r=u+r&255;i=(vt(h,f)|0)+i&255;$[t>>1]=i<<8|r;n=n+1|0;if((n|0)==(c|0)){t=1;break}else t=t+2|0}}else t=0}while(0);ft(f);f=t;be=l;return f|0}function It(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0;E=be;be=be+2432|0;s=E+16|0;a=E;o=E+1912|0;S=E+1888|0;x=E+988|0;T=E+88|0;w=E+24|0;n=pe[e+88>>2]|0;_=(me[n+63>>0]|0)<<8|(me[n+64>>0]|0);y=e+92|0;t=pe[e+4>>2]|0;r=(me[n+58>>0]|0)<<8|(me[n+57>>0]|0)<<16|(me[n+59>>0]|0);i=t+r|0;n=(me[n+61>>0]|0)<<8|(me[n+60>>0]|0)<<16|(me[n+62>>0]|0);if(!n){S=0;be=E;return S|0}pe[y>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[S+20>>2]=0;pe[S>>2]=0;pe[S+4>>2]=0;pe[S+8>>2]=0;pe[S+12>>2]=0;de[S+16>>0]=0;if(pt(y,S)|0){r=0;i=-7;n=-7;while(1){pe[x+(r<<2)>>2]=i;pe[T+(r<<2)>>2]=n;t=(i|0)>6;r=r+1|0;if((r|0)==225)break;else{i=t?-7:i+1|0;n=(t&1)+n|0}}t=w;r=t+64|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(r|0));g=e+284|0;r=_*3|0;i=e+288|0;t=pe[i>>2]|0;e:do{if((t|0)==(r|0))u=13;else{if(t>>>0<=r>>>0){do{if((pe[e+292>>2]|0)>>>0>>0)if(nt(g,r,(t+1|0)==(r|0),2,0)|0){t=pe[i>>2]|0;break}else{de[e+296>>0]=1;t=0;break e}}while(0);Wr((pe[g>>2]|0)+(t<<1)|0,0,r-t<<1|0)|0}pe[i>>2]=r;u=13}}while(0);do{if((u|0)==13){if(!_){pe[a>>2]=1154;pe[a+4>>2]=903;pe[a+8>>2]=1781;_r(o,1100,a)|0;yr(o,s)|0;t=1;break}i=w+4|0;n=w+8|0;e=w+12|0;o=w+16|0;a=w+20|0;s=w+24|0;u=w+28|0;h=w+32|0;c=w+36|0;f=w+40|0;l=w+44|0;d=w+48|0;p=w+52|0;m=w+56|0;v=w+60|0;b=0;r=pe[g>>2]|0;while(1){t=0;do{A=vt(y,S)|0;g=t<<1;P=w+(g<<2)|0;pe[P>>2]=(pe[P>>2]|0)+(pe[x+(A<<2)>>2]|0)&7;g=w+((g|1)<<2)|0;pe[g>>2]=(pe[g>>2]|0)+(pe[T+(A<<2)>>2]|0)&7;t=t+1|0}while((t|0)!=8);A=me[1729+(pe[a>>2]|0)>>0]|0;$[r>>1]=(me[1729+(pe[i>>2]|0)>>0]|0)<<3|(me[1729+(pe[w>>2]|0)>>0]|0)|(me[1729+(pe[n>>2]|0)>>0]|0)<<6|(me[1729+(pe[e>>2]|0)>>0]|0)<<9|(me[1729+(pe[o>>2]|0)>>0]|0)<<12|A<<15;P=me[1729+(pe[f>>2]|0)>>0]|0;$[r+2>>1]=(me[1729+(pe[s>>2]|0)>>0]|0)<<2|A>>>1|(me[1729+(pe[u>>2]|0)>>0]|0)<<5|(me[1729+(pe[h>>2]|0)>>0]|0)<<8|(me[1729+(pe[c>>2]|0)>>0]|0)<<11|P<<14;$[r+4>>1]=(me[1729+(pe[l>>2]|0)>>0]|0)<<1|P>>>2|(me[1729+(pe[d>>2]|0)>>0]|0)<<4|(me[1729+(pe[p>>2]|0)>>0]|0)<<7|(me[1729+(pe[m>>2]|0)>>0]|0)<<10|(me[1729+(pe[v>>2]|0)>>0]|0)<<13;b=b+1|0;if((b|0)==(_|0)){t=1;break}else r=r+6|0}}}while(0)}else t=0;ft(S);P=t;be=E;return P|0}function Rt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0,se=0,ue=0,he=0,ce=0,fe=0,le=0;ce=be;be=be+720|0;he=ce+184|0;se=ce+168|0;ae=ce+160|0;oe=ce+144|0;ne=ce+136|0;ie=ce+120|0;re=ce+112|0;ee=ce+96|0;$=ce+88|0;Q=ce+72|0;Z=ce+64|0;K=ce+48|0;J=ce+40|0;ue=ce+24|0;te=ce+16|0;W=ce;V=ce+208|0;Y=ce+192|0;N=e+240|0;U=pe[N>>2]|0;q=e+256|0;H=pe[q>>2]|0;r=de[(pe[e+88>>2]|0)+17>>0]|0;G=i>>>2;if(!(r<<24>>24)){be=ce;return 1}z=(s|0)==0;X=s+-1|0;R=(o&1|0)!=0;O=i<<1;D=e+92|0;L=e+116|0;F=e+140|0;j=e+236|0;B=a+-1|0;I=(n&1|0)!=0;k=e+188|0;E=e+252|0;A=G+1|0;P=G+2|0;M=G+3|0;C=B<<4;T=r&255;r=0;o=0;n=1;S=0;do{if(!z){w=pe[t+(S<<2)>>2]|0;x=0;while(1){g=x&1;u=(g|0)==0;b=(g<<5^32)+-16|0;g=(g<<1^2)+-1|0;_=u?a:-1;h=u?0:B;e=(x|0)==(X|0);y=R&e;if((h|0)!=(_|0)){v=R&e^1;m=u?w:w+C|0;while(1){if((n|0)==1)n=vt(D,L)|0|512;p=n&7;n=n>>>3;u=me[1823+p>>0]|0;e=0;do{l=(vt(D,F)|0)+o|0;d=l-U|0;o=d>>31;o=o&l|d&~o;if((pe[N>>2]|0)>>>0<=o>>>0){pe[W>>2]=1154;pe[W+4>>2]=903;pe[W+8>>2]=1781;_r(V,1100,W)|0;yr(V,te)|0}pe[Y+(e<<2)>>2]=pe[(pe[j>>2]|0)+(o<<2)>>2];e=e+1|0}while(e>>>0>>0);d=I&(h|0)==(B|0);if(y|d){l=0;do{c=ge(l,i)|0;e=m+c|0;u=(l|0)==0|v;f=l<<1;le=(vt(D,k)|0)+r|0;fe=le-H|0;r=fe>>31;r=r&le|fe&~r;do{if(d){if(!u){fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;break}pe[e>>2]=pe[Y+((me[1831+(p<<2)+f>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(V,1100,oe)|0;yr(V,ae)|0}pe[m+(c+4)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r}else{if(!u){fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;break}pe[e>>2]=pe[Y+((me[1831+(p<<2)+f>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[ie>>2]=1154;pe[ie+4>>2]=903;pe[ie+8>>2]=1781;_r(V,1100,ie)|0;yr(V,ne)|0}pe[m+(c+4)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;pe[m+(c+8)>>2]=pe[Y+((me[(f|1)+(1831+(p<<2))>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[se>>2]=1154;pe[se+4>>2]=903;pe[se+8>>2]=1781;_r(V,1100,se)|0;yr(V,he)|0}pe[m+(c+12)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2]}}while(0);l=l+1|0}while((l|0)!=2)}else{pe[m>>2]=pe[Y+((me[1831+(p<<2)>>0]|0)<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[ue>>2]=1154;pe[ue+4>>2]=903;pe[ue+8>>2]=1781;_r(V,1100,ue)|0;yr(V,J)|0}pe[m+4>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[m+8>>2]=pe[Y+((me[1831+(p<<2)+1>>0]|0)<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[K>>2]=1154;pe[K+4>>2]=903;pe[K+8>>2]=1781;_r(V,1100,K)|0;yr(V,Z)|0}pe[m+12>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[m+(G<<2)>>2]=pe[Y+((me[1831+(p<<2)+2>>0]|0)<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[Q>>2]=1154;pe[Q+4>>2]=903;pe[Q+8>>2]=1781;_r(V,1100,Q)|0;yr(V,$)|0}pe[m+(A<<2)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[m+(P<<2)>>2]=pe[Y+((me[1831+(p<<2)+3>>0]|0)<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[ee>>2]=1154;pe[ee+4>>2]=903;pe[ee+8>>2]=1781;_r(V,1100,ee)|0;yr(V,re)|0}pe[m+(M<<2)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2]}h=h+g|0;if((h|0)==(_|0))break;else m=m+b|0}}x=x+1|0;if((x|0)==(s|0))break;else w=w+O|0}}S=S+1|0}while((S|0)!=(T|0));be=ce;return 1}function Ot(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0,se=0,ue=0,he=0,ce=0,fe=0,le=0;fe=be;be=be+640|0;ue=fe+88|0;se=fe+72|0;ae=fe+64|0;oe=fe+48|0;ne=fe+40|0;ce=fe+24|0;he=fe+16|0;ie=fe;te=fe+128|0;re=fe+112|0;ee=fe+96|0;N=e+240|0;U=pe[N>>2]|0;q=e+256|0;Z=pe[q>>2]|0;Q=e+272|0;$=pe[Q>>2]|0;r=pe[e+88>>2]|0;z=(me[r+63>>0]|0)<<8|(me[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=fe;return 1}X=(s|0)==0;H=s+-1|0;G=i<<1;V=e+92|0;Y=e+116|0;W=a+-1|0;J=e+212|0;K=e+188|0;B=(n&1|0)==0;j=(o&1|0)==0;I=e+288|0;R=e+284|0;O=e+252|0;D=e+140|0;L=e+236|0;F=e+164|0;C=e+268|0;k=W<<5;P=r&255;r=0;n=0;o=0;e=0;u=1;M=0;do{if(!X){E=pe[t+(M<<2)>>2]|0;A=0;while(1){T=A&1;h=(T|0)==0;x=(T<<6^64)+-32|0;T=(T<<1^2)+-1|0;S=h?a:-1;c=h?0:W;if((c|0)!=(S|0)){w=j|(A|0)!=(H|0);_=h?E:E+k|0;while(1){if((u|0)==1)u=vt(V,Y)|0|512;y=u&7;u=u>>>3;f=me[1823+y>>0]|0;h=0;do{b=(vt(V,F)|0)+n|0;g=b-$|0;n=g>>31;n=n&b|g&~n;if((pe[Q>>2]|0)>>>0<=n>>>0){pe[ie>>2]=1154;pe[ie+4>>2]=903;pe[ie+8>>2]=1781;_r(te,1100,ie)|0;yr(te,he)|0}pe[ee+(h<<2)>>2]=ve[(pe[C>>2]|0)+(n<<1)>>1];h=h+1|0}while(h>>>0>>0);h=0;do{b=(vt(V,D)|0)+e|0;g=b-U|0;e=g>>31;e=e&b|g&~e;if((pe[N>>2]|0)>>>0<=e>>>0){pe[ce>>2]=1154;pe[ce+4>>2]=903;pe[ce+8>>2]=1781;_r(te,1100,ce)|0;yr(te,ne)|0}pe[re+(h<<2)>>2]=pe[(pe[L>>2]|0)+(e<<2)>>2];h=h+1|0}while(h>>>0>>0);g=B|(c|0)!=(W|0);v=0;b=_;while(1){m=w|(v|0)==0;p=v<<1;l=0;d=b;while(1){f=(vt(V,J)|0)+r|0;h=f-z|0;r=h>>31;r=r&f|h&~r;h=(vt(V,K)|0)+o|0;f=h-Z|0;o=f>>31;o=o&h|f&~o;if((g|(l|0)==0)&m){h=me[l+p+(1831+(y<<2))>>0]|0;f=r*3|0;if((pe[I>>2]|0)>>>0<=f>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(te,1100,oe)|0;yr(te,ae)|0}le=pe[R>>2]|0;pe[d>>2]=(ve[le+(f<<1)>>1]|0)<<16|pe[ee+(h<<2)>>2];pe[d+4>>2]=(ve[le+(f+2<<1)>>1]|0)<<16|(ve[le+(f+1<<1)>>1]|0);pe[d+8>>2]=pe[re+(h<<2)>>2];if((pe[q>>2]|0)>>>0<=o>>>0){pe[se>>2]=1154;pe[se+4>>2]=903;pe[se+8>>2]=1781;_r(te,1100,se)|0;yr(te,ue)|0}pe[d+12>>2]=pe[(pe[O>>2]|0)+(o<<2)>>2]}l=l+1|0;if((l|0)==2)break;else d=d+16|0}v=v+1|0;if((v|0)==2)break;else b=b+i|0}c=c+T|0;if((c|0)==(S|0))break;else _=_+x|0}}A=A+1|0;if((A|0)==(s|0))break;else E=E+G|0}}M=M+1|0}while((M|0)!=(P|0));be=fe;return 1}function Dt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0;Z=be;be=be+608|0;W=Z+64|0;Y=Z+48|0;V=Z+40|0;K=Z+24|0;J=Z+16|0;G=Z;H=Z+88|0;q=Z+72|0;O=e+272|0;D=pe[O>>2]|0;r=pe[e+88>>2]|0;L=(me[r+63>>0]|0)<<8|(me[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=Z;return 1}F=(s|0)==0;j=s+-1|0;B=i<<1;N=e+92|0;U=e+116|0;z=a+-1|0;X=e+212|0;R=(o&1|0)==0;C=e+288|0;k=e+284|0;I=e+164|0;P=e+268|0;M=z<<4;A=r&255;E=(n&1|0)!=0;r=0;o=0;e=1;S=0;do{if(!F){x=pe[t+(S<<2)>>2]|0;T=0;while(1){_=T&1;n=(_|0)==0;y=(_<<5^32)+-16|0;_=(_<<1^2)+-1|0;w=n?a:-1;u=n?0:z;if((u|0)!=(w|0)){g=R|(T|0)!=(j|0);b=n?x:x+M|0;while(1){if((e|0)==1)e=vt(N,U)|0|512;v=e&7;e=e>>>3;h=me[1823+v>>0]|0;n=0;do{p=(vt(N,I)|0)+o|0;m=p-D|0;o=m>>31;o=o&p|m&~o;if((pe[O>>2]|0)>>>0<=o>>>0){pe[G>>2]=1154;pe[G+4>>2]=903;pe[G+8>>2]=1781;_r(H,1100,G)|0;yr(H,J)|0}pe[q+(n<<2)>>2]=ve[(pe[P>>2]|0)+(o<<1)>>1];n=n+1|0}while(n>>>0>>0);m=(u|0)==(z|0)&E;d=0;p=b;while(1){l=g|(d|0)==0;f=d<<1;n=(vt(N,X)|0)+r|0;c=n-L|0;h=c>>31;h=h&n|c&~h;if(l){r=me[1831+(v<<2)+f>>0]|0;n=h*3|0;if((pe[C>>2]|0)>>>0<=n>>>0){pe[K>>2]=1154;pe[K+4>>2]=903;pe[K+8>>2]=1781;_r(H,1100,K)|0;yr(H,V)|0}c=pe[k>>2]|0;pe[p>>2]=(ve[c+(n<<1)>>1]|0)<<16|pe[q+(r<<2)>>2];pe[p+4>>2]=(ve[c+(n+2<<1)>>1]|0)<<16|(ve[c+(n+1<<1)>>1]|0)}c=p+8|0;n=(vt(N,X)|0)+h|0;h=n-L|0;r=h>>31;r=r&n|h&~r;if(!(m|l^1)){n=me[(f|1)+(1831+(v<<2))>>0]|0;h=r*3|0;if((pe[C>>2]|0)>>>0<=h>>>0){pe[Y>>2]=1154;pe[Y+4>>2]=903;pe[Y+8>>2]=1781;_r(H,1100,Y)|0;yr(H,W)|0}l=pe[k>>2]|0;pe[c>>2]=(ve[l+(h<<1)>>1]|0)<<16|pe[q+(n<<2)>>2];pe[p+12>>2]=(ve[l+(h+2<<1)>>1]|0)<<16|(ve[l+(h+1<<1)>>1]|0)}d=d+1|0;if((d|0)==2)break;else p=p+i|0}u=u+_|0;if((u|0)==(w|0))break;else b=b+y|0}}T=T+1|0;if((T|0)==(s|0))break;else x=x+B|0}}S=S+1|0}while((S|0)!=(A|0));be=Z;return 1}function Lt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0;ae=be;be=be+640|0;ie=ae+88|0;re=ae+72|0;te=ae+64|0;ee=ae+48|0;$=ae+40|0;oe=ae+24|0;ne=ae+16|0;Q=ae;Z=ae+128|0;J=ae+112|0;K=ae+96|0;N=e+272|0;U=pe[N>>2]|0;r=pe[e+88>>2]|0;z=(me[r+63>>0]|0)<<8|(me[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=ae;return 1}X=(s|0)==0;q=s+-1|0;H=i<<1;G=e+92|0;V=e+116|0;Y=a+-1|0;W=e+212|0;B=(n&1|0)==0;j=(o&1|0)==0;D=e+288|0;L=e+284|0;F=e+164|0;R=e+268|0;O=Y<<5;k=r&255;r=0;n=0;o=0;e=0;u=1;I=0;do{if(!X){M=pe[t+(I<<2)>>2]|0;C=0;while(1){A=C&1;h=(A|0)==0;E=(A<<6^64)+-32|0;A=(A<<1^2)+-1|0;P=h?a:-1;c=h?0:Y;if((c|0)!=(P|0)){S=j|(C|0)!=(q|0);T=h?M:M+O|0;while(1){if((u|0)==1)u=vt(G,V)|0|512;x=u&7;u=u>>>3;f=me[1823+x>>0]|0;h=0;do{_=(vt(G,F)|0)+e|0;w=_-U|0;e=w>>31;e=e&_|w&~e;if((pe[N>>2]|0)>>>0<=e>>>0){pe[Q>>2]=1154;pe[Q+4>>2]=903;pe[Q+8>>2]=1781;_r(Z,1100,Q)|0;yr(Z,ne)|0}pe[J+(h<<2)>>2]=ve[(pe[R>>2]|0)+(e<<1)>>1];h=h+1|0}while(h>>>0>>0);h=0;do{_=(vt(G,F)|0)+n|0;w=_-U|0;n=w>>31;n=n&_|w&~n;if((pe[N>>2]|0)>>>0<=n>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(Z,1100,oe)|0;yr(Z,$)|0}pe[K+(h<<2)>>2]=ve[(pe[R>>2]|0)+(n<<1)>>1];h=h+1|0}while(h>>>0>>0);w=B|(c|0)!=(Y|0);y=0;_=T;while(1){g=S|(y|0)==0;b=y<<1;m=0;v=_;while(1){p=(vt(G,W)|0)+o|0;d=p-z|0;o=d>>31;o=o&p|d&~o;d=(vt(G,W)|0)+r|0;p=d-z|0;r=p>>31;r=r&d|p&~r;if((w|(m|0)==0)&g){d=me[m+b+(1831+(x<<2))>>0]|0;p=o*3|0;h=pe[D>>2]|0;if(h>>>0<=p>>>0){pe[ee>>2]=1154;pe[ee+4>>2]=903;pe[ee+8>>2]=1781;_r(Z,1100,ee)|0;yr(Z,te)|0;h=pe[D>>2]|0}f=pe[L>>2]|0;l=r*3|0;if(h>>>0>l>>>0)h=f;else{pe[re>>2]=1154;pe[re+4>>2]=903;pe[re+8>>2]=1781;_r(Z,1100,re)|0;yr(Z,ie)|0;h=pe[L>>2]|0}pe[v>>2]=(ve[f+(p<<1)>>1]|0)<<16|pe[J+(d<<2)>>2];pe[v+4>>2]=(ve[f+(p+2<<1)>>1]|0)<<16|(ve[f+(p+1<<1)>>1]|0);pe[v+8>>2]=(ve[h+(l<<1)>>1]|0)<<16|pe[K+(d<<2)>>2];pe[v+12>>2]=(ve[h+(l+2<<1)>>1]|0)<<16|(ve[h+(l+1<<1)>>1]|0)}m=m+1|0;if((m|0)==2)break;else v=v+16|0}y=y+1|0;if((y|0)==2)break;else _=_+i|0}c=c+A|0;if((c|0)==(P|0))break;else T=T+E|0}}C=C+1|0;if((C|0)==(s|0))break;else M=M+H|0}}I=I+1|0}while((I|0)!=(k|0));be=ae;return 1}function Ft(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0;l=be;be=be+608|0;f=l+88|0;c=l+72|0;u=l+64|0;s=l+48|0;o=l+40|0;a=l+24|0;n=l+16|0;i=l;h=l+96|0;pe[e>>2]=0;t=e+284|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[i>>2]=1154;pe[i+4>>2]=2499;pe[i+8>>2]=1516;_r(h,1100,i)|0;yr(h,n)|0}pe[t>>2]=0;pe[e+288>>2]=0;pe[e+292>>2]=0}de[e+296>>0]=0;t=e+268|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[a>>2]=1154;pe[a+4>>2]=2499;pe[a+8>>2]=1516;_r(h,1100,a)|0;yr(h,o)|0}pe[t>>2]=0;pe[e+272>>2]=0;pe[e+276>>2]=0}de[e+280>>0]=0;t=e+252|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[s>>2]=1154;pe[s+4>>2]=2499;pe[s+8>>2]=1516;_r(h,1100,s)|0;yr(h,u)|0}pe[t>>2]=0;pe[e+256>>2]=0;pe[e+260>>2]=0}de[e+264>>0]=0;t=e+236|0;r=pe[t>>2]|0;if(!r){f=e+248|0;de[f>>0]=0;f=e+212|0;ft(f);f=e+188|0;ft(f);f=e+164|0;ft(f);f=e+140|0;ft(f);f=e+116|0;ft(f);be=l;return}if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[c>>2]=1154;pe[c+4>>2]=2499;pe[c+8>>2]=1516;_r(h,1100,c)|0;yr(h,f)|0}pe[t>>2]=0;pe[e+240>>2]=0;pe[e+244>>2]=0;f=e+248|0;de[f>>0]=0;f=e+212|0;ft(f);f=e+188|0;ft(f);f=e+164|0;ft(f);f=e+140|0;ft(f);f=e+116|0;ft(f);be=l;return}function jt(e,t){e=e|0;t=t|0;var r=0;r=be;be=be+16|0;pe[r>>2]=t;t=pe[63]|0;wr(t,e,r)|0;br(10,t)|0;Xe()}function Bt(){var e=0,t=0;e=be;be=be+16|0;if(!(Fe(200,2)|0)){t=De(pe[49]|0)|0;be=e;return t|0}else jt(2090,e);return 0}function Nt(e){e=e|0;zr(e);return}function Ut(e){e=e|0;var t=0;t=be;be=be+16|0;Ii[e&3]();jt(2139,t)}function zt(){var e=0,t=0;e=Bt()|0;if(((e|0)!=0?(t=pe[e>>2]|0,(t|0)!=0):0)?(e=t+48|0,(pe[e>>2]&-256|0)==1126902528?(pe[e+4>>2]|0)==1129074247:0):0)Ut(pe[t+12>>2]|0);t=pe[28]|0;pe[28]=t+0;Ut(t)}function Xt(e){e=e|0;return}function qt(e){e=e|0;return}function Ht(e){e=e|0;return}function Gt(e){e=e|0;return}function Vt(e){e=e|0;Nt(e);return}function Yt(e){e=e|0;Nt(e);return}function Wt(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;a=be;be=be+64|0;o=a;if((e|0)!=(t|0))if((t|0)!=0?(n=Qt(t,24,40,0)|0,(n|0)!=0):0){t=o;i=t+56|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(i|0));pe[o>>2]=n;pe[o+8>>2]=e;pe[o+12>>2]=-1;pe[o+48>>2]=1;Di[pe[(pe[n>>2]|0)+28>>2]&3](n,o,pe[r>>2]|0,1);if((pe[o+24>>2]|0)==1){pe[r>>2]=pe[o+16>>2];t=1}else t=0}else t=0;else t=1;be=a;return t|0}function Jt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0;e=t+16|0;n=pe[e>>2]|0;do{if(n){if((n|0)!=(r|0)){i=t+36|0;pe[i>>2]=(pe[i>>2]|0)+1;pe[t+24>>2]=2;de[t+54>>0]=1;break}e=t+24|0;if((pe[e>>2]|0)==2)pe[e>>2]=i}else{pe[e>>2]=r;pe[t+24>>2]=i;pe[t+36>>2]=1}}while(0);return}function Kt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;if((e|0)==(pe[t+8>>2]|0))Jt(0,t,r,i);return}function Zt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;if((e|0)==(pe[t+8>>2]|0))Jt(0,t,r,i);else{e=pe[e+8>>2]|0;Di[pe[(pe[e>>2]|0)+28>>2]&3](e,t,r,i)}return}function Qt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0;d=be;be=be+64|0;l=d;f=pe[e>>2]|0;c=e+(pe[f+-8>>2]|0)|0;f=pe[f+-4>>2]|0;pe[l>>2]=r;pe[l+4>>2]=e;pe[l+8>>2]=t;pe[l+12>>2]=i;i=l+16|0;e=l+20|0;t=l+24|0;n=l+28|0;o=l+32|0;a=l+40|0;s=(f|0)==(r|0);u=i;h=u+36|0;do{pe[u>>2]=0;u=u+4|0}while((u|0)<(h|0));$[i+36>>1]=0;de[i+38>>0]=0;e:do{if(s){pe[l+48>>2]=1;Ri[pe[(pe[r>>2]|0)+20>>2]&3](r,l,c,c,1,0);i=(pe[t>>2]|0)==1?c:0}else{Pi[pe[(pe[f>>2]|0)+24>>2]&3](f,l,c,1,0);switch(pe[l+36>>2]|0){case 0:{i=(pe[a>>2]|0)==1&(pe[n>>2]|0)==1&(pe[o>>2]|0)==1?pe[e>>2]|0:0;break e}case 1:break;default:{i=0;break e}}if((pe[t>>2]|0)!=1?!((pe[a>>2]|0)==0&(pe[n>>2]|0)==1&(pe[o>>2]|0)==1):0){i=0;break}i=pe[i>>2]|0}}while(0);be=d;return i|0}function $t(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;de[t+53>>0]=1;do{if((pe[t+4>>2]|0)==(i|0)){de[t+52>>0]=1;i=t+16|0;e=pe[i>>2]|0;if(!e){pe[i>>2]=r;pe[t+24>>2]=n;pe[t+36>>2]=1;if(!((n|0)==1?(pe[t+48>>2]|0)==1:0))break;de[t+54>>0]=1;break}if((e|0)!=(r|0)){n=t+36|0;pe[n>>2]=(pe[n>>2]|0)+1;de[t+54>>0]=1;break}e=t+24|0;i=pe[e>>2]|0;if((i|0)==2){pe[e>>2]=n;i=n}if((i|0)==1?(pe[t+48>>2]|0)==1:0)de[t+54>>0]=1}}while(0);return}function er(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0;e:do{if((e|0)==(pe[t+8>>2]|0)){if((pe[t+4>>2]|0)==(r|0)?(o=t+28|0,(pe[o>>2]|0)!=1):0)pe[o>>2]=i}else{if((e|0)!=(pe[t>>2]|0)){s=pe[e+8>>2]|0;Pi[pe[(pe[s>>2]|0)+24>>2]&3](s,t,r,i,n);break}if((pe[t+16>>2]|0)!=(r|0)?(a=t+20|0,(pe[a>>2]|0)!=(r|0)):0){pe[t+32>>2]=i;i=t+44|0;if((pe[i>>2]|0)==4)break;o=t+52|0;de[o>>0]=0;u=t+53|0;de[u>>0]=0;e=pe[e+8>>2]|0;Ri[pe[(pe[e>>2]|0)+20>>2]&3](e,t,r,r,1,n);if(de[u>>0]|0){if(!(de[o>>0]|0)){o=1;s=13}}else{o=0;s=13}do{if((s|0)==13){pe[a>>2]=r;u=t+40|0;pe[u>>2]=(pe[u>>2]|0)+1;if((pe[t+36>>2]|0)==1?(pe[t+24>>2]|0)==2:0){de[t+54>>0]=1;if(o)break}else s=16;if((s|0)==16?o:0)break;pe[i>>2]=4;break e}}while(0);pe[i>>2]=3;break}if((i|0)==1)pe[t+32>>2]=1}}while(0);return}function tr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0;do{if((e|0)==(pe[t+8>>2]|0)){if((pe[t+4>>2]|0)==(r|0)?(a=t+28|0,(pe[a>>2]|0)!=1):0)pe[a>>2]=i}else if((e|0)==(pe[t>>2]|0)){if((pe[t+16>>2]|0)!=(r|0)?(o=t+20|0,(pe[o>>2]|0)!=(r|0)):0){pe[t+32>>2]=i;pe[o>>2]=r;n=t+40|0;pe[n>>2]=(pe[n>>2]|0)+1;if((pe[t+36>>2]|0)==1?(pe[t+24>>2]|0)==2:0)de[t+54>>0]=1;pe[t+44>>2]=4;break}if((i|0)==1)pe[t+32>>2]=1}}while(0);return}function rr(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;if((e|0)==(pe[t+8>>2]|0))$t(0,t,r,i,n);else{e=pe[e+8>>2]|0;Ri[pe[(pe[e>>2]|0)+20>>2]&3](e,t,r,i,n,o)}return}function ir(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;if((e|0)==(pe[t+8>>2]|0))$t(0,t,r,i,n);return}function nr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;n=be;be=be+16|0;i=n;pe[i>>2]=pe[r>>2];e=Ai[pe[(pe[e>>2]|0)+16>>2]&7](e,t,i)|0;if(e)pe[r>>2]=pe[i>>2];be=n;return e&1|0}function or(e){e=e|0;if(!e)e=0;else e=(Qt(e,24,72,0)|0)!=0;return e&1|0}function ar(){var e=0,t=0,r=0,i=0,n=0,o=0,a=0,s=0;n=be;be=be+48|0;a=n+32|0;r=n+24|0;s=n+16|0;o=n;n=n+36|0;e=Bt()|0;if((e|0)!=0?(i=pe[e>>2]|0,(i|0)!=0):0){e=i+48|0;t=pe[e>>2]|0;e=pe[e+4>>2]|0;if(!((t&-256|0)==1126902528&(e|0)==1129074247)){pe[r>>2]=pe[51];jt(2368,r)}if((t|0)==1126902529&(e|0)==1129074247)e=pe[i+44>>2]|0;else e=i+80|0;pe[n>>2]=e;i=pe[i>>2]|0;e=pe[i+4>>2]|0;if(Ai[pe[(pe[8>>2]|0)+16>>2]&7](8,i,n)|0){s=pe[n>>2]|0;n=pe[51]|0;s=Ci[pe[(pe[s>>2]|0)+8>>2]&1](s)|0;pe[o>>2]=n;pe[o+4>>2]=e;pe[o+8>>2]=s;jt(2282,o)}else{pe[s>>2]=pe[51];pe[s+4>>2]=e;jt(2327,s)}}jt(2406,a)}function sr(){var e=0;e=be;be=be+16|0;if(!(je(196,6)|0)){be=e;return}else jt(2179,e)}function ur(e){e=e|0;var t=0;t=be;be=be+16|0;zr(e);if(!(Ue(pe[49]|0,0)|0)){be=t;return}else jt(2229,t)}function hr(e){e=e|0;var t=0,r=0;t=0;while(1){if((me[2427+t>>0]|0)==(e|0)){r=2;break}t=t+1|0;if((t|0)==87){t=87;e=2515;r=5;break}}if((r|0)==2)if(!t)e=2515;else{e=2515;r=5}if((r|0)==5)while(1){r=e;while(1){e=r+1|0;if(!(de[r>>0]|0))break;else r=e}t=t+-1|0;if(!t)break;else r=5}return e|0}function cr(){var e=0;if(!(pe[52]|0))e=264;else{e=(Le()|0)+60|0;e=pe[e>>2]|0}return e|0}function fr(e){e=e|0;var t=0;if(e>>>0>4294963200){t=cr()|0;pe[t>>2]=0-e;e=-1}return e|0}function lr(e,t){e=+e;t=t|0;var r=0,i=0,n=0;ee[te>>3]=e;r=pe[te>>2]|0;i=pe[te+4>>2]|0;n=Jr(r|0,i|0,52)|0;n=n&2047;switch(n|0){case 0:{if(e!=0.0){e=+lr(e*18446744073709552.0e3,t);r=(pe[t>>2]|0)+-64|0}else r=0;pe[t>>2]=r;break}case 2047:break;default:{pe[t>>2]=n+-1022;pe[te>>2]=r;pe[te+4>>2]=i&-2146435073|1071644672;e=+ee[te>>3]}}return+e}function dr(e,t){e=+e;t=t|0;return+ +lr(e,t)}function pr(e,t,r){e=e|0;t=t|0;r=r|0;do{if(e){if(t>>>0<128){de[e>>0]=t;e=1;break}if(t>>>0<2048){de[e>>0]=t>>>6|192;de[e+1>>0]=t&63|128;e=2;break}if(t>>>0<55296|(t&-8192|0)==57344){de[e>>0]=t>>>12|224;de[e+1>>0]=t>>>6&63|128;de[e+2>>0]=t&63|128;e=3;break}if((t+-65536|0)>>>0<1048576){de[e>>0]=t>>>18|240;de[e+1>>0]=t>>>12&63|128;de[e+2>>0]=t>>>6&63|128;de[e+3>>0]=t&63|128;e=4;break}else{e=cr()|0;pe[e>>2]=84;e=-1;break}}else e=1}while(0);return e|0}function mr(e,t){e=e|0;t=t|0;if(!e)e=0;else e=pr(e,t,0)|0;return e|0}function vr(e){e=e|0;var t=0,r=0;do{if(e){if((pe[e+76>>2]|0)<=-1){t=Or(e)|0;break}r=(Sr(e)|0)==0;t=Or(e)|0;if(!r)Er(e)}else{if(!(pe[65]|0))t=0;else t=vr(pe[65]|0)|0;ze(236);e=pe[58]|0;if(e)do{if((pe[e+76>>2]|0)>-1)r=Sr(e)|0;else r=0;if((pe[e+20>>2]|0)>>>0>(pe[e+28>>2]|0)>>>0)t=Or(e)|0|t;if(r)Er(e);e=pe[e+56>>2]|0}while((e|0)!=0);Be(236)}}while(0);return t|0}function br(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0;if((pe[t+76>>2]|0)>=0?(Sr(t)|0)!=0:0){if((de[t+75>>0]|0)!=(e|0)?(i=t+20|0,n=pe[i>>2]|0,n>>>0<(pe[t+16>>2]|0)>>>0):0){pe[i>>2]=n+1;de[n>>0]=e;r=e&255}else r=Ar(t,e)|0;Er(t)}else a=3;do{if((a|0)==3){if((de[t+75>>0]|0)!=(e|0)?(o=t+20|0,r=pe[o>>2]|0,r>>>0<(pe[t+16>>2]|0)>>>0):0){pe[o>>2]=r+1;de[r>>0]=e;r=e&255;break}r=Ar(t,e)|0}}while(0);return r|0}function gr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;i=r+16|0;n=pe[i>>2]|0;if(!n)if(!(Ir(r)|0)){n=pe[i>>2]|0;o=4}else i=0;else o=4;e:do{if((o|0)==4){a=r+20|0;o=pe[a>>2]|0;if((n-o|0)>>>0>>0){i=Ai[pe[r+36>>2]&7](r,e,t)|0;break}t:do{if((de[r+75>>0]|0)>-1){i=t;while(1){if(!i){n=o;i=0;break t}n=i+-1|0;if((de[e+n>>0]|0)==10)break;else i=n}if((Ai[pe[r+36>>2]&7](r,e,i)|0)>>>0>>0)break e;t=t-i|0;e=e+i|0;n=pe[a>>2]|0}else{n=o;i=0}}while(0);Qr(n|0,e|0,t|0)|0;pe[a>>2]=(pe[a>>2]|0)+t;i=i+t|0}}while(0);return i|0}function yr(e,t){e=e|0;t=t|0;var r=0,i=0;r=be;be=be+16|0;i=r;pe[i>>2]=t;t=wr(pe[64]|0,e,i)|0;be=r;return t|0}function _r(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;i=be;be=be+16|0;n=i;pe[n>>2]=r;r=Tr(e,t,n)|0;be=i;return r|0}function wr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0;m=be;be=be+224|0;f=m+120|0;p=m+80|0;d=m;l=m+136|0;i=p;n=i+40|0;do{pe[i>>2]=0;i=i+4|0}while((i|0)<(n|0));pe[f>>2]=pe[r>>2];if((Dr(0,t,f,d,p)|0)<0)r=-1;else{if((pe[e+76>>2]|0)>-1)h=Sr(e)|0;else h=0;r=pe[e>>2]|0;c=r&32;if((de[e+74>>0]|0)<1)pe[e>>2]=r&-33;r=e+48|0;if(!(pe[r>>2]|0)){n=e+44|0;o=pe[n>>2]|0;pe[n>>2]=l;a=e+28|0;pe[a>>2]=l;s=e+20|0;pe[s>>2]=l;pe[r>>2]=80;u=e+16|0;pe[u>>2]=l+80;i=Dr(e,t,f,d,p)|0;if(o){Ai[pe[e+36>>2]&7](e,0,0)|0;i=(pe[s>>2]|0)==0?-1:i;pe[n>>2]=o;pe[r>>2]=0;pe[u>>2]=0;pe[a>>2]=0;pe[s>>2]=0}}else i=Dr(e,t,f,d,p)|0;r=pe[e>>2]|0;pe[e>>2]=r|c;if(h)Er(e);r=(r&32|0)==0?i:-1}be=m;return r|0}function xr(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+128|0;n=c+112|0;h=c;o=h;a=268;s=o+112|0;do{pe[o>>2]=pe[a>>2];o=o+4|0;a=a+4|0}while((o|0)<(s|0));if((t+-1|0)>>>0>2147483646)if(!t){t=1;u=4}else{t=cr()|0;pe[t>>2]=75;t=-1}else{n=e;u=4}if((u|0)==4){u=-2-n|0;u=t>>>0>u>>>0?u:t;pe[h+48>>2]=u;e=h+20|0;pe[e>>2]=n;pe[h+44>>2]=n;t=n+u|0;n=h+16|0;pe[n>>2]=t;pe[h+28>>2]=t;t=wr(h,r,i)|0;if(u){r=pe[e>>2]|0;de[r+(((r|0)==(pe[n>>2]|0))<<31>>31)>>0]=0}}be=c;return t|0}function Tr(e,t,r){e=e|0;t=t|0;r=r|0;return xr(e,2147483647,t,r)|0}function Sr(e){e=e|0;return 0}function Er(e){e=e|0;return}function Ar(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0;u=be;be=be+16|0;s=u;a=t&255;de[s>>0]=a;i=e+16|0;n=pe[i>>2]|0;if(!n)if(!(Ir(e)|0)){n=pe[i>>2]|0;o=4}else r=-1;else o=4;do{if((o|0)==4){i=e+20|0;o=pe[i>>2]|0;if(o>>>0>>0?(r=t&255,(r|0)!=(de[e+75>>0]|0)):0){pe[i>>2]=o+1;de[o>>0]=a;break}if((Ai[pe[e+36>>2]&7](e,s,1)|0)==1)r=me[s>>0]|0;else r=-1}}while(0);be=u;return r|0}function Pr(e){e=e|0;var t=0,r=0;t=be;be=be+16|0;r=t;pe[r>>2]=pe[e+60>>2];e=fr(Ae(6,r|0)|0)|0;be=t;return e|0}function Mr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0;n=be;be=be+32|0;o=n;i=n+20|0;pe[o>>2]=pe[e+60>>2];pe[o+4>>2]=0;pe[o+8>>2]=t;pe[o+12>>2]=i;pe[o+16>>2]=r;if((fr(Ge(140,o|0)|0)|0)<0){pe[i>>2]=-1;e=-1}else e=pe[i>>2]|0;be=n;return e|0}function Cr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;p=be;be=be+48|0;f=p+16|0;c=p;i=p+32|0;l=e+28|0;n=pe[l>>2]|0;pe[i>>2]=n;d=e+20|0;n=(pe[d>>2]|0)-n|0;pe[i+4>>2]=n;pe[i+8>>2]=t;pe[i+12>>2]=r;u=e+60|0;h=e+44|0;t=2;n=n+r|0;while(1){if(!(pe[52]|0)){pe[f>>2]=pe[u>>2];pe[f+4>>2]=i;pe[f+8>>2]=t;a=fr(Ve(146,f|0)|0)|0}else{qe(7,e|0);pe[c>>2]=pe[u>>2];pe[c+4>>2]=i;pe[c+8>>2]=t;a=fr(Ve(146,c|0)|0)|0;Se(0)}if((n|0)==(a|0)){n=6;break}if((a|0)<0){n=8;break}n=n-a|0;o=pe[i+4>>2]|0;if(a>>>0<=o>>>0)if((t|0)==2){pe[l>>2]=(pe[l>>2]|0)+a;s=o;t=2}else s=o;else{s=pe[h>>2]|0;pe[l>>2]=s;pe[d>>2]=s;s=pe[i+12>>2]|0;a=a-o|0;i=i+8|0;t=t+-1|0}pe[i>>2]=(pe[i>>2]|0)+a;pe[i+4>>2]=s-a}if((n|0)==6){f=pe[h>>2]|0;pe[e+16>>2]=f+(pe[e+48>>2]|0);e=f;pe[l>>2]=e;pe[d>>2]=e}else if((n|0)==8){pe[e+16>>2]=0;pe[l>>2]=0;pe[d>>2]=0;pe[e>>2]=pe[e>>2]|32;if((t|0)==2)r=0;else r=r-(pe[i+4>>2]|0)|0}be=p;return r|0}function kr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;n=be;be=be+80|0;i=n;pe[e+36>>2]=3;if((pe[e>>2]&64|0)==0?(pe[i>>2]=pe[e+60>>2],pe[i+4>>2]=21505,pe[i+8>>2]=n+12,(Ee(54,i|0)|0)!=0):0)de[e+75>>0]=-1;i=Cr(e,t,r)|0;be=n;return i|0}function Ir(e){e=e|0;var t=0,r=0;t=e+74|0;r=de[t>>0]|0;de[t>>0]=r+255|r;t=pe[e>>2]|0;if(!(t&8)){pe[e+8>>2]=0;pe[e+4>>2]=0;t=pe[e+44>>2]|0;pe[e+28>>2]=t;pe[e+20>>2]=t;pe[e+16>>2]=t+(pe[e+48>>2]|0);t=0}else{pe[e>>2]=t|32;t=-1}return t|0}function Rr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;o=t&255;i=(r|0)!=0;e:do{if(i&(e&3|0)!=0){n=t&255;while(1){if((de[e>>0]|0)==n<<24>>24){a=6;break e}e=e+1|0;r=r+-1|0;i=(r|0)!=0;if(!(i&(e&3|0)!=0)){a=5;break}}}else a=5}while(0);if((a|0)==5)if(i)a=6;else r=0;e:do{if((a|0)==6){n=t&255;if((de[e>>0]|0)!=n<<24>>24){i=ge(o,16843009)|0;t:do{if(r>>>0>3)while(1){o=pe[e>>2]^i;if((o&-2139062144^-2139062144)&o+-16843009)break;e=e+4|0;r=r+-4|0;if(r>>>0<=3){a=11;break t}}else a=11}while(0);if((a|0)==11)if(!r){r=0;break}while(1){if((de[e>>0]|0)==n<<24>>24)break e;e=e+1|0;r=r+-1|0;if(!r){r=0;break}}}}}while(0);return((r|0)!=0?e:0)|0}function Or(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0;t=e+20|0;o=e+28|0;if((pe[t>>2]|0)>>>0>(pe[o>>2]|0)>>>0?(Ai[pe[e+36>>2]&7](e,0,0)|0,(pe[t>>2]|0)==0):0)t=-1;else{a=e+4|0;r=pe[a>>2]|0;i=e+8|0;n=pe[i>>2]|0;if(r>>>0>>0)Ai[pe[e+40>>2]&7](e,r-n|0,1)|0;pe[e+16>>2]=0;pe[o>>2]=0;pe[t>>2]=0;pe[i>>2]=0;pe[a>>2]=0;t=0}return t|0}function Dr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0.0,c=0,f=0,l=0,d=0,p=0.0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0,Q=0;Q=be;be=be+624|0;Y=Q+24|0;J=Q+16|0;W=Q+588|0;X=Q+576|0;V=Q;N=Q+536|0;Z=Q+8|0;K=Q+528|0;k=(e|0)!=0;I=N+40|0;B=I;N=N+39|0;U=Z+4|0;z=X+12|0;X=X+11|0;q=W;H=z;G=H-q|0;R=-2-q|0;O=H+2|0;D=Y+288|0;L=W+9|0;F=L;j=W+8|0;o=0;m=t;a=0;t=0;e:while(1){do{if((o|0)>-1)if((a|0)>(2147483647-o|0)){o=cr()|0;pe[o>>2]=75;o=-1;break}else{o=a+o|0;break}}while(0);a=de[m>>0]|0;if(!(a<<24>>24)){C=245;break}else s=m;t:while(1){switch(a<<24>>24){case 37:{a=s;C=9;break t}case 0:{a=s;break t}default:{}}M=s+1|0;a=de[M>>0]|0;s=M}t:do{if((C|0)==9)while(1){C=0;if((de[a+1>>0]|0)!=37)break t;s=s+1|0;a=a+2|0;if((de[a>>0]|0)==37)C=9;else break}}while(0);b=s-m|0;if(k?(pe[e>>2]&32|0)==0:0)gr(m,b,e)|0;if((s|0)!=(m|0)){m=a;a=b;continue}c=a+1|0;s=de[c>>0]|0;u=(s<<24>>24)+-48|0;if(u>>>0<10){M=(de[a+2>>0]|0)==36;c=M?a+3|0:c;s=de[c>>0]|0;d=M?u:-1;t=M?1:t}else d=-1;a=s<<24>>24;t:do{if((a&-32|0)==32){u=0;while(1){if(!(1<>24)+-32|u;c=c+1|0;s=de[c>>0]|0;a=s<<24>>24;if((a&-32|0)!=32){f=u;a=c;break}}}else{f=0;a=c}}while(0);do{if(s<<24>>24==42){u=a+1|0;s=(de[u>>0]|0)+-48|0;if(s>>>0<10?(de[a+2>>0]|0)==36:0){pe[n+(s<<2)>>2]=10;t=1;a=a+3|0;s=pe[i+((de[u>>0]|0)+-48<<3)>>2]|0}else{if(t){o=-1;break e}if(!k){v=f;a=u;t=0;M=0;break}t=(pe[r>>2]|0)+(4-1)&~(4-1);s=pe[t>>2]|0;pe[r>>2]=t+4;t=0;a=u}if((s|0)<0){v=f|8192;M=0-s|0}else{v=f;M=s}}else{u=(s<<24>>24)+-48|0;if(u>>>0<10){s=0;do{s=(s*10|0)+u|0;a=a+1|0;u=(de[a>>0]|0)+-48|0}while(u>>>0<10);if((s|0)<0){o=-1;break e}else{v=f;M=s}}else{v=f;M=0}}}while(0);t:do{if((de[a>>0]|0)==46){u=a+1|0;s=de[u>>0]|0;if(s<<24>>24!=42){c=(s<<24>>24)+-48|0;if(c>>>0<10){a=u;s=0}else{a=u;c=0;break}while(1){s=(s*10|0)+c|0;a=a+1|0;c=(de[a>>0]|0)+-48|0;if(c>>>0>=10){c=s;break t}}}u=a+2|0;s=(de[u>>0]|0)+-48|0;if(s>>>0<10?(de[a+3>>0]|0)==36:0){pe[n+(s<<2)>>2]=10;a=a+4|0;c=pe[i+((de[u>>0]|0)+-48<<3)>>2]|0;break}if(t){o=-1;break e}if(k){a=(pe[r>>2]|0)+(4-1)&~(4-1);c=pe[a>>2]|0;pe[r>>2]=a+4;a=u}else{a=u;c=0}}else c=-1}while(0);l=0;while(1){s=(de[a>>0]|0)+-65|0;if(s>>>0>57){o=-1;break e}u=a+1|0;s=de[5359+(l*58|0)+s>>0]|0;f=s&255;if((f+-1|0)>>>0<8){a=u;l=f}else{P=u;break}}if(!(s<<24>>24)){o=-1;break}u=(d|0)>-1;do{if(s<<24>>24==19)if(u){o=-1;break e}else C=52;else{if(u){pe[n+(d<<2)>>2]=f;E=i+(d<<3)|0;A=pe[E+4>>2]|0;C=V;pe[C>>2]=pe[E>>2];pe[C+4>>2]=A;C=52;break}if(!k){o=0;break e}jr(V,f,r)}}while(0);if((C|0)==52?(C=0,!k):0){m=P;a=b;continue}d=de[a>>0]|0;d=(l|0)!=0&(d&15|0)==3?d&-33:d;u=v&-65537;A=(v&8192|0)==0?v:u;t:do{switch(d|0){case 110:switch(l|0){case 0:{pe[pe[V>>2]>>2]=o;m=P;a=b;continue e}case 1:{pe[pe[V>>2]>>2]=o;m=P;a=b;continue e}case 2:{m=pe[V>>2]|0;pe[m>>2]=o;pe[m+4>>2]=((o|0)<0)<<31>>31;m=P;a=b;continue e}case 3:{$[pe[V>>2]>>1]=o;m=P;a=b;continue e}case 4:{de[pe[V>>2]>>0]=o;m=P;a=b;continue e}case 6:{pe[pe[V>>2]>>2]=o;m=P;a=b;continue e}case 7:{m=pe[V>>2]|0;pe[m>>2]=o;pe[m+4>>2]=((o|0)<0)<<31>>31;m=P;a=b;continue e}default:{m=P;a=b;continue e}}case 112:{l=A|8;c=c>>>0>8?c:8;d=120;C=64;break}case 88:case 120:{l=A;C=64;break}case 111:{u=V;s=pe[u>>2]|0;u=pe[u+4>>2]|0;if((s|0)==0&(u|0)==0)a=I;else{a=I;do{a=a+-1|0;de[a>>0]=s&7|48;s=Jr(s|0,u|0,3)|0;u=re}while(!((s|0)==0&(u|0)==0))}if(!(A&8)){s=A;l=0;f=5839;C=77}else{l=B-a+1|0;s=A;c=(c|0)<(l|0)?l:c;l=0;f=5839;C=77}break}case 105:case 100:{s=V;a=pe[s>>2]|0;s=pe[s+4>>2]|0;if((s|0)<0){a=Yr(0,0,a|0,s|0)|0;s=re;u=V;pe[u>>2]=a;pe[u+4>>2]=s;u=1;f=5839;C=76;break t}if(!(A&2048)){f=A&1;u=f;f=(f|0)==0?5839:5841;C=76}else{u=1;f=5840;C=76}break}case 117:{s=V;a=pe[s>>2]|0;s=pe[s+4>>2]|0;u=0;f=5839;C=76;break}case 99:{de[N>>0]=pe[V>>2];m=N;s=1;l=0;d=5839;a=I;break}case 109:{a=cr()|0;a=hr(pe[a>>2]|0)|0;C=82;break}case 115:{a=pe[V>>2]|0;a=(a|0)!=0?a:5849;C=82;break}case 67:{pe[Z>>2]=pe[V>>2];pe[U>>2]=0;pe[V>>2]=Z;c=-1;C=86;break}case 83:{if(!c){Nr(e,32,M,0,A);a=0;C=98}else C=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{h=+ee[V>>3];pe[J>>2]=0;ee[te>>3]=h;if((pe[te+4>>2]|0)>=0)if(!(A&2048)){E=A&1;S=E;E=(E|0)==0?5857:5862}else{S=1;E=5859}else{h=-h;S=1;E=5856}ee[te>>3]=h;T=pe[te+4>>2]&2146435072;do{if(T>>>0<2146435072|(T|0)==2146435072&0<0){p=+dr(h,J)*2.0;s=p!=0.0;if(s)pe[J>>2]=(pe[J>>2]|0)+-1;w=d|32;if((w|0)==97){m=d&32;b=(m|0)==0?E:E+9|0;v=S|2;a=12-c|0;do{if(!(c>>>0>11|(a|0)==0)){h=8.0;do{a=a+-1|0;h=h*16.0}while((a|0)!=0);if((de[b>>0]|0)==45){h=-(h+(-p-h));break}else{h=p+h-h;break}}else h=p}while(0);s=pe[J>>2]|0;a=(s|0)<0?0-s|0:s;a=Br(a,((a|0)<0)<<31>>31,z)|0;if((a|0)==(z|0)){de[X>>0]=48;a=X}de[a+-1>>0]=(s>>31&2)+43;l=a+-2|0;de[l>>0]=d+15;f=(c|0)<1;u=(A&8|0)==0;s=W;while(1){E=~~h;a=s+1|0;de[s>>0]=me[5823+E>>0]|m;h=(h-+(E|0))*16.0;do{if((a-q|0)==1){if(u&(f&h==0.0))break;de[a>>0]=46;a=s+2|0}}while(0);if(!(h!=0.0))break;else s=a}c=(c|0)!=0&(R+a|0)<(c|0)?O+c-l|0:G-l+a|0;u=c+v|0;Nr(e,32,M,u,A);if(!(pe[e>>2]&32))gr(b,v,e)|0;Nr(e,48,M,u,A^65536);a=a-q|0;if(!(pe[e>>2]&32))gr(W,a,e)|0;s=H-l|0;Nr(e,48,c-(a+s)|0,0,0);if(!(pe[e>>2]&32))gr(l,s,e)|0;Nr(e,32,M,u,A^8192);a=(u|0)<(M|0)?M:u;break}a=(c|0)<0?6:c;if(s){s=(pe[J>>2]|0)+-28|0;pe[J>>2]=s;h=p*268435456.0}else{h=p;s=pe[J>>2]|0}T=(s|0)<0?Y:D;x=T;s=T;do{_=~~h>>>0;pe[s>>2]=_;s=s+4|0;h=(h-+(_>>>0))*1.0e9}while(h!=0.0);u=s;s=pe[J>>2]|0;if((s|0)>0){f=T;while(1){l=(s|0)>29?29:s;c=u+-4|0;do{if(c>>>0>>0)c=f;else{s=0;do{_=Kr(pe[c>>2]|0,0,l|0)|0;_=Zr(_|0,re|0,s|0,0)|0;s=re;y=ai(_|0,s|0,1e9,0)|0;pe[c>>2]=y;s=oi(_|0,s|0,1e9,0)|0;c=c+-4|0}while(c>>>0>=f>>>0);if(!s){c=f;break}c=f+-4|0;pe[c>>2]=s}}while(0);while(1){if(u>>>0<=c>>>0)break;s=u+-4|0;if(!(pe[s>>2]|0))u=s;else break}s=(pe[J>>2]|0)-l|0;pe[J>>2]=s;if((s|0)>0)f=c;else break}}else c=T;if((s|0)<0){b=((a+25|0)/9|0)+1|0;g=(w|0)==102;m=c;while(1){v=0-s|0;v=(v|0)>9?9:v;do{if(m>>>0>>0){s=(1<>>v;c=0;l=m;do{_=pe[l>>2]|0;pe[l>>2]=(_>>>v)+c;c=ge(_&s,f)|0;l=l+4|0}while(l>>>0>>0);s=(pe[m>>2]|0)==0?m+4|0:m;if(!c){c=s;break}pe[u>>2]=c;c=s;u=u+4|0}else c=(pe[m>>2]|0)==0?m+4|0:m}while(0);s=g?T:c;u=(u-s>>2|0)>(b|0)?s+(b<<2)|0:u;s=(pe[J>>2]|0)+v|0;pe[J>>2]=s;if((s|0)>=0){m=c;break}else m=c}}else m=c;do{if(m>>>0>>0){s=(x-m>>2)*9|0;f=pe[m>>2]|0;if(f>>>0<10)break;else c=10;do{c=c*10|0;s=s+1|0}while(f>>>0>=c>>>0)}else s=0}while(0);y=(w|0)==103;_=(a|0)!=0;c=a-((w|0)!=102?s:0)+((_&y)<<31>>31)|0;if((c|0)<(((u-x>>2)*9|0)+-9|0)){l=c+9216|0;g=(l|0)/9|0;c=T+(g+-1023<<2)|0;l=((l|0)%9|0)+1|0;if((l|0)<9){f=10;do{f=f*10|0;l=l+1|0}while((l|0)!=9)}else f=10;v=pe[c>>2]|0;b=(v>>>0)%(f>>>0)|0;if((b|0)==0?(T+(g+-1022<<2)|0)==(u|0):0)f=m;else C=163;do{if((C|0)==163){C=0;p=(((v>>>0)/(f>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;l=(f|0)/2|0;do{if(b>>>0>>0)h=.5;else{if((b|0)==(l|0)?(T+(g+-1022<<2)|0)==(u|0):0){h=1.0;break}h=1.5}}while(0);do{if(S){if((de[E>>0]|0)!=45)break;p=-p;h=-h}}while(0);l=v-b|0;pe[c>>2]=l;if(!(p+h!=p)){f=m;break}w=l+f|0;pe[c>>2]=w;if(w>>>0>999999999){s=m;while(1){f=c+-4|0;pe[c>>2]=0;if(f>>>0>>0){s=s+-4|0;pe[s>>2]=0}w=(pe[f>>2]|0)+1|0;pe[f>>2]=w;if(w>>>0>999999999)c=f;else{m=s;c=f;break}}}s=(x-m>>2)*9|0;l=pe[m>>2]|0;if(l>>>0<10){f=m;break}else f=10;do{f=f*10|0;s=s+1|0}while(l>>>0>=f>>>0);f=m}}while(0);w=c+4|0;m=f;u=u>>>0>w>>>0?w:u}b=0-s|0;while(1){if(u>>>0<=m>>>0){g=0;w=u;break}c=u+-4|0;if(!(pe[c>>2]|0))u=c;else{g=1;w=u;break}}do{if(y){a=(_&1^1)+a|0;if((a|0)>(s|0)&(s|0)>-5){d=d+-1|0;a=a+-1-s|0}else{d=d+-2|0;a=a+-1|0}u=A&8;if(u)break;do{if(g){u=pe[w+-4>>2]|0;if(!u){c=9;break}if(!((u>>>0)%10|0)){f=10;c=0}else{c=0;break}do{f=f*10|0;c=c+1|0}while(((u>>>0)%(f>>>0)|0|0)==0)}else c=9}while(0);u=((w-x>>2)*9|0)+-9|0;if((d|32|0)==102){u=u-c|0;u=(u|0)<0?0:u;a=(a|0)<(u|0)?a:u;u=0;break}else{u=u+s-c|0;u=(u|0)<0?0:u;a=(a|0)<(u|0)?a:u;u=0;break}}else u=A&8}while(0);v=a|u;f=(v|0)!=0&1;l=(d|32|0)==102;if(l){s=(s|0)>0?s:0;d=0}else{c=(s|0)<0?b:s;c=Br(c,((c|0)<0)<<31>>31,z)|0;if((H-c|0)<2)do{c=c+-1|0;de[c>>0]=48}while((H-c|0)<2);de[c+-1>>0]=(s>>31&2)+43;x=c+-2|0;de[x>>0]=d;s=H-x|0;d=x}b=S+1+a+f+s|0;Nr(e,32,M,b,A);if(!(pe[e>>2]&32))gr(E,S,e)|0;Nr(e,48,M,b,A^65536);do{if(l){c=m>>>0>T>>>0?T:m;s=c;do{u=Br(pe[s>>2]|0,0,L)|0;do{if((s|0)==(c|0)){if((u|0)!=(L|0))break;de[j>>0]=48;u=j}else{if(u>>>0<=W>>>0)break;do{u=u+-1|0;de[u>>0]=48}while(u>>>0>W>>>0)}}while(0);if(!(pe[e>>2]&32))gr(u,F-u|0,e)|0;s=s+4|0}while(s>>>0<=T>>>0);do{if(v){if(pe[e>>2]&32)break;gr(5891,1,e)|0}}while(0);if((a|0)>0&s>>>0>>0){u=s;while(1){s=Br(pe[u>>2]|0,0,L)|0;if(s>>>0>W>>>0)do{s=s+-1|0;de[s>>0]=48}while(s>>>0>W>>>0);if(!(pe[e>>2]&32))gr(s,(a|0)>9?9:a,e)|0;u=u+4|0;s=a+-9|0;if(!((a|0)>9&u>>>0>>0)){a=s;break}else a=s}}Nr(e,48,a+9|0,9,0)}else{l=g?w:m+4|0;if((a|0)>-1){f=(u|0)==0;c=m;do{s=Br(pe[c>>2]|0,0,L)|0;if((s|0)==(L|0)){de[j>>0]=48;s=j}do{if((c|0)==(m|0)){u=s+1|0;if(!(pe[e>>2]&32))gr(s,1,e)|0;if(f&(a|0)<1){s=u;break}if(pe[e>>2]&32){s=u;break}gr(5891,1,e)|0;s=u}else{if(s>>>0<=W>>>0)break;do{s=s+-1|0;de[s>>0]=48}while(s>>>0>W>>>0)}}while(0);u=F-s|0;if(!(pe[e>>2]&32))gr(s,(a|0)>(u|0)?u:a,e)|0;a=a-u|0;c=c+4|0}while(c>>>0>>0&(a|0)>-1)}Nr(e,48,a+18|0,18,0);if(pe[e>>2]&32)break;gr(d,H-d|0,e)|0}}while(0);Nr(e,32,M,b,A^8192);a=(b|0)<(M|0)?M:b}else{l=(d&32|0)!=0;f=h!=h|0.0!=0.0;s=f?0:S;c=s+3|0;Nr(e,32,M,c,u);a=pe[e>>2]|0;if(!(a&32)){gr(E,s,e)|0;a=pe[e>>2]|0}if(!(a&32))gr(f?l?5883:5887:l?5875:5879,3,e)|0;Nr(e,32,M,c,A^8192);a=(c|0)<(M|0)?M:c}}while(0);m=P;continue e}default:{u=A;s=c;l=0;d=5839;a=I}}}while(0);t:do{if((C|0)==64){u=V;s=pe[u>>2]|0;u=pe[u+4>>2]|0;f=d&32;if(!((s|0)==0&(u|0)==0)){a=I;do{a=a+-1|0;de[a>>0]=me[5823+(s&15)>>0]|f;s=Jr(s|0,u|0,4)|0;u=re}while(!((s|0)==0&(u|0)==0));C=V;if((l&8|0)==0|(pe[C>>2]|0)==0&(pe[C+4>>2]|0)==0){s=l;l=0;f=5839;C=77}else{s=l;l=2;f=5839+(d>>4)|0;C=77}}else{a=I;s=l;l=0;f=5839;C=77}}else if((C|0)==76){a=Br(a,s,I)|0;s=A;l=u;C=77}else if((C|0)==82){C=0;A=Rr(a,0,c)|0;E=(A|0)==0;m=a;s=E?c:A-a|0;l=0;d=5839;a=E?a+c|0:A}else if((C|0)==86){C=0;s=0;a=0;f=pe[V>>2]|0;while(1){u=pe[f>>2]|0;if(!u)break;a=mr(K,u)|0;if((a|0)<0|a>>>0>(c-s|0)>>>0)break;s=a+s|0;if(c>>>0>s>>>0)f=f+4|0;else break}if((a|0)<0){o=-1;break e}Nr(e,32,M,s,A);if(!s){a=0;C=98}else{u=0;c=pe[V>>2]|0;while(1){a=pe[c>>2]|0;if(!a){a=s;C=98;break t}a=mr(K,a)|0;u=a+u|0;if((u|0)>(s|0)){a=s;C=98;break t}if(!(pe[e>>2]&32))gr(K,a,e)|0;if(u>>>0>=s>>>0){a=s;C=98;break}else c=c+4|0}}}}while(0);if((C|0)==98){C=0;Nr(e,32,M,a,A^8192);m=P;a=(M|0)>(a|0)?M:a;continue}if((C|0)==77){C=0;u=(c|0)>-1?s&-65537:s;s=V;s=(pe[s>>2]|0)!=0|(pe[s+4>>2]|0)!=0;if((c|0)!=0|s){s=(s&1^1)+(B-a)|0;m=a;s=(c|0)>(s|0)?c:s;d=f;a=I}else{m=I;s=0;d=f;a=I}}f=a-m|0;s=(s|0)<(f|0)?f:s;c=l+s|0;a=(M|0)<(c|0)?c:M;Nr(e,32,a,c,u);if(!(pe[e>>2]&32))gr(d,l,e)|0;Nr(e,48,a,c,u^65536);Nr(e,48,s,f,0);if(!(pe[e>>2]&32))gr(m,f,e)|0;Nr(e,32,a,c,u^8192);m=P}e:do{if((C|0)==245)if(!e)if(t){o=1;while(1){t=pe[n+(o<<2)>>2]|0;if(!t)break;jr(i+(o<<3)|0,t,r);o=o+1|0;if((o|0)>=10){o=1;break e}}if((o|0)<10)while(1){if(pe[n+(o<<2)>>2]|0){o=-1;break e}o=o+1|0;if((o|0)>=10){o=1;break}}else o=1}else o=0}while(0);be=Q;return o|0}function Lr(e){e=e|0;if(!(pe[e+68>>2]|0))Er(e);return}function Fr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;i=e+20|0;n=pe[i>>2]|0;e=(pe[e+16>>2]|0)-n|0;e=e>>>0>r>>>0?r:e;Qr(n|0,t|0,e|0)|0;pe[i>>2]=(pe[i>>2]|0)+e;return r|0}function jr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0.0;e:do{if(t>>>0<=20)do{switch(t|0){case 9:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;pe[e>>2]=t;break e}case 10:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;i=e;pe[i>>2]=t;pe[i+4>>2]=((t|0)<0)<<31>>31;break e}case 11:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;i=e;pe[i>>2]=t;pe[i+4>>2]=0;break e}case 12:{i=(pe[r>>2]|0)+(8-1)&~(8-1);t=i;n=pe[t>>2]|0;t=pe[t+4>>2]|0;pe[r>>2]=i+8;i=e;pe[i>>2]=n;pe[i+4>>2]=t;break e}case 13:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;i=(i&65535)<<16>>16;n=e;pe[n>>2]=i;pe[n+4>>2]=((i|0)<0)<<31>>31;break e}case 14:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;n=e;pe[n>>2]=i&65535;pe[n+4>>2]=0;break e}case 15:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;i=(i&255)<<24>>24;n=e;pe[n>>2]=i;pe[n+4>>2]=((i|0)<0)<<31>>31;break e}case 16:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;n=e;pe[n>>2]=i&255;pe[n+4>>2]=0;break e}case 17:{n=(pe[r>>2]|0)+(8-1)&~(8-1);o=+ee[n>>3];pe[r>>2]=n+8;ee[e>>3]=o;break e}case 18:{n=(pe[r>>2]|0)+(8-1)&~(8-1);o=+ee[n>>3];pe[r>>2]=n+8;ee[e>>3]=o;break e}default:break e}}while(0)}while(0);return}function Br(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(t>>>0>0|(t|0)==0&e>>>0>4294967295)while(1){i=ai(e|0,t|0,10,0)|0;r=r+-1|0;de[r>>0]=i|48;i=oi(e|0,t|0,10,0)|0;if(t>>>0>9|(t|0)==9&e>>>0>4294967295){e=i;t=re}else{e=i;break}}if(e)while(1){r=r+-1|0;de[r>>0]=(e>>>0)%10|0|48;if(e>>>0<10)break;else e=(e>>>0)/10|0}return r|0}function Nr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0;s=be;be=be+256|0;a=s;do{if((r|0)>(i|0)&(n&73728|0)==0){n=r-i|0;Wr(a|0,t|0,(n>>>0>256?256:n)|0)|0;t=pe[e>>2]|0;o=(t&32|0)==0;if(n>>>0>255){i=r-i|0;do{if(o){gr(a,256,e)|0;t=pe[e>>2]|0}n=n+-256|0;o=(t&32|0)==0}while(n>>>0>255);if(o)n=i&255;else break}else if(!o)break;gr(a,n,e)|0}}while(0);be=s;return}function Ur(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0;do{if(e>>>0<245){d=e>>>0<11?16:e+11&-8;e=d>>>3;s=pe[151]|0;r=s>>>e;if(r&3){e=(r&1^1)+e|0;i=e<<1;r=644+(i<<2)|0;i=644+(i+2<<2)|0;n=pe[i>>2]|0;o=n+8|0;a=pe[o>>2]|0;do{if((r|0)!=(a|0)){if(a>>>0<(pe[155]|0)>>>0)Xe();t=a+12|0;if((pe[t>>2]|0)==(n|0)){pe[t>>2]=r;pe[i>>2]=a;break}else Xe()}else pe[151]=s&~(1<>2]=j|3;j=n+(j|4)|0;pe[j>>2]=pe[j>>2]|1;j=o;return j|0}a=pe[153]|0;if(d>>>0>a>>>0){if(r){i=2<>>12&16;i=i>>>u;n=i>>>5&8;i=i>>>n;o=i>>>2&4;i=i>>>o;r=i>>>1&2;i=i>>>r;e=i>>>1&1;e=(n|u|o|r|e)+(i>>>e)|0;i=e<<1;r=644+(i<<2)|0;i=644+(i+2<<2)|0;o=pe[i>>2]|0;u=o+8|0;n=pe[u>>2]|0;do{if((r|0)!=(n|0)){if(n>>>0<(pe[155]|0)>>>0)Xe();t=n+12|0;if((pe[t>>2]|0)==(o|0)){pe[t>>2]=r;pe[i>>2]=n;h=pe[153]|0;break}else Xe()}else{pe[151]=s&~(1<>2]=d|3;s=o+d|0;pe[o+(d|4)>>2]=a|1;pe[o+j>>2]=a;if(h){n=pe[156]|0;r=h>>>3;t=r<<1;i=644+(t<<2)|0;e=pe[151]|0;r=1<>2]|0;if(t>>>0<(pe[155]|0)>>>0)Xe();else{c=e;f=t}}else{pe[151]=e|r;c=644+(t+2<<2)|0;f=i}pe[c>>2]=n;pe[f+12>>2]=n;pe[n+8>>2]=f;pe[n+12>>2]=i}pe[153]=a;pe[156]=s;j=u;return j|0}e=pe[152]|0;if(e){r=(e&0-e)+-1|0;F=r>>>12&16;r=r>>>F;L=r>>>5&8;r=r>>>L;j=r>>>2&4;r=r>>>j;e=r>>>1&2;r=r>>>e;i=r>>>1&1;i=pe[908+((L|F|j|e|i)+(r>>>i)<<2)>>2]|0;r=(pe[i+4>>2]&-8)-d|0;e=i;while(1){t=pe[e+16>>2]|0;if(!t){t=pe[e+20>>2]|0;if(!t){u=r;break}}e=(pe[t+4>>2]&-8)-d|0;j=e>>>0>>0;r=j?e:r;e=t;i=j?t:i}o=pe[155]|0;if(i>>>0>>0)Xe();s=i+d|0;if(i>>>0>=s>>>0)Xe();a=pe[i+24>>2]|0;r=pe[i+12>>2]|0;do{if((r|0)==(i|0)){e=i+20|0;t=pe[e>>2]|0;if(!t){e=i+16|0;t=pe[e>>2]|0;if(!t){l=0;break}}while(1){r=t+20|0;n=pe[r>>2]|0;if(n){t=n;e=r;continue}r=t+16|0;n=pe[r>>2]|0;if(!n)break;else{t=n;e=r}}if(e>>>0>>0)Xe();else{pe[e>>2]=0;l=t;break}}else{n=pe[i+8>>2]|0;if(n>>>0>>0)Xe();t=n+12|0;if((pe[t>>2]|0)!=(i|0))Xe();e=r+8|0;if((pe[e>>2]|0)==(i|0)){pe[t>>2]=r;pe[e>>2]=n;l=r;break}else Xe()}}while(0);do{if(a){t=pe[i+28>>2]|0;e=908+(t<<2)|0;if((i|0)==(pe[e>>2]|0)){pe[e>>2]=l;if(!l){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(i|0))pe[t>>2]=l;else pe[a+20>>2]=l;if(!l)break}e=pe[155]|0;if(l>>>0>>0)Xe();pe[l+24>>2]=a;t=pe[i+16>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[l+16>>2]=t;pe[t+24>>2]=l;break}}while(0);t=pe[i+20>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[l+20>>2]=t;pe[t+24>>2]=l;break}}}while(0);if(u>>>0<16){j=u+d|0;pe[i+4>>2]=j|3;j=i+(j+4)|0;pe[j>>2]=pe[j>>2]|1}else{pe[i+4>>2]=d|3;pe[i+(d|4)>>2]=u|1;pe[i+(u+d)>>2]=u;t=pe[153]|0;if(t){o=pe[156]|0;r=t>>>3;t=r<<1;n=644+(t<<2)|0;e=pe[151]|0;r=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{p=t;m=e}}else{pe[151]=e|r;p=644+(t+2<<2)|0;m=n}pe[p>>2]=o;pe[m+12>>2]=o;pe[o+8>>2]=m;pe[o+12>>2]=n}pe[153]=u;pe[156]=s}j=i+8|0;return j|0}else m=d}else m=d}else if(e>>>0<=4294967231){e=e+11|0;f=e&-8;c=pe[152]|0;if(c){r=0-f|0;e=e>>>8;if(e)if(f>>>0>16777215)h=31;else{m=(e+1048320|0)>>>16&8;_=e<>>16&4;_=_<>>16&2;h=14-(p|m|h)+(_<>>15)|0;h=f>>>(h+7|0)&1|h<<1}else h=0;e=pe[908+(h<<2)>>2]|0;e:do{if(!e){n=0;e=0;_=86}else{a=r;n=0;s=f<<((h|0)==31?0:25-(h>>>1)|0);u=e;e=0;while(1){o=pe[u+4>>2]&-8;r=o-f|0;if(r>>>0
>>0)if((o|0)==(f|0)){o=u;e=u;_=90;break e}else e=u;else r=a;_=pe[u+20>>2]|0;u=pe[u+16+(s>>>31<<2)>>2]|0;n=(_|0)==0|(_|0)==(u|0)?n:_;if(!u){_=86;break}else{a=r;s=s<<1}}}}while(0);if((_|0)==86){if((n|0)==0&(e|0)==0){e=2<>>12&16;e=e>>>l;c=e>>>5&8;e=e>>>c;p=e>>>2&4;e=e>>>p;m=e>>>1&2;e=e>>>m;n=e>>>1&1;n=pe[908+((c|l|p|m|n)+(e>>>n)<<2)>>2]|0;e=0}if(!n){s=r;u=e}else{o=n;_=90}}if((_|0)==90)while(1){_=0;m=(pe[o+4>>2]&-8)-f|0;n=m>>>0>>0;r=n?m:r;e=n?o:e;n=pe[o+16>>2]|0;if(n){o=n;_=90;continue}o=pe[o+20>>2]|0;if(!o){s=r;u=e;break}else _=90}if((u|0)!=0?s>>>0<((pe[153]|0)-f|0)>>>0:0){n=pe[155]|0;if(u>>>0>>0)Xe();a=u+f|0;if(u>>>0>=a>>>0)Xe();o=pe[u+24>>2]|0;r=pe[u+12>>2]|0;do{if((r|0)==(u|0)){e=u+20|0;t=pe[e>>2]|0;if(!t){e=u+16|0;t=pe[e>>2]|0;if(!t){d=0;break}}while(1){r=t+20|0;i=pe[r>>2]|0;if(i){t=i;e=r;continue}r=t+16|0;i=pe[r>>2]|0;if(!i)break;else{t=i;e=r}}if(e>>>0>>0)Xe();else{pe[e>>2]=0;d=t;break}}else{i=pe[u+8>>2]|0;if(i>>>0>>0)Xe();t=i+12|0;if((pe[t>>2]|0)!=(u|0))Xe();e=r+8|0;if((pe[e>>2]|0)==(u|0)){pe[t>>2]=r;pe[e>>2]=i;d=r;break}else Xe()}}while(0);do{if(o){t=pe[u+28>>2]|0;e=908+(t<<2)|0;if((u|0)==(pe[e>>2]|0)){pe[e>>2]=d;if(!d){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=o+16|0;if((pe[t>>2]|0)==(u|0))pe[t>>2]=d;else pe[o+20>>2]=d;if(!d)break}e=pe[155]|0;if(d>>>0>>0)Xe();pe[d+24>>2]=o;t=pe[u+16>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[d+16>>2]=t;pe[t+24>>2]=d;break}}while(0);t=pe[u+20>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[d+20>>2]=t;pe[t+24>>2]=d;break}}}while(0);e:do{if(s>>>0>=16){pe[u+4>>2]=f|3;pe[u+(f|4)>>2]=s|1;pe[u+(s+f)>>2]=s;t=s>>>3;if(s>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{b=t;g=e}}else{pe[151]=r|t;b=644+(e+2<<2)|0;g=i}pe[b>>2]=a;pe[g+12>>2]=a;pe[u+(f+8)>>2]=g;pe[u+(f+12)>>2]=i;break}t=s>>>8;if(t)if(s>>>0>16777215)i=31;else{F=(t+1048320|0)>>>16&8;j=t<>>16&4;j=j<>>16&2;i=14-(L|F|i)+(j<>>15)|0;i=s>>>(i+7|0)&1|i<<1}else i=0;t=908+(i<<2)|0;pe[u+(f+28)>>2]=i;pe[u+(f+20)>>2]=0;pe[u+(f+16)>>2]=0;e=pe[152]|0;r=1<>2]=a;pe[u+(f+24)>>2]=t;pe[u+(f+12)>>2]=a;pe[u+(f+8)>>2]=a;break}t=pe[t>>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(s|0)){i=s<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(s|0)){T=r;break t}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=a;pe[u+(f+24)>>2]=t;pe[u+(f+12)>>2]=a;pe[u+(f+8)>>2]=a;break e}}else T=t}while(0);t=T+8|0;e=pe[t>>2]|0;j=pe[155]|0;if(e>>>0>=j>>>0&T>>>0>=j>>>0){pe[e+12>>2]=a;pe[t>>2]=a;pe[u+(f+8)>>2]=e;pe[u+(f+12)>>2]=T;pe[u+(f+24)>>2]=0;break}else Xe()}else{j=s+f|0;pe[u+4>>2]=j|3;j=u+(j+4)|0;pe[j>>2]=pe[j>>2]|1}}while(0);j=u+8|0;return j|0}else m=f}else m=f}else m=-1}while(0);r=pe[153]|0;if(r>>>0>=m>>>0){t=r-m|0;e=pe[156]|0;if(t>>>0>15){pe[156]=e+m;pe[153]=t;pe[e+(m+4)>>2]=t|1;pe[e+r>>2]=t;pe[e+4>>2]=m|3}else{pe[153]=0;pe[156]=0;pe[e+4>>2]=r|3;j=e+(r+4)|0;pe[j>>2]=pe[j>>2]|1}j=e+8|0;return j|0}e=pe[154]|0;if(e>>>0>m>>>0){F=e-m|0;pe[154]=F;j=pe[157]|0;pe[157]=j+m;pe[j+(m+4)>>2]=F|1;pe[j+4>>2]=m|3;j=j+8|0;return j|0}do{if(!(pe[269]|0)){e=Oe(30)|0;if(!(e+-1&e)){pe[271]=e;pe[270]=e;pe[272]=-1;pe[273]=-1;pe[274]=0;pe[262]=0;T=(He(0)|0)&-16^1431655768;pe[269]=T;break}else Xe()}}while(0);u=m+48|0;s=pe[271]|0;h=m+47|0;a=s+h|0;s=0-s|0;c=a&s;if(c>>>0<=m>>>0){j=0;return j|0}e=pe[261]|0;if((e|0)!=0?(g=pe[259]|0,T=g+c|0,T>>>0<=g>>>0|T>>>0>e>>>0):0){j=0;return j|0}e:do{if(!(pe[262]&4)){e=pe[157]|0;t:do{if(e){n=1052;while(1){r=pe[n>>2]|0;if(r>>>0<=e>>>0?(v=n+4|0,(r+(pe[v>>2]|0)|0)>>>0>e>>>0):0){o=n;e=v;break}n=pe[n+8>>2]|0;if(!n){_=174;break t}}r=a-(pe[154]|0)&s;if(r>>>0<2147483647){n=ke(r|0)|0;T=(n|0)==((pe[o>>2]|0)+(pe[e>>2]|0)|0);e=T?r:0;if(T){if((n|0)!=(-1|0)){w=n;p=e;_=194;break e}}else _=184}else e=0}else _=174}while(0);do{if((_|0)==174){o=ke(0)|0;if((o|0)!=(-1|0)){e=o;r=pe[270]|0;n=r+-1|0;if(!(n&e))r=c;else r=c-e+(n+e&0-r)|0;e=pe[259]|0;n=e+r|0;if(r>>>0>m>>>0&r>>>0<2147483647){T=pe[261]|0;if((T|0)!=0?n>>>0<=e>>>0|n>>>0>T>>>0:0){e=0;break}n=ke(r|0)|0;T=(n|0)==(o|0);e=T?r:0;if(T){w=o;p=e;_=194;break e}else _=184}else e=0}else e=0}}while(0);t:do{if((_|0)==184){o=0-r|0;do{if(u>>>0>r>>>0&(r>>>0<2147483647&(n|0)!=(-1|0))?(y=pe[271]|0,y=h-r+y&0-y,y>>>0<2147483647):0)if((ke(y|0)|0)==(-1|0)){ke(o|0)|0;break t}else{r=y+r|0;break}}while(0);if((n|0)!=(-1|0)){w=n;p=r;_=194;break e}}}while(0);pe[262]=pe[262]|4;_=191}else{e=0;_=191}}while(0);if((((_|0)==191?c>>>0<2147483647:0)?(w=ke(c|0)|0,x=ke(0)|0,w>>>0>>0&((w|0)!=(-1|0)&(x|0)!=(-1|0))):0)?(S=x-w|0,E=S>>>0>(m+40|0)>>>0,E):0){p=E?S:e;_=194}if((_|0)==194){e=(pe[259]|0)+p|0;pe[259]=e;if(e>>>0>(pe[260]|0)>>>0)pe[260]=e;a=pe[157]|0;e:do{if(a){o=1052;do{e=pe[o>>2]|0;r=o+4|0;n=pe[r>>2]|0;if((w|0)==(e+n|0)){A=e;P=r;M=n;C=o;_=204;break}o=pe[o+8>>2]|0}while((o|0)!=0);if(((_|0)==204?(pe[C+12>>2]&8|0)==0:0)?a>>>0>>0&a>>>0>=A>>>0:0){pe[P>>2]=M+p;j=(pe[154]|0)+p|0;F=a+8|0;F=(F&7|0)==0?0:0-F&7;L=j-F|0;pe[157]=a+F;pe[154]=L;pe[a+(F+4)>>2]=L|1;pe[a+(j+4)>>2]=40;pe[158]=pe[273];break}e=pe[155]|0;if(w>>>0>>0){pe[155]=w;e=w}r=w+p|0;o=1052;while(1){if((pe[o>>2]|0)==(r|0)){n=o;r=o;_=212;break}o=pe[o+8>>2]|0;if(!o){r=1052;break}}if((_|0)==212)if(!(pe[r+12>>2]&8)){pe[n>>2]=w;l=r+4|0;pe[l>>2]=(pe[l>>2]|0)+p;l=w+8|0;l=(l&7|0)==0?0:0-l&7;h=w+(p+8)|0;h=(h&7|0)==0?0:0-h&7;t=w+(h+p)|0;f=l+m|0;d=w+f|0;c=t-(w+l)-m|0;pe[w+(l+4)>>2]=m|3;t:do{if((t|0)!=(a|0)){if((t|0)==(pe[156]|0)){j=(pe[153]|0)+c|0;pe[153]=j;pe[156]=d;pe[w+(f+4)>>2]=j|1;pe[w+(j+f)>>2]=j;break}s=p+4|0;r=pe[w+(s+h)>>2]|0;if((r&3|0)==1){u=r&-8;o=r>>>3;r:do{if(r>>>0>=256){a=pe[w+((h|24)+p)>>2]|0;i=pe[w+(p+12+h)>>2]|0;do{if((i|0)==(t|0)){n=h|16;i=w+(s+n)|0;r=pe[i>>2]|0;if(!r){i=w+(n+p)|0;r=pe[i>>2]|0;if(!r){D=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;D=r;break}}else{n=pe[w+((h|8)+p)>>2]|0;if(n>>>0>>0)Xe();e=n+12|0;if((pe[e>>2]|0)!=(t|0))Xe();r=i+8|0;if((pe[r>>2]|0)==(t|0)){pe[e>>2]=i;pe[r>>2]=n;D=i;break}else Xe()}}while(0);if(!a)break;e=pe[w+(p+28+h)>>2]|0;r=908+(e<<2)|0;do{if((t|0)!=(pe[r>>2]|0)){if(a>>>0<(pe[155]|0)>>>0)Xe();e=a+16|0;if((pe[e>>2]|0)==(t|0))pe[e>>2]=D;else pe[a+20>>2]=D;if(!D)break r}else{pe[r>>2]=D;if(D)break;pe[152]=pe[152]&~(1<>>0>>0)Xe();pe[D+24>>2]=a;t=h|16;e=pe[w+(t+p)>>2]|0;do{if(e)if(e>>>0>>0)Xe();else{pe[D+16>>2]=e;pe[e+24>>2]=D;break}}while(0);t=pe[w+(s+t)>>2]|0;if(!t)break;if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[D+20>>2]=t;pe[t+24>>2]=D;break}}else{i=pe[w+((h|8)+p)>>2]|0;n=pe[w+(p+12+h)>>2]|0;r=644+(o<<1<<2)|0;do{if((i|0)!=(r|0)){if(i>>>0>>0)Xe();if((pe[i+12>>2]|0)==(t|0))break;Xe()}}while(0);if((n|0)==(i|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();e=n+8|0;if((pe[e>>2]|0)==(t|0)){k=e;break}Xe()}}while(0);pe[i+12>>2]=n;pe[k>>2]=i}}while(0);t=w+((u|h)+p)|0;n=u+c|0}else n=c;t=t+4|0;pe[t>>2]=pe[t>>2]&-2;pe[w+(f+4)>>2]=n|1;pe[w+(n+f)>>2]=n;t=n>>>3;if(n>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0>=(pe[155]|0)>>>0){L=t;F=e;break}Xe()}}while(0);pe[L>>2]=d;pe[F+12>>2]=d;pe[w+(f+8)>>2]=F;pe[w+(f+12)>>2]=i;break}t=n>>>8;do{if(!t)i=0;else{if(n>>>0>16777215){i=31;break}L=(t+1048320|0)>>>16&8;F=t<>>16&4;F=F<>>16&2;i=14-(D|L|i)+(F<>>15)|0;i=n>>>(i+7|0)&1|i<<1}}while(0);t=908+(i<<2)|0;pe[w+(f+28)>>2]=i;pe[w+(f+20)>>2]=0;pe[w+(f+16)>>2]=0;e=pe[152]|0;r=1<>2]=d;pe[w+(f+24)>>2]=t;pe[w+(f+12)>>2]=d;pe[w+(f+8)>>2]=d;break}t=pe[t>>2]|0;r:do{if((pe[t+4>>2]&-8|0)!=(n|0)){i=n<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(n|0)){j=r;break r}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=d;pe[w+(f+24)>>2]=t;pe[w+(f+12)>>2]=d;pe[w+(f+8)>>2]=d;break t}}else j=t}while(0);t=j+8|0;e=pe[t>>2]|0;F=pe[155]|0;if(e>>>0>=F>>>0&j>>>0>=F>>>0){pe[e+12>>2]=d;pe[t>>2]=d;pe[w+(f+8)>>2]=e;pe[w+(f+12)>>2]=j;pe[w+(f+24)>>2]=0;break}else Xe()}else{j=(pe[154]|0)+c|0;pe[154]=j;pe[157]=d;pe[w+(f+4)>>2]=j|1}}while(0);j=w+(l|8)|0;return j|0}else r=1052;while(1){e=pe[r>>2]|0;if(e>>>0<=a>>>0?(t=pe[r+4>>2]|0,i=e+t|0,i>>>0>a>>>0):0)break;r=pe[r+8>>2]|0}n=e+(t+-39)|0;e=e+(t+-47+((n&7|0)==0?0:0-n&7))|0;n=a+16|0;e=e>>>0>>0?a:e;t=e+8|0;r=w+8|0;r=(r&7|0)==0?0:0-r&7;j=p+-40-r|0;pe[157]=w+r;pe[154]=j;pe[w+(r+4)>>2]=j|1;pe[w+(p+-36)>>2]=40;pe[158]=pe[273];r=e+4|0;pe[r>>2]=27;pe[t>>2]=pe[263];pe[t+4>>2]=pe[264];pe[t+8>>2]=pe[265];pe[t+12>>2]=pe[266];pe[263]=w;pe[264]=p;pe[266]=0;pe[265]=t;t=e+28|0;pe[t>>2]=7;if((e+32|0)>>>0>>0)do{j=t;t=t+4|0;pe[t>>2]=7}while((j+8|0)>>>0>>0);if((e|0)!=(a|0)){o=e-a|0;pe[r>>2]=pe[r>>2]&-2;pe[a+4>>2]=o|1;pe[e>>2]=o;t=o>>>3;if(o>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{I=t;R=e}}else{pe[151]=r|t;I=644+(e+2<<2)|0;R=i}pe[I>>2]=a;pe[R+12>>2]=a;pe[a+8>>2]=R;pe[a+12>>2]=i;break}t=o>>>8;if(t)if(o>>>0>16777215)i=31;else{F=(t+1048320|0)>>>16&8;j=t<>>16&4;j=j<>>16&2;i=14-(L|F|i)+(j<>>15)|0;i=o>>>(i+7|0)&1|i<<1}else i=0;r=908+(i<<2)|0;pe[a+28>>2]=i;pe[a+20>>2]=0;pe[n>>2]=0;t=pe[152]|0;e=1<>2]=a;pe[a+24>>2]=r;pe[a+12>>2]=a;pe[a+8>>2]=a;break}t=pe[r>>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(o|0)){i=o<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(o|0)){O=r;break t}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=a;pe[a+24>>2]=t;pe[a+12>>2]=a;pe[a+8>>2]=a;break e}}else O=t}while(0);t=O+8|0;e=pe[t>>2]|0;j=pe[155]|0;if(e>>>0>=j>>>0&O>>>0>=j>>>0){pe[e+12>>2]=a;pe[t>>2]=a;pe[a+8>>2]=e;pe[a+12>>2]=O;pe[a+24>>2]=0;break}else Xe()}}else{j=pe[155]|0;if((j|0)==0|w>>>0>>0)pe[155]=w;pe[263]=w;pe[264]=p;pe[266]=0;pe[160]=pe[269];pe[159]=-1;t=0;do{j=t<<1;F=644+(j<<2)|0;pe[644+(j+3<<2)>>2]=F;pe[644+(j+2<<2)>>2]=F;t=t+1|0}while((t|0)!=32);j=w+8|0;j=(j&7|0)==0?0:0-j&7;F=p+-40-j|0;pe[157]=w+j;pe[154]=F;pe[w+(j+4)>>2]=F|1;pe[w+(p+-36)>>2]=40;pe[158]=pe[273]}}while(0);t=pe[154]|0;if(t>>>0>m>>>0){F=t-m|0;pe[154]=F;j=pe[157]|0;pe[157]=j+m;pe[j+(m+4)>>2]=F|1;pe[j+4>>2]=m|3;j=j+8|0;return j|0}}j=cr()|0;pe[j>>2]=12;j=0;return j|0}function zr(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0;if(!e)return;t=e+-8|0;s=pe[155]|0;if(t>>>0>>0)Xe();r=pe[e+-4>>2]|0;i=r&3;if((i|0)==1)Xe();d=r&-8;m=e+(d+-8)|0;do{if(!(r&1)){t=pe[t>>2]|0;if(!i)return;u=-8-t|0;c=e+u|0;f=t+d|0;if(c>>>0>>0)Xe();if((c|0)==(pe[156]|0)){t=e+(d+-4)|0;r=pe[t>>2]|0;if((r&3|0)!=3){y=c;o=f;break}pe[153]=f;pe[t>>2]=r&-2;pe[e+(u+4)>>2]=f|1;pe[m>>2]=f;return}n=t>>>3;if(t>>>0<256){i=pe[e+(u+8)>>2]|0;r=pe[e+(u+12)>>2]|0;t=644+(n<<1<<2)|0;if((i|0)!=(t|0)){if(i>>>0>>0)Xe();if((pe[i+12>>2]|0)!=(c|0))Xe()}if((r|0)==(i|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();t=r+8|0;if((pe[t>>2]|0)==(c|0))a=t;else Xe()}else a=r+8|0;pe[i+12>>2]=r;pe[a>>2]=i;y=c;o=f;break}a=pe[e+(u+24)>>2]|0;i=pe[e+(u+12)>>2]|0;do{if((i|0)==(c|0)){r=e+(u+20)|0;t=pe[r>>2]|0;if(!t){r=e+(u+16)|0;t=pe[r>>2]|0;if(!t){h=0;break}}while(1){i=t+20|0;n=pe[i>>2]|0;if(n){t=n;r=i;continue}i=t+16|0;n=pe[i>>2]|0;if(!n)break;else{t=n;r=i}}if(r>>>0>>0)Xe();else{pe[r>>2]=0;h=t;break}}else{n=pe[e+(u+8)>>2]|0;if(n>>>0>>0)Xe();t=n+12|0;if((pe[t>>2]|0)!=(c|0))Xe();r=i+8|0;if((pe[r>>2]|0)==(c|0)){pe[t>>2]=i;pe[r>>2]=n;h=i;break}else Xe()}}while(0);if(a){t=pe[e+(u+28)>>2]|0;r=908+(t<<2)|0;if((c|0)==(pe[r>>2]|0)){pe[r>>2]=h;if(!h){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(c|0))pe[t>>2]=h;else pe[a+20>>2]=h;if(!h){y=c;o=f;break}}r=pe[155]|0;if(h>>>0>>0)Xe();pe[h+24>>2]=a;t=pe[e+(u+16)>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[h+16>>2]=t;pe[t+24>>2]=h;break}}while(0);t=pe[e+(u+20)>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[h+20>>2]=t;pe[t+24>>2]=h;y=c;o=f;break}else{y=c;o=f}}else{y=c;o=f}}else{y=t;o=d}}while(0);if(y>>>0>=m>>>0)Xe();t=e+(d+-4)|0;r=pe[t>>2]|0;if(!(r&1))Xe();if(!(r&2)){if((m|0)==(pe[157]|0)){g=(pe[154]|0)+o|0;pe[154]=g;pe[157]=y;pe[y+4>>2]=g|1;if((y|0)!=(pe[156]|0))return;pe[156]=0;pe[153]=0;return}if((m|0)==(pe[156]|0)){g=(pe[153]|0)+o|0;pe[153]=g;pe[156]=y;pe[y+4>>2]=g|1;pe[y+g>>2]=g;return}o=(r&-8)+o|0;n=r>>>3;do{if(r>>>0>=256){a=pe[e+(d+16)>>2]|0;t=pe[e+(d|4)>>2]|0;do{if((t|0)==(m|0)){r=e+(d+12)|0;t=pe[r>>2]|0;if(!t){r=e+(d+8)|0;t=pe[r>>2]|0;if(!t){p=0;break}}while(1){i=t+20|0;n=pe[i>>2]|0;if(n){t=n;r=i;continue}i=t+16|0;n=pe[i>>2]|0;if(!n)break;else{t=n;r=i}}if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[r>>2]=0;p=t;break}}else{r=pe[e+d>>2]|0;if(r>>>0<(pe[155]|0)>>>0)Xe();i=r+12|0;if((pe[i>>2]|0)!=(m|0))Xe();n=t+8|0;if((pe[n>>2]|0)==(m|0)){pe[i>>2]=t;pe[n>>2]=r;p=t;break}else Xe()}}while(0);if(a){t=pe[e+(d+20)>>2]|0;r=908+(t<<2)|0;if((m|0)==(pe[r>>2]|0)){pe[r>>2]=p;if(!p){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(m|0))pe[t>>2]=p;else pe[a+20>>2]=p;if(!p)break}r=pe[155]|0;if(p>>>0>>0)Xe();pe[p+24>>2]=a;t=pe[e+(d+8)>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[p+16>>2]=t;pe[t+24>>2]=p;break}}while(0);t=pe[e+(d+12)>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[p+20>>2]=t;pe[t+24>>2]=p;break}}}else{i=pe[e+d>>2]|0;r=pe[e+(d|4)>>2]|0;t=644+(n<<1<<2)|0;if((i|0)!=(t|0)){if(i>>>0<(pe[155]|0)>>>0)Xe();if((pe[i+12>>2]|0)!=(m|0))Xe()}if((r|0)==(i|0)){pe[151]=pe[151]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=r+8|0;if((pe[t>>2]|0)==(m|0))l=t;else Xe()}else l=r+8|0;pe[i+12>>2]=r;pe[l>>2]=i}}while(0);pe[y+4>>2]=o|1;pe[y+o>>2]=o;if((y|0)==(pe[156]|0)){pe[153]=o;return}}else{pe[t>>2]=r&-2;pe[y+4>>2]=o|1;pe[y+o>>2]=o}t=o>>>3;if(o>>>0<256){r=t<<1;n=644+(r<<2)|0;i=pe[151]|0;t=1<>2]|0;if(r>>>0<(pe[155]|0)>>>0)Xe();else{v=t;b=r}}else{pe[151]=i|t;v=644+(r+2<<2)|0;b=n}pe[v>>2]=y;pe[b+12>>2]=y;pe[y+8>>2]=b;pe[y+12>>2]=n;return}t=o>>>8;if(t)if(o>>>0>16777215)n=31;else{v=(t+1048320|0)>>>16&8;b=t<>>16&4;b=b<>>16&2;n=14-(m|v|n)+(b<>>15)|0;n=o>>>(n+7|0)&1|n<<1}else n=0;t=908+(n<<2)|0;pe[y+28>>2]=n;pe[y+20>>2]=0;pe[y+16>>2]=0;r=pe[152]|0;i=1<>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(o|0)){n=o<<((n|0)==31?0:25-(n>>>1)|0);while(1){r=t+16+(n>>>31<<2)|0;i=pe[r>>2]|0;if(!i)break;if((pe[i+4>>2]&-8|0)==(o|0)){g=i;break t}else{n=n<<1;t=i}}if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[r>>2]=y;pe[y+24>>2]=t;pe[y+12>>2]=y;pe[y+8>>2]=y;break e}}else g=t}while(0);t=g+8|0;r=pe[t>>2]|0;b=pe[155]|0;if(r>>>0>=b>>>0&g>>>0>=b>>>0){pe[r+12>>2]=y;pe[t>>2]=y;pe[y+8>>2]=r;pe[y+12>>2]=g;pe[y+24>>2]=0;break}else Xe()}else{pe[152]=r|i;pe[t>>2]=y;pe[y+24>>2]=t;pe[y+12>>2]=y;pe[y+8>>2]=y}}while(0);y=(pe[159]|0)+-1|0;pe[159]=y;if(!y)t=1060;else return;while(1){t=pe[t>>2]|0;if(!t)break;else t=t+8|0}pe[159]=-1;return}function Xr(e,t){e=e|0;t=t|0;var r=0,i=0;if(!e){e=Ur(t)|0;return e|0}if(t>>>0>4294967231){e=cr()|0;pe[e>>2]=12;e=0;return e|0}r=Hr(e+-8|0,t>>>0<11?16:t+11&-8)|0;if(r){e=r+8|0;return e|0}r=Ur(t)|0;if(!r){e=0;return e|0}i=pe[e+-4>>2]|0;i=(i&-8)-((i&3|0)==0?8:4)|0;Qr(r|0,e|0,(i>>>0>>0?i:t)|0)|0;zr(e);e=r;return e|0}function qr(e){e=e|0;var t=0;if(!e){t=0;return t|0}e=pe[e+-4>>2]|0;t=e&3;if((t|0)==1){t=0;return t|0}t=(e&-8)-((t|0)==0?8:4)|0;return t|0}function Hr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;d=e+4|0;p=pe[d>>2]|0;u=p&-8;c=e+u|0;s=pe[155]|0;r=p&3;if(!((r|0)!=1&e>>>0>=s>>>0&e>>>0>>0))Xe();i=e+(u|4)|0;n=pe[i>>2]|0;if(!(n&1))Xe();if(!r){if(t>>>0<256){e=0;return e|0}if(u>>>0>=(t+4|0)>>>0?(u-t|0)>>>0<=pe[271]<<1>>>0:0)return e|0;e=0;return e|0}if(u>>>0>=t>>>0){r=u-t|0;if(r>>>0<=15)return e|0;pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=r|3;pe[i>>2]=pe[i>>2]|1;Gr(e+t|0,r);return e|0}if((c|0)==(pe[157]|0)){r=(pe[154]|0)+u|0;if(r>>>0<=t>>>0){e=0;return e|0}l=r-t|0;pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=l|1;pe[157]=e+t;pe[154]=l;return e|0}if((c|0)==(pe[156]|0)){i=(pe[153]|0)+u|0;if(i>>>0>>0){e=0;return e|0}r=i-t|0;if(r>>>0>15){pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=r|1;pe[e+i>>2]=r;i=e+(i+4)|0;pe[i>>2]=pe[i>>2]&-2;i=e+t|0}else{pe[d>>2]=p&1|i|2;i=e+(i+4)|0;pe[i>>2]=pe[i>>2]|1;i=0;r=0}pe[153]=r;pe[156]=i;return e|0}if(n&2){e=0;return e|0}f=(n&-8)+u|0;if(f>>>0>>0){e=0;return e|0}l=f-t|0;o=n>>>3;do{if(n>>>0>=256){a=pe[e+(u+24)>>2]|0;o=pe[e+(u+12)>>2]|0;do{if((o|0)==(c|0)){i=e+(u+20)|0;r=pe[i>>2]|0;if(!r){i=e+(u+16)|0;r=pe[i>>2]|0;if(!r){h=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;h=r;break}}else{n=pe[e+(u+8)>>2]|0;if(n>>>0>>0)Xe();r=n+12|0;if((pe[r>>2]|0)!=(c|0))Xe();i=o+8|0;if((pe[i>>2]|0)==(c|0)){pe[r>>2]=o;pe[i>>2]=n;h=o;break}else Xe()}}while(0);if(a){r=pe[e+(u+28)>>2]|0;i=908+(r<<2)|0;if((c|0)==(pe[i>>2]|0)){pe[i>>2]=h;if(!h){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=a+16|0;if((pe[r>>2]|0)==(c|0))pe[r>>2]=h;else pe[a+20>>2]=h;if(!h)break}i=pe[155]|0;if(h>>>0>>0)Xe();pe[h+24>>2]=a;r=pe[e+(u+16)>>2]|0;do{if(r)if(r>>>0>>0)Xe();else{pe[h+16>>2]=r;pe[r+24>>2]=h;break}}while(0);r=pe[e+(u+20)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[h+20>>2]=r;pe[r+24>>2]=h;break}}}else{n=pe[e+(u+8)>>2]|0;i=pe[e+(u+12)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(c|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(c|0))a=r;else Xe()}else a=i+8|0;pe[n+12>>2]=i;pe[a>>2]=n}}while(0);if(l>>>0<16){pe[d>>2]=f|p&1|2;t=e+(f|4)|0;pe[t>>2]=pe[t>>2]|1;return e|0}else{pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=l|3;p=e+(f|4)|0;pe[p>>2]=pe[p>>2]|1;Gr(e+t|0,l);return e|0}return 0}function Gr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0;m=e+t|0;r=pe[e+4>>2]|0;do{if(!(r&1)){h=pe[e>>2]|0;if(!(r&3))return;l=e+(0-h)|0;f=h+t|0;u=pe[155]|0;if(l>>>0>>0)Xe();if((l|0)==(pe[156]|0)){i=e+(t+4)|0;r=pe[i>>2]|0;if((r&3|0)!=3){g=l;a=f;break}pe[153]=f;pe[i>>2]=r&-2;pe[e+(4-h)>>2]=f|1;pe[m>>2]=f;return}o=h>>>3;if(h>>>0<256){n=pe[e+(8-h)>>2]|0;i=pe[e+(12-h)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(l|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(l|0))s=r;else Xe()}else s=i+8|0;pe[n+12>>2]=i;pe[s>>2]=n;g=l;a=f;break}s=pe[e+(24-h)>>2]|0;n=pe[e+(12-h)>>2]|0;do{if((n|0)==(l|0)){n=16-h|0;i=e+(n+4)|0;r=pe[i>>2]|0;if(!r){i=e+n|0;r=pe[i>>2]|0;if(!r){c=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;c=r;break}}else{o=pe[e+(8-h)>>2]|0;if(o>>>0>>0)Xe();r=o+12|0;if((pe[r>>2]|0)!=(l|0))Xe();i=n+8|0;if((pe[i>>2]|0)==(l|0)){pe[r>>2]=n;pe[i>>2]=o;c=n;break}else Xe()}}while(0);if(s){r=pe[e+(28-h)>>2]|0;i=908+(r<<2)|0;if((l|0)==(pe[i>>2]|0)){pe[i>>2]=c;if(!c){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=s+16|0;if((pe[r>>2]|0)==(l|0))pe[r>>2]=c;else pe[s+20>>2]=c;if(!c){g=l;a=f;break}}n=pe[155]|0;if(c>>>0>>0)Xe();pe[c+24>>2]=s;r=16-h|0;i=pe[e+r>>2]|0;do{if(i)if(i>>>0>>0)Xe();else{pe[c+16>>2]=i;pe[i+24>>2]=c;break}}while(0);r=pe[e+(r+4)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[c+20>>2]=r;pe[r+24>>2]=c;g=l;a=f;break}else{g=l;a=f}}else{g=l;a=f}}else{g=e;a=t}}while(0);u=pe[155]|0;if(m>>>0>>0)Xe();r=e+(t+4)|0;i=pe[r>>2]|0;if(!(i&2)){if((m|0)==(pe[157]|0)){b=(pe[154]|0)+a|0;pe[154]=b;pe[157]=g;pe[g+4>>2]=b|1;if((g|0)!=(pe[156]|0))return;pe[156]=0;pe[153]=0;return}if((m|0)==(pe[156]|0)){b=(pe[153]|0)+a|0;pe[153]=b;pe[156]=g;pe[g+4>>2]=b|1;pe[g+b>>2]=b;return}a=(i&-8)+a|0;o=i>>>3;do{if(i>>>0>=256){s=pe[e+(t+24)>>2]|0;n=pe[e+(t+12)>>2]|0;do{if((n|0)==(m|0)){i=e+(t+20)|0;r=pe[i>>2]|0;if(!r){i=e+(t+16)|0;r=pe[i>>2]|0;if(!r){p=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;p=r;break}}else{o=pe[e+(t+8)>>2]|0;if(o>>>0>>0)Xe();r=o+12|0;if((pe[r>>2]|0)!=(m|0))Xe();i=n+8|0;if((pe[i>>2]|0)==(m|0)){pe[r>>2]=n;pe[i>>2]=o;p=n;break}else Xe()}}while(0);if(s){r=pe[e+(t+28)>>2]|0;i=908+(r<<2)|0;if((m|0)==(pe[i>>2]|0)){pe[i>>2]=p;if(!p){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=s+16|0;if((pe[r>>2]|0)==(m|0))pe[r>>2]=p;else pe[s+20>>2]=p;if(!p)break}i=pe[155]|0;if(p>>>0>>0)Xe();pe[p+24>>2]=s;r=pe[e+(t+16)>>2]|0;do{if(r)if(r>>>0>>0)Xe();else{pe[p+16>>2]=r;pe[r+24>>2]=p;break}}while(0);r=pe[e+(t+20)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[p+20>>2]=r;pe[r+24>>2]=p;break}}}else{n=pe[e+(t+8)>>2]|0;i=pe[e+(t+12)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(m|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(m|0))d=r;else Xe()}else d=i+8|0;pe[n+12>>2]=i;pe[d>>2]=n}}while(0);pe[g+4>>2]=a|1;pe[g+a>>2]=a;if((g|0)==(pe[156]|0)){pe[153]=a;return}}else{pe[r>>2]=i&-2;pe[g+4>>2]=a|1;pe[g+a>>2]=a}r=a>>>3;if(a>>>0<256){i=r<<1;o=644+(i<<2)|0;n=pe[151]|0;r=1<>2]|0;if(i>>>0<(pe[155]|0)>>>0)Xe();else{v=r;b=i}}else{pe[151]=n|r;v=644+(i+2<<2)|0;b=o}pe[v>>2]=g;pe[b+12>>2]=g;pe[g+8>>2]=b;pe[g+12>>2]=o;return}r=a>>>8;if(r)if(a>>>0>16777215)o=31;else{v=(r+1048320|0)>>>16&8;b=r<>>16&4;b=b<>>16&2;o=14-(m|v|o)+(b<>>15)|0;o=a>>>(o+7|0)&1|o<<1}else o=0;r=908+(o<<2)|0;pe[g+28>>2]=o;pe[g+20>>2]=0;pe[g+16>>2]=0;i=pe[152]|0;n=1<>2]=g;pe[g+24>>2]=r;pe[g+12>>2]=g;pe[g+8>>2]=g;return}r=pe[r>>2]|0;e:do{if((pe[r+4>>2]&-8|0)!=(a|0)){o=a<<((o|0)==31?0:25-(o>>>1)|0);while(1){i=r+16+(o>>>31<<2)|0;n=pe[i>>2]|0;if(!n)break;if((pe[n+4>>2]&-8|0)==(a|0)){r=n;break e}else{o=o<<1;r=n}}if(i>>>0<(pe[155]|0)>>>0)Xe();pe[i>>2]=g;pe[g+24>>2]=r;pe[g+12>>2]=g;pe[g+8>>2]=g;return}}while(0);i=r+8|0;n=pe[i>>2]|0;b=pe[155]|0;if(!(n>>>0>=b>>>0&r>>>0>=b>>>0))Xe();pe[n+12>>2]=g;pe[i>>2]=g;pe[g+8>>2]=n;pe[g+12>>2]=r;pe[g+24>>2]=0;return}function Vr(){}function Yr(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;i=t-i-(r>>>0>e>>>0|0)>>>0;return(re=i,e-r>>>0|0)|0}function Wr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;i=e+r|0;if((r|0)>=20){t=t&255;o=e&3;a=t|t<<8|t<<16|t<<24;n=i&~3;if(o){o=e+4-o|0;while((e|0)<(o|0)){de[e>>0]=t;e=e+1|0}}while((e|0)<(n|0)){pe[e>>2]=a;e=e+4|0}}while((e|0)<(i|0)){de[e>>0]=t;e=e+1|0}return e-r|0}function Jr(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t>>>r;return e>>>r|(t&(1<>>r-32|0}function Kr(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t<>>32-r;return e<>>0;return(re=t+i+(r>>>0>>0|0)>>>0,r|0)|0}function Qr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if((r|0)>=4096)return Re(e|0,t|0,r|0)|0;i=e|0;if((e&3)==(t&3)){while(e&3){if(!r)return i|0;de[e>>0]=de[t>>0]|0;e=e+1|0;t=t+1|0;r=r-1|0}while((r|0)>=4){pe[e>>2]=pe[t>>2];e=e+4|0;t=t+4|0;r=r-4|0}}while((r|0)>0){de[e>>0]=de[t>>0]|0;e=e+1|0;t=t+1|0;r=r-1|0}return i|0}function $r(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t>>r;return e>>>r|(t&(1<>r-32|0}function ei(e){e=e|0;var t=0;t=de[v+(e&255)>>0]|0;if((t|0)<8)return t|0;t=de[v+(e>>8&255)>>0]|0;if((t|0)<8)return t+8|0;t=de[v+(e>>16&255)>>0]|0;if((t|0)<8)return t+16|0;return(de[v+(e>>>24)>>0]|0)+24|0}function ti(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0;o=e&65535;n=t&65535;r=ge(n,o)|0;i=e>>>16;e=(r>>>16)+(ge(n,i)|0)|0;n=t>>>16;t=ge(n,o)|0;return(re=(e>>>16)+(ge(n,i)|0)+(((e&65535)+t|0)>>>16)|0,e+t<<16|r&65535|0)|0}function ri(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0;h=t>>31|((t|0)<0?-1:0)<<1;u=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1;o=i>>31|((i|0)<0?-1:0)<<1;n=((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1;s=Yr(h^e,u^t,h,u)|0;a=re;e=o^h;t=n^u;return Yr((si(s,a,Yr(o^r,n^i,o,n)|0,re,0)|0)^e,re^t,e,t)|0}function ii(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0;n=be;be=be+16|0;s=n|0;a=t>>31|((t|0)<0?-1:0)<<1;o=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1;h=i>>31|((i|0)<0?-1:0)<<1;u=((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1;e=Yr(a^e,o^t,a,o)|0;t=re;si(e,t,Yr(h^r,u^i,h,u)|0,re,s)|0;i=Yr(pe[s>>2]^a,pe[s+4>>2]^o,a,o)|0;r=re;be=n;return(re=r,i)|0}function ni(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0;n=e;o=r;r=ti(n,o)|0;e=re;return(re=(ge(t,o)|0)+(ge(i,n)|0)+e|e&0,r|0|0)|0}function oi(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;return si(e,t,r,i,0)|0}function ai(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0;o=be;be=be+16|0;n=o|0;si(e,t,r,i,n)|0;be=o;return(re=pe[n+4>>2]|0,pe[n>>2]|0)|0}function si(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;c=e;u=t;h=u;a=r;l=i;s=l;if(!h){o=(n|0)!=0;if(!s){if(o){pe[n>>2]=(c>>>0)%(a>>>0);pe[n+4>>2]=0}l=0;n=(c>>>0)/(a>>>0)>>>0;return(re=l,n)|0}else{if(!o){l=0;n=0;return(re=l,n)|0}pe[n>>2]=e|0;pe[n+4>>2]=t&0;l=0;n=0;return(re=l,n)|0}}o=(s|0)==0;do{if(a){if(!o){o=(ae(s|0)|0)-(ae(h|0)|0)|0;if(o>>>0<=31){f=o+1|0;s=31-o|0;t=o-31>>31;a=f;e=c>>>(f>>>0)&t|h<>>(f>>>0)&t;o=0;s=c<>2]=e|0;pe[n+4>>2]=u|t&0;l=0;n=0;return(re=l,n)|0}o=a-1|0;if(o&a){s=(ae(a|0)|0)+33-(ae(h|0)|0)|0;p=64-s|0;f=32-s|0;u=f>>31;d=s-32|0;t=d>>31;a=s;e=f-1>>31&h>>>(d>>>0)|(h<>>(s>>>0))&t;t=t&h>>>(s>>>0);o=c<>>(d>>>0))&u|c<>31;break}if(n){pe[n>>2]=o&c;pe[n+4>>2]=0}if((a|0)==1){d=u|t&0;p=e|0|0;return(re=d,p)|0}else{p=ei(a|0)|0;d=h>>>(p>>>0)|0;p=h<<32-p|c>>>(p>>>0)|0;return(re=d,p)|0}}else{if(o){if(n){pe[n>>2]=(h>>>0)%(a>>>0);pe[n+4>>2]=0}d=0;p=(h>>>0)/(a>>>0)>>>0;return(re=d,p)|0}if(!c){if(n){pe[n>>2]=0;pe[n+4>>2]=(h>>>0)%(s>>>0)}d=0;p=(h>>>0)/(s>>>0)>>>0;return(re=d,p)|0}o=s-1|0;if(!(o&s)){if(n){pe[n>>2]=e|0;pe[n+4>>2]=o&h|t&0}d=0;p=h>>>((ei(s|0)|0)>>>0);return(re=d,p)|0}o=(ae(s|0)|0)-(ae(h|0)|0)|0;if(o>>>0<=30){t=o+1|0;s=31-o|0;a=t;e=h<>>(t>>>0);t=h>>>(t>>>0);o=0;s=c<>2]=e|0;pe[n+4>>2]=u|t&0;d=0;p=0;return(re=d,p)|0}}while(0);if(!a){h=s;u=0;s=0}else{f=r|0|0;c=l|i&0;h=Zr(f|0,c|0,-1,-1)|0;r=re;u=s;s=0;do{i=u;u=o>>>31|u<<1;o=s|o<<1;i=e<<1|i>>>31|0;l=e>>>31|t<<1|0;Yr(h,r,i,l)|0;p=re;d=p>>31|((p|0)<0?-1:0)<<1;s=d&1;e=Yr(i,l,d&f,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&c)|0;t=re;a=a-1|0}while((a|0)!=0);h=u;u=0}a=0;if(n){pe[n>>2]=e;pe[n+4>>2]=t}d=(o|0)>>>31|(h|a)<<1|(a<<1|o>>>31)&0|u;p=(o<<1|0>>>31)&-2|s;return(re=d,p)|0}function ui(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;return Ai[e&7](t|0,r|0,i|0)|0}function hi(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;Pi[e&3](t|0,r|0,i|0,n|0,o|0)}function ci(e,t){e=e|0;t=t|0;Mi[e&7](t|0)}function fi(e,t){e=e|0;t=t|0;return Ci[e&1](t|0)|0}function li(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;ki[e&0](t|0,r|0,i|0)}function di(e){e=e|0;Ii[e&3]()}function pi(e,t,r,i,n,o,a){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;Ri[e&3](t|0,r|0,i|0,n|0,o|0,a|0)}function mi(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;return Oi[e&1](t|0,r|0,i|0,n|0,o|0)|0}function vi(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;Di[e&3](t|0,r|0,i|0,n|0)}function bi(e,t,r){e=e|0;t=t|0;r=r|0;se(0);return 0}function gi(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;se(1)}function yi(e){e=e|0;se(2)}function _i(e){e=e|0;se(3);return 0}function wi(e,t,r){e=e|0;t=t|0;r=r|0;se(4)}function xi(){se(5)}function Ti(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;se(6)}function Si(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;se(7);return 0}function Ei(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;se(8)}var Ai=[bi,Wt,Fr,Cr,Mr,kr,bi,bi];var Pi=[gi,tr,er,gi];var Mi=[yi,qt,Vt,Ht,Gt,Yt,ur,Lr];var Ci=[_i,Pr];var ki=[wi];var Ii=[xi,ar,sr,xi];var Ri=[Ti,ir,rr,Ti];var Oi=[Si,ut];var Di=[Ei,Kt,Zt,Ei];return{___cxa_can_catch:nr,_crn_get_levels:Tt,_crn_get_uncompressed_size:Et,_crn_decompress:At,_i64Add:Zr,_crn_get_width:wt,___cxa_is_pointer_type:or,_i64Subtract:Yr,_memset:Wr,_malloc:Ur,_free:zr,_memcpy:Qr,_bitshift64Lshr:Jr,_fflush:vr,_bitshift64Shl:Kr,_crn_get_height:xt,___errno_location:cr,_crn_get_dxt_format:St,runPostSets:Vr,_emscripten_replace_memory:We,stackAlloc:Je,stackSave:Ke,stackRestore:Ze,establishStackSpace:Qe,setThrew:$e,setTempRet0:rt,getTempRet0:it,dynCall_iiii:ui,dynCall_viiiii:hi,dynCall_vi:ci,dynCall_ii:fi,dynCall_viii:li,dynCall_v:di,dynCall_viiiiii:pi,dynCall_iiiiii:mi,dynCall_viiii:vi}}(e.Ya,e.Za,buffer);e.___cxa_can_catch=Z.___cxa_can_catch,e._crn_get_levels=Z._crn_get_levels,e.runPostSets=Z.runPostSets,e._crn_get_uncompressed_size=Z._crn_get_uncompressed_size,e._crn_decompress=Z._crn_decompress;var zc=e._i64Add=Z._i64Add;e._crn_get_height=Z._crn_get_height,e.___cxa_is_pointer_type=Z.___cxa_is_pointer_type;var nb=e._i64Subtract=Z._i64Subtract,qb=e._memset=Z._memset,Ea=e._malloc=Z._malloc,Bc=e._memcpy=Z._memcpy,Xa=e._emscripten_replace_memory=Z._emscripten_replace_memory;e._crn_get_dxt_format=Z._crn_get_dxt_format;var rb=e._bitshift64Lshr=Z._bitshift64Lshr,Na=e._free=Z._free;e._fflush=Z._fflush,e._crn_get_width=Z._crn_get_width,e.___errno_location=Z.___errno_location;var sb=e._bitshift64Shl=Z._bitshift64Shl;function ia(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}e.dynCall_iiii=Z.dynCall_iiii,e.dynCall_viiiii=Z.dynCall_viiiii,e.dynCall_vi=Z.dynCall_vi,e.dynCall_ii=Z.dynCall_ii,e.dynCall_viii=Z.dynCall_viii,e.dynCall_v=Z.dynCall_v,e.dynCall_viiiiii=Z.dynCall_viiiiii,e.dynCall_iiiiii=Z.dynCall_iiiiii,e.dynCall_viiii=Z.dynCall_viiii,n.aa=Z.stackAlloc,n.ua=Z.stackSave,n.ba=Z.stackRestore,n.Cd=Z.establishStackSpace,n.rb=Z.setTempRet0,n.fb=Z.getTempRet0,ia.prototype=Error(),ia.prototype.constructor=ia;var rd=null,jb=function t(){e.calledRun||td(),e.calledRun||(jb=t)};function td(t){function r(){if(!e.calledRun&&(e.calledRun=!0,!na)){if(Ha||(Ha=!0,ab(cb)),ab(db),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e._main&&vd&&e.callMain(t),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)gb(e.postRun.shift());ab(eb)}}if(t=t||e.arguments,null===rd&&(rd=Date.now()),!(0 0) var gc = undefined");else{if(!ba&&!ca)throw"Unknown runtime environment. Where are we?";e.read=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},void 0!==arguments&&(e.arguments=arguments),"undefined"!=typeof console?(e.print||(e.print=function(e){console.log(e)}),e.printErr||(e.printErr=function(e){console.log(e)})):e.print||(e.print=function(){}),ca&&(e.load=importScripts),void 0===e.setWindowTitle&&(e.setWindowTitle=function(e){document.title=e})}function ha(e){eval.call(null,e)}for(k in!e.load&&e.read&&(e.load=function(t){ha(e.read(t))}),e.print||(e.print=function(){}),e.printErr||(e.printErr=e.print),e.arguments||(e.arguments=[]),e.thisProgram||(e.thisProgram="./this.program"),e.print=e.print,e.W=e.printErr,e.preRun=[],e.postRun=[],aa)aa.hasOwnProperty(k)&&(e[k]=aa[k]);var n={rb:function(e){ka=e},fb:function(){return ka},ua:function(){return m},ba:function(e){m=e},Ka:function(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:return"*"===e[e.length-1]?n.J:"i"===e[0]?(assert(0==(e=parseInt(e.substr(1)))%8),e/8):0}},eb:function(e){return Math.max(n.Ka(e),n.J)},ud:16,Qd:function(e,t){return"double"===t||"i64"===t?7&e&&(assert(4==(7&e)),e+=4):assert(0==(3&e)),e},Ed:function(e,t,r){return r||"i64"!=e&&"double"!=e?e?Math.min(t||(e?n.eb(e):0),n.J):Math.min(t,8):8},L:function(t,r,i){return i&&i.length?(i.splice||(i=Array.prototype.slice.call(i)),i.splice(0,0,r),e["dynCall_"+t].apply(null,i)):e["dynCall_"+t].call(null,r)},Z:[],Xa:function(e){for(var t=0;t>>0)+4294967296*+(t>>>0):+(e>>>0)+4294967296*+(0|t)},Ua:8,J:4,vd:0};e.Runtime=n,n.addFunction=n.Xa,n.removeFunction=n.nb;var na=!1,oa,pa,ka,ra,sa;function assert(e,t){e||x("Assertion failed: "+t)}function qa(a){var b=e["_"+a];if(!b)try{b=eval("_"+a)}catch(e){}return assert(b,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)"),b}function wa(e,t,r){switch("*"===(r=r||"i8").charAt(r.length-1)&&(r="i32"),r){case"i1":case"i8":y[e>>0]=t;break;case"i16":z[e>>1]=t;break;case"i32":C[e>>2]=t;break;case"i64":pa=[t>>>0,(oa=t,1<=+xa(oa)?0>>0:~~+Aa((oa-+(~~oa>>>0))/4294967296)>>>0:0)],C[e>>2]=pa[0],C[e+4>>2]=pa[1];break;case"float":Ba[e>>2]=t;break;case"double":Ca[e>>3]=t;break;default:x("invalid type for setValue: "+r)}}function Da(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return y[e>>0];case"i16":return z[e>>1];case"i32":case"i64":return C[e>>2];case"float":return Ba[e>>2];case"double":return Ca[e>>3];default:x("invalid type for setValue: "+t)}return null}function D(e,t,r,i){var o,a;a="number"==typeof e?(o=!0,e):(o=!1,e.length);var s,u,h="string"==typeof t?t:null;if(r=4==r?i:[Ea,n.aa,n.Ra,n.R][void 0===r?2:r](Math.max(a,h?1:t.length)),o){for(assert(0==(3&(i=r))),e=r+(-4&a);i>2]=0;for(e=r+a;i>0]=0;return r}if("i8"===h)return e.subarray||e.slice?E.set(e,r):E.set(new Uint8Array(e),r),r;for(i=0;i>0],0!=i||r)&&(o++,!r||o!=r););if(r||(r=o),i="",n<128){for(;0>10,56320|1023&r)))):s+=String.fromCharCode(r)}}function Ka(e,t,r,i){if(!(0>6}else{if(a<=65535){if(i<=r+2)break;t[r++]=224|a>>12}else{if(a<=2097151){if(i<=r+3)break;t[r++]=240|a>>18}else{if(a<=67108863){if(i<=r+4)break;t[r++]=248|a>>24}else{if(i<=r+5)break;t[r++]=252|a>>30,t[r++]=128|a>>24&63}t[r++]=128|a>>18&63}t[r++]=128|a>>12&63}t[r++]=128|a>>6&63}t[r++]=128|63&a}}return t[r]=0,r-n}function La(e){for(var t=0,r=0;r"):o=n;e:for(;f>0];if(!r)return t;t+=String.fromCharCode(r)}},e.stringToAscii=function(e,t){return Ia(e,t,!1)},e.UTF8ArrayToString=Ja,e.UTF8ToString=function(e){return Ja(E,e)},e.stringToUTF8Array=Ka,e.stringToUTF8=function(e,t,r){return Ka(e,E,t,r)},e.lengthBytesUTF8=La,e.UTF16ToString=function(e){for(var t=0,r="";;){var i=z[e+2*t>>1];if(0==i)return r;++t,r+=String.fromCharCode(i)}},e.stringToUTF16=function(e,t,r){if(void 0===r&&(r=2147483647),r<2)return 0;var i=t;r=(r-=2)<2*e.length?r/2:e.length;for(var n=0;n>1]=e.charCodeAt(n),t+=2;return z[t>>1]=0,t-i},e.lengthBytesUTF16=function(e){return 2*e.length},e.UTF32ToString=function(e){for(var t=0,r="";;){var i=C[e+4*t>>2];if(0==i)return r;++t,65536<=i?(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i)):r+=String.fromCharCode(i)}},e.stringToUTF32=function(e,t,r){if(void 0===r&&(r=2147483647),r<4)return 0;var i=t;r=i+r-4;for(var n=0;n>2]=o,r<(t+=4)+4)break}return C[t>>2]=0,t-i},e.lengthBytesUTF32=function(e){for(var t=0,r=0;r>0]=e[r],r+=1}function ta(e,t){for(var r=0;r>0]=e[r]}function Ia(e,t,r){for(var i=0;i>0]=e.charCodeAt(i);r||(y[t>>0]=0)}e.addOnPreRun=fb,e.addOnInit=function(e){cb.unshift(e)},e.addOnPreMain=function(e){db.unshift(e)},e.addOnExit=function(e){H.unshift(e)},e.addOnPostRun=gb,e.intArrayFromString=hb,e.intArrayToString=function(e){for(var t=[],r=0;r>>16)*i+r*(t>>>16)<<16)|0}),Math.Jd=Math.imul,Math.clz32||(Math.clz32=function(e){e>>>=0;for(var t=0;t<32;t++)if(e&1<<31-t)return t;return 32}),Math.Ad=Math.clz32;var xa=Math.abs,Aa=Math.ceil,za=Math.floor,ya=Math.min,I=0,ib=null,jb=null;function kb(){I++,e.monitorRunDependencies&&e.monitorRunDependencies(I)}function lb(){if(I--,e.monitorRunDependencies&&e.monitorRunDependencies(I),0==I&&(null!==ib&&(clearInterval(ib),ib=null),jb)){var t=jb;jb=null,t()}}e.addRunDependency=kb,e.removeRunDependency=lb,e.preloadedImages={},e.preloadedAudios={},Ta=8,la=Ta+5888,cb.push(),D([124,0,0,0,98,7,0,0,124,0,0,0,111,7,0,0,164,0,0,0,124,7,0,0,16,0,0,0,0,0,0,0,164,0,0,0,157,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,227,7,0,0,24,0,0,0,0,0,0,0,164,0,0,0,191,7,0,0,56,0,0,0,0,0,0,0,164,0,0,0,5,8,0,0,40,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,40,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,88,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,114,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,124,1,0,0,236,1,0,0,236,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,239,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,4,0,0,0,231,16,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,115,40,37,117,41,58,32,65,115,115,101,114,116,105,111,110,32,102,97,105,108,117,114,101,58,32,34,37,115,34,10,0,109,95,115,105,122,101,32,60,61,32,109,95,99,97,112,97,99,105,116,121,0,46,47,99,114,110,95,100,101,99,111,109,112,46,104,0,109,105,110,95,110,101,119,95,99,97,112,97,99,105,116,121,32,60,32,40,48,120,55,70,70,70,48,48,48,48,85,32,47,32,101,108,101,109,101,110,116,95,115,105,122,101,41,0,110,101,119,95,99,97,112,97,99,105,116,121,32,38,38,32,40,110,101,119,95,99,97,112,97,99,105,116,121,32,62,32,109,95,99,97,112,97,99,105,116,121,41,0,110,117,109,95,99,111,100,101,115,91,99,93,0,115,111,114,116,101,100,95,112,111,115,32,60,32,116,111,116,97,108,95,117,115,101,100,95,115,121,109,115,0,112,67,111,100,101,115,105,122,101,115,91,115,121,109,95,105,110,100,101,120,93,32,61,61,32,99,111,100,101,115,105,122,101,0,116,32,60,32,40,49,85,32,60,60,32,116,97,98,108,101,95,98,105,116,115,41,0,109,95,108,111,111,107,117,112,91,116,93,32,61,61,32,99,85,73,78,84,51,50,95,77,65,88,0,99,114,110,100,95,109,97,108,108,111,99,58,32,115,105,122,101,32,116,111,111,32,98,105,103,0,99,114,110,100,95,109,97,108,108,111,99,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,0,40,40,117,105,110,116,51,50,41,112,95,110,101,119,32,38,32,40,67,82,78,68,95,77,73,78,95,65,76,76,79,67,95,65,76,73,71,78,77,69,78,84,32,45,32,49,41,41,32,61,61,32,48,0,99,114,110,100,95,114,101,97,108,108,111,99,58,32,98,97,100,32,112,116,114,0,99,114,110,100,95,102,114,101,101,58,32,98,97,100,32,112,116,114,0,102,97,108,115,101,0,40,116,111,116,97,108,95,115,121,109,115,32,62,61,32,49,41,32,38,38,32,40,116,111,116,97,108,95,115,121,109,115,32,60,61,32,112,114,101,102,105,120,95,99,111,100,105,110,103,58,58,99,77,97,120,83,117,112,112,111,114,116,101,100,83,121,109,115,41,0,17,18,19,20,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,16,48,0,110,117,109,95,98,105,116,115,32,60,61,32,51,50,85,0,109,95,98,105,116,95,99,111,117,110,116,32,60,61,32,99,66,105,116,66,117,102,83,105,122,101,0,116,32,33,61,32,99,85,73,78,84,51,50,95,77,65,88,0,109,111,100,101,108,46,109,95,99,111,100,101,95,115,105,122,101,115,91,115,121,109,93,32,61,61,32,108,101,110,0,0,2,3,1,0,2,3,4,5,6,7,1,40,108,101,110,32,62,61,32,49,41,32,38,38,32,40,108,101,110,32,60,61,32,99,77,97,120,69,120,112,101,99,116,101,100,67,111,100,101,83,105,122,101,41,0,105,32,60,32,109,95,115,105,122,101,0,110,101,120,116,95,108,101,118,101,108,95,111,102,115,32,62,32,99,117,114,95,108,101,118,101,108,95,111,102,115,0,1,2,2,3,3,3,3,4,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,2,1,2,0,0,0,1,0,2,1,0,2,0,0,1,2,3,110,117,109,32,38,38,32,40,110,117,109,32,61,61,32,126,110,117,109,95,99,104,101,99,107,41,0,83,116,57,101,120,99,101,112,116,105,111,110,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,117,110,99,97,117,103,104,116,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0],"i8",4,n.Ua);var mb=n.ja(D(12,"i8",2),8);function ob(t){return e.___errno_location&&(C[e.___errno_location()>>2]=t),t}assert(0==mb%8),e._i64Subtract=nb;var J={I:1,F:2,ed:3,bc:4,H:5,Aa:6,vb:7,zc:8,ea:9,Jb:10,va:11,qd:11,Ta:12,da:13,Vb:14,Lc:15,fa:16,wa:17,rd:18,ha:19,ya:20,P:21,q:22,uc:23,Sa:24,Q:25,nd:26,Wb:27,Hc:28,ia:29,bd:30,nc:31,Vc:32,Sb:33,Zc:34,Dc:42,Zb:43,Kb:44,ec:45,fc:46,gc:47,mc:48,od:49,xc:50,dc:51,Pb:35,Ac:37,Bb:52,Eb:53,sd:54,vc:55,Fb:56,Gb:57,Qb:35,Hb:59,Jc:60,yc:61,kd:62,Ic:63,Ec:64,Fc:65,ad:66,Bc:67,yb:68,gd:69,Lb:70,Wc:71,pc:72,Tb:73,Db:74,Qc:76,Cb:77,$c:78,hc:79,ic:80,lc:81,kc:82,jc:83,Kc:38,za:39,qc:36,ga:40,Rc:95,Uc:96,Ob:104,wc:105,zb:97,Yc:91,Oc:88,Gc:92,cd:108,Nb:111,wb:98,Mb:103,tc:101,rc:100,ld:110,Xb:112,Yb:113,ac:115,Ab:114,Rb:89,oc:90,Xc:93,dd:94,xb:99,sc:102,cc:106,Mc:107,md:109,pd:87,Ub:122,hd:116,Pc:95,Cc:123,$b:84,Sc:75,Ib:125,Nc:131,Tc:130,jd:86};function pb(e,t){H.push(function(){n.L("vi",e,[t])}),pb.level=H.length}function tb(){return!!tb.p}e._memset=qb,e._bitshift64Lshr=rb,e._bitshift64Shl=sb;var ub=[],vb={};function wb(e,t){wb.p||(wb.p={}),e in wb.p||(n.L("v",t),wb.p[e]=1)}var xb={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};function yb(e,t){for(var r=0,i=e.length-1;0<=i;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function zb(e){var t="/"===e.charAt(0),r="/"===e.substr(-1);return(e=yb(e.split("/").filter(function(e){return!!e}),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function Ab(e){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."}function Bb(e){if("/"===e)return"/";var t=e.lastIndexOf("/");return-1===t?e:e.substr(t+1)}function Cb(){return zb(Array.prototype.slice.call(arguments,0).join("/"))}function K(e,t){return zb(e+"/"+t)}function Db(){for(var e="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=yb(e.split("/").filter(function(e){return!!e}),!t).join("/"))||"."}var Eb=[];function Fb(e,t){Eb[e]={input:[],output:[],N:t},Gb(e,Hb)}var Hb={open:function(e){var t=Eb[e.g.rdev];if(!t)throw new L(J.ha);e.tty=t,e.seekable=!1},close:function(e){e.tty.N.flush(e.tty)},flush:function(e){e.tty.N.flush(e.tty)},read:function(e,t,r,i){if(!e.tty||!e.tty.N.La)throw new L(J.Aa);for(var n=0,o=0;oe.e.length&&(e.e=M.cb(e),e.o=e.e.length),!e.e||e.e.subarray){var r=e.e?e.e.buffer.byteLength:0;t<=r||(t=Math.max(t,r*(r<1048576?2:1.125)|0),0!=r&&(t=Math.max(t,256)),r=e.e,e.e=new Uint8Array(t),0t)e.e.length=t;else for(;e.e.length=e.g.o)return 0;if(assert(0<=(e=Math.min(e.g.o-n,i))),8>1)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return t.mode},B:function(e){for(var t=[];e.parent!==e;)t.push(e.name),e=e.parent;return t.push(e.A.pa.root),t.reverse(),Cb.apply(null,t)},Ha:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},$a:function(e){if((e&=-32769)in P.Ha)return P.Ha[e];throw new L(J.q)},k:{D:function(e){var t;e=P.B(e);try{t=fs.lstatSync(e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return P.$&&!t.K&&(t.K=4096),P.$&&!t.blocks&&(t.blocks=(t.size+t.K-1)/t.K|0),{dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,K:t.K,blocks:t.blocks}},u:function(e,t){var r=P.B(e);try{void 0!==t.mode&&(fs.chmodSync(r,t.mode),e.mode=t.mode),void 0!==t.size&&fs.truncateSync(r,t.size)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},lookup:function(e,t){var r=K(P.B(e),t);r=P.Ja(r);return P.createNode(e,t,r)},T:function(e,t,r,i){e=P.createNode(e,t,r,i),t=P.B(e);try{N(e.mode)?fs.mkdirSync(t,e.mode):fs.writeFileSync(t,"",{mode:e.mode})}catch(e){if(!e.code)throw e;throw new L(J[e.code])}return e},rename:function(e,t,r){e=P.B(e),t=K(P.B(t),r);try{fs.renameSync(e,t)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},unlink:function(e,t){var r=K(P.B(e),t);try{fs.unlinkSync(r)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},rmdir:function(e,t){var r=K(P.B(e),t);try{fs.rmdirSync(r)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},readdir:function(e){e=P.B(e);try{return fs.readdirSync(e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},symlink:function(e,t,r){e=K(P.B(e),t);try{fs.symlinkSync(r,e)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},readlink:function(e){var t=P.B(e);try{return t=fs.readlinkSync(t),t=Ob.relative(Ob.resolve(e.A.pa.root),t)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}}},n:{open:function(e){var t=P.B(e.g);try{32768==(61440&e.g.mode)&&(e.V=fs.openSync(t,P.$a(e.flags)))}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},close:function(e){try{32768==(61440&e.g.mode)&&e.V&&fs.closeSync(e.V)}catch(e){if(!e.code)throw e;throw new L(J[e.code])}},read:function(e,t,r,i,n){if(0===i)return 0;var o,a=new Buffer(i);try{o=fs.readSync(e.V,a,0,i,n)}catch(e){throw new L(J[e.code])}if(0>>0)%Q.length}function Xb(e){var t=Wb(e.parent.id,e.name);e.M=Q[t],Q[t]=e}function Nb(e,t){var r;if(r=(r=Yb(e,"x"))?r:e.k.lookup?0:J.da)throw new L(r,e);for(r=Q[Wb(e.id,t)];r;r=r.M){var i=r.name;if(r.parent.id===e.id&&i===t)return r}return e.k.lookup(e,t)}function Lb(e,t,r,i){return Zb||((Zb=function(e,t,r,i){e||(e=this),this.parent=e,this.A=e.A,this.U=null,this.id=Sb++,this.name=t,this.mode=r,this.k={},this.n={},this.rdev=i}).prototype={},Object.defineProperties(Zb.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},kb:{get:function(){return N(this.mode)}},jb:{get:function(){return 8192==(61440&this.mode)}}})),Xb(e=new Zb(e,t,r,i)),e}function N(e){return 16384==(61440&e)}var $b={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Yb(e,t){return Tb?0:(-1===t.indexOf("r")||292&e.mode)&&(-1===t.indexOf("w")||146&e.mode)&&(-1===t.indexOf("x")||73&e.mode)?0:J.da}function ac(e,t){try{return Nb(e,t),J.wa}catch(e){}return Yb(e,"wx")}function bc(){for(var e=0;e<=4096;e++)if(!Rb[e])return e;throw new L(J.Sa)}function cc(e){dc||((dc=function(){}).prototype={},Object.defineProperties(dc.prototype,{object:{get:function(){return this.g},set:function(e){this.g=e}},Ld:{get:function(){return 1!=(2097155&this.flags)}},Md:{get:function(){return 0!=(2097155&this.flags)}},Kd:{get:function(){return 1024&this.flags}}}));var t,r=new dc;for(t in e)r[t]=e[t];return e=r,r=bc(),e.fd=r,Rb[r]=e}var Kb={open:function(e){e.n=Qb[e.g.rdev].n,e.n.open&&e.n.open(e)},G:function(){throw new L(J.ia)}},qc;function Gb(e,t){Qb[e]={n:t}}function ec(e,t){var r,i="/"===t,n=!t;if(i&&Pb)throw new L(J.fa);if(!i&&!n){if(t=(r=S(t,{Ia:!1})).path,(r=r.g).U)throw new L(J.fa);if(!N(r.mode))throw new L(J.ya)}n={type:e,pa:{},Oa:t,lb:[]};var o=e.A(n);(o.A=n).root=o,i?Pb=o:r&&(r.U=n,r.A&&r.A.lb.push(n))}function fc(e,t,r){var i=S(e,{parent:!0}).g;if(!(e=Bb(e))||"."===e||".."===e)throw new L(J.q);var n=ac(i,e);if(n)throw new L(n);if(!i.k.T)throw new L(J.I);return i.k.T(i,e,t,r)}function gc(e,t){return t=4095&(void 0!==t?t:438),fc(e,t|=32768,0)}function V(e,t){return t=1023&(void 0!==t?t:511),fc(e,t|=16384,0)}function hc(e,t,r){return void 0===r&&(r=t,t=438),fc(e,8192|t,r)}function ic(e,t){if(!Db(e))throw new L(J.F);var r=S(t,{parent:!0}).g;if(!r)throw new L(J.F);var i=Bb(t),n=ac(r,i);if(n)throw new L(n);if(!r.k.symlink)throw new L(J.I);return r.k.symlink(r,i,e)}function Vb(e){if(!(e=S(e).g))throw new L(J.F);if(!e.k.readlink)throw new L(J.q);return Db(T(e.parent),e.k.readlink(e))}function jc(e,t){var r;if(!(r="string"==typeof e?S(e,{la:!0}).g:e).k.u)throw new L(J.I);r.k.u(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})}function kc(t,r){var i,n,o;if(""===t)throw new L(J.F);if("string"==typeof r){if(void 0===(n=$b[r]))throw Error("Unknown file open mode: "+r)}else n=r;if(i=64&(r=n)?4095&(void 0===i?438:i)|32768:0,"object"==typeof t)o=t;else{t=zb(t);try{o=S(t,{la:!(131072&r)}).g}catch(e){}}if(n=!1,64&r)if(o){if(128&r)throw new L(J.wa)}else o=fc(t,i,0),n=!0;if(!o)throw new L(J.F);if(8192==(61440&o.mode)&&(r&=-513),65536&r&&!N(o.mode))throw new L(J.ya);if(!n&&(i=o?40960==(61440&o.mode)?J.ga:N(o.mode)&&(0!=(2097155&r)||512&r)?J.P:(i=["r","w","rw"][3&r],512&r&&(i+="w"),Yb(o,i)):J.F))throw new L(i);if(512&r){var a;if(!(a="string"==typeof(i=o)?S(i,{la:!0}).g:i).k.u)throw new L(J.I);if(N(a.mode))throw new L(J.P);if(32768!=(61440&a.mode))throw new L(J.q);if(i=Yb(a,"w"))throw new L(i);a.k.u(a,{size:0,timestamp:Date.now()})}r&=-641,(o=cc({g:o,path:T(o),flags:r,seekable:!0,position:0,n:o.n,tb:[],error:!1})).n.open&&o.n.open(o),!e.logReadFiles||1&r||(lc||(lc={}),t in lc||(lc[t]=1,e.printErr("read file: "+t)));try{R.onOpenFile&&(a=0,1!=(2097155&r)&&(a|=1),0!=(2097155&r)&&(a|=2),R.onOpenFile(t,a))}catch(e){console.log("FS.trackingDelegate['onOpenFile']('"+t+"', flags) threw an exception: "+e.message)}return o}function mc(e){e.na&&(e.na=null);try{e.n.close&&e.n.close(e)}catch(e){throw e}finally{Rb[e.fd]=null}}function nc(e,t,r){if(!e.seekable||!e.n.G)throw new L(J.ia);e.position=e.n.G(e,t,r),e.tb=[]}function oc(e,t,r,i,n,o){if(i<0||n<0)throw new L(J.q);if(0==(2097155&e.flags))throw new L(J.ea);if(N(e.g.mode))throw new L(J.P);if(!e.n.write)throw new L(J.q);1024&e.flags&&nc(e,0,2);var a=!0;if(void 0===n)n=e.position,a=!1;else if(!e.seekable)throw new L(J.ia);t=e.n.write(e,t,r,i,n,o),a||(e.position+=t);try{e.path&&R.onWriteToFile&&R.onWriteToFile(e.path)}catch(e){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+e.message)}return t}function pc(){L||((L=function(e,t){this.g=t,this.qb=function(e){for(var t in this.S=e,J)if(J[t]===e){this.code=t;break}},this.qb(e),this.message=xb[e]}).prototype=Error(),L.prototype.constructor=L,[J.F].forEach(function(e){Mb[e]=new L(e),Mb[e].stack=""}))}function rc(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}function sc(e,t,r,i){return gc(e=K("string"==typeof e?e:T(e),t),rc(r,i))}function tc(e,t,r,i,n,o){if(n=gc(e=t?K("string"==typeof e?e:T(e),t):e,i=rc(i,n)),r){if("string"==typeof r){e=Array(r.length),t=0;for(var a=r.length;t>2]}function xc(){var e;if(e=X(),!(e=Rb[e]))throw new L(J.ea);return e}var yc={};function Ga(e){Ga.p||(r=Qa(r),Ga.p=!0,assert(n.R),Ga.bb=n.R,n.R=function(){x("cannot dynamically allocate, sbrk now has control")});var t=r;return 0==e||Ga.bb(e)?t:4294967295}e._i64Add=zc;var Ac=1;function Cc(e,t){if(Dc=e,Ec=t,!Fc)return 1;if(0==e)Y=function(){setTimeout(Gc,t)},Hc="timeout";else if(1==e)Y=function(){Ic(Gc)},Hc="rAF";else if(2==e){if(!window.setImmediate){var r=[];window.addEventListener("message",function(e){e.source===window&&"__emcc"===e.data&&(e.stopPropagation(),r.shift()())},!0),window.setImmediate=function(e){r.push(e),window.postMessage("__emcc","*")}}Y=function(){window.setImmediate(Gc)},Hc="immediate"}return 0}function Jc(a,t,r,s,i){e.noExitRuntime=!0,assert(!Fc,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),Fc=a,Kc=s;var u=Lc;if(Gc=function(){if(!na)if(0>r-6&63;r=r-6,e=e+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[n]}2==r?(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&t)<<4],e+="=="):4==r&&(e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&t)<<2],e+="="),h.src="data:audio/x-"+a.substr(-3)+";base64,"+e,s(h)}},h.src=n,ad(function(){s(h)})}});var r=e.canvas;r&&(r.sa=r.requestPointerLock||r.mozRequestPointerLock||r.webkitRequestPointerLock||r.msRequestPointerLock||function(){},r.Fa=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},r.Fa=r.Fa.bind(document),document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1),document.addEventListener("mspointerlockchange",t,!1),e.elementPointerLock&&r.addEventListener("click",function(e){!Tc&&r.sa&&(r.sa(),e.preventDefault())},!1))}}function bd(t,r,i,n){if(r&&e.ka&&t==e.canvas)return e.ka;var o,a;if(r){if(a={antialias:!1,alpha:!1},n)for(var s in n)a[s]=n[s];(a=GL.createContext(t,a))&&(o=GL.getContext(a).td),t.style.backgroundColor="black"}else o=t.getContext("2d");return o?(i&&(r||assert("undefined"==typeof GLctx,"cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),e.ka=o,r&&GL.Od(a),e.Td=r,Uc.forEach(function(e){e()}),Vc()),o):null}var cd=!1,dd=void 0,ed=void 0;function fd(t,r,i){function n(){Sc=!1;var t=o.parentNode;(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===t?(o.Da=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msExitFullscreen||document.exitFullscreen||function(){},o.Da=o.Da.bind(document),dd&&o.sa(),Sc=!0,ed&&gd()):(t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),ed&&hd()),e.onFullScreen&&e.onFullScreen(Sc),id(o)}void 0===(dd=t)&&(dd=!0),void 0===(ed=r)&&(ed=!1),void 0===(jd=i)&&(jd=null);var o=e.canvas;cd||(cd=!0,document.addEventListener("fullscreenchange",n,!1),document.addEventListener("mozfullscreenchange",n,!1),document.addEventListener("webkitfullscreenchange",n,!1),document.addEventListener("MSFullscreenChange",n,!1));var a=document.createElement("div");o.parentNode.insertBefore(a,o),a.appendChild(o),a.p=a.requestFullScreen||a.mozRequestFullScreen||a.msRequestFullscreen||(a.webkitRequestFullScreen?function(){a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),i?a.p({Ud:i}):a.p()}var kd=0;function ld(e){var t=Date.now();if(0===kd)kd=t+1e3/60;else for(;kd<=t+2;)kd+=1e3/60;t=Math.max(kd-t,0),setTimeout(e,t)}function Ic(e){"undefined"==typeof window?ld(e):(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||ld),window.requestAnimationFrame(e))}function ad(t){e.noExitRuntime=!0,setTimeout(function(){na||t()},1e4)}function $c(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]}function md(e,t,r){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)}function nd(t,r,e){md(t,function(e){assert(e,'Loading data file "'+t+'" failed (no arrayBuffer).'),r(new Uint8Array(e)),lb()},function(){if(!e)throw'Loading data file "'+t+'" failed.';e()}),kb()}var od=[],Wc,Xc,Yc,Zc,jd;function pd(){var t=e.canvas;od.forEach(function(e){e(t.width,t.height)})}function gd(){if("undefined"!=typeof SDL){var e=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=8388608|e}pd()}function hd(){if("undefined"!=typeof SDL){var e=Sa[SDL.screen+0*n.J>>2];C[SDL.screen+0*n.J>>2]=-8388609&e}pd()}function id(t,r,i){r&&i?(t.ub=r,t.hb=i):(r=t.ub,i=t.hb);var n=r,o=i;if(e.forcedAspectRatio&&0this.length-1||e<0)){var t=e%this.chunkSize;return this.gb(e/this.chunkSize|0)[t]}},a.prototype.pb=function(e){this.gb=e},a.prototype.Ca=function(){var e=new XMLHttpRequest;if(e.open("HEAD",u,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw Error("Couldn't load "+u+". Status: "+e.status);var t,o=Number(e.getResponseHeader("Content-length")),a=1048576;(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t||(a=o);var s=this;s.pb(function(e){var t=e*a,r=(e+1)*a-1;r=Math.min(r,o-1);if(void 0===s.Y[e]){var i=s.Y;if(r=(e=e.g.e).length)return 0;if(assert(0<=(i=Math.min(e.length-n,i))),e.slice)for(var o=0;o>2]=0;case 21520:return r.tty?-J.q:-J.Q;case 21531:if(n=X(),!r.n.ib)throw new L(J.Q);return r.n.ib(r,i,n);default:x("bad ioctl syscall "+i)}}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},___syscall6:function(e,t){wc=t;try{return mc(xc()),0}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},_emscripten_set_main_loop_timing:Cc,__ZSt18uncaught_exceptionv:tb,___setErrNo:ob,_sbrk:Ga,___cxa_begin_catch:function(e){var t;tb.p--,ub.push(e);e:{if(e&&!vb[e])for(t in vb)if(vb[t].wd===e)break e;t=e}return t&&vb[t].Sd++,e},_emscripten_memcpy_big:function(e,t,r){return E.set(E.subarray(t,t+r),e),e},_sysconf:function(e){switch(e){case 30:return 4096;case 85:return F/4096;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return"object"==typeof navigator&&navigator.hardwareConcurrency||1}return ob(J.q),-1},_pthread_getspecific:function(e){return yc[e]||0},_pthread_self:function(){return 0},_pthread_once:wb,_pthread_key_create:function(e){return 0==e?J.q:(C[e>>2]=Ac,yc[Ac]=0,Ac++,0)},___unlock:function(){},_emscripten_set_main_loop:Jc,_pthread_setspecific:function(e,t){return e in yc?(yc[e]=t,0):J.q},___lock:function(){},_abort:function(){e.abort()},_pthread_cleanup_push:pb,_time:function(e){var t=Date.now()/1e3|0;return e&&(C[e>>2]=t),t},___syscall140:function(e,t){wc=t;try{var r=xc(),i=X(),n=X(),o=X(),a=X();return assert(0===i),nc(r,n,a),C[o>>2]=r.position,r.na&&0===n&&0===a&&(r.na=null),0}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},___syscall146:function(e,t){wc=t;try{var r,i=xc(),n=X();e:{for(var o=X(),a=0,s=0;s>2],C[n+(8*s+4)>>2],void 0);if(u<0){r=-1;break e}a+=u}r=a}return r}catch(e){return void 0!==vc&&e instanceof L||x(e),-e.S}},STACKTOP:m,STACK_MAX:Va,tempDoublePtr:mb,ABORT:na,cttz_i8:qd};var Z=function(e,t,r){"use asm";var i=e.Int8Array;var n=e.Int16Array;var o=e.Int32Array;var a=e.Uint8Array;var s=e.Uint16Array;var u=e.Uint32Array;var h=e.Float32Array;var c=e.Float64Array;var de=new i(r);var $=new n(r);var pe=new o(r);var me=new a(r);var ve=new s(r);var f=new u(r);var l=new h(r);var ee=new c(r);var d=e.byteLength;var be=t.STACKTOP|0;var p=t.STACK_MAX|0;var te=t.tempDoublePtr|0;var m=t.ABORT|0;var v=t.cttz_i8|0;var b=0;var g=0;var y=0;var _=0;var w=e.NaN,x=e.Infinity;var T=0,S=0,E=0,A=0,P=0.0,M=0,C=0,k=0,I=0.0;var re=0;var R=0;var O=0;var D=0;var L=0;var F=0;var j=0;var B=0;var N=0;var U=0;var z=e.Math.floor;var X=e.Math.abs;var q=e.Math.sqrt;var H=e.Math.pow;var G=e.Math.cos;var V=e.Math.sin;var Y=e.Math.tan;var W=e.Math.acos;var J=e.Math.asin;var K=e.Math.atan;var Z=e.Math.atan2;var Q=e.Math.exp;var ie=e.Math.log;var ne=e.Math.ceil;var ge=e.Math.imul;var oe=e.Math.min;var ae=e.Math.clz32;var se=t.abort;var ue=t.assert;var he=t.invoke_iiii;var ce=t.invoke_viiiii;var fe=t.invoke_vi;var le=t.invoke_ii;var ye=t.invoke_viii;var _e=t.invoke_v;var we=t.invoke_viiiiii;var xe=t.invoke_iiiiii;var Te=t.invoke_viiii;var Se=t._pthread_cleanup_pop;var Ee=t.___syscall54;var Ae=t.___syscall6;var Pe=t._emscripten_set_main_loop_timing;var Me=t.__ZSt18uncaught_exceptionv;var Ce=t.___setErrNo;var ke=t._sbrk;var Ie=t.___cxa_begin_catch;var Re=t._emscripten_memcpy_big;var Oe=t._sysconf;var De=t._pthread_getspecific;var Le=t._pthread_self;var Fe=t._pthread_once;var je=t._pthread_key_create;var Be=t.___unlock;var Ne=t._emscripten_set_main_loop;var Ue=t._pthread_setspecific;var ze=t.___lock;var Xe=t._abort;var qe=t._pthread_cleanup_push;var He=t._time;var Ge=t.___syscall140;var Ve=t.___syscall146;var Ye=0.0;function We(e){if(d(e)&16777215||d(e)<=16777215||d(e)>2147483648)return false;de=new i(e);$=new n(e);pe=new o(e);me=new a(e);ve=new s(e);f=new u(e);l=new h(e);ee=new c(e);r=e;return true}function Je(e){e=e|0;var t=0;t=be;be=be+e|0;be=be+15&-16;return t|0}function Ke(){return be|0}function Ze(e){e=e|0;be=e}function Qe(e,t){e=e|0;t=t|0;be=e;p=t}function $e(e,t){e=e|0;t=t|0;if(!b){b=e;g=t}}function et(e){e=e|0;de[te>>0]=de[e>>0];de[te+1>>0]=de[e+1>>0];de[te+2>>0]=de[e+2>>0];de[te+3>>0]=de[e+3>>0]}function tt(e){e=e|0;de[te>>0]=de[e>>0];de[te+1>>0]=de[e+1>>0];de[te+2>>0]=de[e+2>>0];de[te+3>>0]=de[e+3>>0];de[te+4>>0]=de[e+4>>0];de[te+5>>0]=de[e+5>>0];de[te+6>>0]=de[e+6>>0];de[te+7>>0]=de[e+7>>0]}function rt(e){e=e|0;re=e}function it(){return re|0}function nt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0;m=be;be=be+608|0;l=m+88|0;f=m+72|0;u=m+64|0;s=m+48|0;a=m+24|0;o=m;c=m+96|0;d=m+92|0;h=e+4|0;p=e+8|0;if((pe[h>>2]|0)>>>0>(pe[p>>2]|0)>>>0){pe[o>>2]=1154;pe[o+4>>2]=2120;pe[o+8>>2]=1133;_r(c,1100,o)|0;yr(c,m+16|0)|0}if((2147418112/(i>>>0)|0)>>>0<=t>>>0){pe[a>>2]=1154;pe[a+4>>2]=2121;pe[a+8>>2]=1169;_r(c,1100,a)|0;yr(c,m+40|0)|0}a=pe[p>>2]|0;if(a>>>0>=t>>>0){p=1;be=m;return p|0}do{if(r){if(t){o=t+-1|0;if(!(o&t)){o=11;break}else t=o}else t=-1;t=t>>>16|t;t=t>>>8|t;t=t>>>4|t;t=t>>>2|t;t=(t>>>1|t)+1|0;o=10}else o=10}while(0);if((o|0)==10)if(!t){t=0;o=12}else o=11;if((o|0)==11)if(t>>>0<=a>>>0)o=12;if((o|0)==12){pe[s>>2]=1154;pe[s+4>>2]=2130;pe[s+8>>2]=1217;_r(c,1100,s)|0;yr(c,u)|0}r=ge(t,i)|0;do{if(!n){o=ot(pe[e>>2]|0,r,d,1)|0;if(!o){p=0;be=m;return p|0}else{pe[e>>2]=o;break}}else{a=at(r,d)|0;if(!a){p=0;be=m;return p|0}ki[n&0](a,pe[e>>2]|0,pe[h>>2]|0);o=pe[e>>2]|0;do{if(o)if(!(o&7)){Oi[pe[104>>2]&1](o,0,0,1,pe[27]|0)|0;break}else{pe[f>>2]=1154;pe[f+4>>2]=2499;pe[f+8>>2]=1516;_r(c,1100,f)|0;yr(c,l)|0;break}}while(0);pe[e>>2]=a}}while(0);o=pe[d>>2]|0;if(o>>>0>r>>>0)t=(o>>>0)/(i>>>0)|0;pe[p>>2]=t;p=1;be=m;return p|0}function ot(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0;h=be;be=be+592|0;u=h+48|0;o=h+24|0;n=h;s=h+72|0;a=h+68|0;if(e&7){pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1494;_r(s,1100,n)|0;yr(s,h+16|0)|0;u=0;be=h;return u|0}if(t>>>0>2147418112){pe[o>>2]=1154;pe[o+4>>2]=2499;pe[o+8>>2]=1387;_r(s,1100,o)|0;yr(s,h+40|0)|0;u=0;be=h;return u|0}pe[a>>2]=t;i=Oi[pe[104>>2]&1](e,t,a,i,pe[27]|0)|0;if(r)pe[r>>2]=pe[a>>2];if(!(i&7)){u=i;be=h;return u|0}pe[u>>2]=1154;pe[u+4>>2]=2551;pe[u+8>>2]=1440;_r(s,1100,u)|0;yr(s,h+64|0)|0;u=i;be=h;return u|0}function at(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0;u=be;be=be+592|0;a=u+48|0;s=u+24|0;r=u;o=u+72|0;n=u+68|0;i=e+3&-4;i=(i|0)!=0?i:4;if(i>>>0>2147418112){pe[r>>2]=1154;pe[r+4>>2]=2499;pe[r+8>>2]=1387;_r(o,1100,r)|0;yr(o,u+16|0)|0;s=0;be=u;return s|0}pe[n>>2]=i;r=Oi[pe[104>>2]&1](0,i,n,1,pe[27]|0)|0;e=pe[n>>2]|0;if(t)pe[t>>2]=e;if((r|0)==0|e>>>0>>0){pe[s>>2]=1154;pe[s+4>>2]=2499;pe[s+8>>2]=1413;_r(o,1100,s)|0;yr(o,u+40|0)|0;s=0;be=u;return s|0}if(!(r&7)){s=r;be=u;return s|0}pe[a>>2]=1154;pe[a+4>>2]=2526;pe[a+8>>2]=1440;_r(o,1100,a)|0;yr(o,u+64|0)|0;s=r;be=u;return s|0}function st(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0;B=be;be=be+960|0;L=B+232|0;D=B+216|0;O=B+208|0;R=B+192|0;I=B+184|0;k=B+168|0;C=B+160|0;M=B+144|0;E=B+136|0;S=B+120|0;T=B+112|0;x=B+96|0;y=B+88|0;g=B+72|0;b=B+64|0;v=B+48|0;f=B+40|0;d=B+24|0;l=B+16|0;c=B;P=B+440|0;F=B+376|0;j=B+304|0;m=B+236|0;if((t|0)==0|i>>>0>11){e=0;be=B;return e|0}pe[e>>2]=t;n=j;o=n+68|0;do{pe[n>>2]=0;n=n+4|0}while((n|0)<(o|0));o=0;do{n=de[r+o>>0]|0;if(n<<24>>24){A=j+((n&255)<<2)|0;pe[A>>2]=(pe[A>>2]|0)+1}o=o+1|0}while((o|0)!=(t|0));o=0;h=1;a=0;s=-1;u=0;while(1){n=pe[j+(h<<2)>>2]|0;if(!n)pe[e+28+(h+-1<<2)>>2]=0;else{A=h+-1|0;pe[F+(A<<2)>>2]=o;o=n+o|0;w=16-h|0;pe[e+28+(A<<2)>>2]=(o+-1<>2]=u;pe[m+(h<<2)>>2]=u;a=a>>>0>h>>>0?a:h;s=s>>>0>>0?s:h;u=n+u|0}h=h+1|0;if((h|0)==17){A=a;break}else o=o<<1}pe[e+4>>2]=u;o=e+172|0;do{if(u>>>0>(pe[o>>2]|0)>>>0){pe[o>>2]=u;if(u){n=u+-1|0;if(n&u)p=14}else{n=-1;p=14}if((p|0)==14){w=n>>>16|n;w=w>>>8|w;w=w>>>4|w;w=w>>>2|w;w=(w>>>1|w)+1|0;pe[o>>2]=w>>>0>t>>>0?t:w}a=e+176|0;n=pe[a>>2]|0;do{if(n){w=pe[n+-4>>2]|0;n=n+-8|0;if(!((w|0)!=0?(w|0)==(~pe[n>>2]|0):0)){pe[c>>2]=1154;pe[c+4>>2]=644;pe[c+8>>2]=1863;_r(P,1100,c)|0;yr(P,l)|0}if(!(n&7)){Oi[pe[104>>2]&1](n,0,0,1,pe[27]|0)|0;break}else{pe[d>>2]=1154;pe[d+4>>2]=2499;pe[d+8>>2]=1516;_r(P,1100,d)|0;yr(P,f)|0;break}}}while(0);o=pe[o>>2]|0;o=(o|0)!=0?o:1;n=at((o<<1)+8|0,0)|0;if(!n){pe[a>>2]=0;n=0;break}else{pe[n+4>>2]=o;pe[n>>2]=~o;pe[a>>2]=n+8;p=25;break}}else p=25}while(0);e:do{if((p|0)==25){w=e+24|0;de[w>>0]=s;de[e+25>>0]=A;o=e+176|0;a=0;do{_=de[r+a>>0]|0;n=_&255;if(_<<24>>24){if(!(pe[j+(n<<2)>>2]|0)){pe[v>>2]=1154;pe[v+4>>2]=2273;pe[v+8>>2]=1261;_r(P,1100,v)|0;yr(P,b)|0}_=m+(n<<2)|0;n=pe[_>>2]|0;pe[_>>2]=n+1;if(n>>>0>=u>>>0){pe[g>>2]=1154;pe[g+4>>2]=2277;pe[g+8>>2]=1274;_r(P,1100,g)|0;yr(P,y)|0}$[(pe[o>>2]|0)+(n<<1)>>1]=a}a=a+1|0}while((a|0)!=(t|0));n=de[w>>0]|0;y=(n&255)>>>0>>0?i:0;_=e+8|0;pe[_>>2]=y;g=(y|0)!=0;if(g){b=1<>>0>(pe[n>>2]|0)>>>0){pe[n>>2]=b;a=e+168|0;n=pe[a>>2]|0;do{if(n){v=pe[n+-4>>2]|0;n=n+-8|0;if(!((v|0)!=0?(v|0)==(~pe[n>>2]|0):0)){pe[x>>2]=1154;pe[x+4>>2]=644;pe[x+8>>2]=1863;_r(P,1100,x)|0;yr(P,T)|0}if(!(n&7)){Oi[pe[104>>2]&1](n,0,0,1,pe[27]|0)|0;break}else{pe[S>>2]=1154;pe[S+4>>2]=2499;pe[S+8>>2]=1516;_r(P,1100,S)|0;yr(P,E)|0;break}}}while(0);n=b<<2;o=at(n+8|0,0)|0;if(!o){pe[a>>2]=0;n=0;break e}else{E=o+8|0;pe[o+4>>2]=b;pe[o>>2]=~b;pe[a>>2]=E;o=E;break}}else{o=e+168|0;n=b<<2;a=o;o=pe[o>>2]|0}}while(0);Wr(o|0,-1,n|0)|0;p=e+176|0;v=1;do{if(pe[j+(v<<2)>>2]|0){t=y-v|0;m=1<>2]|0;if(o>>>0>=16){pe[M>>2]=1154;pe[M+4>>2]=1953;pe[M+8>>2]=1737;_r(P,1100,M)|0;yr(P,C)|0}n=pe[e+28+(o<<2)>>2]|0;if(!n)d=-1;else d=(n+-1|0)>>>(16-v|0);if(s>>>0<=d>>>0){f=(pe[e+96+(o<<2)>>2]|0)-s|0;l=v<<16;do{n=ve[(pe[p>>2]|0)+(f+s<<1)>>1]|0;if((me[r+n>>0]|0|0)!=(v|0)){pe[k>>2]=1154;pe[k+4>>2]=2319;pe[k+8>>2]=1303;_r(P,1100,k)|0;yr(P,I)|0}c=s<>>0>=b>>>0){pe[R>>2]=1154;pe[R+4>>2]=2325;pe[R+8>>2]=1337;_r(P,1100,R)|0;yr(P,O)|0}n=pe[a>>2]|0;if((pe[n+(u<<2)>>2]|0)!=-1){pe[D>>2]=1154;pe[D+4>>2]=2327;pe[D+8>>2]=1360;_r(P,1100,D)|0;yr(P,L)|0;n=pe[a>>2]|0}pe[n+(u<<2)>>2]=o;h=h+1|0}while(h>>>0>>0);s=s+1|0}while(s>>>0<=d>>>0)}}v=v+1|0}while(y>>>0>=v>>>0);n=de[w>>0]|0}o=e+96|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F>>2]|0);o=e+100|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+4>>2]|0);o=e+104|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+8>>2]|0);o=e+108|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+12>>2]|0);o=e+112|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+16>>2]|0);o=e+116|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+20>>2]|0);o=e+120|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+24>>2]|0);o=e+124|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+28>>2]|0);o=e+128|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+32>>2]|0);o=e+132|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+36>>2]|0);o=e+136|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+40>>2]|0);o=e+140|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+44>>2]|0);o=e+144|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+48>>2]|0);o=e+148|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+52>>2]|0);o=e+152|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+56>>2]|0);o=e+156|0;pe[o>>2]=(pe[o>>2]|0)-(pe[F+60>>2]|0);o=e+16|0;pe[o>>2]=0;a=e+20|0;pe[a>>2]=n&255;t:do{if(g){while(1){if(!i)break t;n=i+-1|0;if(!(pe[j+(i<<2)>>2]|0))i=n;else break}pe[o>>2]=pe[e+28+(n<<2)>>2];n=y+1|0;pe[a>>2]=n;if(n>>>0<=A>>>0){while(1){if(pe[j+(n<<2)>>2]|0)break;n=n+1|0;if(n>>>0>A>>>0)break t}pe[a>>2]=n}}}while(0);pe[e+92>>2]=-1;pe[e+160>>2]=1048575;pe[e+12>>2]=32-(pe[_>>2]|0);n=1}}while(0);e=n;be=B;return e|0}function ut(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0;if(!e){n=Ur(t)|0;if(!r){r=n;return r|0}if(!n)o=0;else o=qr(n)|0;pe[r>>2]=o;r=n;return r|0}if(!t){zr(e);if(!r){r=0;return r|0}pe[r>>2]=0;r=0;return r|0}n=Xr(e,t)|0;o=(n|0)!=0;if(o|i^1)o=o?n:e;else{n=Xr(e,t)|0;o=(n|0)==0?e:n}if(!r){r=n;return r|0}t=qr(o)|0;pe[r>>2]=t;r=n;return r|0}function ht(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(!((e|0)!=0&t>>>0>73&(r|0)!=0)){r=0;return r|0}if((pe[r>>2]|0)!=40|t>>>0<74){r=0;return r|0}if(((me[e>>0]|0)<<8|(me[e+1>>0]|0)|0)!=18552){r=0;return r|0}if(((me[e+2>>0]|0)<<8|(me[e+3>>0]|0))>>>0<74){r=0;return r|0}if(((me[e+7>>0]|0)<<16|(me[e+6>>0]|0)<<24|(me[e+8>>0]|0)<<8|(me[e+9>>0]|0))>>>0>t>>>0){r=0;return r|0}pe[r+4>>2]=(me[e+12>>0]|0)<<8|(me[e+13>>0]|0);pe[r+8>>2]=(me[e+14>>0]|0)<<8|(me[e+15>>0]|0);pe[r+12>>2]=me[e+16>>0];pe[r+16>>2]=me[e+17>>0];t=e+18|0;i=r+32|0;pe[i>>2]=me[t>>0];pe[i+4>>2]=0;t=de[t>>0]|0;pe[r+20>>2]=t<<24>>24==0|t<<24>>24==9?8:16;pe[r+24>>2]=(me[e+26>>0]|0)<<16|(me[e+25>>0]|0)<<24|(me[e+27>>0]|0)<<8|(me[e+28>>0]|0);pe[r+28>>2]=(me[e+30>>0]|0)<<16|(me[e+29>>0]|0)<<24|(me[e+31>>0]|0)<<8|(me[e+32>>0]|0);r=1;return r|0}function ct(e){e=e|0;Ie(e|0)|0;zt()}function ft(e){e=e|0;var t=0,r=0,i=0,n=0,o=0;o=be;be=be+544|0;n=o;i=o+24|0;t=pe[e+20>>2]|0;if(t)lt(t);t=e+4|0;r=pe[t>>2]|0;if(!r){n=e+16|0;de[n>>0]=0;be=o;return}if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1516;_r(i,1100,n)|0;yr(i,o+16|0)|0}pe[t>>2]=0;pe[e+8>>2]=0;pe[e+12>>2]=0;n=e+16|0;de[n>>0]=0;be=o;return}function lt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;d=be;be=be+640|0;l=d+112|0;f=d+96|0;c=d+88|0;h=d+72|0;u=d+64|0;s=d+48|0;i=d+40|0;o=d+24|0;n=d+16|0;r=d;a=d+120|0;if(!e){be=d;return}t=pe[e+168>>2]|0;do{if(t){p=pe[t+-4>>2]|0;t=t+-8|0;if(!((p|0)!=0?(p|0)==(~pe[t>>2]|0):0)){pe[r>>2]=1154;pe[r+4>>2]=644;pe[r+8>>2]=1863;_r(a,1100,r)|0;yr(a,n)|0}if(!(t&7)){Oi[pe[104>>2]&1](t,0,0,1,pe[27]|0)|0;break}else{pe[o>>2]=1154;pe[o+4>>2]=2499;pe[o+8>>2]=1516;_r(a,1100,o)|0;yr(a,i)|0;break}}}while(0);t=pe[e+176>>2]|0;do{if(t){p=pe[t+-4>>2]|0;t=t+-8|0;if(!((p|0)!=0?(p|0)==(~pe[t>>2]|0):0)){pe[s>>2]=1154;pe[s+4>>2]=644;pe[s+8>>2]=1863;_r(a,1100,s)|0;yr(a,u)|0}if(!(t&7)){Oi[pe[104>>2]&1](t,0,0,1,pe[27]|0)|0;break}else{pe[h>>2]=1154;pe[h+4>>2]=2499;pe[h+8>>2]=1516;_r(a,1100,h)|0;yr(a,c)|0;break}}}while(0);if(!(e&7)){Oi[pe[104>>2]&1](e,0,0,1,pe[27]|0)|0;be=d;return}else{pe[f>>2]=1154;pe[f+4>>2]=2499;pe[f+8>>2]=1516;_r(a,1100,f)|0;yr(a,l)|0;be=d;return}}function dt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+560|0;a=c+40|0;s=c+24|0;t=c;o=c+48|0;n=e+8|0;r=pe[n>>2]|0;if((r+-1|0)>>>0>=8192){pe[t>>2]=1154;pe[t+4>>2]=2997;pe[t+8>>2]=1541;_r(o,1100,t)|0;yr(o,c+16|0)|0}pe[e>>2]=r;i=e+20|0;t=pe[i>>2]|0;if(!t){t=at(180,0)|0;if(!t)t=0;else{h=t+164|0;pe[h>>2]=0;pe[h+4>>2]=0;pe[h+8>>2]=0;pe[h+12>>2]=0}pe[i>>2]=t;h=t;u=pe[e>>2]|0}else{h=t;u=r}if(!(pe[n>>2]|0)){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(o,1100,s)|0;yr(o,a)|0;o=pe[e>>2]|0}else o=u;n=pe[e+4>>2]|0;if(o>>>0>16){r=o;t=0}else{e=0;h=st(h,u,n,e)|0;be=c;return h|0}while(1){i=t+1|0;if(r>>>0>3){r=r>>>1;t=i}else{r=i;break}}e=t+2+((r|0)!=32&1<>>0>>0&1)|0;e=e>>>0<11?e&255:11;h=st(h,u,n,e)|0;be=c;return h|0}function pt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0;L=be;be=be+800|0;k=L+256|0;C=L+240|0;M=L+232|0;P=L+216|0;A=L+208|0;E=L+192|0;S=L+184|0;T=L+168|0;x=L+160|0;w=L+144|0;_=L+136|0;y=L+120|0;g=L+112|0;b=L+96|0;v=L+88|0;m=L+72|0;f=L+64|0;c=L+48|0;s=L+40|0;u=L+24|0;o=L+16|0;n=L;O=L+288|0;D=L+264|0;I=mt(e,14)|0;if(!I){pe[t>>2]=0;r=t+4|0;i=pe[r>>2]|0;if(i){if(!(i&7))Oi[pe[104>>2]&1](i,0,0,1,pe[27]|0)|0;else{pe[n>>2]=1154;pe[n+4>>2]=2499;pe[n+8>>2]=1516;_r(O,1100,n)|0;yr(O,o)|0}pe[r>>2]=0;pe[t+8>>2]=0;pe[t+12>>2]=0}de[t+16>>0]=0;r=t+20|0;i=pe[r>>2]|0;if(!i){t=1;be=L;return t|0}lt(i);pe[r>>2]=0;t=1;be=L;return t|0}d=t+4|0;p=t+8|0;r=pe[p>>2]|0;if((r|0)!=(I|0)){if(r>>>0<=I>>>0){do{if((pe[t+12>>2]|0)>>>0>>0){if(nt(d,I,(r+1|0)==(I|0),1,0)|0){r=pe[p>>2]|0;break}de[t+16>>0]=1;t=0;be=L;return t|0}}while(0);Wr((pe[d>>2]|0)+r|0,0,I-r|0)|0}pe[p>>2]=I}Wr(pe[d>>2]|0,0,I|0)|0;l=e+20|0;r=pe[l>>2]|0;if((r|0)<5){o=e+4|0;a=e+8|0;n=e+16|0;do{i=pe[o>>2]|0;if((i|0)==(pe[a>>2]|0))i=0;else{pe[o>>2]=i+1;i=me[i>>0]|0}r=r+8|0;pe[l>>2]=r;if((r|0)>=33){pe[u>>2]=1154;pe[u+4>>2]=3199;pe[u+8>>2]=1650;_r(O,1100,u)|0;yr(O,s)|0;r=pe[l>>2]|0}i=i<<32-r|pe[n>>2];pe[n>>2]=i}while((r|0)<5)}else{i=e+16|0;n=i;i=pe[i>>2]|0}h=i>>>27;pe[n>>2]=i<<5;pe[l>>2]=r+-5;if((h+-1|0)>>>0>20){t=0;be=L;return t|0}pe[D+20>>2]=0;pe[D>>2]=0;pe[D+4>>2]=0;pe[D+8>>2]=0;pe[D+12>>2]=0;de[D+16>>0]=0;r=D+4|0;i=D+8|0;e:do{if(nt(r,21,0,1,0)|0){s=pe[i>>2]|0;u=pe[r>>2]|0;Wr(u+s|0,0,21-s|0)|0;pe[i>>2]=21;if(h){n=e+4|0;o=e+8|0;a=e+16|0;s=0;do{r=pe[l>>2]|0;if((r|0)<3)do{i=pe[n>>2]|0;if((i|0)==(pe[o>>2]|0))i=0;else{pe[n>>2]=i+1;i=me[i>>0]|0}r=r+8|0;pe[l>>2]=r;if((r|0)>=33){pe[c>>2]=1154;pe[c+4>>2]=3199;pe[c+8>>2]=1650;_r(O,1100,c)|0;yr(O,f)|0;r=pe[l>>2]|0}i=i<<32-r|pe[a>>2];pe[a>>2]=i}while((r|0)<3);else i=pe[a>>2]|0;pe[a>>2]=i<<3;pe[l>>2]=r+-3;de[u+(me[1611+s>>0]|0)>>0]=i>>>29;s=s+1|0}while((s|0)!=(h|0))}if(dt(D)|0){s=e+4|0;u=e+8|0;h=e+16|0;i=0;t:while(1){a=I-i|0;r=vt(e,D)|0;r:do{if(r>>>0<17){if((pe[p>>2]|0)>>>0<=i>>>0){pe[m>>2]=1154;pe[m+4>>2]=903;pe[m+8>>2]=1781;_r(O,1100,m)|0;yr(O,v)|0}de[(pe[d>>2]|0)+i>>0]=r;r=i+1|0}else switch(r|0){case 17:{r=pe[l>>2]|0;if((r|0)<3)do{n=pe[s>>2]|0;if((n|0)==(pe[u>>2]|0))n=0;else{pe[s>>2]=n+1;n=me[n>>0]|0}r=r+8|0;pe[l>>2]=r;if((r|0)>=33){pe[b>>2]=1154;pe[b+4>>2]=3199;pe[b+8>>2]=1650;_r(O,1100,b)|0;yr(O,g)|0;r=pe[l>>2]|0}n=n<<32-r|pe[h>>2];pe[h>>2]=n}while((r|0)<3);else n=pe[h>>2]|0;pe[h>>2]=n<<3;pe[l>>2]=r+-3;r=(n>>>29)+3|0;if(r>>>0>a>>>0){r=0;break e}r=r+i|0;break r}case 18:{r=pe[l>>2]|0;if((r|0)<7)do{n=pe[s>>2]|0;if((n|0)==(pe[u>>2]|0))n=0;else{pe[s>>2]=n+1;n=me[n>>0]|0}r=r+8|0;pe[l>>2]=r;if((r|0)>=33){pe[y>>2]=1154;pe[y+4>>2]=3199;pe[y+8>>2]=1650;_r(O,1100,y)|0;yr(O,_)|0;r=pe[l>>2]|0}n=n<<32-r|pe[h>>2];pe[h>>2]=n}while((r|0)<7);else n=pe[h>>2]|0;pe[h>>2]=n<<7;pe[l>>2]=r+-7;r=(n>>>25)+11|0;if(r>>>0>a>>>0){r=0;break e}r=r+i|0;break r}default:{if((r+-19|0)>>>0>=2){R=90;break t}o=pe[l>>2]|0;if((r|0)==19){if((o|0)<2){n=o;while(1){r=pe[s>>2]|0;if((r|0)==(pe[u>>2]|0))o=0;else{pe[s>>2]=r+1;o=me[r>>0]|0}r=n+8|0;pe[l>>2]=r;if((r|0)>=33){pe[w>>2]=1154;pe[w+4>>2]=3199;pe[w+8>>2]=1650;_r(O,1100,w)|0;yr(O,x)|0;r=pe[l>>2]|0}n=o<<32-r|pe[h>>2];pe[h>>2]=n;if((r|0)<2)n=r;else break}}else{n=pe[h>>2]|0;r=o}pe[h>>2]=n<<2;pe[l>>2]=r+-2;o=(n>>>30)+3|0}else{if((o|0)<6){n=o;while(1){r=pe[s>>2]|0;if((r|0)==(pe[u>>2]|0))o=0;else{pe[s>>2]=r+1;o=me[r>>0]|0}r=n+8|0;pe[l>>2]=r;if((r|0)>=33){pe[T>>2]=1154;pe[T+4>>2]=3199;pe[T+8>>2]=1650;_r(O,1100,T)|0;yr(O,S)|0;r=pe[l>>2]|0}n=o<<32-r|pe[h>>2];pe[h>>2]=n;if((r|0)<6)n=r;else break}}else{n=pe[h>>2]|0;r=o}pe[h>>2]=n<<6;pe[l>>2]=r+-6;o=(n>>>26)+7|0}if((i|0)==0|o>>>0>a>>>0){r=0;break e}r=i+-1|0;if((pe[p>>2]|0)>>>0<=r>>>0){pe[E>>2]=1154;pe[E+4>>2]=903;pe[E+8>>2]=1781;_r(O,1100,E)|0;yr(O,A)|0}n=de[(pe[d>>2]|0)+r>>0]|0;if(!(n<<24>>24)){r=0;break e}r=o+i|0;if(i>>>0>=r>>>0){r=i;break r}do{if((pe[p>>2]|0)>>>0<=i>>>0){pe[P>>2]=1154;pe[P+4>>2]=903;pe[P+8>>2]=1781;_r(O,1100,P)|0;yr(O,M)|0}de[(pe[d>>2]|0)+i>>0]=n;i=i+1|0}while((i|0)!=(r|0))}}}while(0);if(I>>>0>r>>>0)i=r;else break}if((R|0)==90){pe[C>>2]=1154;pe[C+4>>2]=3140;pe[C+8>>2]=1632;_r(O,1100,C)|0;yr(O,k)|0;r=0;break}if((I|0)==(r|0))r=dt(t)|0;else r=0}else r=0}else{de[D+16>>0]=1;r=0}}while(0);ft(D);t=r;be=L;return t|0}function mt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+544|0;s=c+16|0;a=c;o=c+24|0;if(!t){h=0;be=c;return h|0}if(t>>>0<=16){h=bt(e,t)|0;be=c;return h|0}u=bt(e,t+-16|0)|0;h=e+20|0;t=pe[h>>2]|0;if((t|0)<16){i=e+4|0;n=e+8|0;r=e+16|0;do{e=pe[i>>2]|0;if((e|0)==(pe[n>>2]|0))e=0;else{pe[i>>2]=e+1;e=me[e>>0]|0}t=t+8|0;pe[h>>2]=t;if((t|0)>=33){pe[a>>2]=1154;pe[a+4>>2]=3199;pe[a+8>>2]=1650;_r(o,1100,a)|0;yr(o,s)|0;t=pe[h>>2]|0}e=e<<32-t|pe[r>>2];pe[r>>2]=e}while((t|0)<16)}else{e=e+16|0;r=e;e=pe[e>>2]|0}pe[r>>2]=e<<16;pe[h>>2]=t+-16;h=e>>>16|u<<16;be=c;return h|0}function vt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0;y=be;be=be+608|0;m=y+88|0;p=y+72|0;l=y+64|0;f=y+48|0;c=y+40|0;d=y+24|0;h=y+16|0;u=y;b=y+96|0;v=pe[t+20>>2]|0;g=e+20|0;s=pe[g>>2]|0;do{if((s|0)<24){a=e+4|0;i=pe[a>>2]|0;n=pe[e+8>>2]|0;r=i>>>0>>0;if((s|0)>=16){if(r){pe[a>>2]=i+1;r=me[i>>0]|0}else r=0;pe[g>>2]=s+8;a=e+16|0;o=r<<24-s|pe[a>>2];pe[a>>2]=o;break}if(r){o=(me[i>>0]|0)<<8;r=i+1|0}else{o=0;r=i}if(r>>>0>>0){i=me[r>>0]|0;r=r+1|0}else i=0;pe[a>>2]=r;pe[g>>2]=s+16;a=e+16|0;o=(i|o)<<16-s|pe[a>>2];pe[a>>2]=o}else{o=e+16|0;a=o;o=pe[o>>2]|0}}while(0);n=(o>>>16)+1|0;do{if(n>>>0<=(pe[v+16>>2]|0)>>>0){i=pe[(pe[v+168>>2]|0)+(o>>>(32-(pe[v+8>>2]|0)|0)<<2)>>2]|0;if((i|0)==-1){pe[u>>2]=1154;pe[u+4>>2]=3244;pe[u+8>>2]=1677;_r(b,1100,u)|0;yr(b,h)|0}r=i&65535;i=i>>>16;if((pe[t+8>>2]|0)>>>0<=r>>>0){pe[d>>2]=1154;pe[d+4>>2]=902;pe[d+8>>2]=1781;_r(b,1100,d)|0;yr(b,c)|0}if((me[(pe[t+4>>2]|0)+r>>0]|0|0)!=(i|0)){pe[f>>2]=1154;pe[f+4>>2]=3248;pe[f+8>>2]=1694;_r(b,1100,f)|0;yr(b,l)|0}}else{i=pe[v+20>>2]|0;while(1){r=i+-1|0;if(n>>>0>(pe[v+28+(r<<2)>>2]|0)>>>0)i=i+1|0;else break}r=(o>>>(32-i|0))+(pe[v+96+(r<<2)>>2]|0)|0;if(r>>>0<(pe[t>>2]|0)>>>0){r=ve[(pe[v+176>>2]|0)+(r<<1)>>1]|0;break}pe[p>>2]=1154;pe[p+4>>2]=3266;pe[p+8>>2]=1632;_r(b,1100,p)|0;yr(b,m)|0;g=0;be=y;return g|0}}while(0);pe[a>>2]=pe[a>>2]<>2]=(pe[g>>2]|0)-i;g=r;be=y;return g|0}function bt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+560|0;s=c+40|0;u=c+24|0;r=c;a=c+48|0;if(t>>>0>=33){pe[r>>2]=1154;pe[r+4>>2]=3190;pe[r+8>>2]=1634;_r(a,1100,r)|0;yr(a,c+16|0)|0}h=e+20|0;r=pe[h>>2]|0;if((r|0)>=(t|0)){o=e+16|0;a=o;o=pe[o>>2]|0;s=r;u=32-t|0;u=o>>>u;o=o<>2]=o;t=s-t|0;pe[h>>2]=t;be=c;return u|0}n=e+4|0;o=e+8|0;i=e+16|0;do{e=pe[n>>2]|0;if((e|0)==(pe[o>>2]|0))e=0;else{pe[n>>2]=e+1;e=me[e>>0]|0}r=r+8|0;pe[h>>2]=r;if((r|0)>=33){pe[u>>2]=1154;pe[u+4>>2]=3199;pe[u+8>>2]=1650;_r(a,1100,u)|0;yr(a,s)|0;r=pe[h>>2]|0}e=e<<32-r|pe[i>>2];pe[i>>2]=e}while((r|0)<(t|0));u=32-t|0;u=e>>>u;s=e<>2]=s;t=r-t|0;pe[h>>2]=t;be=c;return u|0}function gt(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0;p=be;be=be+544|0;l=p+16|0;f=p;c=p+24|0;if((e|0)==0|t>>>0<62){d=0;be=p;return d|0}h=at(300,0)|0;if(!h){d=0;be=p;return d|0}pe[h>>2]=519686845;r=h+4|0;pe[r>>2]=0;i=h+8|0;pe[i>>2]=0;u=h+88|0;n=h+136|0;o=h+160|0;a=u;s=a+44|0;do{pe[a>>2]=0;a=a+4|0}while((a|0)<(s|0));de[u+44>>0]=0;m=h+184|0;a=h+208|0;s=h+232|0;v=h+252|0;pe[v>>2]=0;pe[v+4>>2]=0;pe[v+8>>2]=0;de[v+12>>0]=0;v=h+268|0;pe[v>>2]=0;pe[v+4>>2]=0;pe[v+8>>2]=0;de[v+12>>0]=0;v=h+284|0;pe[v>>2]=0;pe[v+4>>2]=0;pe[v+8>>2]=0;de[v+12>>0]=0;pe[n>>2]=0;pe[n+4>>2]=0;pe[n+8>>2]=0;pe[n+12>>2]=0;pe[n+16>>2]=0;de[n+20>>0]=0;pe[o>>2]=0;pe[o+4>>2]=0;pe[o+8>>2]=0;pe[o+12>>2]=0;pe[o+16>>2]=0;de[o+20>>0]=0;pe[m>>2]=0;pe[m+4>>2]=0;pe[m+8>>2]=0;pe[m+12>>2]=0;pe[m+16>>2]=0;de[m+20>>0]=0;pe[a>>2]=0;pe[a+4>>2]=0;pe[a+8>>2]=0;pe[a+12>>2]=0;pe[a+16>>2]=0;de[a+20>>0]=0;pe[s>>2]=0;pe[s+4>>2]=0;pe[s+8>>2]=0;pe[s+12>>2]=0;de[s+16>>0]=0;do{if(((t>>>0>=74?((me[e>>0]|0)<<8|(me[e+1>>0]|0)|0)==18552:0)?((me[e+2>>0]|0)<<8|(me[e+3>>0]|0))>>>0>=74:0)?((me[e+7>>0]|0)<<16|(me[e+6>>0]|0)<<24|(me[e+8>>0]|0)<<8|(me[e+9>>0]|0))>>>0<=t>>>0:0){pe[u>>2]=e;pe[r>>2]=e;pe[i>>2]=t;if(Pt(h)|0){r=pe[u>>2]|0;if((me[r+39>>0]|0)<<8|(me[r+40>>0]|0)){if(!(Mt(h)|0))break;if(!(Ct(h)|0))break;r=pe[u>>2]|0}if(!((me[r+55>>0]|0)<<8|(me[r+56>>0]|0))){v=h;be=p;return v|0}if(kt(h)|0?It(h)|0:0){v=h;be=p;return v|0}}}else d=7}while(0);if((d|0)==7)pe[u>>2]=0;Ft(h);if(!(h&7)){Oi[pe[104>>2]&1](h,0,0,1,pe[27]|0)|0;v=0;be=p;return v|0}else{pe[f>>2]=1154;pe[f+4>>2]=2499;pe[f+8>>2]=1516;_r(c,1100,f)|0;yr(c,l)|0;v=0;be=p;return v|0}return 0}function yt(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+544|0;h=c;u=c+24|0;o=pe[e+88>>2]|0;s=(me[o+70+(n<<2)+1>>0]|0)<<16|(me[o+70+(n<<2)>>0]|0)<<24|(me[o+70+(n<<2)+2>>0]|0)<<8|(me[o+70+(n<<2)+3>>0]|0);a=n+1|0;if(a>>>0<(me[o+16>>0]|0)>>>0)o=(me[o+70+(a<<2)+1>>0]|0)<<16|(me[o+70+(a<<2)>>0]|0)<<24|(me[o+70+(a<<2)+2>>0]|0)<<8|(me[o+70+(a<<2)+3>>0]|0);else o=pe[e+8>>2]|0;if(o>>>0>s>>>0){u=e+4|0;u=pe[u>>2]|0;u=u+s|0;h=o-s|0;h=_t(e,u,h,t,r,i,n)|0;be=c;return h|0}pe[h>>2]=1154;pe[h+4>>2]=3704;pe[h+8>>2]=1792;_r(u,1100,h)|0;yr(u,c+16|0)|0;u=e+4|0;u=pe[u>>2]|0;u=u+s|0;h=o-s|0;h=_t(e,u,h,t,r,i,n)|0;be=c;return h|0}function _t(e,t,r,i,n,o,a){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;var s=0,u=0,h=0,c=0;c=pe[e+88>>2]|0;u=((me[c+12>>0]|0)<<8|(me[c+13>>0]|0))>>>a;h=((me[c+14>>0]|0)<<8|(me[c+15>>0]|0))>>>a;u=u>>>0>1?(u+3|0)>>>2:1;h=h>>>0>1?(h+3|0)>>>2:1;c=c+18|0;a=de[c>>0]|0;a=ge(a<<24>>24==0|a<<24>>24==9?8:16,u)|0;if(o)if((o&3|0)==0&a>>>0<=o>>>0)a=o;else{e=0;return e|0}if((ge(a,h)|0)>>>0>n>>>0){e=0;return e|0}o=(u+1|0)>>>1;s=(h+1|0)>>>1;if(!r){e=0;return e|0}pe[e+92>>2]=t;pe[e+96>>2]=t;pe[e+104>>2]=r;pe[e+100>>2]=t+r;pe[e+108>>2]=0;pe[e+112>>2]=0;switch(me[c>>0]|0|0){case 0:{Rt(e,i,n,a,u,h,o,s)|0;e=1;return e|0}case 4:case 6:case 5:case 3:case 2:{Ot(e,i,n,a,u,h,o,s)|0;e=1;return e|0}case 9:{Dt(e,i,n,a,u,h,o,s)|0;e=1;return e|0}case 8:case 7:{Lt(e,i,n,a,u,h,o,s)|0;e=1;return e|0}default:{e=0;return e|0}}return 0}function wt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ht(e,t,r)|0;be=i;return pe[r+4>>2]|0}function xt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ht(e,t,r)|0;be=i;return pe[r+8>>2]|0}function Tt(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ht(e,t,r)|0;be=i;return pe[r+12>>2]|0}function St(e,t){e=e|0;t=t|0;var r=0,i=0;i=be;be=be+48|0;r=i;pe[r>>2]=40;ht(e,t,r)|0;be=i;return pe[r+32>>2]|0}function Et(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,h=0;u=be;be=be+576|0;a=u+56|0;o=u+40|0;n=u+64|0;h=u;pe[h>>2]=40;ht(e,t,h)|0;i=(((pe[h+4>>2]|0)>>>r)+3|0)>>>2;t=(((pe[h+8>>2]|0)>>>r)+3|0)>>>2;r=h+32|0;e=pe[r+4>>2]|0;do{switch(pe[r>>2]|0){case 0:{if(!e)e=8;else s=13;break}case 1:{if(!e)s=12;else s=13;break}case 2:{if(!e)s=12;else s=13;break}case 3:{if(!e)s=12;else s=13;break}case 4:{if(!e)s=12;else s=13;break}case 5:{if(!e)s=12;else s=13;break}case 6:{if(!e)s=12;else s=13;break}case 7:{if(!e)s=12;else s=13;break}case 8:{if(!e)s=12;else s=13;break}case 9:{if(!e)e=8;else s=13;break}default:s=13}}while(0);if((s|0)==12)e=16;else if((s|0)==13){pe[o>>2]=1154;pe[o+4>>2]=2663;pe[o+8>>2]=1535;_r(n,1100,o)|0;yr(n,a)|0;e=0}h=ge(ge(t,i)|0,e)|0;be=u;return h|0}function At(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0;p=be;be=be+608|0;l=p+80|0;d=p+64|0;s=p+56|0;a=p+40|0;c=p+88|0;m=p;f=p+84|0;pe[m>>2]=40;ht(e,t,m)|0;u=(((pe[m+4>>2]|0)>>>n)+3|0)>>>2;m=m+32|0;o=pe[m+4>>2]|0;do{switch(pe[m>>2]|0){case 0:{if(!o)o=8;else h=13;break}case 1:{if(!o)h=12;else h=13;break}case 2:{if(!o)h=12;else h=13;break}case 3:{if(!o)h=12;else h=13;break}case 4:{if(!o)h=12;else h=13;break}case 5:{if(!o)h=12;else h=13;break}case 6:{if(!o)h=12;else h=13;break}case 7:{if(!o)h=12;else h=13;break}case 8:{if(!o)h=12;else h=13;break}case 9:{if(!o)o=8;else h=13;break}default:h=13}}while(0);if((h|0)==12)o=16;else if((h|0)==13){pe[a>>2]=1154;pe[a+4>>2]=2663;pe[a+8>>2]=1535;_r(c,1100,a)|0;yr(c,s)|0;o=0}s=ge(o,u)|0;a=gt(e,t)|0;pe[f>>2]=r;o=(a|0)==0;if(!(n>>>0>15|(i>>>0<8|o))?(pe[a>>2]|0)==519686845:0)yt(a,f,i,s,n)|0;if(o){be=p;return}if((pe[a>>2]|0)!=519686845){be=p;return}Ft(a);if(!(a&7)){Oi[pe[104>>2]&1](a,0,0,1,pe[27]|0)|0;be=p;return}else{pe[d>>2]=1154;pe[d+4>>2]=2499;pe[d+8>>2]=1516;_r(c,1100,d)|0;yr(c,l)|0;be=p;return}}function Pt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0;a=e+92|0;i=pe[e+4>>2]|0;o=e+88|0;n=pe[o>>2]|0;t=(me[n+68>>0]|0)<<8|(me[n+67>>0]|0)<<16|(me[n+69>>0]|0);r=i+t|0;n=(me[n+65>>0]|0)<<8|(me[n+66>>0]|0);if(!n){e=0;return e|0}pe[a>>2]=r;pe[e+96>>2]=r;pe[e+104>>2]=n;pe[e+100>>2]=i+(n+t);pe[e+108>>2]=0;pe[e+112>>2]=0;if(!(pt(a,e+116|0)|0)){e=0;return e|0}t=pe[o>>2]|0;do{if(!((me[t+39>>0]|0)<<8|(me[t+40>>0]|0))){if(!((me[t+55>>0]|0)<<8|(me[t+56>>0]|0))){e=0;return e|0}}else{if(!(pt(a,e+140|0)|0)){e=0;return e|0}if(pt(a,e+188|0)|0){t=pe[o>>2]|0;break}else{e=0;return e|0}}}while(0);if((me[t+55>>0]|0)<<8|(me[t+56>>0]|0)){if(!(pt(a,e+164|0)|0)){e=0;return e|0}if(!(pt(a,e+212|0)|0)){e=0;return e|0}}e=1;return e|0}function Mt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;p=be;be=be+592|0;u=p+16|0;s=p;a=p+72|0;d=p+24|0;i=e+88|0;t=pe[i>>2]|0;l=(me[t+39>>0]|0)<<8|(me[t+40>>0]|0);c=e+236|0;o=e+240|0;r=pe[o>>2]|0;if((r|0)!=(l|0)){if(r>>>0<=l>>>0){do{if((pe[e+244>>2]|0)>>>0>>0){if(nt(c,l,(r+1|0)==(l|0),4,0)|0){t=pe[o>>2]|0;break}de[e+248>>0]=1;d=0;be=p;return d|0}else t=r}while(0);Wr((pe[c>>2]|0)+(t<<2)|0,0,l-t<<2|0)|0;t=pe[i>>2]|0}pe[o>>2]=l}h=e+92|0;r=pe[e+4>>2]|0;i=(me[t+34>>0]|0)<<8|(me[t+33>>0]|0)<<16|(me[t+35>>0]|0);n=r+i|0;t=(me[t+37>>0]|0)<<8|(me[t+36>>0]|0)<<16|(me[t+38>>0]|0);if(!t){d=0;be=p;return d|0}pe[h>>2]=n;pe[e+96>>2]=n;pe[e+104>>2]=t;pe[e+100>>2]=r+(t+i);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[d+20>>2]=0;pe[d>>2]=0;pe[d+4>>2]=0;pe[d+8>>2]=0;pe[d+12>>2]=0;de[d+16>>0]=0;e=d+24|0;pe[d+44>>2]=0;pe[e>>2]=0;pe[e+4>>2]=0;pe[e+8>>2]=0;pe[e+12>>2]=0;de[e+16>>0]=0;if(pt(h,d)|0?(f=d+24|0,pt(h,f)|0):0){if(!(pe[o>>2]|0)){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(a,1100,s)|0;yr(a,u)|0}if(!l)t=1;else{i=0;n=0;o=0;t=0;a=0;e=0;s=0;r=pe[c>>2]|0;while(1){i=(vt(h,d)|0)+i&31;n=(vt(h,f)|0)+n&63;o=(vt(h,d)|0)+o&31;t=(vt(h,d)|0)+t|0;a=(vt(h,f)|0)+a&63;e=(vt(h,d)|0)+e&31;pe[r>>2]=n<<5|i<<11|o|t<<27|a<<21|e<<16;s=s+1|0;if((s|0)==(l|0)){t=1;break}else{t=t&31;r=r+4|0}}}}else t=0;ft(d+24|0);ft(d);d=t;be=p;return d|0}function Ct(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0;E=be;be=be+1024|0;s=E+16|0;a=E;o=E+504|0;S=E+480|0;x=E+284|0;T=E+88|0;w=E+24|0;n=pe[e+88>>2]|0;_=(me[n+47>>0]|0)<<8|(me[n+48>>0]|0);y=e+92|0;t=pe[e+4>>2]|0;r=(me[n+42>>0]|0)<<8|(me[n+41>>0]|0)<<16|(me[n+43>>0]|0);i=t+r|0;n=(me[n+45>>0]|0)<<8|(me[n+44>>0]|0)<<16|(me[n+46>>0]|0);if(!n){S=0;be=E;return S|0}pe[y>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[S+20>>2]=0;pe[S>>2]=0;pe[S+4>>2]=0;pe[S+8>>2]=0;pe[S+12>>2]=0;de[S+16>>0]=0;if(pt(y,S)|0){r=0;i=-3;n=-3;while(1){pe[x+(r<<2)>>2]=i;pe[T+(r<<2)>>2]=n;t=(i|0)>2;r=r+1|0;if((r|0)==49)break;else{i=t?-3:i+1|0;n=(t&1)+n|0}}t=w;r=t+64|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(r|0));g=e+252|0;r=e+256|0;t=pe[r>>2]|0;e:do{if((t|0)==(_|0))u=13;else{if(t>>>0<=_>>>0){do{if((pe[e+260>>2]|0)>>>0<_>>>0)if(nt(g,_,(t+1|0)==(_|0),4,0)|0){t=pe[r>>2]|0;break}else{de[e+264>>0]=1;t=0;break e}}while(0);Wr((pe[g>>2]|0)+(t<<2)|0,0,_-t<<2|0)|0}pe[r>>2]=_;u=13}}while(0);do{if((u|0)==13){if(!_){pe[a>>2]=1154;pe[a+4>>2]=903;pe[a+8>>2]=1781;_r(o,1100,a)|0;yr(o,s)|0;t=1;break}i=w+4|0;n=w+8|0;e=w+12|0;o=w+16|0;a=w+20|0;s=w+24|0;u=w+28|0;h=w+32|0;c=w+36|0;f=w+40|0;l=w+44|0;d=w+48|0;p=w+52|0;m=w+56|0;v=w+60|0;b=0;r=pe[g>>2]|0;while(1){t=0;do{A=vt(y,S)|0;g=t<<1;P=w+(g<<2)|0;pe[P>>2]=(pe[P>>2]|0)+(pe[x+(A<<2)>>2]|0)&3;g=w+((g|1)<<2)|0;pe[g>>2]=(pe[g>>2]|0)+(pe[T+(A<<2)>>2]|0)&3;t=t+1|0}while((t|0)!=8);pe[r>>2]=(me[1725+(pe[i>>2]|0)>>0]|0)<<2|(me[1725+(pe[w>>2]|0)>>0]|0)|(me[1725+(pe[n>>2]|0)>>0]|0)<<4|(me[1725+(pe[e>>2]|0)>>0]|0)<<6|(me[1725+(pe[o>>2]|0)>>0]|0)<<8|(me[1725+(pe[a>>2]|0)>>0]|0)<<10|(me[1725+(pe[s>>2]|0)>>0]|0)<<12|(me[1725+(pe[u>>2]|0)>>0]|0)<<14|(me[1725+(pe[h>>2]|0)>>0]|0)<<16|(me[1725+(pe[c>>2]|0)>>0]|0)<<18|(me[1725+(pe[f>>2]|0)>>0]|0)<<20|(me[1725+(pe[l>>2]|0)>>0]|0)<<22|(me[1725+(pe[d>>2]|0)>>0]|0)<<24|(me[1725+(pe[p>>2]|0)>>0]|0)<<26|(me[1725+(pe[m>>2]|0)>>0]|0)<<28|(me[1725+(pe[v>>2]|0)>>0]|0)<<30;b=b+1|0;if((b|0)==(_|0)){t=1;break}else r=r+4|0}}}while(0)}else t=0;ft(S);P=t;be=E;return P|0}function kt(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0;l=be;be=be+560|0;u=l+16|0;s=l;a=l+48|0;f=l+24|0;n=pe[e+88>>2]|0;c=(me[n+55>>0]|0)<<8|(me[n+56>>0]|0);h=e+92|0;t=pe[e+4>>2]|0;r=(me[n+50>>0]|0)<<8|(me[n+49>>0]|0)<<16|(me[n+51>>0]|0);i=t+r|0;n=(me[n+53>>0]|0)<<8|(me[n+52>>0]|0)<<16|(me[n+54>>0]|0);if(!n){f=0;be=l;return f|0}pe[h>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[f+20>>2]=0;pe[f>>2]=0;pe[f+4>>2]=0;pe[f+8>>2]=0;pe[f+12>>2]=0;de[f+16>>0]=0;e:do{if(pt(h,f)|0){o=e+268|0;r=e+272|0;t=pe[r>>2]|0;if((t|0)!=(c|0)){if(t>>>0<=c>>>0){do{if((pe[e+276>>2]|0)>>>0>>0)if(nt(o,c,(t+1|0)==(c|0),2,0)|0){t=pe[r>>2]|0;break}else{de[e+280>>0]=1;t=0;break e}}while(0);Wr((pe[o>>2]|0)+(t<<1)|0,0,c-t<<1|0)|0}pe[r>>2]=c}if(!c){pe[s>>2]=1154;pe[s+4>>2]=903;pe[s+8>>2]=1781;_r(a,1100,s)|0;yr(a,u)|0;t=1;break}r=0;i=0;n=0;t=pe[o>>2]|0;while(1){u=vt(h,f)|0;r=u+r&255;i=(vt(h,f)|0)+i&255;$[t>>1]=i<<8|r;n=n+1|0;if((n|0)==(c|0)){t=1;break}else t=t+2|0}}else t=0}while(0);ft(f);f=t;be=l;return f|0}function It(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0;E=be;be=be+2432|0;s=E+16|0;a=E;o=E+1912|0;S=E+1888|0;x=E+988|0;T=E+88|0;w=E+24|0;n=pe[e+88>>2]|0;_=(me[n+63>>0]|0)<<8|(me[n+64>>0]|0);y=e+92|0;t=pe[e+4>>2]|0;r=(me[n+58>>0]|0)<<8|(me[n+57>>0]|0)<<16|(me[n+59>>0]|0);i=t+r|0;n=(me[n+61>>0]|0)<<8|(me[n+60>>0]|0)<<16|(me[n+62>>0]|0);if(!n){S=0;be=E;return S|0}pe[y>>2]=i;pe[e+96>>2]=i;pe[e+104>>2]=n;pe[e+100>>2]=t+(n+r);pe[e+108>>2]=0;pe[e+112>>2]=0;pe[S+20>>2]=0;pe[S>>2]=0;pe[S+4>>2]=0;pe[S+8>>2]=0;pe[S+12>>2]=0;de[S+16>>0]=0;if(pt(y,S)|0){r=0;i=-7;n=-7;while(1){pe[x+(r<<2)>>2]=i;pe[T+(r<<2)>>2]=n;t=(i|0)>6;r=r+1|0;if((r|0)==225)break;else{i=t?-7:i+1|0;n=(t&1)+n|0}}t=w;r=t+64|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(r|0));g=e+284|0;r=_*3|0;i=e+288|0;t=pe[i>>2]|0;e:do{if((t|0)==(r|0))u=13;else{if(t>>>0<=r>>>0){do{if((pe[e+292>>2]|0)>>>0>>0)if(nt(g,r,(t+1|0)==(r|0),2,0)|0){t=pe[i>>2]|0;break}else{de[e+296>>0]=1;t=0;break e}}while(0);Wr((pe[g>>2]|0)+(t<<1)|0,0,r-t<<1|0)|0}pe[i>>2]=r;u=13}}while(0);do{if((u|0)==13){if(!_){pe[a>>2]=1154;pe[a+4>>2]=903;pe[a+8>>2]=1781;_r(o,1100,a)|0;yr(o,s)|0;t=1;break}i=w+4|0;n=w+8|0;e=w+12|0;o=w+16|0;a=w+20|0;s=w+24|0;u=w+28|0;h=w+32|0;c=w+36|0;f=w+40|0;l=w+44|0;d=w+48|0;p=w+52|0;m=w+56|0;v=w+60|0;b=0;r=pe[g>>2]|0;while(1){t=0;do{A=vt(y,S)|0;g=t<<1;P=w+(g<<2)|0;pe[P>>2]=(pe[P>>2]|0)+(pe[x+(A<<2)>>2]|0)&7;g=w+((g|1)<<2)|0;pe[g>>2]=(pe[g>>2]|0)+(pe[T+(A<<2)>>2]|0)&7;t=t+1|0}while((t|0)!=8);A=me[1729+(pe[a>>2]|0)>>0]|0;$[r>>1]=(me[1729+(pe[i>>2]|0)>>0]|0)<<3|(me[1729+(pe[w>>2]|0)>>0]|0)|(me[1729+(pe[n>>2]|0)>>0]|0)<<6|(me[1729+(pe[e>>2]|0)>>0]|0)<<9|(me[1729+(pe[o>>2]|0)>>0]|0)<<12|A<<15;P=me[1729+(pe[f>>2]|0)>>0]|0;$[r+2>>1]=(me[1729+(pe[s>>2]|0)>>0]|0)<<2|A>>>1|(me[1729+(pe[u>>2]|0)>>0]|0)<<5|(me[1729+(pe[h>>2]|0)>>0]|0)<<8|(me[1729+(pe[c>>2]|0)>>0]|0)<<11|P<<14;$[r+4>>1]=(me[1729+(pe[l>>2]|0)>>0]|0)<<1|P>>>2|(me[1729+(pe[d>>2]|0)>>0]|0)<<4|(me[1729+(pe[p>>2]|0)>>0]|0)<<7|(me[1729+(pe[m>>2]|0)>>0]|0)<<10|(me[1729+(pe[v>>2]|0)>>0]|0)<<13;b=b+1|0;if((b|0)==(_|0)){t=1;break}else r=r+6|0}}}while(0)}else t=0;ft(S);P=t;be=E;return P|0}function Rt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0,se=0,ue=0,he=0,ce=0,fe=0,le=0;ce=be;be=be+720|0;he=ce+184|0;se=ce+168|0;ae=ce+160|0;oe=ce+144|0;ne=ce+136|0;ie=ce+120|0;re=ce+112|0;ee=ce+96|0;$=ce+88|0;Q=ce+72|0;Z=ce+64|0;K=ce+48|0;J=ce+40|0;ue=ce+24|0;te=ce+16|0;W=ce;V=ce+208|0;Y=ce+192|0;N=e+240|0;U=pe[N>>2]|0;q=e+256|0;H=pe[q>>2]|0;r=de[(pe[e+88>>2]|0)+17>>0]|0;G=i>>>2;if(!(r<<24>>24)){be=ce;return 1}z=(s|0)==0;X=s+-1|0;R=(o&1|0)!=0;O=i<<1;D=e+92|0;L=e+116|0;F=e+140|0;j=e+236|0;B=a+-1|0;I=(n&1|0)!=0;k=e+188|0;E=e+252|0;A=G+1|0;P=G+2|0;M=G+3|0;C=B<<4;T=r&255;r=0;o=0;n=1;S=0;do{if(!z){w=pe[t+(S<<2)>>2]|0;x=0;while(1){g=x&1;u=(g|0)==0;b=(g<<5^32)+-16|0;g=(g<<1^2)+-1|0;_=u?a:-1;h=u?0:B;e=(x|0)==(X|0);y=R&e;if((h|0)!=(_|0)){v=R&e^1;m=u?w:w+C|0;while(1){if((n|0)==1)n=vt(D,L)|0|512;p=n&7;n=n>>>3;u=me[1823+p>>0]|0;e=0;do{l=(vt(D,F)|0)+o|0;d=l-U|0;o=d>>31;o=o&l|d&~o;if((pe[N>>2]|0)>>>0<=o>>>0){pe[W>>2]=1154;pe[W+4>>2]=903;pe[W+8>>2]=1781;_r(V,1100,W)|0;yr(V,te)|0}pe[Y+(e<<2)>>2]=pe[(pe[j>>2]|0)+(o<<2)>>2];e=e+1|0}while(e>>>0>>0);d=I&(h|0)==(B|0);if(y|d){l=0;do{c=ge(l,i)|0;e=m+c|0;u=(l|0)==0|v;f=l<<1;le=(vt(D,k)|0)+r|0;fe=le-H|0;r=fe>>31;r=r&le|fe&~r;do{if(d){if(!u){fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;break}pe[e>>2]=pe[Y+((me[1831+(p<<2)+f>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(V,1100,oe)|0;yr(V,ae)|0}pe[m+(c+4)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r}else{if(!u){fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;break}pe[e>>2]=pe[Y+((me[1831+(p<<2)+f>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[ie>>2]=1154;pe[ie+4>>2]=903;pe[ie+8>>2]=1781;_r(V,1100,ie)|0;yr(V,ne)|0}pe[m+(c+4)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;pe[m+(c+8)>>2]=pe[Y+((me[(f|1)+(1831+(p<<2))>>0]|0)<<2)>>2];if((pe[q>>2]|0)>>>0<=r>>>0){pe[se>>2]=1154;pe[se+4>>2]=903;pe[se+8>>2]=1781;_r(V,1100,se)|0;yr(V,he)|0}pe[m+(c+12)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2]}}while(0);l=l+1|0}while((l|0)!=2)}else{pe[m>>2]=pe[Y+((me[1831+(p<<2)>>0]|0)<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[ue>>2]=1154;pe[ue+4>>2]=903;pe[ue+8>>2]=1781;_r(V,1100,ue)|0;yr(V,J)|0}pe[m+4>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[m+8>>2]=pe[Y+((me[1831+(p<<2)+1>>0]|0)<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[K>>2]=1154;pe[K+4>>2]=903;pe[K+8>>2]=1781;_r(V,1100,K)|0;yr(V,Z)|0}pe[m+12>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[m+(G<<2)>>2]=pe[Y+((me[1831+(p<<2)+2>>0]|0)<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[Q>>2]=1154;pe[Q+4>>2]=903;pe[Q+8>>2]=1781;_r(V,1100,Q)|0;yr(V,$)|0}pe[m+(A<<2)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2];pe[m+(P<<2)>>2]=pe[Y+((me[1831+(p<<2)+3>>0]|0)<<2)>>2];fe=(vt(D,k)|0)+r|0;le=fe-H|0;r=le>>31;r=r&fe|le&~r;if((pe[q>>2]|0)>>>0<=r>>>0){pe[ee>>2]=1154;pe[ee+4>>2]=903;pe[ee+8>>2]=1781;_r(V,1100,ee)|0;yr(V,re)|0}pe[m+(M<<2)>>2]=pe[(pe[E>>2]|0)+(r<<2)>>2]}h=h+g|0;if((h|0)==(_|0))break;else m=m+b|0}}x=x+1|0;if((x|0)==(s|0))break;else w=w+O|0}}S=S+1|0}while((S|0)!=(T|0));be=ce;return 1}function Ot(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0,se=0,ue=0,he=0,ce=0,fe=0,le=0;fe=be;be=be+640|0;ue=fe+88|0;se=fe+72|0;ae=fe+64|0;oe=fe+48|0;ne=fe+40|0;ce=fe+24|0;he=fe+16|0;ie=fe;te=fe+128|0;re=fe+112|0;ee=fe+96|0;N=e+240|0;U=pe[N>>2]|0;q=e+256|0;Z=pe[q>>2]|0;Q=e+272|0;$=pe[Q>>2]|0;r=pe[e+88>>2]|0;z=(me[r+63>>0]|0)<<8|(me[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=fe;return 1}X=(s|0)==0;H=s+-1|0;G=i<<1;V=e+92|0;Y=e+116|0;W=a+-1|0;J=e+212|0;K=e+188|0;B=(n&1|0)==0;j=(o&1|0)==0;I=e+288|0;R=e+284|0;O=e+252|0;D=e+140|0;L=e+236|0;F=e+164|0;C=e+268|0;k=W<<5;P=r&255;r=0;n=0;o=0;e=0;u=1;M=0;do{if(!X){E=pe[t+(M<<2)>>2]|0;A=0;while(1){T=A&1;h=(T|0)==0;x=(T<<6^64)+-32|0;T=(T<<1^2)+-1|0;S=h?a:-1;c=h?0:W;if((c|0)!=(S|0)){w=j|(A|0)!=(H|0);_=h?E:E+k|0;while(1){if((u|0)==1)u=vt(V,Y)|0|512;y=u&7;u=u>>>3;f=me[1823+y>>0]|0;h=0;do{b=(vt(V,F)|0)+n|0;g=b-$|0;n=g>>31;n=n&b|g&~n;if((pe[Q>>2]|0)>>>0<=n>>>0){pe[ie>>2]=1154;pe[ie+4>>2]=903;pe[ie+8>>2]=1781;_r(te,1100,ie)|0;yr(te,he)|0}pe[ee+(h<<2)>>2]=ve[(pe[C>>2]|0)+(n<<1)>>1];h=h+1|0}while(h>>>0>>0);h=0;do{b=(vt(V,D)|0)+e|0;g=b-U|0;e=g>>31;e=e&b|g&~e;if((pe[N>>2]|0)>>>0<=e>>>0){pe[ce>>2]=1154;pe[ce+4>>2]=903;pe[ce+8>>2]=1781;_r(te,1100,ce)|0;yr(te,ne)|0}pe[re+(h<<2)>>2]=pe[(pe[L>>2]|0)+(e<<2)>>2];h=h+1|0}while(h>>>0>>0);g=B|(c|0)!=(W|0);v=0;b=_;while(1){m=w|(v|0)==0;p=v<<1;l=0;d=b;while(1){f=(vt(V,J)|0)+r|0;h=f-z|0;r=h>>31;r=r&f|h&~r;h=(vt(V,K)|0)+o|0;f=h-Z|0;o=f>>31;o=o&h|f&~o;if((g|(l|0)==0)&m){h=me[l+p+(1831+(y<<2))>>0]|0;f=r*3|0;if((pe[I>>2]|0)>>>0<=f>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(te,1100,oe)|0;yr(te,ae)|0}le=pe[R>>2]|0;pe[d>>2]=(ve[le+(f<<1)>>1]|0)<<16|pe[ee+(h<<2)>>2];pe[d+4>>2]=(ve[le+(f+2<<1)>>1]|0)<<16|(ve[le+(f+1<<1)>>1]|0);pe[d+8>>2]=pe[re+(h<<2)>>2];if((pe[q>>2]|0)>>>0<=o>>>0){pe[se>>2]=1154;pe[se+4>>2]=903;pe[se+8>>2]=1781;_r(te,1100,se)|0;yr(te,ue)|0}pe[d+12>>2]=pe[(pe[O>>2]|0)+(o<<2)>>2]}l=l+1|0;if((l|0)==2)break;else d=d+16|0}v=v+1|0;if((v|0)==2)break;else b=b+i|0}c=c+T|0;if((c|0)==(S|0))break;else _=_+x|0}}A=A+1|0;if((A|0)==(s|0))break;else E=E+G|0}}M=M+1|0}while((M|0)!=(P|0));be=fe;return 1}function Dt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0;Z=be;be=be+608|0;W=Z+64|0;Y=Z+48|0;V=Z+40|0;K=Z+24|0;J=Z+16|0;G=Z;H=Z+88|0;q=Z+72|0;O=e+272|0;D=pe[O>>2]|0;r=pe[e+88>>2]|0;L=(me[r+63>>0]|0)<<8|(me[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=Z;return 1}F=(s|0)==0;j=s+-1|0;B=i<<1;N=e+92|0;U=e+116|0;z=a+-1|0;X=e+212|0;R=(o&1|0)==0;C=e+288|0;k=e+284|0;I=e+164|0;P=e+268|0;M=z<<4;A=r&255;E=(n&1|0)!=0;r=0;o=0;e=1;S=0;do{if(!F){x=pe[t+(S<<2)>>2]|0;T=0;while(1){_=T&1;n=(_|0)==0;y=(_<<5^32)+-16|0;_=(_<<1^2)+-1|0;w=n?a:-1;u=n?0:z;if((u|0)!=(w|0)){g=R|(T|0)!=(j|0);b=n?x:x+M|0;while(1){if((e|0)==1)e=vt(N,U)|0|512;v=e&7;e=e>>>3;h=me[1823+v>>0]|0;n=0;do{p=(vt(N,I)|0)+o|0;m=p-D|0;o=m>>31;o=o&p|m&~o;if((pe[O>>2]|0)>>>0<=o>>>0){pe[G>>2]=1154;pe[G+4>>2]=903;pe[G+8>>2]=1781;_r(H,1100,G)|0;yr(H,J)|0}pe[q+(n<<2)>>2]=ve[(pe[P>>2]|0)+(o<<1)>>1];n=n+1|0}while(n>>>0>>0);m=(u|0)==(z|0)&E;d=0;p=b;while(1){l=g|(d|0)==0;f=d<<1;n=(vt(N,X)|0)+r|0;c=n-L|0;h=c>>31;h=h&n|c&~h;if(l){r=me[1831+(v<<2)+f>>0]|0;n=h*3|0;if((pe[C>>2]|0)>>>0<=n>>>0){pe[K>>2]=1154;pe[K+4>>2]=903;pe[K+8>>2]=1781;_r(H,1100,K)|0;yr(H,V)|0}c=pe[k>>2]|0;pe[p>>2]=(ve[c+(n<<1)>>1]|0)<<16|pe[q+(r<<2)>>2];pe[p+4>>2]=(ve[c+(n+2<<1)>>1]|0)<<16|(ve[c+(n+1<<1)>>1]|0)}c=p+8|0;n=(vt(N,X)|0)+h|0;h=n-L|0;r=h>>31;r=r&n|h&~r;if(!(m|l^1)){n=me[(f|1)+(1831+(v<<2))>>0]|0;h=r*3|0;if((pe[C>>2]|0)>>>0<=h>>>0){pe[Y>>2]=1154;pe[Y+4>>2]=903;pe[Y+8>>2]=1781;_r(H,1100,Y)|0;yr(H,W)|0}l=pe[k>>2]|0;pe[c>>2]=(ve[l+(h<<1)>>1]|0)<<16|pe[q+(n<<2)>>2];pe[p+12>>2]=(ve[l+(h+2<<1)>>1]|0)<<16|(ve[l+(h+1<<1)>>1]|0)}d=d+1|0;if((d|0)==2)break;else p=p+i|0}u=u+_|0;if((u|0)==(w|0))break;else b=b+y|0}}T=T+1|0;if((T|0)==(s|0))break;else x=x+B|0}}S=S+1|0}while((S|0)!=(A|0));be=Z;return 1}function Lt(e,t,r,i,n,o,a,s){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;s=s|0;var u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0,Q=0,$=0,ee=0,te=0,re=0,ie=0,ne=0,oe=0,ae=0;ae=be;be=be+640|0;ie=ae+88|0;re=ae+72|0;te=ae+64|0;ee=ae+48|0;$=ae+40|0;oe=ae+24|0;ne=ae+16|0;Q=ae;Z=ae+128|0;J=ae+112|0;K=ae+96|0;N=e+272|0;U=pe[N>>2]|0;r=pe[e+88>>2]|0;z=(me[r+63>>0]|0)<<8|(me[r+64>>0]|0);r=de[r+17>>0]|0;if(!(r<<24>>24)){be=ae;return 1}X=(s|0)==0;q=s+-1|0;H=i<<1;G=e+92|0;V=e+116|0;Y=a+-1|0;W=e+212|0;B=(n&1|0)==0;j=(o&1|0)==0;D=e+288|0;L=e+284|0;F=e+164|0;R=e+268|0;O=Y<<5;k=r&255;r=0;n=0;o=0;e=0;u=1;I=0;do{if(!X){M=pe[t+(I<<2)>>2]|0;C=0;while(1){A=C&1;h=(A|0)==0;E=(A<<6^64)+-32|0;A=(A<<1^2)+-1|0;P=h?a:-1;c=h?0:Y;if((c|0)!=(P|0)){S=j|(C|0)!=(q|0);T=h?M:M+O|0;while(1){if((u|0)==1)u=vt(G,V)|0|512;x=u&7;u=u>>>3;f=me[1823+x>>0]|0;h=0;do{_=(vt(G,F)|0)+e|0;w=_-U|0;e=w>>31;e=e&_|w&~e;if((pe[N>>2]|0)>>>0<=e>>>0){pe[Q>>2]=1154;pe[Q+4>>2]=903;pe[Q+8>>2]=1781;_r(Z,1100,Q)|0;yr(Z,ne)|0}pe[J+(h<<2)>>2]=ve[(pe[R>>2]|0)+(e<<1)>>1];h=h+1|0}while(h>>>0>>0);h=0;do{_=(vt(G,F)|0)+n|0;w=_-U|0;n=w>>31;n=n&_|w&~n;if((pe[N>>2]|0)>>>0<=n>>>0){pe[oe>>2]=1154;pe[oe+4>>2]=903;pe[oe+8>>2]=1781;_r(Z,1100,oe)|0;yr(Z,$)|0}pe[K+(h<<2)>>2]=ve[(pe[R>>2]|0)+(n<<1)>>1];h=h+1|0}while(h>>>0>>0);w=B|(c|0)!=(Y|0);y=0;_=T;while(1){g=S|(y|0)==0;b=y<<1;m=0;v=_;while(1){p=(vt(G,W)|0)+o|0;d=p-z|0;o=d>>31;o=o&p|d&~o;d=(vt(G,W)|0)+r|0;p=d-z|0;r=p>>31;r=r&d|p&~r;if((w|(m|0)==0)&g){d=me[m+b+(1831+(x<<2))>>0]|0;p=o*3|0;h=pe[D>>2]|0;if(h>>>0<=p>>>0){pe[ee>>2]=1154;pe[ee+4>>2]=903;pe[ee+8>>2]=1781;_r(Z,1100,ee)|0;yr(Z,te)|0;h=pe[D>>2]|0}f=pe[L>>2]|0;l=r*3|0;if(h>>>0>l>>>0)h=f;else{pe[re>>2]=1154;pe[re+4>>2]=903;pe[re+8>>2]=1781;_r(Z,1100,re)|0;yr(Z,ie)|0;h=pe[L>>2]|0}pe[v>>2]=(ve[f+(p<<1)>>1]|0)<<16|pe[J+(d<<2)>>2];pe[v+4>>2]=(ve[f+(p+2<<1)>>1]|0)<<16|(ve[f+(p+1<<1)>>1]|0);pe[v+8>>2]=(ve[h+(l<<1)>>1]|0)<<16|pe[K+(d<<2)>>2];pe[v+12>>2]=(ve[h+(l+2<<1)>>1]|0)<<16|(ve[h+(l+1<<1)>>1]|0)}m=m+1|0;if((m|0)==2)break;else v=v+16|0}y=y+1|0;if((y|0)==2)break;else _=_+i|0}c=c+A|0;if((c|0)==(P|0))break;else T=T+E|0}}C=C+1|0;if((C|0)==(s|0))break;else M=M+H|0}}I=I+1|0}while((I|0)!=(k|0));be=ae;return 1}function Ft(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0;l=be;be=be+608|0;f=l+88|0;c=l+72|0;u=l+64|0;s=l+48|0;o=l+40|0;a=l+24|0;n=l+16|0;i=l;h=l+96|0;pe[e>>2]=0;t=e+284|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[i>>2]=1154;pe[i+4>>2]=2499;pe[i+8>>2]=1516;_r(h,1100,i)|0;yr(h,n)|0}pe[t>>2]=0;pe[e+288>>2]=0;pe[e+292>>2]=0}de[e+296>>0]=0;t=e+268|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[a>>2]=1154;pe[a+4>>2]=2499;pe[a+8>>2]=1516;_r(h,1100,a)|0;yr(h,o)|0}pe[t>>2]=0;pe[e+272>>2]=0;pe[e+276>>2]=0}de[e+280>>0]=0;t=e+252|0;r=pe[t>>2]|0;if(r){if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[s>>2]=1154;pe[s+4>>2]=2499;pe[s+8>>2]=1516;_r(h,1100,s)|0;yr(h,u)|0}pe[t>>2]=0;pe[e+256>>2]=0;pe[e+260>>2]=0}de[e+264>>0]=0;t=e+236|0;r=pe[t>>2]|0;if(!r){f=e+248|0;de[f>>0]=0;f=e+212|0;ft(f);f=e+188|0;ft(f);f=e+164|0;ft(f);f=e+140|0;ft(f);f=e+116|0;ft(f);be=l;return}if(!(r&7))Oi[pe[104>>2]&1](r,0,0,1,pe[27]|0)|0;else{pe[c>>2]=1154;pe[c+4>>2]=2499;pe[c+8>>2]=1516;_r(h,1100,c)|0;yr(h,f)|0}pe[t>>2]=0;pe[e+240>>2]=0;pe[e+244>>2]=0;f=e+248|0;de[f>>0]=0;f=e+212|0;ft(f);f=e+188|0;ft(f);f=e+164|0;ft(f);f=e+140|0;ft(f);f=e+116|0;ft(f);be=l;return}function jt(e,t){e=e|0;t=t|0;var r=0;r=be;be=be+16|0;pe[r>>2]=t;t=pe[63]|0;wr(t,e,r)|0;br(10,t)|0;Xe()}function Bt(){var e=0,t=0;e=be;be=be+16|0;if(!(Fe(200,2)|0)){t=De(pe[49]|0)|0;be=e;return t|0}else jt(2090,e);return 0}function Nt(e){e=e|0;zr(e);return}function Ut(e){e=e|0;var t=0;t=be;be=be+16|0;Ii[e&3]();jt(2139,t)}function zt(){var e=0,t=0;e=Bt()|0;if(((e|0)!=0?(t=pe[e>>2]|0,(t|0)!=0):0)?(e=t+48|0,(pe[e>>2]&-256|0)==1126902528?(pe[e+4>>2]|0)==1129074247:0):0)Ut(pe[t+12>>2]|0);t=pe[28]|0;pe[28]=t+0;Ut(t)}function Xt(e){e=e|0;return}function qt(e){e=e|0;return}function Ht(e){e=e|0;return}function Gt(e){e=e|0;return}function Vt(e){e=e|0;Nt(e);return}function Yt(e){e=e|0;Nt(e);return}function Wt(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;a=be;be=be+64|0;o=a;if((e|0)!=(t|0))if((t|0)!=0?(n=Qt(t,24,40,0)|0,(n|0)!=0):0){t=o;i=t+56|0;do{pe[t>>2]=0;t=t+4|0}while((t|0)<(i|0));pe[o>>2]=n;pe[o+8>>2]=e;pe[o+12>>2]=-1;pe[o+48>>2]=1;Di[pe[(pe[n>>2]|0)+28>>2]&3](n,o,pe[r>>2]|0,1);if((pe[o+24>>2]|0)==1){pe[r>>2]=pe[o+16>>2];t=1}else t=0}else t=0;else t=1;be=a;return t|0}function Jt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0;e=t+16|0;n=pe[e>>2]|0;do{if(n){if((n|0)!=(r|0)){i=t+36|0;pe[i>>2]=(pe[i>>2]|0)+1;pe[t+24>>2]=2;de[t+54>>0]=1;break}e=t+24|0;if((pe[e>>2]|0)==2)pe[e>>2]=i}else{pe[e>>2]=r;pe[t+24>>2]=i;pe[t+36>>2]=1}}while(0);return}function Kt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;if((e|0)==(pe[t+8>>2]|0))Jt(0,t,r,i);return}function Zt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;if((e|0)==(pe[t+8>>2]|0))Jt(0,t,r,i);else{e=pe[e+8>>2]|0;Di[pe[(pe[e>>2]|0)+28>>2]&3](e,t,r,i)}return}function Qt(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0;d=be;be=be+64|0;l=d;f=pe[e>>2]|0;c=e+(pe[f+-8>>2]|0)|0;f=pe[f+-4>>2]|0;pe[l>>2]=r;pe[l+4>>2]=e;pe[l+8>>2]=t;pe[l+12>>2]=i;i=l+16|0;e=l+20|0;t=l+24|0;n=l+28|0;o=l+32|0;a=l+40|0;s=(f|0)==(r|0);u=i;h=u+36|0;do{pe[u>>2]=0;u=u+4|0}while((u|0)<(h|0));$[i+36>>1]=0;de[i+38>>0]=0;e:do{if(s){pe[l+48>>2]=1;Ri[pe[(pe[r>>2]|0)+20>>2]&3](r,l,c,c,1,0);i=(pe[t>>2]|0)==1?c:0}else{Pi[pe[(pe[f>>2]|0)+24>>2]&3](f,l,c,1,0);switch(pe[l+36>>2]|0){case 0:{i=(pe[a>>2]|0)==1&(pe[n>>2]|0)==1&(pe[o>>2]|0)==1?pe[e>>2]|0:0;break e}case 1:break;default:{i=0;break e}}if((pe[t>>2]|0)!=1?!((pe[a>>2]|0)==0&(pe[n>>2]|0)==1&(pe[o>>2]|0)==1):0){i=0;break}i=pe[i>>2]|0}}while(0);be=d;return i|0}function $t(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;de[t+53>>0]=1;do{if((pe[t+4>>2]|0)==(i|0)){de[t+52>>0]=1;i=t+16|0;e=pe[i>>2]|0;if(!e){pe[i>>2]=r;pe[t+24>>2]=n;pe[t+36>>2]=1;if(!((n|0)==1?(pe[t+48>>2]|0)==1:0))break;de[t+54>>0]=1;break}if((e|0)!=(r|0)){n=t+36|0;pe[n>>2]=(pe[n>>2]|0)+1;de[t+54>>0]=1;break}e=t+24|0;i=pe[e>>2]|0;if((i|0)==2){pe[e>>2]=n;i=n}if((i|0)==1?(pe[t+48>>2]|0)==1:0)de[t+54>>0]=1}}while(0);return}function er(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0;e:do{if((e|0)==(pe[t+8>>2]|0)){if((pe[t+4>>2]|0)==(r|0)?(o=t+28|0,(pe[o>>2]|0)!=1):0)pe[o>>2]=i}else{if((e|0)!=(pe[t>>2]|0)){s=pe[e+8>>2]|0;Pi[pe[(pe[s>>2]|0)+24>>2]&3](s,t,r,i,n);break}if((pe[t+16>>2]|0)!=(r|0)?(a=t+20|0,(pe[a>>2]|0)!=(r|0)):0){pe[t+32>>2]=i;i=t+44|0;if((pe[i>>2]|0)==4)break;o=t+52|0;de[o>>0]=0;u=t+53|0;de[u>>0]=0;e=pe[e+8>>2]|0;Ri[pe[(pe[e>>2]|0)+20>>2]&3](e,t,r,r,1,n);if(de[u>>0]|0){if(!(de[o>>0]|0)){o=1;s=13}}else{o=0;s=13}do{if((s|0)==13){pe[a>>2]=r;u=t+40|0;pe[u>>2]=(pe[u>>2]|0)+1;if((pe[t+36>>2]|0)==1?(pe[t+24>>2]|0)==2:0){de[t+54>>0]=1;if(o)break}else s=16;if((s|0)==16?o:0)break;pe[i>>2]=4;break e}}while(0);pe[i>>2]=3;break}if((i|0)==1)pe[t+32>>2]=1}}while(0);return}function tr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0;do{if((e|0)==(pe[t+8>>2]|0)){if((pe[t+4>>2]|0)==(r|0)?(a=t+28|0,(pe[a>>2]|0)!=1):0)pe[a>>2]=i}else if((e|0)==(pe[t>>2]|0)){if((pe[t+16>>2]|0)!=(r|0)?(o=t+20|0,(pe[o>>2]|0)!=(r|0)):0){pe[t+32>>2]=i;pe[o>>2]=r;n=t+40|0;pe[n>>2]=(pe[n>>2]|0)+1;if((pe[t+36>>2]|0)==1?(pe[t+24>>2]|0)==2:0)de[t+54>>0]=1;pe[t+44>>2]=4;break}if((i|0)==1)pe[t+32>>2]=1}}while(0);return}function rr(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;if((e|0)==(pe[t+8>>2]|0))$t(0,t,r,i,n);else{e=pe[e+8>>2]|0;Ri[pe[(pe[e>>2]|0)+20>>2]&3](e,t,r,i,n,o)}return}function ir(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;if((e|0)==(pe[t+8>>2]|0))$t(0,t,r,i,n);return}function nr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;n=be;be=be+16|0;i=n;pe[i>>2]=pe[r>>2];e=Ai[pe[(pe[e>>2]|0)+16>>2]&7](e,t,i)|0;if(e)pe[r>>2]=pe[i>>2];be=n;return e&1|0}function or(e){e=e|0;if(!e)e=0;else e=(Qt(e,24,72,0)|0)!=0;return e&1|0}function ar(){var e=0,t=0,r=0,i=0,n=0,o=0,a=0,s=0;n=be;be=be+48|0;a=n+32|0;r=n+24|0;s=n+16|0;o=n;n=n+36|0;e=Bt()|0;if((e|0)!=0?(i=pe[e>>2]|0,(i|0)!=0):0){e=i+48|0;t=pe[e>>2]|0;e=pe[e+4>>2]|0;if(!((t&-256|0)==1126902528&(e|0)==1129074247)){pe[r>>2]=pe[51];jt(2368,r)}if((t|0)==1126902529&(e|0)==1129074247)e=pe[i+44>>2]|0;else e=i+80|0;pe[n>>2]=e;i=pe[i>>2]|0;e=pe[i+4>>2]|0;if(Ai[pe[(pe[8>>2]|0)+16>>2]&7](8,i,n)|0){s=pe[n>>2]|0;n=pe[51]|0;s=Ci[pe[(pe[s>>2]|0)+8>>2]&1](s)|0;pe[o>>2]=n;pe[o+4>>2]=e;pe[o+8>>2]=s;jt(2282,o)}else{pe[s>>2]=pe[51];pe[s+4>>2]=e;jt(2327,s)}}jt(2406,a)}function sr(){var e=0;e=be;be=be+16|0;if(!(je(196,6)|0)){be=e;return}else jt(2179,e)}function ur(e){e=e|0;var t=0;t=be;be=be+16|0;zr(e);if(!(Ue(pe[49]|0,0)|0)){be=t;return}else jt(2229,t)}function hr(e){e=e|0;var t=0,r=0;t=0;while(1){if((me[2427+t>>0]|0)==(e|0)){r=2;break}t=t+1|0;if((t|0)==87){t=87;e=2515;r=5;break}}if((r|0)==2)if(!t)e=2515;else{e=2515;r=5}if((r|0)==5)while(1){r=e;while(1){e=r+1|0;if(!(de[r>>0]|0))break;else r=e}t=t+-1|0;if(!t)break;else r=5}return e|0}function cr(){var e=0;if(!(pe[52]|0))e=264;else{e=(Le()|0)+60|0;e=pe[e>>2]|0}return e|0}function fr(e){e=e|0;var t=0;if(e>>>0>4294963200){t=cr()|0;pe[t>>2]=0-e;e=-1}return e|0}function lr(e,t){e=+e;t=t|0;var r=0,i=0,n=0;ee[te>>3]=e;r=pe[te>>2]|0;i=pe[te+4>>2]|0;n=Jr(r|0,i|0,52)|0;n=n&2047;switch(n|0){case 0:{if(e!=0.0){e=+lr(e*18446744073709552.0e3,t);r=(pe[t>>2]|0)+-64|0}else r=0;pe[t>>2]=r;break}case 2047:break;default:{pe[t>>2]=n+-1022;pe[te>>2]=r;pe[te+4>>2]=i&-2146435073|1071644672;e=+ee[te>>3]}}return+e}function dr(e,t){e=+e;t=t|0;return+ +lr(e,t)}function pr(e,t,r){e=e|0;t=t|0;r=r|0;do{if(e){if(t>>>0<128){de[e>>0]=t;e=1;break}if(t>>>0<2048){de[e>>0]=t>>>6|192;de[e+1>>0]=t&63|128;e=2;break}if(t>>>0<55296|(t&-8192|0)==57344){de[e>>0]=t>>>12|224;de[e+1>>0]=t>>>6&63|128;de[e+2>>0]=t&63|128;e=3;break}if((t+-65536|0)>>>0<1048576){de[e>>0]=t>>>18|240;de[e+1>>0]=t>>>12&63|128;de[e+2>>0]=t>>>6&63|128;de[e+3>>0]=t&63|128;e=4;break}else{e=cr()|0;pe[e>>2]=84;e=-1;break}}else e=1}while(0);return e|0}function mr(e,t){e=e|0;t=t|0;if(!e)e=0;else e=pr(e,t,0)|0;return e|0}function vr(e){e=e|0;var t=0,r=0;do{if(e){if((pe[e+76>>2]|0)<=-1){t=Or(e)|0;break}r=(Sr(e)|0)==0;t=Or(e)|0;if(!r)Er(e)}else{if(!(pe[65]|0))t=0;else t=vr(pe[65]|0)|0;ze(236);e=pe[58]|0;if(e)do{if((pe[e+76>>2]|0)>-1)r=Sr(e)|0;else r=0;if((pe[e+20>>2]|0)>>>0>(pe[e+28>>2]|0)>>>0)t=Or(e)|0|t;if(r)Er(e);e=pe[e+56>>2]|0}while((e|0)!=0);Be(236)}}while(0);return t|0}function br(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0;if((pe[t+76>>2]|0)>=0?(Sr(t)|0)!=0:0){if((de[t+75>>0]|0)!=(e|0)?(i=t+20|0,n=pe[i>>2]|0,n>>>0<(pe[t+16>>2]|0)>>>0):0){pe[i>>2]=n+1;de[n>>0]=e;r=e&255}else r=Ar(t,e)|0;Er(t)}else a=3;do{if((a|0)==3){if((de[t+75>>0]|0)!=(e|0)?(o=t+20|0,r=pe[o>>2]|0,r>>>0<(pe[t+16>>2]|0)>>>0):0){pe[o>>2]=r+1;de[r>>0]=e;r=e&255;break}r=Ar(t,e)|0}}while(0);return r|0}function gr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;i=r+16|0;n=pe[i>>2]|0;if(!n)if(!(Ir(r)|0)){n=pe[i>>2]|0;o=4}else i=0;else o=4;e:do{if((o|0)==4){a=r+20|0;o=pe[a>>2]|0;if((n-o|0)>>>0>>0){i=Ai[pe[r+36>>2]&7](r,e,t)|0;break}t:do{if((de[r+75>>0]|0)>-1){i=t;while(1){if(!i){n=o;i=0;break t}n=i+-1|0;if((de[e+n>>0]|0)==10)break;else i=n}if((Ai[pe[r+36>>2]&7](r,e,i)|0)>>>0>>0)break e;t=t-i|0;e=e+i|0;n=pe[a>>2]|0}else{n=o;i=0}}while(0);Qr(n|0,e|0,t|0)|0;pe[a>>2]=(pe[a>>2]|0)+t;i=i+t|0}}while(0);return i|0}function yr(e,t){e=e|0;t=t|0;var r=0,i=0;r=be;be=be+16|0;i=r;pe[i>>2]=t;t=wr(pe[64]|0,e,i)|0;be=r;return t|0}function _r(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;i=be;be=be+16|0;n=i;pe[n>>2]=r;r=Tr(e,t,n)|0;be=i;return r|0}function wr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0;m=be;be=be+224|0;f=m+120|0;p=m+80|0;d=m;l=m+136|0;i=p;n=i+40|0;do{pe[i>>2]=0;i=i+4|0}while((i|0)<(n|0));pe[f>>2]=pe[r>>2];if((Dr(0,t,f,d,p)|0)<0)r=-1;else{if((pe[e+76>>2]|0)>-1)h=Sr(e)|0;else h=0;r=pe[e>>2]|0;c=r&32;if((de[e+74>>0]|0)<1)pe[e>>2]=r&-33;r=e+48|0;if(!(pe[r>>2]|0)){n=e+44|0;o=pe[n>>2]|0;pe[n>>2]=l;a=e+28|0;pe[a>>2]=l;s=e+20|0;pe[s>>2]=l;pe[r>>2]=80;u=e+16|0;pe[u>>2]=l+80;i=Dr(e,t,f,d,p)|0;if(o){Ai[pe[e+36>>2]&7](e,0,0)|0;i=(pe[s>>2]|0)==0?-1:i;pe[n>>2]=o;pe[r>>2]=0;pe[u>>2]=0;pe[a>>2]=0;pe[s>>2]=0}}else i=Dr(e,t,f,d,p)|0;r=pe[e>>2]|0;pe[e>>2]=r|c;if(h)Er(e);r=(r&32|0)==0?i:-1}be=m;return r|0}function xr(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0,c=0;c=be;be=be+128|0;n=c+112|0;h=c;o=h;a=268;s=o+112|0;do{pe[o>>2]=pe[a>>2];o=o+4|0;a=a+4|0}while((o|0)<(s|0));if((t+-1|0)>>>0>2147483646)if(!t){t=1;u=4}else{t=cr()|0;pe[t>>2]=75;t=-1}else{n=e;u=4}if((u|0)==4){u=-2-n|0;u=t>>>0>u>>>0?u:t;pe[h+48>>2]=u;e=h+20|0;pe[e>>2]=n;pe[h+44>>2]=n;t=n+u|0;n=h+16|0;pe[n>>2]=t;pe[h+28>>2]=t;t=wr(h,r,i)|0;if(u){r=pe[e>>2]|0;de[r+(((r|0)==(pe[n>>2]|0))<<31>>31)>>0]=0}}be=c;return t|0}function Tr(e,t,r){e=e|0;t=t|0;r=r|0;return xr(e,2147483647,t,r)|0}function Sr(e){e=e|0;return 0}function Er(e){e=e|0;return}function Ar(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0;u=be;be=be+16|0;s=u;a=t&255;de[s>>0]=a;i=e+16|0;n=pe[i>>2]|0;if(!n)if(!(Ir(e)|0)){n=pe[i>>2]|0;o=4}else r=-1;else o=4;do{if((o|0)==4){i=e+20|0;o=pe[i>>2]|0;if(o>>>0>>0?(r=t&255,(r|0)!=(de[e+75>>0]|0)):0){pe[i>>2]=o+1;de[o>>0]=a;break}if((Ai[pe[e+36>>2]&7](e,s,1)|0)==1)r=me[s>>0]|0;else r=-1}}while(0);be=u;return r|0}function Pr(e){e=e|0;var t=0,r=0;t=be;be=be+16|0;r=t;pe[r>>2]=pe[e+60>>2];e=fr(Ae(6,r|0)|0)|0;be=t;return e|0}function Mr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0;n=be;be=be+32|0;o=n;i=n+20|0;pe[o>>2]=pe[e+60>>2];pe[o+4>>2]=0;pe[o+8>>2]=t;pe[o+12>>2]=i;pe[o+16>>2]=r;if((fr(Ge(140,o|0)|0)|0)<0){pe[i>>2]=-1;e=-1}else e=pe[i>>2]|0;be=n;return e|0}function Cr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;p=be;be=be+48|0;f=p+16|0;c=p;i=p+32|0;l=e+28|0;n=pe[l>>2]|0;pe[i>>2]=n;d=e+20|0;n=(pe[d>>2]|0)-n|0;pe[i+4>>2]=n;pe[i+8>>2]=t;pe[i+12>>2]=r;u=e+60|0;h=e+44|0;t=2;n=n+r|0;while(1){if(!(pe[52]|0)){pe[f>>2]=pe[u>>2];pe[f+4>>2]=i;pe[f+8>>2]=t;a=fr(Ve(146,f|0)|0)|0}else{qe(7,e|0);pe[c>>2]=pe[u>>2];pe[c+4>>2]=i;pe[c+8>>2]=t;a=fr(Ve(146,c|0)|0)|0;Se(0)}if((n|0)==(a|0)){n=6;break}if((a|0)<0){n=8;break}n=n-a|0;o=pe[i+4>>2]|0;if(a>>>0<=o>>>0)if((t|0)==2){pe[l>>2]=(pe[l>>2]|0)+a;s=o;t=2}else s=o;else{s=pe[h>>2]|0;pe[l>>2]=s;pe[d>>2]=s;s=pe[i+12>>2]|0;a=a-o|0;i=i+8|0;t=t+-1|0}pe[i>>2]=(pe[i>>2]|0)+a;pe[i+4>>2]=s-a}if((n|0)==6){f=pe[h>>2]|0;pe[e+16>>2]=f+(pe[e+48>>2]|0);e=f;pe[l>>2]=e;pe[d>>2]=e}else if((n|0)==8){pe[e+16>>2]=0;pe[l>>2]=0;pe[d>>2]=0;pe[e>>2]=pe[e>>2]|32;if((t|0)==2)r=0;else r=r-(pe[i+4>>2]|0)|0}be=p;return r|0}function kr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;n=be;be=be+80|0;i=n;pe[e+36>>2]=3;if((pe[e>>2]&64|0)==0?(pe[i>>2]=pe[e+60>>2],pe[i+4>>2]=21505,pe[i+8>>2]=n+12,(Ee(54,i|0)|0)!=0):0)de[e+75>>0]=-1;i=Cr(e,t,r)|0;be=n;return i|0}function Ir(e){e=e|0;var t=0,r=0;t=e+74|0;r=de[t>>0]|0;de[t>>0]=r+255|r;t=pe[e>>2]|0;if(!(t&8)){pe[e+8>>2]=0;pe[e+4>>2]=0;t=pe[e+44>>2]|0;pe[e+28>>2]=t;pe[e+20>>2]=t;pe[e+16>>2]=t+(pe[e+48>>2]|0);t=0}else{pe[e>>2]=t|32;t=-1}return t|0}function Rr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;o=t&255;i=(r|0)!=0;e:do{if(i&(e&3|0)!=0){n=t&255;while(1){if((de[e>>0]|0)==n<<24>>24){a=6;break e}e=e+1|0;r=r+-1|0;i=(r|0)!=0;if(!(i&(e&3|0)!=0)){a=5;break}}}else a=5}while(0);if((a|0)==5)if(i)a=6;else r=0;e:do{if((a|0)==6){n=t&255;if((de[e>>0]|0)!=n<<24>>24){i=ge(o,16843009)|0;t:do{if(r>>>0>3)while(1){o=pe[e>>2]^i;if((o&-2139062144^-2139062144)&o+-16843009)break;e=e+4|0;r=r+-4|0;if(r>>>0<=3){a=11;break t}}else a=11}while(0);if((a|0)==11)if(!r){r=0;break}while(1){if((de[e>>0]|0)==n<<24>>24)break e;e=e+1|0;r=r+-1|0;if(!r){r=0;break}}}}}while(0);return((r|0)!=0?e:0)|0}function Or(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0;t=e+20|0;o=e+28|0;if((pe[t>>2]|0)>>>0>(pe[o>>2]|0)>>>0?(Ai[pe[e+36>>2]&7](e,0,0)|0,(pe[t>>2]|0)==0):0)t=-1;else{a=e+4|0;r=pe[a>>2]|0;i=e+8|0;n=pe[i>>2]|0;if(r>>>0>>0)Ai[pe[e+40>>2]&7](e,r-n|0,1)|0;pe[e+16>>2]=0;pe[o>>2]=0;pe[t>>2]=0;pe[i>>2]=0;pe[a>>2]=0;t=0}return t|0}function Dr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0.0,c=0,f=0,l=0,d=0,p=0.0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0,B=0,N=0,U=0,z=0,X=0,q=0,H=0,G=0,V=0,Y=0,W=0,J=0,K=0,Z=0,Q=0;Q=be;be=be+624|0;Y=Q+24|0;J=Q+16|0;W=Q+588|0;X=Q+576|0;V=Q;N=Q+536|0;Z=Q+8|0;K=Q+528|0;k=(e|0)!=0;I=N+40|0;B=I;N=N+39|0;U=Z+4|0;z=X+12|0;X=X+11|0;q=W;H=z;G=H-q|0;R=-2-q|0;O=H+2|0;D=Y+288|0;L=W+9|0;F=L;j=W+8|0;o=0;m=t;a=0;t=0;e:while(1){do{if((o|0)>-1)if((a|0)>(2147483647-o|0)){o=cr()|0;pe[o>>2]=75;o=-1;break}else{o=a+o|0;break}}while(0);a=de[m>>0]|0;if(!(a<<24>>24)){C=245;break}else s=m;t:while(1){switch(a<<24>>24){case 37:{a=s;C=9;break t}case 0:{a=s;break t}default:{}}M=s+1|0;a=de[M>>0]|0;s=M}t:do{if((C|0)==9)while(1){C=0;if((de[a+1>>0]|0)!=37)break t;s=s+1|0;a=a+2|0;if((de[a>>0]|0)==37)C=9;else break}}while(0);b=s-m|0;if(k?(pe[e>>2]&32|0)==0:0)gr(m,b,e)|0;if((s|0)!=(m|0)){m=a;a=b;continue}c=a+1|0;s=de[c>>0]|0;u=(s<<24>>24)+-48|0;if(u>>>0<10){M=(de[a+2>>0]|0)==36;c=M?a+3|0:c;s=de[c>>0]|0;d=M?u:-1;t=M?1:t}else d=-1;a=s<<24>>24;t:do{if((a&-32|0)==32){u=0;while(1){if(!(1<>24)+-32|u;c=c+1|0;s=de[c>>0]|0;a=s<<24>>24;if((a&-32|0)!=32){f=u;a=c;break}}}else{f=0;a=c}}while(0);do{if(s<<24>>24==42){u=a+1|0;s=(de[u>>0]|0)+-48|0;if(s>>>0<10?(de[a+2>>0]|0)==36:0){pe[n+(s<<2)>>2]=10;t=1;a=a+3|0;s=pe[i+((de[u>>0]|0)+-48<<3)>>2]|0}else{if(t){o=-1;break e}if(!k){v=f;a=u;t=0;M=0;break}t=(pe[r>>2]|0)+(4-1)&~(4-1);s=pe[t>>2]|0;pe[r>>2]=t+4;t=0;a=u}if((s|0)<0){v=f|8192;M=0-s|0}else{v=f;M=s}}else{u=(s<<24>>24)+-48|0;if(u>>>0<10){s=0;do{s=(s*10|0)+u|0;a=a+1|0;u=(de[a>>0]|0)+-48|0}while(u>>>0<10);if((s|0)<0){o=-1;break e}else{v=f;M=s}}else{v=f;M=0}}}while(0);t:do{if((de[a>>0]|0)==46){u=a+1|0;s=de[u>>0]|0;if(s<<24>>24!=42){c=(s<<24>>24)+-48|0;if(c>>>0<10){a=u;s=0}else{a=u;c=0;break}while(1){s=(s*10|0)+c|0;a=a+1|0;c=(de[a>>0]|0)+-48|0;if(c>>>0>=10){c=s;break t}}}u=a+2|0;s=(de[u>>0]|0)+-48|0;if(s>>>0<10?(de[a+3>>0]|0)==36:0){pe[n+(s<<2)>>2]=10;a=a+4|0;c=pe[i+((de[u>>0]|0)+-48<<3)>>2]|0;break}if(t){o=-1;break e}if(k){a=(pe[r>>2]|0)+(4-1)&~(4-1);c=pe[a>>2]|0;pe[r>>2]=a+4;a=u}else{a=u;c=0}}else c=-1}while(0);l=0;while(1){s=(de[a>>0]|0)+-65|0;if(s>>>0>57){o=-1;break e}u=a+1|0;s=de[5359+(l*58|0)+s>>0]|0;f=s&255;if((f+-1|0)>>>0<8){a=u;l=f}else{P=u;break}}if(!(s<<24>>24)){o=-1;break}u=(d|0)>-1;do{if(s<<24>>24==19)if(u){o=-1;break e}else C=52;else{if(u){pe[n+(d<<2)>>2]=f;E=i+(d<<3)|0;A=pe[E+4>>2]|0;C=V;pe[C>>2]=pe[E>>2];pe[C+4>>2]=A;C=52;break}if(!k){o=0;break e}jr(V,f,r)}}while(0);if((C|0)==52?(C=0,!k):0){m=P;a=b;continue}d=de[a>>0]|0;d=(l|0)!=0&(d&15|0)==3?d&-33:d;u=v&-65537;A=(v&8192|0)==0?v:u;t:do{switch(d|0){case 110:switch(l|0){case 0:{pe[pe[V>>2]>>2]=o;m=P;a=b;continue e}case 1:{pe[pe[V>>2]>>2]=o;m=P;a=b;continue e}case 2:{m=pe[V>>2]|0;pe[m>>2]=o;pe[m+4>>2]=((o|0)<0)<<31>>31;m=P;a=b;continue e}case 3:{$[pe[V>>2]>>1]=o;m=P;a=b;continue e}case 4:{de[pe[V>>2]>>0]=o;m=P;a=b;continue e}case 6:{pe[pe[V>>2]>>2]=o;m=P;a=b;continue e}case 7:{m=pe[V>>2]|0;pe[m>>2]=o;pe[m+4>>2]=((o|0)<0)<<31>>31;m=P;a=b;continue e}default:{m=P;a=b;continue e}}case 112:{l=A|8;c=c>>>0>8?c:8;d=120;C=64;break}case 88:case 120:{l=A;C=64;break}case 111:{u=V;s=pe[u>>2]|0;u=pe[u+4>>2]|0;if((s|0)==0&(u|0)==0)a=I;else{a=I;do{a=a+-1|0;de[a>>0]=s&7|48;s=Jr(s|0,u|0,3)|0;u=re}while(!((s|0)==0&(u|0)==0))}if(!(A&8)){s=A;l=0;f=5839;C=77}else{l=B-a+1|0;s=A;c=(c|0)<(l|0)?l:c;l=0;f=5839;C=77}break}case 105:case 100:{s=V;a=pe[s>>2]|0;s=pe[s+4>>2]|0;if((s|0)<0){a=Yr(0,0,a|0,s|0)|0;s=re;u=V;pe[u>>2]=a;pe[u+4>>2]=s;u=1;f=5839;C=76;break t}if(!(A&2048)){f=A&1;u=f;f=(f|0)==0?5839:5841;C=76}else{u=1;f=5840;C=76}break}case 117:{s=V;a=pe[s>>2]|0;s=pe[s+4>>2]|0;u=0;f=5839;C=76;break}case 99:{de[N>>0]=pe[V>>2];m=N;s=1;l=0;d=5839;a=I;break}case 109:{a=cr()|0;a=hr(pe[a>>2]|0)|0;C=82;break}case 115:{a=pe[V>>2]|0;a=(a|0)!=0?a:5849;C=82;break}case 67:{pe[Z>>2]=pe[V>>2];pe[U>>2]=0;pe[V>>2]=Z;c=-1;C=86;break}case 83:{if(!c){Nr(e,32,M,0,A);a=0;C=98}else C=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{h=+ee[V>>3];pe[J>>2]=0;ee[te>>3]=h;if((pe[te+4>>2]|0)>=0)if(!(A&2048)){E=A&1;S=E;E=(E|0)==0?5857:5862}else{S=1;E=5859}else{h=-h;S=1;E=5856}ee[te>>3]=h;T=pe[te+4>>2]&2146435072;do{if(T>>>0<2146435072|(T|0)==2146435072&0<0){p=+dr(h,J)*2.0;s=p!=0.0;if(s)pe[J>>2]=(pe[J>>2]|0)+-1;w=d|32;if((w|0)==97){m=d&32;b=(m|0)==0?E:E+9|0;v=S|2;a=12-c|0;do{if(!(c>>>0>11|(a|0)==0)){h=8.0;do{a=a+-1|0;h=h*16.0}while((a|0)!=0);if((de[b>>0]|0)==45){h=-(h+(-p-h));break}else{h=p+h-h;break}}else h=p}while(0);s=pe[J>>2]|0;a=(s|0)<0?0-s|0:s;a=Br(a,((a|0)<0)<<31>>31,z)|0;if((a|0)==(z|0)){de[X>>0]=48;a=X}de[a+-1>>0]=(s>>31&2)+43;l=a+-2|0;de[l>>0]=d+15;f=(c|0)<1;u=(A&8|0)==0;s=W;while(1){E=~~h;a=s+1|0;de[s>>0]=me[5823+E>>0]|m;h=(h-+(E|0))*16.0;do{if((a-q|0)==1){if(u&(f&h==0.0))break;de[a>>0]=46;a=s+2|0}}while(0);if(!(h!=0.0))break;else s=a}c=(c|0)!=0&(R+a|0)<(c|0)?O+c-l|0:G-l+a|0;u=c+v|0;Nr(e,32,M,u,A);if(!(pe[e>>2]&32))gr(b,v,e)|0;Nr(e,48,M,u,A^65536);a=a-q|0;if(!(pe[e>>2]&32))gr(W,a,e)|0;s=H-l|0;Nr(e,48,c-(a+s)|0,0,0);if(!(pe[e>>2]&32))gr(l,s,e)|0;Nr(e,32,M,u,A^8192);a=(u|0)<(M|0)?M:u;break}a=(c|0)<0?6:c;if(s){s=(pe[J>>2]|0)+-28|0;pe[J>>2]=s;h=p*268435456.0}else{h=p;s=pe[J>>2]|0}T=(s|0)<0?Y:D;x=T;s=T;do{_=~~h>>>0;pe[s>>2]=_;s=s+4|0;h=(h-+(_>>>0))*1.0e9}while(h!=0.0);u=s;s=pe[J>>2]|0;if((s|0)>0){f=T;while(1){l=(s|0)>29?29:s;c=u+-4|0;do{if(c>>>0>>0)c=f;else{s=0;do{_=Kr(pe[c>>2]|0,0,l|0)|0;_=Zr(_|0,re|0,s|0,0)|0;s=re;y=ai(_|0,s|0,1e9,0)|0;pe[c>>2]=y;s=oi(_|0,s|0,1e9,0)|0;c=c+-4|0}while(c>>>0>=f>>>0);if(!s){c=f;break}c=f+-4|0;pe[c>>2]=s}}while(0);while(1){if(u>>>0<=c>>>0)break;s=u+-4|0;if(!(pe[s>>2]|0))u=s;else break}s=(pe[J>>2]|0)-l|0;pe[J>>2]=s;if((s|0)>0)f=c;else break}}else c=T;if((s|0)<0){b=((a+25|0)/9|0)+1|0;g=(w|0)==102;m=c;while(1){v=0-s|0;v=(v|0)>9?9:v;do{if(m>>>0>>0){s=(1<>>v;c=0;l=m;do{_=pe[l>>2]|0;pe[l>>2]=(_>>>v)+c;c=ge(_&s,f)|0;l=l+4|0}while(l>>>0>>0);s=(pe[m>>2]|0)==0?m+4|0:m;if(!c){c=s;break}pe[u>>2]=c;c=s;u=u+4|0}else c=(pe[m>>2]|0)==0?m+4|0:m}while(0);s=g?T:c;u=(u-s>>2|0)>(b|0)?s+(b<<2)|0:u;s=(pe[J>>2]|0)+v|0;pe[J>>2]=s;if((s|0)>=0){m=c;break}else m=c}}else m=c;do{if(m>>>0>>0){s=(x-m>>2)*9|0;f=pe[m>>2]|0;if(f>>>0<10)break;else c=10;do{c=c*10|0;s=s+1|0}while(f>>>0>=c>>>0)}else s=0}while(0);y=(w|0)==103;_=(a|0)!=0;c=a-((w|0)!=102?s:0)+((_&y)<<31>>31)|0;if((c|0)<(((u-x>>2)*9|0)+-9|0)){l=c+9216|0;g=(l|0)/9|0;c=T+(g+-1023<<2)|0;l=((l|0)%9|0)+1|0;if((l|0)<9){f=10;do{f=f*10|0;l=l+1|0}while((l|0)!=9)}else f=10;v=pe[c>>2]|0;b=(v>>>0)%(f>>>0)|0;if((b|0)==0?(T+(g+-1022<<2)|0)==(u|0):0)f=m;else C=163;do{if((C|0)==163){C=0;p=(((v>>>0)/(f>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;l=(f|0)/2|0;do{if(b>>>0>>0)h=.5;else{if((b|0)==(l|0)?(T+(g+-1022<<2)|0)==(u|0):0){h=1.0;break}h=1.5}}while(0);do{if(S){if((de[E>>0]|0)!=45)break;p=-p;h=-h}}while(0);l=v-b|0;pe[c>>2]=l;if(!(p+h!=p)){f=m;break}w=l+f|0;pe[c>>2]=w;if(w>>>0>999999999){s=m;while(1){f=c+-4|0;pe[c>>2]=0;if(f>>>0>>0){s=s+-4|0;pe[s>>2]=0}w=(pe[f>>2]|0)+1|0;pe[f>>2]=w;if(w>>>0>999999999)c=f;else{m=s;c=f;break}}}s=(x-m>>2)*9|0;l=pe[m>>2]|0;if(l>>>0<10){f=m;break}else f=10;do{f=f*10|0;s=s+1|0}while(l>>>0>=f>>>0);f=m}}while(0);w=c+4|0;m=f;u=u>>>0>w>>>0?w:u}b=0-s|0;while(1){if(u>>>0<=m>>>0){g=0;w=u;break}c=u+-4|0;if(!(pe[c>>2]|0))u=c;else{g=1;w=u;break}}do{if(y){a=(_&1^1)+a|0;if((a|0)>(s|0)&(s|0)>-5){d=d+-1|0;a=a+-1-s|0}else{d=d+-2|0;a=a+-1|0}u=A&8;if(u)break;do{if(g){u=pe[w+-4>>2]|0;if(!u){c=9;break}if(!((u>>>0)%10|0)){f=10;c=0}else{c=0;break}do{f=f*10|0;c=c+1|0}while(((u>>>0)%(f>>>0)|0|0)==0)}else c=9}while(0);u=((w-x>>2)*9|0)+-9|0;if((d|32|0)==102){u=u-c|0;u=(u|0)<0?0:u;a=(a|0)<(u|0)?a:u;u=0;break}else{u=u+s-c|0;u=(u|0)<0?0:u;a=(a|0)<(u|0)?a:u;u=0;break}}else u=A&8}while(0);v=a|u;f=(v|0)!=0&1;l=(d|32|0)==102;if(l){s=(s|0)>0?s:0;d=0}else{c=(s|0)<0?b:s;c=Br(c,((c|0)<0)<<31>>31,z)|0;if((H-c|0)<2)do{c=c+-1|0;de[c>>0]=48}while((H-c|0)<2);de[c+-1>>0]=(s>>31&2)+43;x=c+-2|0;de[x>>0]=d;s=H-x|0;d=x}b=S+1+a+f+s|0;Nr(e,32,M,b,A);if(!(pe[e>>2]&32))gr(E,S,e)|0;Nr(e,48,M,b,A^65536);do{if(l){c=m>>>0>T>>>0?T:m;s=c;do{u=Br(pe[s>>2]|0,0,L)|0;do{if((s|0)==(c|0)){if((u|0)!=(L|0))break;de[j>>0]=48;u=j}else{if(u>>>0<=W>>>0)break;do{u=u+-1|0;de[u>>0]=48}while(u>>>0>W>>>0)}}while(0);if(!(pe[e>>2]&32))gr(u,F-u|0,e)|0;s=s+4|0}while(s>>>0<=T>>>0);do{if(v){if(pe[e>>2]&32)break;gr(5891,1,e)|0}}while(0);if((a|0)>0&s>>>0>>0){u=s;while(1){s=Br(pe[u>>2]|0,0,L)|0;if(s>>>0>W>>>0)do{s=s+-1|0;de[s>>0]=48}while(s>>>0>W>>>0);if(!(pe[e>>2]&32))gr(s,(a|0)>9?9:a,e)|0;u=u+4|0;s=a+-9|0;if(!((a|0)>9&u>>>0>>0)){a=s;break}else a=s}}Nr(e,48,a+9|0,9,0)}else{l=g?w:m+4|0;if((a|0)>-1){f=(u|0)==0;c=m;do{s=Br(pe[c>>2]|0,0,L)|0;if((s|0)==(L|0)){de[j>>0]=48;s=j}do{if((c|0)==(m|0)){u=s+1|0;if(!(pe[e>>2]&32))gr(s,1,e)|0;if(f&(a|0)<1){s=u;break}if(pe[e>>2]&32){s=u;break}gr(5891,1,e)|0;s=u}else{if(s>>>0<=W>>>0)break;do{s=s+-1|0;de[s>>0]=48}while(s>>>0>W>>>0)}}while(0);u=F-s|0;if(!(pe[e>>2]&32))gr(s,(a|0)>(u|0)?u:a,e)|0;a=a-u|0;c=c+4|0}while(c>>>0>>0&(a|0)>-1)}Nr(e,48,a+18|0,18,0);if(pe[e>>2]&32)break;gr(d,H-d|0,e)|0}}while(0);Nr(e,32,M,b,A^8192);a=(b|0)<(M|0)?M:b}else{l=(d&32|0)!=0;f=h!=h|0.0!=0.0;s=f?0:S;c=s+3|0;Nr(e,32,M,c,u);a=pe[e>>2]|0;if(!(a&32)){gr(E,s,e)|0;a=pe[e>>2]|0}if(!(a&32))gr(f?l?5883:5887:l?5875:5879,3,e)|0;Nr(e,32,M,c,A^8192);a=(c|0)<(M|0)?M:c}}while(0);m=P;continue e}default:{u=A;s=c;l=0;d=5839;a=I}}}while(0);t:do{if((C|0)==64){u=V;s=pe[u>>2]|0;u=pe[u+4>>2]|0;f=d&32;if(!((s|0)==0&(u|0)==0)){a=I;do{a=a+-1|0;de[a>>0]=me[5823+(s&15)>>0]|f;s=Jr(s|0,u|0,4)|0;u=re}while(!((s|0)==0&(u|0)==0));C=V;if((l&8|0)==0|(pe[C>>2]|0)==0&(pe[C+4>>2]|0)==0){s=l;l=0;f=5839;C=77}else{s=l;l=2;f=5839+(d>>4)|0;C=77}}else{a=I;s=l;l=0;f=5839;C=77}}else if((C|0)==76){a=Br(a,s,I)|0;s=A;l=u;C=77}else if((C|0)==82){C=0;A=Rr(a,0,c)|0;E=(A|0)==0;m=a;s=E?c:A-a|0;l=0;d=5839;a=E?a+c|0:A}else if((C|0)==86){C=0;s=0;a=0;f=pe[V>>2]|0;while(1){u=pe[f>>2]|0;if(!u)break;a=mr(K,u)|0;if((a|0)<0|a>>>0>(c-s|0)>>>0)break;s=a+s|0;if(c>>>0>s>>>0)f=f+4|0;else break}if((a|0)<0){o=-1;break e}Nr(e,32,M,s,A);if(!s){a=0;C=98}else{u=0;c=pe[V>>2]|0;while(1){a=pe[c>>2]|0;if(!a){a=s;C=98;break t}a=mr(K,a)|0;u=a+u|0;if((u|0)>(s|0)){a=s;C=98;break t}if(!(pe[e>>2]&32))gr(K,a,e)|0;if(u>>>0>=s>>>0){a=s;C=98;break}else c=c+4|0}}}}while(0);if((C|0)==98){C=0;Nr(e,32,M,a,A^8192);m=P;a=(M|0)>(a|0)?M:a;continue}if((C|0)==77){C=0;u=(c|0)>-1?s&-65537:s;s=V;s=(pe[s>>2]|0)!=0|(pe[s+4>>2]|0)!=0;if((c|0)!=0|s){s=(s&1^1)+(B-a)|0;m=a;s=(c|0)>(s|0)?c:s;d=f;a=I}else{m=I;s=0;d=f;a=I}}f=a-m|0;s=(s|0)<(f|0)?f:s;c=l+s|0;a=(M|0)<(c|0)?c:M;Nr(e,32,a,c,u);if(!(pe[e>>2]&32))gr(d,l,e)|0;Nr(e,48,a,c,u^65536);Nr(e,48,s,f,0);if(!(pe[e>>2]&32))gr(m,f,e)|0;Nr(e,32,a,c,u^8192);m=P}e:do{if((C|0)==245)if(!e)if(t){o=1;while(1){t=pe[n+(o<<2)>>2]|0;if(!t)break;jr(i+(o<<3)|0,t,r);o=o+1|0;if((o|0)>=10){o=1;break e}}if((o|0)<10)while(1){if(pe[n+(o<<2)>>2]|0){o=-1;break e}o=o+1|0;if((o|0)>=10){o=1;break}}else o=1}else o=0}while(0);be=Q;return o|0}function Lr(e){e=e|0;if(!(pe[e+68>>2]|0))Er(e);return}function Fr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;i=e+20|0;n=pe[i>>2]|0;e=(pe[e+16>>2]|0)-n|0;e=e>>>0>r>>>0?r:e;Qr(n|0,t|0,e|0)|0;pe[i>>2]=(pe[i>>2]|0)+e;return r|0}function jr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0.0;e:do{if(t>>>0<=20)do{switch(t|0){case 9:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;pe[e>>2]=t;break e}case 10:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;i=e;pe[i>>2]=t;pe[i+4>>2]=((t|0)<0)<<31>>31;break e}case 11:{i=(pe[r>>2]|0)+(4-1)&~(4-1);t=pe[i>>2]|0;pe[r>>2]=i+4;i=e;pe[i>>2]=t;pe[i+4>>2]=0;break e}case 12:{i=(pe[r>>2]|0)+(8-1)&~(8-1);t=i;n=pe[t>>2]|0;t=pe[t+4>>2]|0;pe[r>>2]=i+8;i=e;pe[i>>2]=n;pe[i+4>>2]=t;break e}case 13:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;i=(i&65535)<<16>>16;n=e;pe[n>>2]=i;pe[n+4>>2]=((i|0)<0)<<31>>31;break e}case 14:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;n=e;pe[n>>2]=i&65535;pe[n+4>>2]=0;break e}case 15:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;i=(i&255)<<24>>24;n=e;pe[n>>2]=i;pe[n+4>>2]=((i|0)<0)<<31>>31;break e}case 16:{n=(pe[r>>2]|0)+(4-1)&~(4-1);i=pe[n>>2]|0;pe[r>>2]=n+4;n=e;pe[n>>2]=i&255;pe[n+4>>2]=0;break e}case 17:{n=(pe[r>>2]|0)+(8-1)&~(8-1);o=+ee[n>>3];pe[r>>2]=n+8;ee[e>>3]=o;break e}case 18:{n=(pe[r>>2]|0)+(8-1)&~(8-1);o=+ee[n>>3];pe[r>>2]=n+8;ee[e>>3]=o;break e}default:break e}}while(0)}while(0);return}function Br(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(t>>>0>0|(t|0)==0&e>>>0>4294967295)while(1){i=ai(e|0,t|0,10,0)|0;r=r+-1|0;de[r>>0]=i|48;i=oi(e|0,t|0,10,0)|0;if(t>>>0>9|(t|0)==9&e>>>0>4294967295){e=i;t=re}else{e=i;break}}if(e)while(1){r=r+-1|0;de[r>>0]=(e>>>0)%10|0|48;if(e>>>0<10)break;else e=(e>>>0)/10|0}return r|0}function Nr(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0;s=be;be=be+256|0;a=s;do{if((r|0)>(i|0)&(n&73728|0)==0){n=r-i|0;Wr(a|0,t|0,(n>>>0>256?256:n)|0)|0;t=pe[e>>2]|0;o=(t&32|0)==0;if(n>>>0>255){i=r-i|0;do{if(o){gr(a,256,e)|0;t=pe[e>>2]|0}n=n+-256|0;o=(t&32|0)==0}while(n>>>0>255);if(o)n=i&255;else break}else if(!o)break;gr(a,n,e)|0}}while(0);be=s;return}function Ur(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0,_=0,w=0,x=0,T=0,S=0,E=0,A=0,P=0,M=0,C=0,k=0,I=0,R=0,O=0,D=0,L=0,F=0,j=0;do{if(e>>>0<245){d=e>>>0<11?16:e+11&-8;e=d>>>3;s=pe[151]|0;r=s>>>e;if(r&3){e=(r&1^1)+e|0;i=e<<1;r=644+(i<<2)|0;i=644+(i+2<<2)|0;n=pe[i>>2]|0;o=n+8|0;a=pe[o>>2]|0;do{if((r|0)!=(a|0)){if(a>>>0<(pe[155]|0)>>>0)Xe();t=a+12|0;if((pe[t>>2]|0)==(n|0)){pe[t>>2]=r;pe[i>>2]=a;break}else Xe()}else pe[151]=s&~(1<>2]=j|3;j=n+(j|4)|0;pe[j>>2]=pe[j>>2]|1;j=o;return j|0}a=pe[153]|0;if(d>>>0>a>>>0){if(r){i=2<>>12&16;i=i>>>u;n=i>>>5&8;i=i>>>n;o=i>>>2&4;i=i>>>o;r=i>>>1&2;i=i>>>r;e=i>>>1&1;e=(n|u|o|r|e)+(i>>>e)|0;i=e<<1;r=644+(i<<2)|0;i=644+(i+2<<2)|0;o=pe[i>>2]|0;u=o+8|0;n=pe[u>>2]|0;do{if((r|0)!=(n|0)){if(n>>>0<(pe[155]|0)>>>0)Xe();t=n+12|0;if((pe[t>>2]|0)==(o|0)){pe[t>>2]=r;pe[i>>2]=n;h=pe[153]|0;break}else Xe()}else{pe[151]=s&~(1<>2]=d|3;s=o+d|0;pe[o+(d|4)>>2]=a|1;pe[o+j>>2]=a;if(h){n=pe[156]|0;r=h>>>3;t=r<<1;i=644+(t<<2)|0;e=pe[151]|0;r=1<>2]|0;if(t>>>0<(pe[155]|0)>>>0)Xe();else{c=e;f=t}}else{pe[151]=e|r;c=644+(t+2<<2)|0;f=i}pe[c>>2]=n;pe[f+12>>2]=n;pe[n+8>>2]=f;pe[n+12>>2]=i}pe[153]=a;pe[156]=s;j=u;return j|0}e=pe[152]|0;if(e){r=(e&0-e)+-1|0;F=r>>>12&16;r=r>>>F;L=r>>>5&8;r=r>>>L;j=r>>>2&4;r=r>>>j;e=r>>>1&2;r=r>>>e;i=r>>>1&1;i=pe[908+((L|F|j|e|i)+(r>>>i)<<2)>>2]|0;r=(pe[i+4>>2]&-8)-d|0;e=i;while(1){t=pe[e+16>>2]|0;if(!t){t=pe[e+20>>2]|0;if(!t){u=r;break}}e=(pe[t+4>>2]&-8)-d|0;j=e>>>0>>0;r=j?e:r;e=t;i=j?t:i}o=pe[155]|0;if(i>>>0>>0)Xe();s=i+d|0;if(i>>>0>=s>>>0)Xe();a=pe[i+24>>2]|0;r=pe[i+12>>2]|0;do{if((r|0)==(i|0)){e=i+20|0;t=pe[e>>2]|0;if(!t){e=i+16|0;t=pe[e>>2]|0;if(!t){l=0;break}}while(1){r=t+20|0;n=pe[r>>2]|0;if(n){t=n;e=r;continue}r=t+16|0;n=pe[r>>2]|0;if(!n)break;else{t=n;e=r}}if(e>>>0>>0)Xe();else{pe[e>>2]=0;l=t;break}}else{n=pe[i+8>>2]|0;if(n>>>0>>0)Xe();t=n+12|0;if((pe[t>>2]|0)!=(i|0))Xe();e=r+8|0;if((pe[e>>2]|0)==(i|0)){pe[t>>2]=r;pe[e>>2]=n;l=r;break}else Xe()}}while(0);do{if(a){t=pe[i+28>>2]|0;e=908+(t<<2)|0;if((i|0)==(pe[e>>2]|0)){pe[e>>2]=l;if(!l){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(i|0))pe[t>>2]=l;else pe[a+20>>2]=l;if(!l)break}e=pe[155]|0;if(l>>>0>>0)Xe();pe[l+24>>2]=a;t=pe[i+16>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[l+16>>2]=t;pe[t+24>>2]=l;break}}while(0);t=pe[i+20>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[l+20>>2]=t;pe[t+24>>2]=l;break}}}while(0);if(u>>>0<16){j=u+d|0;pe[i+4>>2]=j|3;j=i+(j+4)|0;pe[j>>2]=pe[j>>2]|1}else{pe[i+4>>2]=d|3;pe[i+(d|4)>>2]=u|1;pe[i+(u+d)>>2]=u;t=pe[153]|0;if(t){o=pe[156]|0;r=t>>>3;t=r<<1;n=644+(t<<2)|0;e=pe[151]|0;r=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{p=t;m=e}}else{pe[151]=e|r;p=644+(t+2<<2)|0;m=n}pe[p>>2]=o;pe[m+12>>2]=o;pe[o+8>>2]=m;pe[o+12>>2]=n}pe[153]=u;pe[156]=s}j=i+8|0;return j|0}else m=d}else m=d}else if(e>>>0<=4294967231){e=e+11|0;f=e&-8;c=pe[152]|0;if(c){r=0-f|0;e=e>>>8;if(e)if(f>>>0>16777215)h=31;else{m=(e+1048320|0)>>>16&8;_=e<>>16&4;_=_<>>16&2;h=14-(p|m|h)+(_<>>15)|0;h=f>>>(h+7|0)&1|h<<1}else h=0;e=pe[908+(h<<2)>>2]|0;e:do{if(!e){n=0;e=0;_=86}else{a=r;n=0;s=f<<((h|0)==31?0:25-(h>>>1)|0);u=e;e=0;while(1){o=pe[u+4>>2]&-8;r=o-f|0;if(r>>>0>>0)if((o|0)==(f|0)){o=u;e=u;_=90;break e}else e=u;else r=a;_=pe[u+20>>2]|0;u=pe[u+16+(s>>>31<<2)>>2]|0;n=(_|0)==0|(_|0)==(u|0)?n:_;if(!u){_=86;break}else{a=r;s=s<<1}}}}while(0);if((_|0)==86){if((n|0)==0&(e|0)==0){e=2<>>12&16;e=e>>>l;c=e>>>5&8;e=e>>>c;p=e>>>2&4;e=e>>>p;m=e>>>1&2;e=e>>>m;n=e>>>1&1;n=pe[908+((c|l|p|m|n)+(e>>>n)<<2)>>2]|0;e=0}if(!n){s=r;u=e}else{o=n;_=90}}if((_|0)==90)while(1){_=0;m=(pe[o+4>>2]&-8)-f|0;n=m>>>0>>0;r=n?m:r;e=n?o:e;n=pe[o+16>>2]|0;if(n){o=n;_=90;continue}o=pe[o+20>>2]|0;if(!o){s=r;u=e;break}else _=90}if((u|0)!=0?s>>>0<((pe[153]|0)-f|0)>>>0:0){n=pe[155]|0;if(u>>>0>>0)Xe();a=u+f|0;if(u>>>0>=a>>>0)Xe();o=pe[u+24>>2]|0;r=pe[u+12>>2]|0;do{if((r|0)==(u|0)){e=u+20|0;t=pe[e>>2]|0;if(!t){e=u+16|0;t=pe[e>>2]|0;if(!t){d=0;break}}while(1){r=t+20|0;i=pe[r>>2]|0;if(i){t=i;e=r;continue}r=t+16|0;i=pe[r>>2]|0;if(!i)break;else{t=i;e=r}}if(e>>>0>>0)Xe();else{pe[e>>2]=0;d=t;break}}else{i=pe[u+8>>2]|0;if(i>>>0>>0)Xe();t=i+12|0;if((pe[t>>2]|0)!=(u|0))Xe();e=r+8|0;if((pe[e>>2]|0)==(u|0)){pe[t>>2]=r;pe[e>>2]=i;d=r;break}else Xe()}}while(0);do{if(o){t=pe[u+28>>2]|0;e=908+(t<<2)|0;if((u|0)==(pe[e>>2]|0)){pe[e>>2]=d;if(!d){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=o+16|0;if((pe[t>>2]|0)==(u|0))pe[t>>2]=d;else pe[o+20>>2]=d;if(!d)break}e=pe[155]|0;if(d>>>0>>0)Xe();pe[d+24>>2]=o;t=pe[u+16>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[d+16>>2]=t;pe[t+24>>2]=d;break}}while(0);t=pe[u+20>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[d+20>>2]=t;pe[t+24>>2]=d;break}}}while(0);e:do{if(s>>>0>=16){pe[u+4>>2]=f|3;pe[u+(f|4)>>2]=s|1;pe[u+(s+f)>>2]=s;t=s>>>3;if(s>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{b=t;g=e}}else{pe[151]=r|t;b=644+(e+2<<2)|0;g=i}pe[b>>2]=a;pe[g+12>>2]=a;pe[u+(f+8)>>2]=g;pe[u+(f+12)>>2]=i;break}t=s>>>8;if(t)if(s>>>0>16777215)i=31;else{F=(t+1048320|0)>>>16&8;j=t<>>16&4;j=j<>>16&2;i=14-(L|F|i)+(j<>>15)|0;i=s>>>(i+7|0)&1|i<<1}else i=0;t=908+(i<<2)|0;pe[u+(f+28)>>2]=i;pe[u+(f+20)>>2]=0;pe[u+(f+16)>>2]=0;e=pe[152]|0;r=1<>2]=a;pe[u+(f+24)>>2]=t;pe[u+(f+12)>>2]=a;pe[u+(f+8)>>2]=a;break}t=pe[t>>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(s|0)){i=s<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(s|0)){T=r;break t}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=a;pe[u+(f+24)>>2]=t;pe[u+(f+12)>>2]=a;pe[u+(f+8)>>2]=a;break e}}else T=t}while(0);t=T+8|0;e=pe[t>>2]|0;j=pe[155]|0;if(e>>>0>=j>>>0&T>>>0>=j>>>0){pe[e+12>>2]=a;pe[t>>2]=a;pe[u+(f+8)>>2]=e;pe[u+(f+12)>>2]=T;pe[u+(f+24)>>2]=0;break}else Xe()}else{j=s+f|0;pe[u+4>>2]=j|3;j=u+(j+4)|0;pe[j>>2]=pe[j>>2]|1}}while(0);j=u+8|0;return j|0}else m=f}else m=f}else m=-1}while(0);r=pe[153]|0;if(r>>>0>=m>>>0){t=r-m|0;e=pe[156]|0;if(t>>>0>15){pe[156]=e+m;pe[153]=t;pe[e+(m+4)>>2]=t|1;pe[e+r>>2]=t;pe[e+4>>2]=m|3}else{pe[153]=0;pe[156]=0;pe[e+4>>2]=r|3;j=e+(r+4)|0;pe[j>>2]=pe[j>>2]|1}j=e+8|0;return j|0}e=pe[154]|0;if(e>>>0>m>>>0){F=e-m|0;pe[154]=F;j=pe[157]|0;pe[157]=j+m;pe[j+(m+4)>>2]=F|1;pe[j+4>>2]=m|3;j=j+8|0;return j|0}do{if(!(pe[269]|0)){e=Oe(30)|0;if(!(e+-1&e)){pe[271]=e;pe[270]=e;pe[272]=-1;pe[273]=-1;pe[274]=0;pe[262]=0;T=(He(0)|0)&-16^1431655768;pe[269]=T;break}else Xe()}}while(0);u=m+48|0;s=pe[271]|0;h=m+47|0;a=s+h|0;s=0-s|0;c=a&s;if(c>>>0<=m>>>0){j=0;return j|0}e=pe[261]|0;if((e|0)!=0?(g=pe[259]|0,T=g+c|0,T>>>0<=g>>>0|T>>>0>e>>>0):0){j=0;return j|0}e:do{if(!(pe[262]&4)){e=pe[157]|0;t:do{if(e){n=1052;while(1){r=pe[n>>2]|0;if(r>>>0<=e>>>0?(v=n+4|0,(r+(pe[v>>2]|0)|0)>>>0>e>>>0):0){o=n;e=v;break}n=pe[n+8>>2]|0;if(!n){_=174;break t}}r=a-(pe[154]|0)&s;if(r>>>0<2147483647){n=ke(r|0)|0;T=(n|0)==((pe[o>>2]|0)+(pe[e>>2]|0)|0);e=T?r:0;if(T){if((n|0)!=(-1|0)){w=n;p=e;_=194;break e}}else _=184}else e=0}else _=174}while(0);do{if((_|0)==174){o=ke(0)|0;if((o|0)!=(-1|0)){e=o;r=pe[270]|0;n=r+-1|0;if(!(n&e))r=c;else r=c-e+(n+e&0-r)|0;e=pe[259]|0;n=e+r|0;if(r>>>0>m>>>0&r>>>0<2147483647){T=pe[261]|0;if((T|0)!=0?n>>>0<=e>>>0|n>>>0>T>>>0:0){e=0;break}n=ke(r|0)|0;T=(n|0)==(o|0);e=T?r:0;if(T){w=o;p=e;_=194;break e}else _=184}else e=0}else e=0}}while(0);t:do{if((_|0)==184){o=0-r|0;do{if(u>>>0>r>>>0&(r>>>0<2147483647&(n|0)!=(-1|0))?(y=pe[271]|0,y=h-r+y&0-y,y>>>0<2147483647):0)if((ke(y|0)|0)==(-1|0)){ke(o|0)|0;break t}else{r=y+r|0;break}}while(0);if((n|0)!=(-1|0)){w=n;p=r;_=194;break e}}}while(0);pe[262]=pe[262]|4;_=191}else{e=0;_=191}}while(0);if((((_|0)==191?c>>>0<2147483647:0)?(w=ke(c|0)|0,x=ke(0)|0,w>>>0>>0&((w|0)!=(-1|0)&(x|0)!=(-1|0))):0)?(S=x-w|0,E=S>>>0>(m+40|0)>>>0,E):0){p=E?S:e;_=194}if((_|0)==194){e=(pe[259]|0)+p|0;pe[259]=e;if(e>>>0>(pe[260]|0)>>>0)pe[260]=e;a=pe[157]|0;e:do{if(a){o=1052;do{e=pe[o>>2]|0;r=o+4|0;n=pe[r>>2]|0;if((w|0)==(e+n|0)){A=e;P=r;M=n;C=o;_=204;break}o=pe[o+8>>2]|0}while((o|0)!=0);if(((_|0)==204?(pe[C+12>>2]&8|0)==0:0)?a>>>0>>0&a>>>0>=A>>>0:0){pe[P>>2]=M+p;j=(pe[154]|0)+p|0;F=a+8|0;F=(F&7|0)==0?0:0-F&7;L=j-F|0;pe[157]=a+F;pe[154]=L;pe[a+(F+4)>>2]=L|1;pe[a+(j+4)>>2]=40;pe[158]=pe[273];break}e=pe[155]|0;if(w>>>0>>0){pe[155]=w;e=w}r=w+p|0;o=1052;while(1){if((pe[o>>2]|0)==(r|0)){n=o;r=o;_=212;break}o=pe[o+8>>2]|0;if(!o){r=1052;break}}if((_|0)==212)if(!(pe[r+12>>2]&8)){pe[n>>2]=w;l=r+4|0;pe[l>>2]=(pe[l>>2]|0)+p;l=w+8|0;l=(l&7|0)==0?0:0-l&7;h=w+(p+8)|0;h=(h&7|0)==0?0:0-h&7;t=w+(h+p)|0;f=l+m|0;d=w+f|0;c=t-(w+l)-m|0;pe[w+(l+4)>>2]=m|3;t:do{if((t|0)!=(a|0)){if((t|0)==(pe[156]|0)){j=(pe[153]|0)+c|0;pe[153]=j;pe[156]=d;pe[w+(f+4)>>2]=j|1;pe[w+(j+f)>>2]=j;break}s=p+4|0;r=pe[w+(s+h)>>2]|0;if((r&3|0)==1){u=r&-8;o=r>>>3;r:do{if(r>>>0>=256){a=pe[w+((h|24)+p)>>2]|0;i=pe[w+(p+12+h)>>2]|0;do{if((i|0)==(t|0)){n=h|16;i=w+(s+n)|0;r=pe[i>>2]|0;if(!r){i=w+(n+p)|0;r=pe[i>>2]|0;if(!r){D=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;D=r;break}}else{n=pe[w+((h|8)+p)>>2]|0;if(n>>>0>>0)Xe();e=n+12|0;if((pe[e>>2]|0)!=(t|0))Xe();r=i+8|0;if((pe[r>>2]|0)==(t|0)){pe[e>>2]=i;pe[r>>2]=n;D=i;break}else Xe()}}while(0);if(!a)break;e=pe[w+(p+28+h)>>2]|0;r=908+(e<<2)|0;do{if((t|0)!=(pe[r>>2]|0)){if(a>>>0<(pe[155]|0)>>>0)Xe();e=a+16|0;if((pe[e>>2]|0)==(t|0))pe[e>>2]=D;else pe[a+20>>2]=D;if(!D)break r}else{pe[r>>2]=D;if(D)break;pe[152]=pe[152]&~(1<>>0>>0)Xe();pe[D+24>>2]=a;t=h|16;e=pe[w+(t+p)>>2]|0;do{if(e)if(e>>>0>>0)Xe();else{pe[D+16>>2]=e;pe[e+24>>2]=D;break}}while(0);t=pe[w+(s+t)>>2]|0;if(!t)break;if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[D+20>>2]=t;pe[t+24>>2]=D;break}}else{i=pe[w+((h|8)+p)>>2]|0;n=pe[w+(p+12+h)>>2]|0;r=644+(o<<1<<2)|0;do{if((i|0)!=(r|0)){if(i>>>0>>0)Xe();if((pe[i+12>>2]|0)==(t|0))break;Xe()}}while(0);if((n|0)==(i|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();e=n+8|0;if((pe[e>>2]|0)==(t|0)){k=e;break}Xe()}}while(0);pe[i+12>>2]=n;pe[k>>2]=i}}while(0);t=w+((u|h)+p)|0;n=u+c|0}else n=c;t=t+4|0;pe[t>>2]=pe[t>>2]&-2;pe[w+(f+4)>>2]=n|1;pe[w+(n+f)>>2]=n;t=n>>>3;if(n>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0>=(pe[155]|0)>>>0){L=t;F=e;break}Xe()}}while(0);pe[L>>2]=d;pe[F+12>>2]=d;pe[w+(f+8)>>2]=F;pe[w+(f+12)>>2]=i;break}t=n>>>8;do{if(!t)i=0;else{if(n>>>0>16777215){i=31;break}L=(t+1048320|0)>>>16&8;F=t<>>16&4;F=F<>>16&2;i=14-(D|L|i)+(F<>>15)|0;i=n>>>(i+7|0)&1|i<<1}}while(0);t=908+(i<<2)|0;pe[w+(f+28)>>2]=i;pe[w+(f+20)>>2]=0;pe[w+(f+16)>>2]=0;e=pe[152]|0;r=1<>2]=d;pe[w+(f+24)>>2]=t;pe[w+(f+12)>>2]=d;pe[w+(f+8)>>2]=d;break}t=pe[t>>2]|0;r:do{if((pe[t+4>>2]&-8|0)!=(n|0)){i=n<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(n|0)){j=r;break r}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=d;pe[w+(f+24)>>2]=t;pe[w+(f+12)>>2]=d;pe[w+(f+8)>>2]=d;break t}}else j=t}while(0);t=j+8|0;e=pe[t>>2]|0;F=pe[155]|0;if(e>>>0>=F>>>0&j>>>0>=F>>>0){pe[e+12>>2]=d;pe[t>>2]=d;pe[w+(f+8)>>2]=e;pe[w+(f+12)>>2]=j;pe[w+(f+24)>>2]=0;break}else Xe()}else{j=(pe[154]|0)+c|0;pe[154]=j;pe[157]=d;pe[w+(f+4)>>2]=j|1}}while(0);j=w+(l|8)|0;return j|0}else r=1052;while(1){e=pe[r>>2]|0;if(e>>>0<=a>>>0?(t=pe[r+4>>2]|0,i=e+t|0,i>>>0>a>>>0):0)break;r=pe[r+8>>2]|0}n=e+(t+-39)|0;e=e+(t+-47+((n&7|0)==0?0:0-n&7))|0;n=a+16|0;e=e>>>0>>0?a:e;t=e+8|0;r=w+8|0;r=(r&7|0)==0?0:0-r&7;j=p+-40-r|0;pe[157]=w+r;pe[154]=j;pe[w+(r+4)>>2]=j|1;pe[w+(p+-36)>>2]=40;pe[158]=pe[273];r=e+4|0;pe[r>>2]=27;pe[t>>2]=pe[263];pe[t+4>>2]=pe[264];pe[t+8>>2]=pe[265];pe[t+12>>2]=pe[266];pe[263]=w;pe[264]=p;pe[266]=0;pe[265]=t;t=e+28|0;pe[t>>2]=7;if((e+32|0)>>>0>>0)do{j=t;t=t+4|0;pe[t>>2]=7}while((j+8|0)>>>0>>0);if((e|0)!=(a|0)){o=e-a|0;pe[r>>2]=pe[r>>2]&-2;pe[a+4>>2]=o|1;pe[e>>2]=o;t=o>>>3;if(o>>>0<256){e=t<<1;i=644+(e<<2)|0;r=pe[151]|0;t=1<>2]|0;if(e>>>0<(pe[155]|0)>>>0)Xe();else{I=t;R=e}}else{pe[151]=r|t;I=644+(e+2<<2)|0;R=i}pe[I>>2]=a;pe[R+12>>2]=a;pe[a+8>>2]=R;pe[a+12>>2]=i;break}t=o>>>8;if(t)if(o>>>0>16777215)i=31;else{F=(t+1048320|0)>>>16&8;j=t<>>16&4;j=j<>>16&2;i=14-(L|F|i)+(j<>>15)|0;i=o>>>(i+7|0)&1|i<<1}else i=0;r=908+(i<<2)|0;pe[a+28>>2]=i;pe[a+20>>2]=0;pe[n>>2]=0;t=pe[152]|0;e=1<>2]=a;pe[a+24>>2]=r;pe[a+12>>2]=a;pe[a+8>>2]=a;break}t=pe[r>>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(o|0)){i=o<<((i|0)==31?0:25-(i>>>1)|0);while(1){e=t+16+(i>>>31<<2)|0;r=pe[e>>2]|0;if(!r)break;if((pe[r+4>>2]&-8|0)==(o|0)){O=r;break t}else{i=i<<1;t=r}}if(e>>>0<(pe[155]|0)>>>0)Xe();else{pe[e>>2]=a;pe[a+24>>2]=t;pe[a+12>>2]=a;pe[a+8>>2]=a;break e}}else O=t}while(0);t=O+8|0;e=pe[t>>2]|0;j=pe[155]|0;if(e>>>0>=j>>>0&O>>>0>=j>>>0){pe[e+12>>2]=a;pe[t>>2]=a;pe[a+8>>2]=e;pe[a+12>>2]=O;pe[a+24>>2]=0;break}else Xe()}}else{j=pe[155]|0;if((j|0)==0|w>>>0>>0)pe[155]=w;pe[263]=w;pe[264]=p;pe[266]=0;pe[160]=pe[269];pe[159]=-1;t=0;do{j=t<<1;F=644+(j<<2)|0;pe[644+(j+3<<2)>>2]=F;pe[644+(j+2<<2)>>2]=F;t=t+1|0}while((t|0)!=32);j=w+8|0;j=(j&7|0)==0?0:0-j&7;F=p+-40-j|0;pe[157]=w+j;pe[154]=F;pe[w+(j+4)>>2]=F|1;pe[w+(p+-36)>>2]=40;pe[158]=pe[273]}}while(0);t=pe[154]|0;if(t>>>0>m>>>0){F=t-m|0;pe[154]=F;j=pe[157]|0;pe[157]=j+m;pe[j+(m+4)>>2]=F|1;pe[j+4>>2]=m|3;j=j+8|0;return j|0}}j=cr()|0;pe[j>>2]=12;j=0;return j|0}function zr(e){e=e|0;var t=0,r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0,y=0;if(!e)return;t=e+-8|0;s=pe[155]|0;if(t>>>0>>0)Xe();r=pe[e+-4>>2]|0;i=r&3;if((i|0)==1)Xe();d=r&-8;m=e+(d+-8)|0;do{if(!(r&1)){t=pe[t>>2]|0;if(!i)return;u=-8-t|0;c=e+u|0;f=t+d|0;if(c>>>0>>0)Xe();if((c|0)==(pe[156]|0)){t=e+(d+-4)|0;r=pe[t>>2]|0;if((r&3|0)!=3){y=c;o=f;break}pe[153]=f;pe[t>>2]=r&-2;pe[e+(u+4)>>2]=f|1;pe[m>>2]=f;return}n=t>>>3;if(t>>>0<256){i=pe[e+(u+8)>>2]|0;r=pe[e+(u+12)>>2]|0;t=644+(n<<1<<2)|0;if((i|0)!=(t|0)){if(i>>>0>>0)Xe();if((pe[i+12>>2]|0)!=(c|0))Xe()}if((r|0)==(i|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();t=r+8|0;if((pe[t>>2]|0)==(c|0))a=t;else Xe()}else a=r+8|0;pe[i+12>>2]=r;pe[a>>2]=i;y=c;o=f;break}a=pe[e+(u+24)>>2]|0;i=pe[e+(u+12)>>2]|0;do{if((i|0)==(c|0)){r=e+(u+20)|0;t=pe[r>>2]|0;if(!t){r=e+(u+16)|0;t=pe[r>>2]|0;if(!t){h=0;break}}while(1){i=t+20|0;n=pe[i>>2]|0;if(n){t=n;r=i;continue}i=t+16|0;n=pe[i>>2]|0;if(!n)break;else{t=n;r=i}}if(r>>>0>>0)Xe();else{pe[r>>2]=0;h=t;break}}else{n=pe[e+(u+8)>>2]|0;if(n>>>0>>0)Xe();t=n+12|0;if((pe[t>>2]|0)!=(c|0))Xe();r=i+8|0;if((pe[r>>2]|0)==(c|0)){pe[t>>2]=i;pe[r>>2]=n;h=i;break}else Xe()}}while(0);if(a){t=pe[e+(u+28)>>2]|0;r=908+(t<<2)|0;if((c|0)==(pe[r>>2]|0)){pe[r>>2]=h;if(!h){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(c|0))pe[t>>2]=h;else pe[a+20>>2]=h;if(!h){y=c;o=f;break}}r=pe[155]|0;if(h>>>0>>0)Xe();pe[h+24>>2]=a;t=pe[e+(u+16)>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[h+16>>2]=t;pe[t+24>>2]=h;break}}while(0);t=pe[e+(u+20)>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[h+20>>2]=t;pe[t+24>>2]=h;y=c;o=f;break}else{y=c;o=f}}else{y=c;o=f}}else{y=t;o=d}}while(0);if(y>>>0>=m>>>0)Xe();t=e+(d+-4)|0;r=pe[t>>2]|0;if(!(r&1))Xe();if(!(r&2)){if((m|0)==(pe[157]|0)){g=(pe[154]|0)+o|0;pe[154]=g;pe[157]=y;pe[y+4>>2]=g|1;if((y|0)!=(pe[156]|0))return;pe[156]=0;pe[153]=0;return}if((m|0)==(pe[156]|0)){g=(pe[153]|0)+o|0;pe[153]=g;pe[156]=y;pe[y+4>>2]=g|1;pe[y+g>>2]=g;return}o=(r&-8)+o|0;n=r>>>3;do{if(r>>>0>=256){a=pe[e+(d+16)>>2]|0;t=pe[e+(d|4)>>2]|0;do{if((t|0)==(m|0)){r=e+(d+12)|0;t=pe[r>>2]|0;if(!t){r=e+(d+8)|0;t=pe[r>>2]|0;if(!t){p=0;break}}while(1){i=t+20|0;n=pe[i>>2]|0;if(n){t=n;r=i;continue}i=t+16|0;n=pe[i>>2]|0;if(!n)break;else{t=n;r=i}}if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[r>>2]=0;p=t;break}}else{r=pe[e+d>>2]|0;if(r>>>0<(pe[155]|0)>>>0)Xe();i=r+12|0;if((pe[i>>2]|0)!=(m|0))Xe();n=t+8|0;if((pe[n>>2]|0)==(m|0)){pe[i>>2]=t;pe[n>>2]=r;p=t;break}else Xe()}}while(0);if(a){t=pe[e+(d+20)>>2]|0;r=908+(t<<2)|0;if((m|0)==(pe[r>>2]|0)){pe[r>>2]=p;if(!p){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=a+16|0;if((pe[t>>2]|0)==(m|0))pe[t>>2]=p;else pe[a+20>>2]=p;if(!p)break}r=pe[155]|0;if(p>>>0>>0)Xe();pe[p+24>>2]=a;t=pe[e+(d+8)>>2]|0;do{if(t)if(t>>>0>>0)Xe();else{pe[p+16>>2]=t;pe[t+24>>2]=p;break}}while(0);t=pe[e+(d+12)>>2]|0;if(t)if(t>>>0<(pe[155]|0)>>>0)Xe();else{pe[p+20>>2]=t;pe[t+24>>2]=p;break}}}else{i=pe[e+d>>2]|0;r=pe[e+(d|4)>>2]|0;t=644+(n<<1<<2)|0;if((i|0)!=(t|0)){if(i>>>0<(pe[155]|0)>>>0)Xe();if((pe[i+12>>2]|0)!=(m|0))Xe()}if((r|0)==(i|0)){pe[151]=pe[151]&~(1<>>0<(pe[155]|0)>>>0)Xe();t=r+8|0;if((pe[t>>2]|0)==(m|0))l=t;else Xe()}else l=r+8|0;pe[i+12>>2]=r;pe[l>>2]=i}}while(0);pe[y+4>>2]=o|1;pe[y+o>>2]=o;if((y|0)==(pe[156]|0)){pe[153]=o;return}}else{pe[t>>2]=r&-2;pe[y+4>>2]=o|1;pe[y+o>>2]=o}t=o>>>3;if(o>>>0<256){r=t<<1;n=644+(r<<2)|0;i=pe[151]|0;t=1<>2]|0;if(r>>>0<(pe[155]|0)>>>0)Xe();else{v=t;b=r}}else{pe[151]=i|t;v=644+(r+2<<2)|0;b=n}pe[v>>2]=y;pe[b+12>>2]=y;pe[y+8>>2]=b;pe[y+12>>2]=n;return}t=o>>>8;if(t)if(o>>>0>16777215)n=31;else{v=(t+1048320|0)>>>16&8;b=t<>>16&4;b=b<>>16&2;n=14-(m|v|n)+(b<>>15)|0;n=o>>>(n+7|0)&1|n<<1}else n=0;t=908+(n<<2)|0;pe[y+28>>2]=n;pe[y+20>>2]=0;pe[y+16>>2]=0;r=pe[152]|0;i=1<>2]|0;t:do{if((pe[t+4>>2]&-8|0)!=(o|0)){n=o<<((n|0)==31?0:25-(n>>>1)|0);while(1){r=t+16+(n>>>31<<2)|0;i=pe[r>>2]|0;if(!i)break;if((pe[i+4>>2]&-8|0)==(o|0)){g=i;break t}else{n=n<<1;t=i}}if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[r>>2]=y;pe[y+24>>2]=t;pe[y+12>>2]=y;pe[y+8>>2]=y;break e}}else g=t}while(0);t=g+8|0;r=pe[t>>2]|0;b=pe[155]|0;if(r>>>0>=b>>>0&g>>>0>=b>>>0){pe[r+12>>2]=y;pe[t>>2]=y;pe[y+8>>2]=r;pe[y+12>>2]=g;pe[y+24>>2]=0;break}else Xe()}else{pe[152]=r|i;pe[t>>2]=y;pe[y+24>>2]=t;pe[y+12>>2]=y;pe[y+8>>2]=y}}while(0);y=(pe[159]|0)+-1|0;pe[159]=y;if(!y)t=1060;else return;while(1){t=pe[t>>2]|0;if(!t)break;else t=t+8|0}pe[159]=-1;return}function Xr(e,t){e=e|0;t=t|0;var r=0,i=0;if(!e){e=Ur(t)|0;return e|0}if(t>>>0>4294967231){e=cr()|0;pe[e>>2]=12;e=0;return e|0}r=Hr(e+-8|0,t>>>0<11?16:t+11&-8)|0;if(r){e=r+8|0;return e|0}r=Ur(t)|0;if(!r){e=0;return e|0}i=pe[e+-4>>2]|0;i=(i&-8)-((i&3|0)==0?8:4)|0;Qr(r|0,e|0,(i>>>0>>0?i:t)|0)|0;zr(e);e=r;return e|0}function qr(e){e=e|0;var t=0;if(!e){t=0;return t|0}e=pe[e+-4>>2]|0;t=e&3;if((t|0)==1){t=0;return t|0}t=(e&-8)-((t|0)==0?8:4)|0;return t|0}function Hr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;d=e+4|0;p=pe[d>>2]|0;u=p&-8;c=e+u|0;s=pe[155]|0;r=p&3;if(!((r|0)!=1&e>>>0>=s>>>0&e>>>0>>0))Xe();i=e+(u|4)|0;n=pe[i>>2]|0;if(!(n&1))Xe();if(!r){if(t>>>0<256){e=0;return e|0}if(u>>>0>=(t+4|0)>>>0?(u-t|0)>>>0<=pe[271]<<1>>>0:0)return e|0;e=0;return e|0}if(u>>>0>=t>>>0){r=u-t|0;if(r>>>0<=15)return e|0;pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=r|3;pe[i>>2]=pe[i>>2]|1;Gr(e+t|0,r);return e|0}if((c|0)==(pe[157]|0)){r=(pe[154]|0)+u|0;if(r>>>0<=t>>>0){e=0;return e|0}l=r-t|0;pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=l|1;pe[157]=e+t;pe[154]=l;return e|0}if((c|0)==(pe[156]|0)){i=(pe[153]|0)+u|0;if(i>>>0>>0){e=0;return e|0}r=i-t|0;if(r>>>0>15){pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=r|1;pe[e+i>>2]=r;i=e+(i+4)|0;pe[i>>2]=pe[i>>2]&-2;i=e+t|0}else{pe[d>>2]=p&1|i|2;i=e+(i+4)|0;pe[i>>2]=pe[i>>2]|1;i=0;r=0}pe[153]=r;pe[156]=i;return e|0}if(n&2){e=0;return e|0}f=(n&-8)+u|0;if(f>>>0>>0){e=0;return e|0}l=f-t|0;o=n>>>3;do{if(n>>>0>=256){a=pe[e+(u+24)>>2]|0;o=pe[e+(u+12)>>2]|0;do{if((o|0)==(c|0)){i=e+(u+20)|0;r=pe[i>>2]|0;if(!r){i=e+(u+16)|0;r=pe[i>>2]|0;if(!r){h=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;h=r;break}}else{n=pe[e+(u+8)>>2]|0;if(n>>>0>>0)Xe();r=n+12|0;if((pe[r>>2]|0)!=(c|0))Xe();i=o+8|0;if((pe[i>>2]|0)==(c|0)){pe[r>>2]=o;pe[i>>2]=n;h=o;break}else Xe()}}while(0);if(a){r=pe[e+(u+28)>>2]|0;i=908+(r<<2)|0;if((c|0)==(pe[i>>2]|0)){pe[i>>2]=h;if(!h){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=a+16|0;if((pe[r>>2]|0)==(c|0))pe[r>>2]=h;else pe[a+20>>2]=h;if(!h)break}i=pe[155]|0;if(h>>>0>>0)Xe();pe[h+24>>2]=a;r=pe[e+(u+16)>>2]|0;do{if(r)if(r>>>0>>0)Xe();else{pe[h+16>>2]=r;pe[r+24>>2]=h;break}}while(0);r=pe[e+(u+20)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[h+20>>2]=r;pe[r+24>>2]=h;break}}}else{n=pe[e+(u+8)>>2]|0;i=pe[e+(u+12)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(c|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(c|0))a=r;else Xe()}else a=i+8|0;pe[n+12>>2]=i;pe[a>>2]=n}}while(0);if(l>>>0<16){pe[d>>2]=f|p&1|2;t=e+(f|4)|0;pe[t>>2]=pe[t>>2]|1;return e|0}else{pe[d>>2]=p&1|t|2;pe[e+(t+4)>>2]=l|3;p=e+(f|4)|0;pe[p>>2]=pe[p>>2]|1;Gr(e+t|0,l);return e|0}return 0}function Gr(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0,m=0,v=0,b=0,g=0;m=e+t|0;r=pe[e+4>>2]|0;do{if(!(r&1)){h=pe[e>>2]|0;if(!(r&3))return;l=e+(0-h)|0;f=h+t|0;u=pe[155]|0;if(l>>>0>>0)Xe();if((l|0)==(pe[156]|0)){i=e+(t+4)|0;r=pe[i>>2]|0;if((r&3|0)!=3){g=l;a=f;break}pe[153]=f;pe[i>>2]=r&-2;pe[e+(4-h)>>2]=f|1;pe[m>>2]=f;return}o=h>>>3;if(h>>>0<256){n=pe[e+(8-h)>>2]|0;i=pe[e+(12-h)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(l|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(l|0))s=r;else Xe()}else s=i+8|0;pe[n+12>>2]=i;pe[s>>2]=n;g=l;a=f;break}s=pe[e+(24-h)>>2]|0;n=pe[e+(12-h)>>2]|0;do{if((n|0)==(l|0)){n=16-h|0;i=e+(n+4)|0;r=pe[i>>2]|0;if(!r){i=e+n|0;r=pe[i>>2]|0;if(!r){c=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;c=r;break}}else{o=pe[e+(8-h)>>2]|0;if(o>>>0>>0)Xe();r=o+12|0;if((pe[r>>2]|0)!=(l|0))Xe();i=n+8|0;if((pe[i>>2]|0)==(l|0)){pe[r>>2]=n;pe[i>>2]=o;c=n;break}else Xe()}}while(0);if(s){r=pe[e+(28-h)>>2]|0;i=908+(r<<2)|0;if((l|0)==(pe[i>>2]|0)){pe[i>>2]=c;if(!c){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=s+16|0;if((pe[r>>2]|0)==(l|0))pe[r>>2]=c;else pe[s+20>>2]=c;if(!c){g=l;a=f;break}}n=pe[155]|0;if(c>>>0>>0)Xe();pe[c+24>>2]=s;r=16-h|0;i=pe[e+r>>2]|0;do{if(i)if(i>>>0>>0)Xe();else{pe[c+16>>2]=i;pe[i+24>>2]=c;break}}while(0);r=pe[e+(r+4)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[c+20>>2]=r;pe[r+24>>2]=c;g=l;a=f;break}else{g=l;a=f}}else{g=l;a=f}}else{g=e;a=t}}while(0);u=pe[155]|0;if(m>>>0>>0)Xe();r=e+(t+4)|0;i=pe[r>>2]|0;if(!(i&2)){if((m|0)==(pe[157]|0)){b=(pe[154]|0)+a|0;pe[154]=b;pe[157]=g;pe[g+4>>2]=b|1;if((g|0)!=(pe[156]|0))return;pe[156]=0;pe[153]=0;return}if((m|0)==(pe[156]|0)){b=(pe[153]|0)+a|0;pe[153]=b;pe[156]=g;pe[g+4>>2]=b|1;pe[g+b>>2]=b;return}a=(i&-8)+a|0;o=i>>>3;do{if(i>>>0>=256){s=pe[e+(t+24)>>2]|0;n=pe[e+(t+12)>>2]|0;do{if((n|0)==(m|0)){i=e+(t+20)|0;r=pe[i>>2]|0;if(!r){i=e+(t+16)|0;r=pe[i>>2]|0;if(!r){p=0;break}}while(1){n=r+20|0;o=pe[n>>2]|0;if(o){r=o;i=n;continue}n=r+16|0;o=pe[n>>2]|0;if(!o)break;else{r=o;i=n}}if(i>>>0>>0)Xe();else{pe[i>>2]=0;p=r;break}}else{o=pe[e+(t+8)>>2]|0;if(o>>>0>>0)Xe();r=o+12|0;if((pe[r>>2]|0)!=(m|0))Xe();i=n+8|0;if((pe[i>>2]|0)==(m|0)){pe[r>>2]=n;pe[i>>2]=o;p=n;break}else Xe()}}while(0);if(s){r=pe[e+(t+28)>>2]|0;i=908+(r<<2)|0;if((m|0)==(pe[i>>2]|0)){pe[i>>2]=p;if(!p){pe[152]=pe[152]&~(1<>>0<(pe[155]|0)>>>0)Xe();r=s+16|0;if((pe[r>>2]|0)==(m|0))pe[r>>2]=p;else pe[s+20>>2]=p;if(!p)break}i=pe[155]|0;if(p>>>0>>0)Xe();pe[p+24>>2]=s;r=pe[e+(t+16)>>2]|0;do{if(r)if(r>>>0>>0)Xe();else{pe[p+16>>2]=r;pe[r+24>>2]=p;break}}while(0);r=pe[e+(t+20)>>2]|0;if(r)if(r>>>0<(pe[155]|0)>>>0)Xe();else{pe[p+20>>2]=r;pe[r+24>>2]=p;break}}}else{n=pe[e+(t+8)>>2]|0;i=pe[e+(t+12)>>2]|0;r=644+(o<<1<<2)|0;if((n|0)!=(r|0)){if(n>>>0>>0)Xe();if((pe[n+12>>2]|0)!=(m|0))Xe()}if((i|0)==(n|0)){pe[151]=pe[151]&~(1<>>0>>0)Xe();r=i+8|0;if((pe[r>>2]|0)==(m|0))d=r;else Xe()}else d=i+8|0;pe[n+12>>2]=i;pe[d>>2]=n}}while(0);pe[g+4>>2]=a|1;pe[g+a>>2]=a;if((g|0)==(pe[156]|0)){pe[153]=a;return}}else{pe[r>>2]=i&-2;pe[g+4>>2]=a|1;pe[g+a>>2]=a}r=a>>>3;if(a>>>0<256){i=r<<1;o=644+(i<<2)|0;n=pe[151]|0;r=1<>2]|0;if(i>>>0<(pe[155]|0)>>>0)Xe();else{v=r;b=i}}else{pe[151]=n|r;v=644+(i+2<<2)|0;b=o}pe[v>>2]=g;pe[b+12>>2]=g;pe[g+8>>2]=b;pe[g+12>>2]=o;return}r=a>>>8;if(r)if(a>>>0>16777215)o=31;else{v=(r+1048320|0)>>>16&8;b=r<>>16&4;b=b<>>16&2;o=14-(m|v|o)+(b<>>15)|0;o=a>>>(o+7|0)&1|o<<1}else o=0;r=908+(o<<2)|0;pe[g+28>>2]=o;pe[g+20>>2]=0;pe[g+16>>2]=0;i=pe[152]|0;n=1<>2]=g;pe[g+24>>2]=r;pe[g+12>>2]=g;pe[g+8>>2]=g;return}r=pe[r>>2]|0;e:do{if((pe[r+4>>2]&-8|0)!=(a|0)){o=a<<((o|0)==31?0:25-(o>>>1)|0);while(1){i=r+16+(o>>>31<<2)|0;n=pe[i>>2]|0;if(!n)break;if((pe[n+4>>2]&-8|0)==(a|0)){r=n;break e}else{o=o<<1;r=n}}if(i>>>0<(pe[155]|0)>>>0)Xe();pe[i>>2]=g;pe[g+24>>2]=r;pe[g+12>>2]=g;pe[g+8>>2]=g;return}}while(0);i=r+8|0;n=pe[i>>2]|0;b=pe[155]|0;if(!(n>>>0>=b>>>0&r>>>0>=b>>>0))Xe();pe[n+12>>2]=g;pe[i>>2]=g;pe[g+8>>2]=n;pe[g+12>>2]=r;pe[g+24>>2]=0;return}function Vr(){}function Yr(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;i=t-i-(r>>>0>e>>>0|0)>>>0;return(re=i,e-r>>>0|0)|0}function Wr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0,o=0,a=0;i=e+r|0;if((r|0)>=20){t=t&255;o=e&3;a=t|t<<8|t<<16|t<<24;n=i&~3;if(o){o=e+4-o|0;while((e|0)<(o|0)){de[e>>0]=t;e=e+1|0}}while((e|0)<(n|0)){pe[e>>2]=a;e=e+4|0}}while((e|0)<(i|0)){de[e>>0]=t;e=e+1|0}return e-r|0}function Jr(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t>>>r;return e>>>r|(t&(1<>>r-32|0}function Kr(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t<>>32-r;return e<>>0;return(re=t+i+(r>>>0>>0|0)>>>0,r|0)|0}function Qr(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if((r|0)>=4096)return Re(e|0,t|0,r|0)|0;i=e|0;if((e&3)==(t&3)){while(e&3){if(!r)return i|0;de[e>>0]=de[t>>0]|0;e=e+1|0;t=t+1|0;r=r-1|0}while((r|0)>=4){pe[e>>2]=pe[t>>2];e=e+4|0;t=t+4|0;r=r-4|0}}while((r|0)>0){de[e>>0]=de[t>>0]|0;e=e+1|0;t=t+1|0;r=r-1|0}return i|0}function $r(e,t,r){e=e|0;t=t|0;r=r|0;if((r|0)<32){re=t>>r;return e>>>r|(t&(1<>r-32|0}function ei(e){e=e|0;var t=0;t=de[v+(e&255)>>0]|0;if((t|0)<8)return t|0;t=de[v+(e>>8&255)>>0]|0;if((t|0)<8)return t+8|0;t=de[v+(e>>16&255)>>0]|0;if((t|0)<8)return t+16|0;return(de[v+(e>>>24)>>0]|0)+24|0}function ti(e,t){e=e|0;t=t|0;var r=0,i=0,n=0,o=0;o=e&65535;n=t&65535;r=ge(n,o)|0;i=e>>>16;e=(r>>>16)+(ge(n,i)|0)|0;n=t>>>16;t=ge(n,o)|0;return(re=(e>>>16)+(ge(n,i)|0)+(((e&65535)+t|0)>>>16)|0,e+t<<16|r&65535|0)|0}function ri(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0;h=t>>31|((t|0)<0?-1:0)<<1;u=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1;o=i>>31|((i|0)<0?-1:0)<<1;n=((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1;s=Yr(h^e,u^t,h,u)|0;a=re;e=o^h;t=n^u;return Yr((si(s,a,Yr(o^r,n^i,o,n)|0,re,0)|0)^e,re^t,e,t)|0}function ii(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0,a=0,s=0,u=0,h=0;n=be;be=be+16|0;s=n|0;a=t>>31|((t|0)<0?-1:0)<<1;o=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1;h=i>>31|((i|0)<0?-1:0)<<1;u=((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1;e=Yr(a^e,o^t,a,o)|0;t=re;si(e,t,Yr(h^r,u^i,h,u)|0,re,s)|0;i=Yr(pe[s>>2]^a,pe[s+4>>2]^o,a,o)|0;r=re;be=n;return(re=r,i)|0}function ni(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0;n=e;o=r;r=ti(n,o)|0;e=re;return(re=(ge(t,o)|0)+(ge(i,n)|0)+e|e&0,r|0|0)|0}function oi(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;return si(e,t,r,i,0)|0}function ai(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,o=0;o=be;be=be+16|0;n=o|0;si(e,t,r,i,n)|0;be=o;return(re=pe[n+4>>2]|0,pe[n>>2]|0)|0}function si(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;var o=0,a=0,s=0,u=0,h=0,c=0,f=0,l=0,d=0,p=0;c=e;u=t;h=u;a=r;l=i;s=l;if(!h){o=(n|0)!=0;if(!s){if(o){pe[n>>2]=(c>>>0)%(a>>>0);pe[n+4>>2]=0}l=0;n=(c>>>0)/(a>>>0)>>>0;return(re=l,n)|0}else{if(!o){l=0;n=0;return(re=l,n)|0}pe[n>>2]=e|0;pe[n+4>>2]=t&0;l=0;n=0;return(re=l,n)|0}}o=(s|0)==0;do{if(a){if(!o){o=(ae(s|0)|0)-(ae(h|0)|0)|0;if(o>>>0<=31){f=o+1|0;s=31-o|0;t=o-31>>31;a=f;e=c>>>(f>>>0)&t|h<>>(f>>>0)&t;o=0;s=c<>2]=e|0;pe[n+4>>2]=u|t&0;l=0;n=0;return(re=l,n)|0}o=a-1|0;if(o&a){s=(ae(a|0)|0)+33-(ae(h|0)|0)|0;p=64-s|0;f=32-s|0;u=f>>31;d=s-32|0;t=d>>31;a=s;e=f-1>>31&h>>>(d>>>0)|(h<>>(s>>>0))&t;t=t&h>>>(s>>>0);o=c<>>(d>>>0))&u|c<>31;break}if(n){pe[n>>2]=o&c;pe[n+4>>2]=0}if((a|0)==1){d=u|t&0;p=e|0|0;return(re=d,p)|0}else{p=ei(a|0)|0;d=h>>>(p>>>0)|0;p=h<<32-p|c>>>(p>>>0)|0;return(re=d,p)|0}}else{if(o){if(n){pe[n>>2]=(h>>>0)%(a>>>0);pe[n+4>>2]=0}d=0;p=(h>>>0)/(a>>>0)>>>0;return(re=d,p)|0}if(!c){if(n){pe[n>>2]=0;pe[n+4>>2]=(h>>>0)%(s>>>0)}d=0;p=(h>>>0)/(s>>>0)>>>0;return(re=d,p)|0}o=s-1|0;if(!(o&s)){if(n){pe[n>>2]=e|0;pe[n+4>>2]=o&h|t&0}d=0;p=h>>>((ei(s|0)|0)>>>0);return(re=d,p)|0}o=(ae(s|0)|0)-(ae(h|0)|0)|0;if(o>>>0<=30){t=o+1|0;s=31-o|0;a=t;e=h<>>(t>>>0);t=h>>>(t>>>0);o=0;s=c<>2]=e|0;pe[n+4>>2]=u|t&0;d=0;p=0;return(re=d,p)|0}}while(0);if(!a){h=s;u=0;s=0}else{f=r|0|0;c=l|i&0;h=Zr(f|0,c|0,-1,-1)|0;r=re;u=s;s=0;do{i=u;u=o>>>31|u<<1;o=s|o<<1;i=e<<1|i>>>31|0;l=e>>>31|t<<1|0;Yr(h,r,i,l)|0;p=re;d=p>>31|((p|0)<0?-1:0)<<1;s=d&1;e=Yr(i,l,d&f,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&c)|0;t=re;a=a-1|0}while((a|0)!=0);h=u;u=0}a=0;if(n){pe[n>>2]=e;pe[n+4>>2]=t}d=(o|0)>>>31|(h|a)<<1|(a<<1|o>>>31)&0|u;p=(o<<1|0>>>31)&-2|s;return(re=d,p)|0}function ui(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;return Ai[e&7](t|0,r|0,i|0)|0}function hi(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;Pi[e&3](t|0,r|0,i|0,n|0,o|0)}function ci(e,t){e=e|0;t=t|0;Mi[e&7](t|0)}function fi(e,t){e=e|0;t=t|0;return Ci[e&1](t|0)|0}function li(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;ki[e&0](t|0,r|0,i|0)}function di(e){e=e|0;Ii[e&3]()}function pi(e,t,r,i,n,o,a){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;a=a|0;Ri[e&3](t|0,r|0,i|0,n|0,o|0,a|0)}function mi(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;return Oi[e&1](t|0,r|0,i|0,n|0,o|0)|0}function vi(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;Di[e&3](t|0,r|0,i|0,n|0)}function bi(e,t,r){e=e|0;t=t|0;r=r|0;se(0);return 0}function gi(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;se(1)}function yi(e){e=e|0;se(2)}function _i(e){e=e|0;se(3);return 0}function wi(e,t,r){e=e|0;t=t|0;r=r|0;se(4)}function xi(){se(5)}function Ti(e,t,r,i,n,o){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;o=o|0;se(6)}function Si(e,t,r,i,n){e=e|0;t=t|0;r=r|0;i=i|0;n=n|0;se(7);return 0}function Ei(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;se(8)}var Ai=[bi,Wt,Fr,Cr,Mr,kr,bi,bi];var Pi=[gi,tr,er,gi];var Mi=[yi,qt,Vt,Ht,Gt,Yt,ur,Lr];var Ci=[_i,Pr];var ki=[wi];var Ii=[xi,ar,sr,xi];var Ri=[Ti,ir,rr,Ti];var Oi=[Si,ut];var Di=[Ei,Kt,Zt,Ei];return{___cxa_can_catch:nr,_crn_get_levels:Tt,_crn_get_uncompressed_size:Et,_crn_decompress:At,_i64Add:Zr,_crn_get_width:wt,___cxa_is_pointer_type:or,_i64Subtract:Yr,_memset:Wr,_malloc:Ur,_free:zr,_memcpy:Qr,_bitshift64Lshr:Jr,_fflush:vr,_bitshift64Shl:Kr,_crn_get_height:xt,___errno_location:cr,_crn_get_dxt_format:St,runPostSets:Vr,_emscripten_replace_memory:We,stackAlloc:Je,stackSave:Ke,stackRestore:Ze,establishStackSpace:Qe,setThrew:$e,setTempRet0:rt,getTempRet0:it,dynCall_iiii:ui,dynCall_viiiii:hi,dynCall_vi:ci,dynCall_ii:fi,dynCall_viii:li,dynCall_v:di,dynCall_viiiiii:pi,dynCall_iiiiii:mi,dynCall_viiii:vi}}(e.Ya,e.Za,buffer);e.___cxa_can_catch=Z.___cxa_can_catch,e._crn_get_levels=Z._crn_get_levels,e.runPostSets=Z.runPostSets,e._crn_get_uncompressed_size=Z._crn_get_uncompressed_size,e._crn_decompress=Z._crn_decompress;var zc=e._i64Add=Z._i64Add;e._crn_get_height=Z._crn_get_height,e.___cxa_is_pointer_type=Z.___cxa_is_pointer_type;var nb=e._i64Subtract=Z._i64Subtract,qb=e._memset=Z._memset,Ea=e._malloc=Z._malloc,Bc=e._memcpy=Z._memcpy,Xa=e._emscripten_replace_memory=Z._emscripten_replace_memory;e._crn_get_dxt_format=Z._crn_get_dxt_format;var rb=e._bitshift64Lshr=Z._bitshift64Lshr,Na=e._free=Z._free;e._fflush=Z._fflush,e._crn_get_width=Z._crn_get_width,e.___errno_location=Z.___errno_location;var sb=e._bitshift64Shl=Z._bitshift64Shl;function ia(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}e.dynCall_iiii=Z.dynCall_iiii,e.dynCall_viiiii=Z.dynCall_viiiii,e.dynCall_vi=Z.dynCall_vi,e.dynCall_ii=Z.dynCall_ii,e.dynCall_viii=Z.dynCall_viii,e.dynCall_v=Z.dynCall_v,e.dynCall_viiiiii=Z.dynCall_viiiiii,e.dynCall_iiiiii=Z.dynCall_iiiiii,e.dynCall_viiii=Z.dynCall_viiii,n.aa=Z.stackAlloc,n.ua=Z.stackSave,n.ba=Z.stackRestore,n.Cd=Z.establishStackSpace,n.rb=Z.setTempRet0,n.fb=Z.getTempRet0,ia.prototype=Error(),ia.prototype.constructor=ia;var rd=null,jb=function t(){e.calledRun||td(),e.calledRun||(jb=t)};function td(t){function r(){if(!e.calledRun&&(e.calledRun=!0,!na)){if(Ha||(Ha=!0,ab(cb)),ab(db),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e._main&&vd&&e.callMain(t),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)gb(e.postRun.shift());ab(eb)}}if(t=t||e.arguments,null===rd&&(rd=Date.now()),!(0>6],n=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:i,primitive:n,tag:r,tagStr:s.tag[r]}}function f(e,t,r){var i=e.readUInt8(r);if(e.isError(i))return i;if(!t&&128===i)return null;if(0==(128&i))return i;var n=127&i;if(4>=8)a++;(n=new h(2+a))[0]=o,n[1]=128|a;s=1+a;for(var u=i.length;0>=8)n[s]=255&u;return this._createEncoderBuffer([n,i])},s.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"!==t)return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)?this._createEncoderBuffer(e):"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported");for(var r=new h(2*e.length),i=0;i>=7)n++}var a=new h(n),s=a.length-1;for(i=e.length-1;0<=i;i--){o=e[i];for(a[s--]=127&o;0<(o>>=7);)a[s--]=128|127&o}return this._createEncoderBuffer(a)},s.prototype._encodeTime=function(e,t){var r,i=new Date(e);return"gentime"===t?r=[u(i.getFullYear()),u(i.getUTCMonth()+1),u(i.getUTCDate()),u(i.getUTCHours()),u(i.getUTCMinutes()),u(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[u(i.getFullYear()%100),u(i.getUTCMonth()+1),u(i.getUTCDate()),u(i.getUTCHours()),u(i.getUTCMinutes()),u(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},s.prototype._encodeNull=function(){return this._createEncoderBuffer("")},s.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!h.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new h(r)}if(h.isBuffer(e)){var i=e.length;0===e.length&&i++;var n=new h(i);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);i=1;for(var o=e;256<=o;o>>=8)i++;for(o=(n=new Array(i)).length-1;0<=o;o--)n[o]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(new h(n))},s.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},s.prototype._skipDefault=function(e,t,r){var i,n=this._baseState;if(null===n.default)return!1;var o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i>16&255,o[s++]=i>>8&255,o[s++]=255&i;2===n?(i=h[e.charCodeAt(t)]<<2|h[e.charCodeAt(t+1)]>>4,o[s++]=255&i):1===n&&(i=h[e.charCodeAt(t)]<<10|h[e.charCodeAt(t+1)]<<4|h[e.charCodeAt(t+2)]>>2,o[s++]=i>>8&255,o[s++]=255&i);return o},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,n="",o=[],a=0,s=r-i;a>2],n+=u[t<<4&63],n+="=="):2==i&&(t=(e[r-2]<<8)+e[r-1],n+=u[t>>10],n+=u[t>>4&63],n+=u[t<<2&63],n+="=");return o.push(n),o.join("")};for(var u=[],h=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,o=i.length;n>18&63]+u[n>>12&63]+u[n>>6&63]+u[63&n]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],17:[function(T,e,t){!function(e,t){"use strict";function v(e,t){if(!e)throw new Error(t||"Assertion failed")}function r(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function b(e,t,r){if(b.isBN(e))return e;this.negative=0,this.words=null,this.length=0,(this.red=null)!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var i;"object"==typeof e?e.exports=b:t.BN=b,(b.BN=b).wordSize=26;try{i=T("buffer").Buffer}catch(e){}function a(e,t,r){for(var i=0,n=Math.min(e.length,r),o=t;o>>26-a&67108863,26<=(a+=24)&&(a-=26,n++);else if("le"===r)for(n=i=0;i>>26-a&67108863,26<=(a+=24)&&(a-=26,n++);return this.strip()},b.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r>>26-o&4194303,26<=(o+=24)&&(o-=26,i++);r+6!==t&&(n=a(e,t,r+6),this.words[i]|=n<>>26-o&4194303),this.strip()},b.prototype._parseBase=function(e,t,r){this.words=[0];for(var i=0,n=this.length=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var o=e.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,h=r;h"};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function n(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;i=(r.length=i)-1|0;var n=0|e.words[0],o=0|t.words[0],a=n*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var h=1;h>>26,f=67108863&u,l=Math.min(h,t.length-1),d=Math.max(0,h-e.length+1);d<=l;d++){var p=h-d|0;c+=(a=(n=0|e.words[p])*(o=0|t.words[d])+f)/67108864|0,f=67108863&a}r.words[h]=0|f,u=0|c}return 0!==u?r.words[h]=0|u:r.length--,r.strip()}b.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,n=0,o=0;o>>24-i&16777215)||o!==this.length-1?l[6-s.length]+s+r:s+r,26<=(i+=2)&&(i-=26,o--)}for(0!==n&&(r=n.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&2<=e&&e<=36){var u=d[e],h=p[e];r="";var c=this.clone();for(c.negative=0;!c.isZero();){var f=c.modn(h).toString(e);r=(c=c.idivn(h)).isZero()?f+r:l[u-f.length]+f+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}v(!1,"Base should be between 2 and 36")},b.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:2>>=13),64<=t&&(r+=7,t>>>=7),8<=t&&(r+=4,t>>>=4),2<=t&&(r+=2,t>>>=2),r+t},b.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},b.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},b.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},b.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},b.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},b.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},b.prototype.iuxor=function(e){var t,r;r=this.length>e.length?(t=this,e):(t=e,this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},b.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},b.prototype.inotn=function(e){v("number"==typeof e&&0<=e);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),0>26-r),this.strip()},b.prototype.notn=function(e){return this.clone().inotn(e)},b.prototype.setn=function(e,t){v("number"==typeof e&&0<=e);var r=e/26|0,i=e%26;return this._expand(1+r),this.words[r]=t?this.words[r]|1<e.length?(r=this,e):(r=e,this);for(var n=0,o=0;o>>26;for(;0!==n&&o>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},b.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;i=0>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,m=d>>>13,v=0|a[2],b=8191&v,g=v>>>13,y=0|a[3],_=8191&y,w=y>>>13,x=0|a[4],T=8191&x,S=x>>>13,E=0|a[5],A=8191&E,P=E>>>13,M=0|a[6],C=8191&M,k=M>>>13,I=0|a[7],R=8191&I,O=I>>>13,D=0|a[8],L=8191&D,F=D>>>13,j=0|a[9],B=8191&j,N=j>>>13,U=0|s[0],z=8191&U,X=U>>>13,q=0|s[1],H=8191&q,G=q>>>13,V=0|s[2],Y=8191&V,W=V>>>13,J=0|s[3],K=8191&J,Z=J>>>13,Q=0|s[4],$=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ie=te>>>13,ne=0|s[6],oe=8191&ne,ae=ne>>>13,se=0|s[7],ue=8191&se,he=se>>>13,ce=0|s[8],fe=8191&ce,le=ce>>>13,de=0|s[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ve=(h+(i=Math.imul(f,z))|0)+((8191&(n=(n=Math.imul(f,X))+Math.imul(l,z)|0))<<13)|0;h=((o=Math.imul(l,X))+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(p,z),n=(n=Math.imul(p,X))+Math.imul(m,z)|0,o=Math.imul(m,X);var be=(h+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,G)|0)+Math.imul(l,H)|0))<<13)|0;h=((o=o+Math.imul(l,G)|0)+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(b,z),n=(n=Math.imul(b,X))+Math.imul(g,z)|0,o=Math.imul(g,X),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,G)|0;var ge=(h+(i=i+Math.imul(f,Y)|0)|0)+((8191&(n=(n=n+Math.imul(f,W)|0)+Math.imul(l,Y)|0))<<13)|0;h=((o=o+Math.imul(l,W)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(_,z),n=(n=Math.imul(_,X))+Math.imul(w,z)|0,o=Math.imul(w,X),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(g,H)|0,o=o+Math.imul(g,G)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,W)|0;var ye=(h+(i=i+Math.imul(f,K)|0)|0)+((8191&(n=(n=n+Math.imul(f,Z)|0)+Math.imul(l,K)|0))<<13)|0;h=((o=o+Math.imul(l,Z)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(T,z),n=(n=Math.imul(T,X))+Math.imul(S,z)|0,o=Math.imul(S,X),i=i+Math.imul(_,H)|0,n=(n=n+Math.imul(_,G)|0)+Math.imul(w,H)|0,o=o+Math.imul(w,G)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,W)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,W)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,Z)|0;var _e=(h+(i=i+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,ee)|0)+Math.imul(l,$)|0))<<13)|0;h=((o=o+Math.imul(l,ee)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(A,z),n=(n=Math.imul(A,X))+Math.imul(P,z)|0,o=Math.imul(P,X),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(S,H)|0,o=o+Math.imul(S,G)|0,i=i+Math.imul(_,Y)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,Y)|0,o=o+Math.imul(w,W)|0,i=i+Math.imul(b,K)|0,n=(n=n+Math.imul(b,Z)|0)+Math.imul(g,K)|0,o=o+Math.imul(g,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,ee)|0;var we=(h+(i=i+Math.imul(f,re)|0)|0)+((8191&(n=(n=n+Math.imul(f,ie)|0)+Math.imul(l,re)|0))<<13)|0;h=((o=o+Math.imul(l,ie)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(C,z),n=(n=Math.imul(C,X))+Math.imul(k,z)|0,o=Math.imul(k,X),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(P,H)|0,o=o+Math.imul(P,G)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,W)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,W)|0,i=i+Math.imul(_,K)|0,n=(n=n+Math.imul(_,Z)|0)+Math.imul(w,K)|0,o=o+Math.imul(w,Z)|0,i=i+Math.imul(b,$)|0,n=(n=n+Math.imul(b,ee)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ie)|0;var xe=(h+(i=i+Math.imul(f,oe)|0)|0)+((8191&(n=(n=n+Math.imul(f,ae)|0)+Math.imul(l,oe)|0))<<13)|0;h=((o=o+Math.imul(l,ae)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(R,z),n=(n=Math.imul(R,X))+Math.imul(O,z)|0,o=Math.imul(O,X),i=i+Math.imul(C,H)|0,n=(n=n+Math.imul(C,G)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,G)|0,i=i+Math.imul(A,Y)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(P,Y)|0,o=o+Math.imul(P,W)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(S,K)|0,o=o+Math.imul(S,Z)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,ee)|0)+Math.imul(w,$)|0,o=o+Math.imul(w,ee)|0,i=i+Math.imul(b,re)|0,n=(n=n+Math.imul(b,ie)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ie)|0,i=i+Math.imul(p,oe)|0,n=(n=n+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Te=(h+(i=i+Math.imul(f,ue)|0)|0)+((8191&(n=(n=n+Math.imul(f,he)|0)+Math.imul(l,ue)|0))<<13)|0;h=((o=o+Math.imul(l,he)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(L,z),n=(n=Math.imul(L,X))+Math.imul(F,z)|0,o=Math.imul(F,X),i=i+Math.imul(R,H)|0,n=(n=n+Math.imul(R,G)|0)+Math.imul(O,H)|0,o=o+Math.imul(O,G)|0,i=i+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,W)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,W)|0,i=i+Math.imul(A,K)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,Z)|0,i=i+Math.imul(T,$)|0,n=(n=n+Math.imul(T,ee)|0)+Math.imul(S,$)|0,o=o+Math.imul(S,ee)|0,i=i+Math.imul(_,re)|0,n=(n=n+Math.imul(_,ie)|0)+Math.imul(w,re)|0,o=o+Math.imul(w,ie)|0,i=i+Math.imul(b,oe)|0,n=(n=n+Math.imul(b,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0,i=i+Math.imul(p,ue)|0,n=(n=n+Math.imul(p,he)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,he)|0;var Se=(h+(i=i+Math.imul(f,fe)|0)|0)+((8191&(n=(n=n+Math.imul(f,le)|0)+Math.imul(l,fe)|0))<<13)|0;h=((o=o+Math.imul(l,le)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(B,z),n=(n=Math.imul(B,X))+Math.imul(N,z)|0,o=Math.imul(N,X),i=i+Math.imul(L,H)|0,n=(n=n+Math.imul(L,G)|0)+Math.imul(F,H)|0,o=o+Math.imul(F,G)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,W)|0,i=i+Math.imul(C,K)|0,n=(n=n+Math.imul(C,Z)|0)+Math.imul(k,K)|0,o=o+Math.imul(k,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,i=i+Math.imul(T,re)|0,n=(n=n+Math.imul(T,ie)|0)+Math.imul(S,re)|0,o=o+Math.imul(S,ie)|0,i=i+Math.imul(_,oe)|0,n=(n=n+Math.imul(_,ae)|0)+Math.imul(w,oe)|0,o=o+Math.imul(w,ae)|0,i=i+Math.imul(b,ue)|0,n=(n=n+Math.imul(b,he)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,he)|0,i=i+Math.imul(p,fe)|0,n=(n=n+Math.imul(p,le)|0)+Math.imul(m,fe)|0,o=o+Math.imul(m,le)|0;var Ee=(h+(i=i+Math.imul(f,pe)|0)|0)+((8191&(n=(n=n+Math.imul(f,me)|0)+Math.imul(l,pe)|0))<<13)|0;h=((o=o+Math.imul(l,me)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(B,H),n=(n=Math.imul(B,G))+Math.imul(N,H)|0,o=Math.imul(N,G),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,W)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,W)|0,i=i+Math.imul(R,K)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,K)|0,o=o+Math.imul(O,Z)|0,i=i+Math.imul(C,$)|0,n=(n=n+Math.imul(C,ee)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,ee)|0,i=i+Math.imul(A,re)|0,n=(n=n+Math.imul(A,ie)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ie)|0,i=i+Math.imul(T,oe)|0,n=(n=n+Math.imul(T,ae)|0)+Math.imul(S,oe)|0,o=o+Math.imul(S,ae)|0,i=i+Math.imul(_,ue)|0,n=(n=n+Math.imul(_,he)|0)+Math.imul(w,ue)|0,o=o+Math.imul(w,he)|0,i=i+Math.imul(b,fe)|0,n=(n=n+Math.imul(b,le)|0)+Math.imul(g,fe)|0,o=o+Math.imul(g,le)|0;var Ae=(h+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;h=((o=o+Math.imul(m,me)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(B,Y),n=(n=Math.imul(B,W))+Math.imul(N,Y)|0,o=Math.imul(N,W),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(F,K)|0,o=o+Math.imul(F,Z)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,ee)|0)+Math.imul(O,$)|0,o=o+Math.imul(O,ee)|0,i=i+Math.imul(C,re)|0,n=(n=n+Math.imul(C,ie)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ie)|0,i=i+Math.imul(A,oe)|0,n=(n=n+Math.imul(A,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,i=i+Math.imul(T,ue)|0,n=(n=n+Math.imul(T,he)|0)+Math.imul(S,ue)|0,o=o+Math.imul(S,he)|0,i=i+Math.imul(_,fe)|0,n=(n=n+Math.imul(_,le)|0)+Math.imul(w,fe)|0,o=o+Math.imul(w,le)|0;var Pe=(h+(i=i+Math.imul(b,pe)|0)|0)+((8191&(n=(n=n+Math.imul(b,me)|0)+Math.imul(g,pe)|0))<<13)|0;h=((o=o+Math.imul(g,me)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(B,K),n=(n=Math.imul(B,Z))+Math.imul(N,K)|0,o=Math.imul(N,Z),i=i+Math.imul(L,$)|0,n=(n=n+Math.imul(L,ee)|0)+Math.imul(F,$)|0,o=o+Math.imul(F,ee)|0,i=i+Math.imul(R,re)|0,n=(n=n+Math.imul(R,ie)|0)+Math.imul(O,re)|0,o=o+Math.imul(O,ie)|0,i=i+Math.imul(C,oe)|0,n=(n=n+Math.imul(C,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,i=i+Math.imul(A,ue)|0,n=(n=n+Math.imul(A,he)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,he)|0,i=i+Math.imul(T,fe)|0,n=(n=n+Math.imul(T,le)|0)+Math.imul(S,fe)|0,o=o+Math.imul(S,le)|0;var Me=(h+(i=i+Math.imul(_,pe)|0)|0)+((8191&(n=(n=n+Math.imul(_,me)|0)+Math.imul(w,pe)|0))<<13)|0;h=((o=o+Math.imul(w,me)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(B,$),n=(n=Math.imul(B,ee))+Math.imul(N,$)|0,o=Math.imul(N,ee),i=i+Math.imul(L,re)|0,n=(n=n+Math.imul(L,ie)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ie)|0,i=i+Math.imul(R,oe)|0,n=(n=n+Math.imul(R,ae)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,ae)|0,i=i+Math.imul(C,ue)|0,n=(n=n+Math.imul(C,he)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,he)|0,i=i+Math.imul(A,fe)|0,n=(n=n+Math.imul(A,le)|0)+Math.imul(P,fe)|0,o=o+Math.imul(P,le)|0;var Ce=(h+(i=i+Math.imul(T,pe)|0)|0)+((8191&(n=(n=n+Math.imul(T,me)|0)+Math.imul(S,pe)|0))<<13)|0;h=((o=o+Math.imul(S,me)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(B,re),n=(n=Math.imul(B,ie))+Math.imul(N,re)|0,o=Math.imul(N,ie),i=i+Math.imul(L,oe)|0,n=(n=n+Math.imul(L,ae)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,ae)|0,i=i+Math.imul(R,ue)|0,n=(n=n+Math.imul(R,he)|0)+Math.imul(O,ue)|0,o=o+Math.imul(O,he)|0,i=i+Math.imul(C,fe)|0,n=(n=n+Math.imul(C,le)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,le)|0;var ke=(h+(i=i+Math.imul(A,pe)|0)|0)+((8191&(n=(n=n+Math.imul(A,me)|0)+Math.imul(P,pe)|0))<<13)|0;h=((o=o+Math.imul(P,me)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(B,oe),n=(n=Math.imul(B,ae))+Math.imul(N,oe)|0,o=Math.imul(N,ae),i=i+Math.imul(L,ue)|0,n=(n=n+Math.imul(L,he)|0)+Math.imul(F,ue)|0,o=o+Math.imul(F,he)|0,i=i+Math.imul(R,fe)|0,n=(n=n+Math.imul(R,le)|0)+Math.imul(O,fe)|0,o=o+Math.imul(O,le)|0;var Ie=(h+(i=i+Math.imul(C,pe)|0)|0)+((8191&(n=(n=n+Math.imul(C,me)|0)+Math.imul(k,pe)|0))<<13)|0;h=((o=o+Math.imul(k,me)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(B,ue),n=(n=Math.imul(B,he))+Math.imul(N,ue)|0,o=Math.imul(N,he),i=i+Math.imul(L,fe)|0,n=(n=n+Math.imul(L,le)|0)+Math.imul(F,fe)|0,o=o+Math.imul(F,le)|0;var Re=(h+(i=i+Math.imul(R,pe)|0)|0)+((8191&(n=(n=n+Math.imul(R,me)|0)+Math.imul(O,pe)|0))<<13)|0;h=((o=o+Math.imul(O,me)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(B,fe),n=(n=Math.imul(B,le))+Math.imul(N,fe)|0,o=Math.imul(N,le);var Oe=(h+(i=i+Math.imul(L,pe)|0)|0)+((8191&(n=(n=n+Math.imul(L,me)|0)+Math.imul(F,pe)|0))<<13)|0;h=((o=o+Math.imul(F,me)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863;var De=(h+(i=Math.imul(B,pe))|0)+((8191&(n=(n=Math.imul(B,me))+Math.imul(N,pe)|0))<<13)|0;return h=((o=Math.imul(N,me))+(n>>>13)|0)+(De>>>26)|0,De&=67108863,u[0]=ve,u[1]=be,u[2]=ge,u[3]=ye,u[4]=_e,u[5]=we,u[6]=xe,u[7]=Te,u[8]=Se,u[9]=Ee,u[10]=Ae,u[11]=Pe,u[12]=Me,u[13]=Ce,u[14]=ke,u[15]=Ie,u[16]=Re,u[17]=Oe,u[18]=De,0!==h&&(u[19]=h,r.length++),r};function s(e,t,r){return(new u).mulp(e,t,r)}function u(e,t){this.x=e,this.y=t}Math.imul||(o=n),b.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?o(this,e,t):r<63?n(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r.strip()}(this,e,t):s(this,e,t)},u.prototype.makeRBT=function(e){for(var t=new Array(e),r=b.prototype._countBits(e)-1,i=0;i>=1;return i},u.prototype.permute=function(e,t,r,i,n,o){for(var a=0;a>>=1)n++;return 1<>>=13,r[2*o+1]=8191&n,n>>>=13;for(o=2*t;o>=26,t+=i/67108864|0,t+=n>>>26,this.words[r]=67108863&n}return 0!==t&&(this.words[r]=t,this.length++),this},b.prototype.muln=function(e){return this.clone().imuln(e)},b.prototype.sqr=function(){return this.mul(this)},b.prototype.isqr=function(){return this.imul(this.clone())},b.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>n}return t}(e);if(0===t.length)return new b(1);for(var r=this,i=0;i>>26-r<<26-r;if(0!=r){var o=0;for(t=0;t>>26-r}o&&(this.words[t]=o,this.length++)}if(0!=i){for(t=this.length-1;0<=t;t--)this.words[t+i]=this.words[t];for(t=0;t>>n<o)for(this.length-=o,u=0;u>>n,h=c&a}return s&&0!==h&&(s.words[s.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},b.prototype.ishrn=function(e,t,r){return v(0===this.negative),this.iushrn(e,t,r)},b.prototype.shln=function(e){return this.clone().ishln(e)},b.prototype.ushln=function(e){return this.clone().iushln(e)},b.prototype.shrn=function(e){return this.clone().ishrn(e)},b.prototype.ushrn=function(e){return this.clone().iushrn(e)},b.prototype.testn=function(e){v("number"==typeof e&&0<=e);var t=e%26,r=(e-t)/26,i=1<>>t<>26)-(s/67108864|0),this.words[i+r]=67108863&n}for(;i>26,this.words[i+r]=67108863&n;if(0===a)return this.strip();for(v(-1===a),i=a=0;i>26,this.words[i]=67108863&n;return this.negative=1,this.strip()},b.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,s=i.length-n.length;if("mod"!==t){(a=new b(null)).length=1+s,a.words=new Array(a.length);for(var u=0;uthis.length||this.cmp(e)<0?{div:new b(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new b(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new b(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,n,o},b.prototype.div=function(e){return this.divmod(e,"div",!1).div},b.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},b.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},b.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},b.prototype.modn=function(e){v(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;0<=i;i--)r=(t*r+(0|this.words[i]))%e;return r},b.prototype.idivn=function(e){v(e<=67108863);for(var t=0,r=this.length-1;0<=r;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},b.prototype.divn=function(e){return this.clone().idivn(e)},b.prototype.egcd=function(e){v(0===e.negative),v(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new b(1),n=new b(0),o=new b(0),a=new b(1),s=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++s;for(var u=r.clone(),h=t.clone();!t.isZero();){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(0>>26,a&=67108863,this.words[o]=a}return 0!==n&&(this.words[o]=n,this.length++),this},b.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},b.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),1e.length)return 1;if(this.lengththis.n;);var i=t>>22,n=o}n>>>=22,0===(e.words[i-10]=n)&&10>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},b._prime=function(e){if(h[e])return h[e];var t;if("k256"===e)t=new m;else if("p224"===e)t=new g;else if("p192"===e)t=new y;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return h[e]=t},w.prototype._verify1=function(e){v(0===e.negative,"red works only with positives"),v(e.red,"red works only with red numbers")},w.prototype._verify2=function(e,t){v(0==(e.negative|t.negative),"red works only with positives"),v(e.red&&e.red===t.red,"red works only with red numbers")},w.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},w.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},w.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return 0<=r.cmp(this.m)&&r.isub(this.m),r},w.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},w.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},w.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},w.prototype.isqr=function(e){return this.imul(e,e.clone())},w.prototype.sqr=function(e){return this.mul(e,e)},w.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(v(t%2==1),3===t){var r=this.m.add(new b(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);v(!i.isZero());var o=new b(1).toRed(this),a=o.redNeg(),s=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new b(2*u*u).toRed(this);0!==this.pow(u,s).cmp(a);)u.redIAdd(a);for(var h=this.pow(u,i),c=this.pow(e,i.addn(1).iushrn(1)),f=this.pow(e,i),l=n;0!==f.cmp(o);){for(var d=f,p=0;0!==d.cmp(o);p++)d=d.redSqr();v(p>h&1;n!==r[0]&&(n=this.sqr(n)),0!=c||0!==o?(o<<=1,o|=c,(4===++a||0===i&&0===h)&&(n=this.mul(n,r[o]),o=a=0)):a=0}s=26}return n},w.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},w.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},b.mont=function(e){return new x(e)},r(x,w),x.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},x.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},x.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return 0<=n.cmp(this.m)?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new b(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return 0<=n.cmp(this.m)?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},x.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:19}],18:[function(e,t,r){var i;function n(e){this.rand=e}if(t.exports=function(e){return i||(i=new n(null)),i.generate(e)},(t.exports.Rand=n).prototype.generate=function(e){return this._rand(e)},n.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^c[p>>>16&255]^f[m>>>8&255]^l[255&v]^t[b++],a=h[p>>>24]^c[m>>>16&255]^f[v>>>8&255]^l[255&d]^t[b++],s=h[m>>>24]^c[v>>>16&255]^f[d>>>8&255]^l[255&p]^t[b++],u=h[v>>>24]^c[d>>>16&255]^f[p>>>8&255]^l[255&m]^t[b++],d=o,p=a,m=s,v=u;return o=(i[d>>>24]<<24|i[p>>>16&255]<<16|i[m>>>8&255]<<8|i[255&v])^t[b++],a=(i[p>>>24]<<24|i[m>>>16&255]<<16|i[v>>>8&255]<<8|i[255&d])^t[b++],s=(i[m>>>24]<<24|i[v>>>16&255]<<16|i[d>>>8&255]<<8|i[255&p])^t[b++],u=(i[v>>>24]<<24|i[d>>>16&255]<<16|i[p>>>8&255]<<8|i[255&m])^t[b++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var f=[0,1,2,4,8,16,32,64,128,27,54],l=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],i=[],n=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var h=s^s<<1^s<<2^s<<3^s<<4;h=h>>>8^255&h^99;var c=e[i[r[a]=h]=a],f=e[c],l=e[f],d=257*e[h]^16843008*h;n[0][a]=d<<24|d>>>8,n[1][a]=d<<16|d>>>16,n[2][a]=d<<8|d>>>24,n[3][a]=d,d=16843009*l^65537*f^257*c^16843008*a,o[0][h]=d<<24|d>>>8,o[1][h]=d<<16|d>>>16,o[2][h]=d<<8|d>>>24,o[3][h]=d,0===a?a=s=1:(a=c^e[e[e[l^c]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:i,SUB_MIX:n,INV_SUB_MIX:o}}();function s(e){this._key=o(e),this._reset()}s.blockSize=16,s.keySize=32,s.prototype.blockSize=s.blockSize,s.prototype.keySize=s.keySize,s.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,i=4*(r+1),n=[],o=0;o>>24,a=l.SBOX[a>>>24]<<24|l.SBOX[a>>>16&255]<<16|l.SBOX[a>>>8&255]<<8|l.SBOX[255&a],a^=f[o/t|0]<<24):6>>24]<<24|l.SBOX[a>>>16&255]<<16|l.SBOX[a>>>8&255]<<8|l.SBOX[255&a]),n[o]=n[o-t]^a}for(var s=[],u=0;u>>24]]^l.INV_SUB_MIX[1][l.SBOX[c>>>16&255]]^l.INV_SUB_MIX[2][l.SBOX[c>>>8&255]]^l.INV_SUB_MIX[3][l.SBOX[255&c]]}this._nRounds=r,this._keySchedule=n,this._invKeySchedule=s},s.prototype.encryptBlockRaw=function(e){return a(e=o(e),this._keySchedule,l.SUB_MIX,l.SBOX,this._nRounds)},s.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},s.prototype.decryptBlock=function(e){var t=(e=o(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,l.INV_SUB_MIX,l.INV_SBOX,this._nRounds),i=n.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},s.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},t.exports.AES=s},{"safe-buffer":143}],21:[function(e,t,r){var a=e("./aes"),h=e("safe-buffer").Buffer,s=e("cipher-base"),i=e("inherits"),c=e("./ghash"),n=e("buffer-xor"),f=e("./incr32");function o(e,t,r,i){s.call(this);var n=h.alloc(4,0);this._cipher=new a.AES(t);var o=this._cipher.encryptBlock(n);this._ghash=new c(o),r=function(e,t,r){if(12===t.length)return e._finID=h.concat([t,h.from([0,0,0,1])]),h.concat([t,h.from([0,0,0,2])]);var i=new c(r),n=t.length,o=n%16;i.update(t),o&&(o=16-o,i.update(h.alloc(o,0))),i.update(h.alloc(8,0));var a=8*n,s=h.alloc(8);s.writeUIntBE(a,0,8),i.update(s),e._finID=i.state;var u=h.from(e._finID);return f(u),u}(this,r,o),this._prev=h.from(r),this._cache=h.allocUnsafe(0),this._secCache=h.allocUnsafe(0),this._decrypt=i,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}i(o,s),o.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=h.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},o.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=n(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var i=Math.min(e.length,t.length),n=0;n>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=i.alloc(16,0),this.cache=i.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t>>1|(1&r[e-1])<<31;r[0]=r[0]>>>1,t&&(r[0]=r[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=i.concat([this.cache,e]);16<=this.cache.length;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(i.concat([this.cache,n],16)),this.ghash(o([0,e,0,t])),this.state},t.exports=a},{"safe-buffer":143}],26:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],27:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":48}],28:[function(e,t,r){var o=e("safe-buffer").Buffer,a=e("buffer-xor");function s(e,t,r){var i=t.length,n=a(t,e._cache);return e._cache=e._cache.slice(i),e._prev=o.concat([e._prev,r?t:n]),n}r.encrypt=function(e,t,r){for(var i,n=o.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=o.allocUnsafe(0)),!(e._cache.length<=t.length)){n=o.concat([n,s(e,t,r)]);break}i=e._cache.length,n=o.concat([n,s(e,t.slice(0,i),r)]),t=t.slice(i)}return n}},{"buffer-xor":48,"safe-buffer":143}],29:[function(e,t,r){var a=e("safe-buffer").Buffer;function s(e,t,r){for(var i,n,o=-1,a=0;++o<8;)i=t&1<<7-o?128:0,a+=(128&(n=e._cipher.encryptBlock(e._prev)[0]^i))>>o%8,e._prev=u(e._prev,r?i:n);return a}function u(e,t){var r=e.length,i=-1,n=a.allocUnsafe(e.length);for(e=a.concat([e,a.from([t])]);++i>7;return n}r.encrypt=function(e,t,r){for(var i=t.length,n=a.allocUnsafe(i),o=-1;++o=t)throw new Error("invalid sig")}t.exports=function(e,t,r,i,n){var o=m(r);if("ec"===o.type){if("ecdsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong public key type");return function(e,t,r){var i=v[r.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var n=new p(i),o=r.data.subjectPrivateKey.data;return n.verify(t,e,o)}(e,t,o)}if("dsa"===o.type){if("dsa"!==i)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,n=r.data.q,o=r.data.g,a=r.data.pub_key,s=m.signature.decode(e,"der"),u=s.s,h=s.r;b(u,n),b(h,n);var c=d.mont(i),f=u.invm(n);return 0===o.toRed(c).redPow(new d(t).mul(f).mod(n)).fromRed().mul(a.toRed(c).redPow(h.mul(f).mod(n)).fromRed()).mod(i).mod(n).cmp(h)}(e,t,o)}if("rsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong public key type");t=l.concat([n,t]);for(var a=o.modulus.byteLength(),s=[1],u=0;t.length+s.length+2=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function d(e,t){if(f.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return D(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return L(e).length;default:if(i)return D(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function m(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):2147483647=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=f.from(t,i)),f.isBuffer(t))return 0===t.length?-1:v(e,t,r,i,n);if("number"==typeof t)return t&=255,f.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,i,n){var o,a=1,s=e.length,u=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s/=a=2,u/=2,r/=2}function h(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(n){var c=-1;for(o=r;o>>10&1023|55296),c=56320|1023&c),i.push(c),n+=f}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);var r="",i=0;for(;ithis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return S(this,t,r);case"utf8":case"utf-8":return _(this,t,r);case"ascii":return x(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return y(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}.apply(this,arguments)},f.prototype.equals=function(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===f.compare(this,e)},f.prototype.inspect=function(){var e="",t=B.INSPECT_MAX_BYTES;return 0t&&(e+=" ... ")),""},f.prototype.compare=function(e,t,r,i,n){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(n<=i&&r<=t)return 0;if(n<=i)return-1;if(r<=t)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(i,n),h=e.slice(t,r),c=0;cthis.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o,a,s,u,h,c,f,l,d,p=!1;;)switch(i){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return l=t,d=r,F(D(e,(f=this).length-l),f,l,d);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return g(this,e,t,r);case"base64":return u=this,h=t,c=r,F(L(e),u,h,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=t,s=r,F(function(e,t){for(var r,i,n,o=[],a=0;a>8,n=r%256,o.push(n),o.push(i);return o}(e,(o=this).length-a),o,a,s);default:if(p)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),p=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function x(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;ne.length)throw new RangeError("Index out of range")}function M(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,o=Math.min(e.length-r,2);n>>8*(i?n:1-n)}function C(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,o=Math.min(e.length-r,4);n>>8*(i?n:3-n)&255}function k(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(e,t,r,i,n){return n||k(e,0,r,4),o.write(e,t,r,i,23,4),r+4}function R(e,t,r,i,n){return n||k(e,0,r,8),o.write(e,t,r,i,52,8),r+8}f.prototype.slice=function(e,t){var r,i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):i>>8):M(this,e,t,!0),t+2},f.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},f.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):C(this,e,t,!0),t+4},f.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},f.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},f.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;0<=--o&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},f.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,127,-128),f.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},f.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},f.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},f.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):C(this,e,t,!0),t+4},f.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},f.prototype.writeFloatLE=function(e,t,r){return I(this,e,t,!0,r)},f.prototype.writeFloatBE=function(e,t,r){return I(this,e,t,!1,r)},f.prototype.writeDoubleLE=function(e,t,r){return R(this,e,t,!0,r)},f.prototype.writeDoubleBE=function(e,t,r){return R(this,e,t,!1,r)},f.prototype.copy=function(e,t,r,i){if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),0=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function L(e){return i.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(t,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,i){for(var n=0;n=t.length||n>=e.length);++n)t[n+r]=e[n];return n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":16,ieee754:101,isarray:105}],50:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){i=e}finally{r(i)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var i=this._decoder.write(e);return r&&(i+=this._decoder.end()),i},t.exports=a},{inherits:103,"safe-buffer":143,stream:152,string_decoder:153}],51:[function(e,t,r){(function(e){function t(e){return Object.prototype.toString.call(e)}r.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===t(e)},r.isBoolean=function(e){return"boolean"==typeof e},r.isNull=function(e){return null===e},r.isNullOrUndefined=function(e){return null==e},r.isNumber=function(e){return"number"==typeof e},r.isString=function(e){return"string"==typeof e},r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=function(e){return void 0===e},r.isRegExp=function(e){return"[object RegExp]"===t(e)},r.isObject=function(e){return"object"==typeof e&&null!==e},r.isDate=function(e){return"[object Date]"===t(e)},r.isError=function(e){return"[object Error]"===t(e)||e instanceof Error},r.isFunction=function(e){return"function"==typeof e},r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":104}],52:[function(e,s,t){(function(o){var t=e("elliptic"),i=e("bn.js");s.exports=function(e){return new n(e)};var r={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function n(e){this.curveType=r[e],this.curveType||(this.curveType={name:e}),this.curve=new t.ec(this.curveType.name),this.keys=void 0}function a(e,t,r){Array.isArray(e)||(e=e.toArray());var i=new o(e);if(r&&i.length>>2),i=0,n=0;i>5]|=128<>>9<<4)]=t;for(var r=1732584193,i=-271733879,n=-1732584194,o=271733878,a=0;a>>32-t}(m(m(t,e),m(i,o)),n),r)}function f(e,t,r,i,n,o,a){return s(t&r|~t&i,e,t,n,o,a)}function l(e,t,r,i,n,o,a){return s(t&i|r&~i,e,t,n,o,a)}function d(e,t,r,i,n,o,a){return s(t^r^i,e,t,n,o,a)}function p(e,t,r,i,n,o,a){return s(r^(t|~i),e,t,n,o,a)}function m(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.exports=function(e){return i(e,n)}},{"./make-hash":54}],56:[function(e,t,r){"use strict";var i=e("inherits"),n=e("./legacy"),a=e("cipher-base"),s=e("safe-buffer").Buffer,o=e("create-hash/md5"),u=e("ripemd160"),h=e("sha.js"),c=s.alloc(128);function f(e,t){a.call(this,"digest"),"string"==typeof t&&(t=s.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,(this._key=t).length>r)?t=("rmd160"===e?new u:h(e)).update(t).digest():t.length>>1];r=l.r28shl(r,o),i=l.r28shl(i,o),l.pc2(r,i,e.keys,n)}},u.prototype._update=function(e,t,r,i){var n=this._desState,o=l.readUInt32BE(e,t),a=l.readUInt32BE(e,t+4);l.ip(o,a,n.tmp,0),o=n.tmp[0],a=n.tmp[1],"encrypt"===this.type?this._encrypt(n,o,a,n.tmp,0):this._decrypt(n,o,a,n.tmp,0),o=n.tmp[0],a=n.tmp[1],l.writeUInt32BE(r,o,i),l.writeUInt32BE(r,a,i+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,i=t;i>>0,o=f}l.rip(a,o,i,n)},u.prototype._decrypt=function(e,t,r,i,n){for(var o=r,a=t,s=e.keys.length-2;0<=s;s-=2){var u=e.keys[s],h=e.keys[s+1];l.expand(o,e.tmp,0),u^=e.tmp[0],h^=e.tmp[1];var c=l.substitute(u,h),f=o;o=(a^l.permute(c))>>>0,a=f}l.rip(o,a,i,n)}},{"../des":59,inherits:103,"minimalistic-assert":109}],63:[function(e,t,r){"use strict";var o=e("minimalistic-assert"),i=e("inherits"),n=e("../des"),a=n.Cipher,s=n.DES;function u(e,t){o.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),n=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:n})]:[s.create({type:"decrypt",key:n}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}function h(e){a.call(this,e);var t=new u(this.type,this.options.key);this._edeState=t}i(h,a),(t.exports=h).create=function(e){return new h(e)},h.prototype._update=function(e,t,r,i){var n=this._edeState;n.ciphers[0]._update(e,t,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},h.prototype._pad=s.prototype._pad,h.prototype._unpad=s.prototype._unpad},{"../des":59,inherits:103,"minimalistic-assert":109}],64:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,i){for(var n=0,o=0,a=6;0<=a;a-=2){for(var s=0;s<=24;s+=8)n<<=1,n|=t>>>s+a&1;for(s=0;s<=24;s+=8)n<<=1,n|=e>>>s+a&1}for(a=6;0<=a;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[i+0]=n>>>0,r[i+1]=o>>>0},r.rip=function(e,t,r,i){for(var n=0,o=0,a=0;a<4;a++)for(var s=24;0<=s;s-=8)n<<=1,n|=t>>>s+a&1,n<<=1,n|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;0<=s;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[i+0]=n>>>0,r[i+1]=o>>>0},r.pc1=function(e,t,r,i){for(var n=0,o=0,a=7;5<=a;a--){for(var s=0;s<=24;s+=8)n<<=1,n|=t>>s+a&1;for(s=0;s<=24;s+=8)n<<=1,n|=e>>s+a&1}for(s=0;s<=24;s+=8)n<<=1,n|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[i+0]=n>>>0,r[i+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var u=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var n=0,o=0,a=u.length>>>1,s=0;s>>u[s]&1;for(s=a;s>>u[s]&1;r[i+0]=n>>>0,r[i+1]=o>>>0},r.expand=function(e,t,r){var i=0,n=0;i=(1&e)<<5|e>>>27;for(var o=23;15<=o;o-=4)i<<=6,i|=e>>>o&63;for(o=11;3<=o;o-=4)n|=e>>>o&63,n<<=6;n|=(31&e)<<1|e>>>31,t[r+0]=i>>>0,t[r+1]=n>>>0};var n=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,i=0;i<4;i++){r<<=4,r|=n[64*i+(e>>>18-6*i&63)]}for(i=0;i<4;i++){r<<=4,r|=n[256+64*i+(t>>>18-6*i&63)]}return r>>>0};var i=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>i[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var i=e.toString(2);i.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(u),r.testn(1)||r.iadd(h),t.cmp(h)){if(!t.cmp(c))for(;r.mod(f).cmp(l);)r.iadd(p)}else for(;r.mod(a).cmp(d);)r.iadd(p);if(v(i=r.shrn(1))&&v(r)&&b(i)&&b(r)&&s.test(i)&&s.test(r))return r}}},{"bn.js":17,"miller-rabin":108,randombytes:130}],68:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],69:[function(e,t,r){"use strict";var i=r;i.version=e("../package.json").version,i.utils=e("./elliptic/utils"),i.rand=e("brorand"),i.curve=e("./elliptic/curve"),i.curves=e("./elliptic/curves"),i.ec=e("./elliptic/ec"),i.eddsa=e("./elliptic/eddsa")},{"../package.json":84,"./elliptic/curve":72,"./elliptic/curves":75,"./elliptic/ec":76,"./elliptic/eddsa":79,"./elliptic/utils":83,brorand:18}],70:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../../elliptic").utils,E=n.getNAF,A=n.getJSF,f=n.assert;function o(e,t){this.type=e,this.p=new i(t.p,16),this.red=t.prime?i.red(t.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=t.n&&new i(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||0>1]):a.mixedAdd(n[-u-1>>1].neg()):0>1]):a.add(n[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},o.prototype._wnafMulAdd=function(e,t,r,i,n){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,h=0;h>1]:S<0&&(T=a[v][-S-1>>1].neg()),y="affine"===T.type?y.mixedAdd(T):y.add(T))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},a.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n":""},c.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},c.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(e),n=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=i.redAdd(t),a=o.redSub(r),s=i.redSub(t),u=n.redMul(a),h=o.redMul(s),c=n.redMul(s),f=a.redMul(o);return this.curve.point(u,h,f,c)},c.prototype._projDbl=function(){var e,t,r,i=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(h=this.curve._mulA(n)).redAdd(o);if(this.zOne)e=i.redSub(n).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(h.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=i.redSub(n).redISub(o).redMul(u),t=a.redMul(h.redSub(o)),r=a.redMul(u)}}else{var h=n.redAdd(o);s=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=h.redSub(s).redSub(s);e=this.curve._mulC(i.redISub(h)).redMul(u),t=this.curve._mulC(h).redMul(n.redISub(o)),r=h.redMul(u)}return this.curve.point(e,t,r)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),n=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=n.redSub(i),s=n.redAdd(i),u=r.redAdd(t),h=o.redMul(a),c=s.redMul(u),f=o.redMul(u),l=a.redMul(s);return this.curve.point(h,c,l,f)},c.prototype._projAdd=function(e){var t,r,i=this.z.redMul(e.z),n=i.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=n.redSub(s),h=n.redAdd(s),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),f=i.redMul(u).redMul(c);return r=this.curve.twisted?(t=i.redMul(h).redMul(a.redSub(this.curve._mulA(o))),u.redMul(h)):(t=i.redMul(h).redMul(a.redSub(o)),this.curve._mulC(u).redMul(h)),this.curve.point(f,t,r)},c.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},c.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},c.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},c.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},c.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),0<=r.cmp(this.curve.p))return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}return!1},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},{"../../elliptic":69,"../curve":72,"bn.js":17,inherits:103}],72:[function(e,t,r){"use strict";var i=r;i.base=e("./base"),i.short=e("./short"),i.mont=e("./mont"),i.edwards=e("./edwards")},{"./base":70,"./edwards":71,"./mont":73,"./short":74}],73:[function(e,t,r){"use strict";var i=e("../curve"),n=e("bn.js"),o=e("inherits"),a=i.base,s=e("../../elliptic").utils;function u(e){a.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function h(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,a),(t.exports=u).prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),i=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===i.redSqrt().redSqr().cmp(i)},o(h,a.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},u.prototype.point=function(e,t){return new h(this,e,t)},u.prototype.pointFromJSON=function(e){return h.fromJSON(this,e)},h.prototype.precompute=function(){},h.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},h.fromJSON=function(e,t){return new h(e,t[0],t[1]||e.one)},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},h.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),i=e.redMul(t),n=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},h.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},h.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=n.redMul(i),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},h.prototype.mul=function(e){for(var t=e.clone(),r=this,i=this.curve.point(null,null),n=[];0!==t.cmpn(0);t.iushrn(1))n.push(t.andln(1));for(var o=n.length-1;0<=o;o--)0===n[o]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},h.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},h.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},h.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},h.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},h.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":69,"../curve":72,"bn.js":17,inherits:103}],74:[function(e,t,r){"use strict";var i=e("../curve"),n=e("../../elliptic"),w=e("bn.js"),o=e("inherits"),a=i.base,s=n.utils.assert;function u(e){a.call(this,"short",e),this.a=new w(e.a,16).toRed(this.red),this.b=new w(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function h(e,t,r,i){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new w(t,16),this.y=new w(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(e,t,r,i){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new w(0)):(this.x=new w(t,16),this.y=new w(r,16),this.z=new w(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,a),(t.exports=u).prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new w(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=(t=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(e.lambda)r=new w(e.lambda,16);else{var n=this._getEndoRoots(this.n);0===this.g.mul(n[0]).x.cmp(this.g.x.redMul(t))?r=n[0]:(r=n[1],s(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new w(e.a,16),b:new w(e.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:w.mont(e),r=new w(2).toRed(t).redInvm(),i=r.redNeg(),n=new w(3).toRed(t).redNeg().redSqrt().redMul(r);return[i.redAdd(n).fromRed(),i.redSub(n).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,i,n,o,a,s,u,h,c=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=e,l=this.n.clone(),d=new w(1),p=new w(0),m=new w(0),v=new w(1),b=0;0!==f.cmpn(0);){var g=l.div(f);u=l.sub(g.mul(f)),h=m.sub(g.mul(d));var y=v.sub(g.mul(p));if(!i&&u.cmp(c)<0)t=s.neg(),r=d,i=u.neg(),n=h;else if(i&&2==++b)break;l=f,f=s=u,m=d,d=h,v=p,p=y}o=u.neg(),a=h;var _=i.sqr().add(n.sqr());return 0<=o.sqr().add(a.sqr()).cmp(_)&&(o=t,a=r),i.negative&&(i=i.neg(),n=n.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:n},{a:o,b:a}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],n=i.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=n.mul(r.a),s=o.mul(i.a),u=n.mul(r.b),h=o.mul(i.b);return{k1:e.sub(a).sub(s),k2:u.add(h).neg()}},u.prototype.pointFromX=function(e,t){(e=new w(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(t&&!n||!t&&n)&&(i=i.redNeg()),this.point(e,i)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,o=0;o":""},h.prototype.isInfinity=function(){return this.inf},h.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},h.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),o=n.redSqr().redISub(this.x.redAdd(this.x)),a=n.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(e){return e=new w(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},h.prototype.mulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},h.prototype.jmulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},h.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},h.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t},h.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new c(this,e,t,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),n=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=i.redSub(n),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),c=h.redMul(s),f=i.redMul(h),l=u.redSqr().redIAdd(c).redISub(f).redISub(f),d=u.redMul(f.redISub(l)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),n=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(i),s=n.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),h=u.redMul(a),c=r.redMul(u),f=s.redSqr().redIAdd(h).redISub(c).redISub(c),l=s.redMul(c.redISub(f)).redISub(n.redMul(h)),d=this.z.redMul(a);return this.curve.jpoint(f,l,d)},c.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":69,"../curve":72,"bn.js":17,inherits:103}],75:[function(e,t,r){"use strict";var i,n=r,o=e("hash.js"),a=e("../elliptic"),s=a.utils.assert;function u(e){"short"===e.type?this.curve=new a.curve.short(e):"edwards"===e.type?this.curve=new a.curve.edwards(e):this.curve=new a.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function h(t,r){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var e=new u(r);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:e}),e}})}n.PresetCurve=u,h("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),h("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),h("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),h("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),h("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),h("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),h("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=e("./precomputed/secp256k1")}catch(e){i=void 0}h("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},{"../elliptic":69,"./precomputed/secp256k1":82,"hash.js":88}],76:[function(e,t,r){"use strict";var v=e("bn.js"),b=e("hmac-drbg"),o=e("../../elliptic"),d=o.utils.assert,i=e("./key"),g=e("./signature");function n(e){if(!(this instanceof n))return new n(e);"string"==typeof e&&(d(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}(t.exports=n).prototype.keyPair=function(e){return new i(this,e)},n.prototype.keyFromPrivate=function(e,t){return i.fromPrivate(this,e,t)},n.prototype.keyFromPublic=function(e,t){return i.fromPublic(this,e,t)},n.prototype.genKeyPair=function(e){e||(e={});for(var t=new b({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new v(2));;){var n=new v(t.generate(r));if(!(0>1;if(0<=a.cmp(this.curve.p.umod(this.curve.n))&&h)throw new Error("Unable to find sencond key candinate");a=h?this.curve.pointFromX(a.add(this.curve.n),u):this.curve.pointFromX(a,u);var c=t.r.invm(n),f=n.sub(o).mul(c).umod(n),l=s.mul(c).umod(n);return this.g.mulAdd(f,a,l)},n.prototype.getKeyRecoveryParam=function(e,t,r,i){if(null!==(t=new g(t,i)).recoveryParam)return t.recoveryParam;for(var n=0;n<4;n++){var o;try{o=this.recoverPubKey(e,t,n)}catch(e){continue}if(o.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":69,"./key":77,"./signature":78,"bn.js":17,"hmac-drbg":100}],77:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}(t.exports=o).fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new i(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?n(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||n(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":69,"bn.js":17}],78:[function(e,t,r){"use strict";var s=e("bn.js"),u=e("../../elliptic").utils,i=u.assert;function n(e,t){if(e instanceof n)return e;this._importDER(e,t)||(i(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function h(){this.place=0}function c(e,t){var r=e[t.place++];if(!(128&r))return r;for(var i=15&r,n=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}(t.exports=n).prototype._importDER=function(e,t){e=u.toArray(e,t);var r=new h;if(48!==e[r.place++])return!1;if(c(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var i=c(e,r),n=e.slice(r.place,i+r.place);if(r.place+=i,2!==e[r.place++])return!1;var o=c(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===n[0]&&128&n[1]&&(n=n.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(n),this.s=new s(a),!(this.recoveryParam=null)},n.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=a(t),r=a(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];f(i,t.length),(i=i.concat(t)).push(2),f(i,r.length);var n=i.concat(r),o=[48];return f(o,n.length),o=o.concat(n),u.encode(o,e)}},{"../../elliptic":69,"bn.js":17}],79:[function(e,t,r){"use strict";var i=e("hash.js"),n=e("../../elliptic"),o=n.utils,a=o.assert,u=o.parseBytes,s=e("./key"),h=e("./signature");function c(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof c))return new c(e);e=n.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=i.sha512}(t.exports=c).prototype.sign=function(e,t){e=u(e);var r=this.keyFromSecret(t),i=this.hashInt(r.messagePrefix(),e),n=this.g.mul(i),o=this.encodePoint(n),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),s=i.add(a).umod(this.curve.n);return this.makeSignature({R:n,S:s,Rencoded:o})},c.prototype.verify=function(e,t,r){e=u(e),t=this.makeSignature(t);var i=this.keyFromPublic(r),n=this.hashInt(t.Rencoded(),i.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(i.pub().mul(n)).eq(o)},c.prototype.hashInt=function(){for(var e=this.hash(),t=0;t>1)-1>1)-a:a,n.isubn(o)}else o=0;r.push(o);for(var s=0!==n.cmpn(0)&&0===n.andln(i-1)?t+1:1,u=1;ur&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},i.prototype.once=function(e,t){if(!u(t))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(e,i),r||(r=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},i.prototype.removeListener=function(e,t){var r,i,n,o;if(!u(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=(r=this._events[e]).length,i=-1,r===t||u(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(h(r)){for(o=n;0=this._blockSize;){for(var n=this._blockOffset;n=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,i[n++]=e>>>16&255,i[n++]=e>>>8&255,i[n++]=255&e}else for(i[n++]=255&e,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),n(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return i(e,17)^i(e,19)^e>>>10}},{"../utils":99}],99:[function(e,t,r){"use strict";var h=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function n(e){return 1===e.length?"0"+e:e}function a(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>8,a=255&n;o?r.push(o,a):r.push(a)}else for(i=0;i>>0}return o},r.split32=function(e,t){for(var r=new Array(4*e.length),i=0,n=0;i>>24,r[n+1]=o>>>16&255,r[n+2]=o>>>8&255,r[n+3]=255&o):(r[n+3]=o>>>24,r[n+2]=o>>>16&255,r[n+1]=o>>>8&255,r[n]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,i){return e+t+r+i>>>0},r.sum32_5=function(e,t,r,i,n){return e+t+r+i+n>>>0},r.sum64=function(e,t,r,i){var n=e[t],o=i+e[t+1]>>>0,a=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,i){return(t+i>>>0>>0},r.sum64_lo=function(e,t,r,i){return t+i>>>0},r.sum64_4_hi=function(e,t,r,i,n,o,a,s){var u=0,h=t;return u+=(h=h+i>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,i,n,o,a,s){return t+i+o+s>>>0},r.sum64_5_hi=function(e,t,r,i,n,o,a,s,u,h){var c=0,f=t;return c+=(f=f+i>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,i,n,o,a,s,u,h){return t+i+o+s+h>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:103,"minimalistic-assert":109}],100:[function(e,t,r){"use strict";var i=e("hash.js"),a=e("minimalistic-crypto-utils"),n=e("minimalistic-assert");function o(e){if(!(this instanceof o))return new o(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=a.toArray(e.entropy,e.entropyEnc||"hex"),r=a.toArray(e.nonce,e.nonceEnc||"hex"),i=a.toArray(e.pers,e.persEnc||"hex");n(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,i)}(t.exports=o).prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},o.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=r,r=t,t=null),r&&(r=a.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length>1,c=-7,f=r?n-1:0,l=r?-1:1,d=e[t+f];for(f+=l,o=d&(1<<-c)-1,d>>=-c,c+=s;0>=-c,c+=i;0>1,l=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:o-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),2<=(t+=1<=a+f?l/u:l*Math.pow(2,1-f))*u&&(a++,u/=2),c<=a+f?(s=0,a=c):1<=a+f?(s=(t*u-1)*Math.pow(2,n),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,n),a=0));8<=n;e[r+d]=255&s,d+=p,s/=256,n-=8);for(a=a<>>32-t}function u(e,t,r,i,n,o,a){return s(e+(t&r|~t&i)+n+o|0,a)+t|0}function h(e,t,r,i,n,o,a){return s(e+(t&i|r&~i)+n+o|0,a)+t|0}function c(e,t,r,i,n,o,a){return s(e+(t^r^i)+n+o|0,a)+t|0}function f(e,t,r,i,n,o,a){return s(e+(r^(t|~i))+n+o|0,a)+t|0}e(i,r),i.prototype._update=function(){for(var e=a,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,i=this._b,n=this._c,o=this._d;i=f(i=f(i=f(i=f(i=c(i=c(i=c(i=c(i=h(i=h(i=h(i=h(i=u(i=u(i=u(i=u(i,n=u(n,o=u(o,r=u(r,i,n,o,e[0],3614090360,7),i,n,e[1],3905402710,12),r,i,e[2],606105819,17),o,r,e[3],3250441966,22),n=u(n,o=u(o,r=u(r,i,n,o,e[4],4118548399,7),i,n,e[5],1200080426,12),r,i,e[6],2821735955,17),o,r,e[7],4249261313,22),n=u(n,o=u(o,r=u(r,i,n,o,e[8],1770035416,7),i,n,e[9],2336552879,12),r,i,e[10],4294925233,17),o,r,e[11],2304563134,22),n=u(n,o=u(o,r=u(r,i,n,o,e[12],1804603682,7),i,n,e[13],4254626195,12),r,i,e[14],2792965006,17),o,r,e[15],1236535329,22),n=h(n,o=h(o,r=h(r,i,n,o,e[1],4129170786,5),i,n,e[6],3225465664,9),r,i,e[11],643717713,14),o,r,e[0],3921069994,20),n=h(n,o=h(o,r=h(r,i,n,o,e[5],3593408605,5),i,n,e[10],38016083,9),r,i,e[15],3634488961,14),o,r,e[4],3889429448,20),n=h(n,o=h(o,r=h(r,i,n,o,e[9],568446438,5),i,n,e[14],3275163606,9),r,i,e[3],4107603335,14),o,r,e[8],1163531501,20),n=h(n,o=h(o,r=h(r,i,n,o,e[13],2850285829,5),i,n,e[2],4243563512,9),r,i,e[7],1735328473,14),o,r,e[12],2368359562,20),n=c(n,o=c(o,r=c(r,i,n,o,e[5],4294588738,4),i,n,e[8],2272392833,11),r,i,e[11],1839030562,16),o,r,e[14],4259657740,23),n=c(n,o=c(o,r=c(r,i,n,o,e[1],2763975236,4),i,n,e[4],1272893353,11),r,i,e[7],4139469664,16),o,r,e[10],3200236656,23),n=c(n,o=c(o,r=c(r,i,n,o,e[13],681279174,4),i,n,e[0],3936430074,11),r,i,e[3],3572445317,16),o,r,e[6],76029189,23),n=c(n,o=c(o,r=c(r,i,n,o,e[9],3654602809,4),i,n,e[12],3873151461,11),r,i,e[15],530742520,16),o,r,e[2],3299628645,23),n=f(n,o=f(o,r=f(r,i,n,o,e[0],4096336452,6),i,n,e[7],1126891415,10),r,i,e[14],2878612391,15),o,r,e[5],4237533241,21),n=f(n,o=f(o,r=f(r,i,n,o,e[12],1700485571,6),i,n,e[3],2399980690,10),r,i,e[10],4293915773,15),o,r,e[1],2240044497,21),n=f(n,o=f(o,r=f(r,i,n,o,e[8],1873313359,6),i,n,e[15],4264355552,10),r,i,e[6],2734768916,15),o,r,e[13],1309151649,21),n=f(n,o=f(o,r=f(r,i,n,o,e[4],4149444226,6),i,n,e[11],3174756917,10),r,i,e[2],718787259,15),o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+o|0},i.prototype._digest=function(){this._block[this._blockOffset++]=128,56=this._blockSize;){for(var n=this._blockOffset;n>8,a=255&n;o?r.push(o,a):r.push(a)}return r},i.zero2=n,i.toHex=o,i.encode=function(e,t){return"hex"===t?o(e):e}},{}],111:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],112:[function(e,t,r){"use strict";var i=e("asn1.js");r.certificate=e("./certificate");var n=i.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});r.RSAPrivateKey=n;var o=i.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});r.RSAPublicKey=o;var a=i.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=a;var s=i.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=i.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=u;var h=i.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=h;var c=i.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});r.DSAPrivateKey=c,r.DSAparam=i.define("DSAparam",function(){this.int()});var f=i.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=f;var l=i.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=i.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":113,"asn1.js":2}],113:[function(e,t,r){"use strict";var i=e("asn1.js"),n=i.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),o=i.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),a=i.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional())}),s=i.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())}),u=i.define("RelativeDistinguishedName",function(){this.setof(o)}),h=i.define("RDNSequence",function(){this.seqof(u)}),c=i.define("Name",function(){this.choice({rdnSequence:this.use(h)})}),f=i.define("Validity",function(){this.seq().obj(this.key("notBefore").use(n),this.key("notAfter").use(n))}),l=i.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),d=i.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(c),this.key("validity").use(f),this.key("subject").use(c),this.key("subjectPublicKeyInfo").use(s),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(l).optional())}),p=i.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())});t.exports=p},{"asn1.js":2}],114:[function(e,t,r){(function(l){var d=/Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m,p=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m,m=/^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m,v=e("evp_bytestokey"),b=e("browserify-aes");t.exports=function(e,t){var r,i=e.toString(),n=i.match(d);if(n){var o="aes"+n[1],a=new l(n[2],"hex"),s=new l(n[3].replace(/\r?\n/g,""),"base64"),u=v(t,a.slice(0,8),parseInt(n[1],10)).key,h=[],c=b.createDecipheriv(o,u,a);h.push(c.update(s)),h.push(c.final()),r=l.concat(h)}else{var f=i.match(m);r=new l(f[2].replace(/\r?\n/g,""),"base64")}return{tag:i.match(p)[1],data:r}}}).call(this,e("buffer").Buffer)},{"browserify-aes":22,buffer:49,evp_bytestokey:86}],115:[function(t,r,e){(function(f){var s=t("./asn1"),l=t("./aesid.json"),u=t("./fixProc"),d=t("browserify-aes"),p=t("pbkdf2");function e(e){var t;"object"!=typeof e||f.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new f(e));var r,i,n=u(e,t),o=n.tag,a=n.data;switch(o){case"CERTIFICATE":i=s.certificate.decode(a,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(i||(i=s.PublicKey.decode(a,"der")),r=i.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPublicKey.decode(i.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return i.subjectPrivateKey=i.subjectPublicKey,{type:"ec",data:i};case"1.2.840.10040.4.1":return i.algorithm.params.pub_key=s.DSAparam.decode(i.subjectPublicKey.data,"der"),{type:"dsa",data:i.algorithm.params};default:throw new Error("unknown key id "+r)}throw new Error("unknown key type "+o);case"ENCRYPTED PRIVATE KEY":a=function(e,t){var r=e.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),n=l[e.algorithm.decrypt.cipher.algo.join(".")],o=e.algorithm.decrypt.cipher.iv,a=e.subjectPrivateKey,s=parseInt(n.split("-")[1],10)/8,u=p.pbkdf2Sync(t,r,i,s),h=d.createDecipheriv(n,u,o),c=[];return c.push(h.update(a)),c.push(h.final()),f.concat(c)}(a=s.EncryptedPrivateKey.decode(a,"der"),t);case"PRIVATE KEY":switch(r=(i=s.PrivateKey.decode(a,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPrivateKey.decode(i.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:i.algorithm.curve,privateKey:s.ECPrivateKey.decode(i.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return i.algorithm.params.priv_key=s.DSAparam.decode(i.subjectPrivateKey,"der"),{type:"dsa",params:i.algorithm.params};default:throw new Error("unknown key id "+r)}throw new Error("unknown key type "+o);case"RSA PUBLIC KEY":return s.RSAPublicKey.decode(a,"der");case"RSA PRIVATE KEY":return s.RSAPrivateKey.decode(a,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:s.DSAPrivateKey.decode(a,"der")};case"EC PRIVATE KEY":return{curve:(a=s.ECPrivateKey.decode(a,"der")).parameters.value,privateKey:a.privateKey};default:throw new Error("unknown key type "+o)}}(r.exports=e).signature=s.signature}).call(this,t("buffer").Buffer)},{"./aesid.json":111,"./asn1":112,"./fixProc":114,"browserify-aes":22,buffer:49,pbkdf2:117}],116:[function(e,t,h){(function(n){function o(e,t){for(var r=0,i=e.length-1;0<=i;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,a=function(e){return t.exec(e).slice(1)};function s(e,t){if(e.filter)return e.filter(t);for(var r=[],i=0;in?t=i(t):t.lengtha||0<=new h(t).cmp(o.modulus))throw new Error("decryption error");n=r?m(new h(t),o):d(t,o);var s=new c(a-n.length);if(s.fill(0),n=c.concat([s,n],a),4===i)return function(e,t){e.modulus;var r=e.modulus.byteLength(),i=(t.length,p("sha1").update(new c("")).digest()),n=i.length;if(0!==t[0])throw new Error("decryption error");var o=t.slice(1,n+1),a=t.slice(n+1),s=l(o,f(a,n)),u=l(a,f(s,r-n-1));if(function(e,t){e=new c(e),t=new c(t);var r=0,i=e.length;e.length!==t.length&&(r++,i=Math.min(e.length,t.length));var n=-1;for(;++n=t.length){o++;break}var a=t.slice(2,n-1);t.slice(n-1,n);("0002"!==i.toString("hex")&&!r||"0001"!==i.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(n)}(0,n,r);if(3===i)return n;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":125,"./withPublic":128,"./xor":129,"bn.js":17,"browserify-rsa":40,buffer:49,"create-hash":53,"parse-asn1":115}],127:[function(e,t,r){(function(l){var a=e("parse-asn1"),d=e("randombytes"),p=e("create-hash"),m=e("./mgf"),v=e("./xor"),b=e("bn.js"),s=e("./withPublic"),u=e("browserify-rsa");t.exports=function(e,t,r){var i;i=e.padding?e.padding:r?1:4;var n,o=a(e);if(4===i)n=function(e,t){var r=e.modulus.byteLength(),i=t.length,n=p("sha1").update(new l("")).digest(),o=n.length,a=2*o;if(r-a-2t.highWaterMark&&(t.highWaterMark=function(e){return u<=e?e=u:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function c(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(y("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?v(f,e):f(e))}function f(e){y("emit readable"),e.emit("readable"),w(e)}function d(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.highWaterMark||t.ended))return y("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?T(this):c(this),null;if(0===(e=h(e,t))&&t.ended)return 0===t.length&&T(this),null;var i,n=t.needReadable;return y("need readable",n),(0===t.length||t.length-e>>32-t}function p(e,t,r,i,n,o,a,s){return d(e+(t^r^i)+o+a|0,s)+n|0}function m(e,t,r,i,n,o,a,s){return d(e+(t&r|~t&i)+o+a|0,s)+n|0}function v(e,t,r,i,n,o,a,s){return d(e+((t|~r)^i)+o+a|0,s)+n|0}function b(e,t,r,i,n,o,a,s){return d(e+(t&i|r&~i)+o+a|0,s)+n|0}function g(e,t,r,i,n,o,a,s){return d(e+(t^(r|~i))+o+a|0,s)+n|0}e(i,r),i.prototype._update=function(){for(var e=new Array(16),t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,i=this._b,n=this._c,o=this._d,a=this._e;a=p(a,r=p(r,i,n,o,a,e[0],0,11),i,n=d(n,10),o,e[1],0,14),i=p(i=d(i,10),n=p(n,o=p(o,a,r,i,n,e[2],0,15),a,r=d(r,10),i,e[3],0,12),o,a=d(a,10),r,e[4],0,5),o=p(o=d(o,10),a=p(a,r=p(r,i,n,o,a,e[5],0,8),i,n=d(n,10),o,e[6],0,7),r,i=d(i,10),n,e[7],0,9),r=p(r=d(r,10),i=p(i,n=p(n,o,a,r,i,e[8],0,11),o,a=d(a,10),r,e[9],0,13),n,o=d(o,10),a,e[10],0,14),n=p(n=d(n,10),o=p(o,a=p(a,r,i,n,o,e[11],0,15),r,i=d(i,10),n,e[12],0,6),a,r=d(r,10),i,e[13],0,7),a=m(a=d(a,10),r=p(r,i=p(i,n,o,a,r,e[14],0,9),n,o=d(o,10),a,e[15],0,8),i,n=d(n,10),o,e[7],1518500249,7),i=m(i=d(i,10),n=m(n,o=m(o,a,r,i,n,e[4],1518500249,6),a,r=d(r,10),i,e[13],1518500249,8),o,a=d(a,10),r,e[1],1518500249,13),o=m(o=d(o,10),a=m(a,r=m(r,i,n,o,a,e[10],1518500249,11),i,n=d(n,10),o,e[6],1518500249,9),r,i=d(i,10),n,e[15],1518500249,7),r=m(r=d(r,10),i=m(i,n=m(n,o,a,r,i,e[3],1518500249,15),o,a=d(a,10),r,e[12],1518500249,7),n,o=d(o,10),a,e[0],1518500249,12),n=m(n=d(n,10),o=m(o,a=m(a,r,i,n,o,e[9],1518500249,15),r,i=d(i,10),n,e[5],1518500249,9),a,r=d(r,10),i,e[2],1518500249,11),a=m(a=d(a,10),r=m(r,i=m(i,n,o,a,r,e[14],1518500249,7),n,o=d(o,10),a,e[11],1518500249,13),i,n=d(n,10),o,e[8],1518500249,12),i=v(i=d(i,10),n=v(n,o=v(o,a,r,i,n,e[3],1859775393,11),a,r=d(r,10),i,e[10],1859775393,13),o,a=d(a,10),r,e[14],1859775393,6),o=v(o=d(o,10),a=v(a,r=v(r,i,n,o,a,e[4],1859775393,7),i,n=d(n,10),o,e[9],1859775393,14),r,i=d(i,10),n,e[15],1859775393,9),r=v(r=d(r,10),i=v(i,n=v(n,o,a,r,i,e[8],1859775393,13),o,a=d(a,10),r,e[1],1859775393,15),n,o=d(o,10),a,e[2],1859775393,14),n=v(n=d(n,10),o=v(o,a=v(a,r,i,n,o,e[7],1859775393,8),r,i=d(i,10),n,e[0],1859775393,13),a,r=d(r,10),i,e[6],1859775393,6),a=v(a=d(a,10),r=v(r,i=v(i,n,o,a,r,e[13],1859775393,5),n,o=d(o,10),a,e[11],1859775393,12),i,n=d(n,10),o,e[5],1859775393,7),i=b(i=d(i,10),n=b(n,o=v(o,a,r,i,n,e[12],1859775393,5),a,r=d(r,10),i,e[1],2400959708,11),o,a=d(a,10),r,e[9],2400959708,12),o=b(o=d(o,10),a=b(a,r=b(r,i,n,o,a,e[11],2400959708,14),i,n=d(n,10),o,e[10],2400959708,15),r,i=d(i,10),n,e[0],2400959708,14),r=b(r=d(r,10),i=b(i,n=b(n,o,a,r,i,e[8],2400959708,15),o,a=d(a,10),r,e[12],2400959708,9),n,o=d(o,10),a,e[4],2400959708,8),n=b(n=d(n,10),o=b(o,a=b(a,r,i,n,o,e[13],2400959708,9),r,i=d(i,10),n,e[3],2400959708,14),a,r=d(r,10),i,e[7],2400959708,5),a=b(a=d(a,10),r=b(r,i=b(i,n,o,a,r,e[15],2400959708,6),n,o=d(o,10),a,e[14],2400959708,8),i,n=d(n,10),o,e[5],2400959708,6),i=g(i=d(i,10),n=b(n,o=b(o,a,r,i,n,e[6],2400959708,5),a,r=d(r,10),i,e[2],2400959708,12),o,a=d(a,10),r,e[4],2840853838,9),o=g(o=d(o,10),a=g(a,r=g(r,i,n,o,a,e[0],2840853838,15),i,n=d(n,10),o,e[5],2840853838,5),r,i=d(i,10),n,e[9],2840853838,11),r=g(r=d(r,10),i=g(i,n=g(n,o,a,r,i,e[7],2840853838,6),o,a=d(a,10),r,e[12],2840853838,8),n,o=d(o,10),a,e[2],2840853838,13),n=g(n=d(n,10),o=g(o,a=g(a,r,i,n,o,e[10],2840853838,12),r,i=d(i,10),n,e[14],2840853838,5),a,r=d(r,10),i,e[1],2840853838,12),a=g(a=d(a,10),r=g(r,i=g(i,n,o,a,r,e[3],2840853838,13),n,o=d(o,10),a,e[8],2840853838,14),i,n=d(n,10),o,e[11],2840853838,11),i=g(i=d(i,10),n=g(n,o=g(o,a,r,i,n,e[6],2840853838,8),a,r=d(r,10),i,e[15],2840853838,5),o,a=d(a,10),r,e[13],2840853838,6),o=d(o,10);var s=this._a,u=this._b,h=this._c,c=this._d,f=this._e;f=g(f,s=g(s,u,h,c,f,e[5],1352829926,8),u,h=d(h,10),c,e[14],1352829926,9),u=g(u=d(u,10),h=g(h,c=g(c,f,s,u,h,e[7],1352829926,9),f,s=d(s,10),u,e[0],1352829926,11),c,f=d(f,10),s,e[9],1352829926,13),c=g(c=d(c,10),f=g(f,s=g(s,u,h,c,f,e[2],1352829926,15),u,h=d(h,10),c,e[11],1352829926,15),s,u=d(u,10),h,e[4],1352829926,5),s=g(s=d(s,10),u=g(u,h=g(h,c,f,s,u,e[13],1352829926,7),c,f=d(f,10),s,e[6],1352829926,7),h,c=d(c,10),f,e[15],1352829926,8),h=g(h=d(h,10),c=g(c,f=g(f,s,u,h,c,e[8],1352829926,11),s,u=d(u,10),h,e[1],1352829926,14),f,s=d(s,10),u,e[10],1352829926,14),f=b(f=d(f,10),s=g(s,u=g(u,h,c,f,s,e[3],1352829926,12),h,c=d(c,10),f,e[12],1352829926,6),u,h=d(h,10),c,e[6],1548603684,9),u=b(u=d(u,10),h=b(h,c=b(c,f,s,u,h,e[11],1548603684,13),f,s=d(s,10),u,e[3],1548603684,15),c,f=d(f,10),s,e[7],1548603684,7),c=b(c=d(c,10),f=b(f,s=b(s,u,h,c,f,e[0],1548603684,12),u,h=d(h,10),c,e[13],1548603684,8),s,u=d(u,10),h,e[5],1548603684,9),s=b(s=d(s,10),u=b(u,h=b(h,c,f,s,u,e[10],1548603684,11),c,f=d(f,10),s,e[14],1548603684,7),h,c=d(c,10),f,e[15],1548603684,7),h=b(h=d(h,10),c=b(c,f=b(f,s,u,h,c,e[8],1548603684,12),s,u=d(u,10),h,e[12],1548603684,7),f,s=d(s,10),u,e[4],1548603684,6),f=b(f=d(f,10),s=b(s,u=b(u,h,c,f,s,e[9],1548603684,15),h,c=d(c,10),f,e[1],1548603684,13),u,h=d(h,10),c,e[2],1548603684,11),u=v(u=d(u,10),h=v(h,c=v(c,f,s,u,h,e[15],1836072691,9),f,s=d(s,10),u,e[5],1836072691,7),c,f=d(f,10),s,e[1],1836072691,15),c=v(c=d(c,10),f=v(f,s=v(s,u,h,c,f,e[3],1836072691,11),u,h=d(h,10),c,e[7],1836072691,8),s,u=d(u,10),h,e[14],1836072691,6),s=v(s=d(s,10),u=v(u,h=v(h,c,f,s,u,e[6],1836072691,6),c,f=d(f,10),s,e[9],1836072691,14),h,c=d(c,10),f,e[11],1836072691,12),h=v(h=d(h,10),c=v(c,f=v(f,s,u,h,c,e[8],1836072691,13),s,u=d(u,10),h,e[12],1836072691,5),f,s=d(s,10),u,e[2],1836072691,14),f=v(f=d(f,10),s=v(s,u=v(u,h,c,f,s,e[10],1836072691,13),h,c=d(c,10),f,e[0],1836072691,13),u,h=d(h,10),c,e[4],1836072691,7),u=m(u=d(u,10),h=m(h,c=v(c,f,s,u,h,e[13],1836072691,5),f,s=d(s,10),u,e[8],2053994217,15),c,f=d(f,10),s,e[6],2053994217,5),c=m(c=d(c,10),f=m(f,s=m(s,u,h,c,f,e[4],2053994217,8),u,h=d(h,10),c,e[1],2053994217,11),s,u=d(u,10),h,e[3],2053994217,14),s=m(s=d(s,10),u=m(u,h=m(h,c,f,s,u,e[11],2053994217,14),c,f=d(f,10),s,e[15],2053994217,6),h,c=d(c,10),f,e[0],2053994217,14),h=m(h=d(h,10),c=m(c,f=m(f,s,u,h,c,e[5],2053994217,6),s,u=d(u,10),h,e[12],2053994217,9),f,s=d(s,10),u,e[2],2053994217,12),f=m(f=d(f,10),s=m(s,u=m(u,h,c,f,s,e[13],2053994217,9),h,c=d(c,10),f,e[9],2053994217,12),u,h=d(h,10),c,e[7],2053994217,5),u=p(u=d(u,10),h=m(h,c=m(c,f,s,u,h,e[10],2053994217,15),f,s=d(s,10),u,e[14],2053994217,8),c,f=d(f,10),s,e[12],0,8),c=p(c=d(c,10),f=p(f,s=p(s,u,h,c,f,e[15],0,5),u,h=d(h,10),c,e[10],0,12),s,u=d(u,10),h,e[4],0,9),s=p(s=d(s,10),u=p(u,h=p(h,c,f,s,u,e[1],0,12),c,f=d(f,10),s,e[5],0,5),h,c=d(c,10),f,e[8],0,14),h=p(h=d(h,10),c=p(c,f=p(f,s,u,h,c,e[7],0,6),s,u=d(u,10),h,e[6],0,8),f,s=d(s,10),u,e[2],0,13),f=p(f=d(f,10),s=p(s,u=p(u,h,c,f,s,e[13],0,6),h,c=d(c,10),f,e[14],0,5),u,h=d(h,10),c,e[0],0,15),u=p(u=d(u,10),h=p(h,c=p(c,f,s,u,h,e[3],0,13),f,s=d(s,10),u,e[9],0,11),c,f=d(f,10),s,e[11],0,11),c=d(c,10);var l=this._b+n+c|0;this._b=this._c+o+f|0,this._c=this._d+a+s|0,this._d=this._e+r+u|0,this._e=this._a+i+h|0,this._a=l},i.prototype._digest=function(){this._block[this._blockOffset++]=128,56=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=4294967295&r,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":143}],145:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":146,"./sha1":147,"./sha224":148,"./sha256":149,"./sha384":150,"./sha512":151}],146:[function(e,t,r){var i=e("inherits"),n=e("./hash"),o=e("safe-buffer").Buffer,b=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function s(){this.init(),this._w=a,n.call(this,64,56)}i(s,n),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,r,i,n,o,a,s=this._w,u=0|this._a,h=0|this._b,c=0|this._c,f=0|this._d,l=0|this._e,d=0;d<16;++d)s[d]=e.readInt32BE(4*d);for(;d<80;++d)s[d]=s[d-3]^s[d-8]^s[d-14]^s[d-16];for(var p=0;p<80;++p){var m=~~(p/20),v=0|((a=u)<<5|a>>>27)+(i=h,n=c,o=f,0===(r=m)?i&n|~i&o:2===r?i&n|i&o|n&o:i^n^o)+l+s[p]+b[m];l=f,f=c,c=(t=h)<<30|t>>>2,h=u,u=v}this._a=u+this._a|0,this._b=h+this._b|0,this._c=c+this._c|0,this._d=f+this._d|0,this._e=l+this._e|0},s.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=s},{"./hash":144,inherits:103,"safe-buffer":143}],147:[function(e,t,r){var i=e("inherits"),n=e("./hash"),o=e("safe-buffer").Buffer,g=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function s(){this.init(),this._w=a,n.call(this,64,56)}i(s,n),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,r,i,n,o,a,s,u=this._w,h=0|this._a,c=0|this._b,f=0|this._c,l=0|this._d,d=0|this._e,p=0;p<16;++p)u[p]=e.readInt32BE(4*p);for(;p<80;++p)u[p]=(t=u[p-3]^u[p-8]^u[p-14]^u[p-16])<<1|t>>>31;for(var m=0;m<80;++m){var v=~~(m/20),b=0|((s=h)<<5|s>>>27)+(n=c,o=f,a=l,0===(i=v)?n&o|~n&a:2===i?n&o|n&a|o&a:n^o^a)+d+u[m]+g[v];d=l,l=f,f=(r=c)<<30|r>>>2,c=h,h=b}this._a=h+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=l+this._d|0,this._e=d+this._e|0},s.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=s},{"./hash":144,inherits:103,"safe-buffer":143}],148:[function(e,t,r){var i=e("inherits"),n=e("./sha256"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}i(u,n),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=u},{"./hash":144,"./sha256":149,inherits:103,"safe-buffer":143}],149:[function(e,t,r){var i=e("inherits"),n=e("./hash"),o=e("safe-buffer").Buffer,w=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function s(){this.init(),this._w=a,n.call(this,64,56)}i(s,n),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(e){for(var t,r,i,n,o,a,s,u=this._w,h=0|this._a,c=0|this._b,f=0|this._c,l=0|this._d,d=0|this._e,p=0|this._f,m=0|this._g,v=0|this._h,b=0;b<16;++b)u[b]=e.readInt32BE(4*b);for(;b<64;++b)u[b]=0|(((r=u[b-2])>>>17|r<<15)^(r>>>19|r<<13)^r>>>10)+u[b-7]+(((t=u[b-15])>>>7|t<<25)^(t>>>18|t<<14)^t>>>3)+u[b-16];for(var g=0;g<64;++g){var y=v+(((s=d)>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7))+((a=m)^d&(p^a))+w[g]+u[g]|0,_=0|(((o=h)>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10))+((i=h)&(n=c)|f&(i|n));v=m,m=p,p=d,d=l+y|0,l=f,f=c,c=h,h=y+_|0}this._a=h+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=l+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=m+this._g|0,this._h=v+this._h|0},s.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=s},{"./hash":144,inherits:103,"safe-buffer":143}],150:[function(e,t,r){var i=e("inherits"),n=e("./sha512"),o=e("./hash"),a=e("safe-buffer").Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}i(u,n),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var i=a.allocUnsafe(48);function e(e,t,r){i.writeInt32BE(e,r),i.writeInt32BE(t,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),i},t.exports=u},{"./hash":144,"./sha512":151,inherits:103,"safe-buffer":143}],151:[function(e,t,r){var i=e("inherits"),n=e("./hash"),o=e("safe-buffer").Buffer,ee=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function s(){this.init(),this._w=a,n.call(this,128,112)}function te(e,t,r){return r^e&(t^r)}function re(e,t,r){return e&t|r&(e|t)}function ie(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function ne(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function oe(e,t){return e>>>0>>0?1:0}i(s,n),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(e){for(var t,r,i,n,o,a,s,u,h=this._w,c=0|this._ah,f=0|this._bh,l=0|this._ch,d=0|this._dh,p=0|this._eh,m=0|this._fh,v=0|this._gh,b=0|this._hh,g=0|this._al,y=0|this._bl,_=0|this._cl,w=0|this._dl,x=0|this._el,T=0|this._fl,S=0|this._gl,E=0|this._hl,A=0;A<32;A+=2)h[A]=e.readInt32BE(4*A),h[A+1]=e.readInt32BE(4*A+4);for(;A<160;A+=2){var P=h[A-30],M=h[A-30+1],C=((s=P)>>>1|(u=M)<<31)^(s>>>8|u<<24)^s>>>7,k=((o=M)>>>1|(a=P)<<31)^(o>>>8|a<<24)^(o>>>7|a<<25);P=h[A-4],M=h[A-4+1];var I=((i=P)>>>19|(n=M)<<13)^(n>>>29|i<<3)^i>>>6,R=((t=M)>>>19|(r=P)<<13)^(r>>>29|t<<3)^(t>>>6|r<<26),O=h[A-14],D=h[A-14+1],L=h[A-32],F=h[A-32+1],j=k+D|0,B=C+O+oe(j,k)|0;B=(B=B+I+oe(j=j+R|0,R)|0)+L+oe(j=j+F|0,F)|0,h[A]=B,h[A+1]=j}for(var N=0;N<160;N+=2){B=h[N],j=h[N+1];var U=re(c,f,l),z=re(g,y,_),X=ie(c,g),q=ie(g,c),H=ne(p,x),G=ne(x,p),V=ee[N],Y=ee[N+1],W=te(p,m,v),J=te(x,T,S),K=E+G|0,Z=b+H+oe(K,E)|0;Z=(Z=(Z=Z+W+oe(K=K+J|0,J)|0)+V+oe(K=K+Y|0,Y)|0)+B+oe(K=K+j|0,j)|0;var Q=q+z|0,$=X+U+oe(Q,q)|0;b=v,E=S,v=m,S=T,m=p,T=x,p=d+Z+oe(x=w+K|0,w)|0,d=l,w=_,l=f,_=y,f=c,y=g,c=Z+$+oe(g=K+Q|0,K)|0}this._al=this._al+g|0,this._bl=this._bl+y|0,this._cl=this._cl+_|0,this._dl=this._dl+w|0,this._el=this._el+x|0,this._fl=this._fl+T|0,this._gl=this._gl+S|0,this._hl=this._hl+E|0,this._ah=this._ah+c+oe(this._al,g)|0,this._bh=this._bh+f+oe(this._bl,y)|0,this._ch=this._ch+l+oe(this._cl,_)|0,this._dh=this._dh+d+oe(this._dl,w)|0,this._eh=this._eh+p+oe(this._el,x)|0,this._fh=this._fh+m+oe(this._fl,T)|0,this._gh=this._gh+v+oe(this._gl,S)|0,this._hh=this._hh+b+oe(this._hl,E)|0},s.prototype._hash=function(){var i=o.allocUnsafe(64);function e(e,t,r){i.writeInt32BE(e,r),i.writeInt32BE(t,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),i},t.exports=s},{"./hash":144,inherits:103,"safe-buffer":143}],152:[function(e,t,r){t.exports=i;var c=e("events").EventEmitter;function i(){c.call(this)}e("inherits")(i,c),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),(i.Stream=i).prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function n(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",n),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",s));var o=!1;function a(){o||(o=!0,t.end())}function s(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function u(e){if(h(),0===c.listenerCount(this,"error"))throw e}function h(){r.removeListener("data",i),t.removeListener("drain",n),r.removeListener("end",a),r.removeListener("close",s),r.removeListener("error",u),t.removeListener("error",u),r.removeListener("end",h),r.removeListener("close",h),t.removeListener("close",h)}return r.on("error",u),t.on("error",u),r.on("end",h),r.on("close",h),t.on("close",h),t.emit("pipe",r),t}},{events:85,inherits:103,"readable-stream/duplex.js":132,"readable-stream/passthrough.js":138,"readable-stream/readable.js":139,"readable-stream/transform.js":140,"readable-stream/writable.js":141}],153:[function(e,t,r){var i=e("buffer").Buffer,n=i.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};var o=r.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!n(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=s;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=u;break;default:return void(this.write=a)}this.charBuffer=new i(6),this.charReceived=0,this.charLength=0};function a(e){return e.toString(this.encoding)}function s(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function u(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}o.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},o.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,i=this.charBuffer,n=this.encoding;t+=i.slice(0,r).toString(n)}return t}},{buffer:49}],154:[function(e,t,r){(function(r){function i(e){try{if(!r.localStorage)return!1}catch(e){return!1}var t=r.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}t.exports=function(e,t){if(i("noDeprecation"))return e;var r=!1;return function(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],155:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r>2)*(r+3>>2)*8;case p:case m:case c:case v:return(t+3>>2)*(r+3>>2)*16;case ne:case ae:return Math.floor((Math.max(t,8)*Math.max(r,8)*4+7)/8);case oe:case se:return Math.floor((Math.max(t,16)*Math.max(r,8)*2+7)/8);case b:case n:return Math.floor((t+3)/4)*Math.floor((r+3)/4)*16;case g:case o:return Math.floor((t+4)/5)*Math.floor((r+3)/4)*16;case y:case a:return Math.floor((t+4)/5)*Math.floor((r+4)/5)*16;case _:case s:return Math.floor((t+5)/6)*Math.floor((r+4)/5)*16;case w:case u:return Math.floor((t+5)/6)*Math.floor((r+5)/6)*16;case x:case I:return Math.floor((t+7)/8)*Math.floor((r+4)/5)*16;case T:case R:return Math.floor((t+7)/8)*Math.floor((r+5)/6)*16;case S:case O:return Math.floor((t+7)/8)*Math.floor((r+7)/8)*16;case E:case D:return Math.floor((t+9)/10)*Math.floor((r+4)/5)*16;case A:case L:return Math.floor((t+9)/10)*Math.floor((r+5)/6)*16;case P:case F:return Math.floor((t+9)/10)*Math.floor((r+7)/8)*16;case M:case j:return Math.floor((t+9)/10)*Math.floor((r+9)/10)*16;case C:case B:return Math.floor((t+11)/12)*Math.floor((r+9)/10)*16;case k:case N:return Math.floor((t+11)/12)*Math.floor((r+11)/12)*16;default:return 0}}(t.exports=f).prototype.init=function(e,t,r,i,n,o,a,s){this.src=e,this.width=i,this.height=n,this.data=t,this.type=r,this.levels=o,this.internalFormat=a,this.isCompressedImage=!0,this.crunch=s,this.preserveSource=!0;var u=this.complete;return this.complete=!!t,!u&&this.complete&&this.onload&&this.onload({target:this}),this},f.prototype.dispose=function(){this.data=null},f.prototype.generateWebGLTexture=function(e){if(null===this.data)throw"Trying to create a second (or more) webgl texture from the same CompressedImage : "+this.src;for(var t=this.width,r=this.height,i=this.levels,n=0,o=0;o>=1)<1&&(t=1),(r>>=1)<1&&(r=1),n+=a}1>8&255,e>>16&255,e>>24&255)}(i)}var n=1;t[V]&z&&(n=Math.max(1,t[J]));var o=t[W],a=t[Y],s=t[G]+4,u=new Uint8Array(e,s);return this.init(this.src,u,"DDS",o,a,n,r)},f.prototype._loadASTC=function(e){var t=new Int8Array(e,0,Ee);if(new Uint32Array(e.slice(0,4))!=Ae)throw"Invalid magic number in ASTC header";for(var r=[b,g,y,_,w,x,T,S,E,A,P,M,C,k],i=e.byteLength-Ee,n=new Uint8Array([t[7],t[8],t[9],0]),o=new Uint8Array([t[10],t[11],t[12],0]),a=new Uint32Array(n.buffer)[0],s=new Uint32Array(o.buffer)[0],u=0,h=0;h 0.0) {\n c.rgb /= c.a;\n\n vec3 rgb = pow(c.rgb, vec3(1. / gamma));\n rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast);\n rgb.r *= red;\n rgb.g *= green;\n rgb.b *= blue;\n c.rgb = rgb * brightness;\n\n c.rgb *= c.a;\n }\n\n gl_FragColor = c * alpha;\n}\n"),Object.assign(this,{gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},e)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.gamma=Math.max(this.gamma,1e-4),this.uniforms.saturation=this.saturation,this.uniforms.contrast=this.contrast,this.uniforms.brightness=this.brightness,this.uniforms.red=this.red,this.uniforms.green=this.green,this.uniforms.blue=this.blue,this.uniforms.alpha=this.alpha,e.applyFilter(this,t,r,i)},e}(l.Filter),d=function(i){function e(e,t,r){void 0===e&&(e=4),void 0===t&&(t=3),void 0===r&&(r=!1),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r?"\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 uOffset;\nuniform vec4 filterClamp;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample top right pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample bottom right pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample bottom left pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Average\n color *= 0.25;\n\n gl_FragColor = color;\n}\n":"\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 uOffset;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample top right pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample bottom right pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Sample bottom left pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Average\n color *= 0.25;\n\n gl_FragColor = color;\n}"),this.uniforms.uOffset=new Float32Array(2),this._pixelSize=new l.Point,this.pixelSize=1,this._clamp=r,this._kernels=null,Array.isArray(e)?this.kernels=e:(this._blur=e,this.quality=t)}i&&(e.__proto__=i);var t={kernels:{configurable:!0},clamp:{configurable:!0},pixelSize:{configurable:!0},quality:{configurable:!0},blur:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){var n,o=this.pixelSize.x/t.size.width,a=this.pixelSize.y/t.size.height;if(1===this._quality||0===this._blur)n=this._kernels[0]+.5,this.uniforms.uOffset[0]=n*o,this.uniforms.uOffset[1]=n*a,e.applyFilter(this,t,r,i);else{for(var s,u=e.getRenderTarget(!0),h=t,c=u,f=this._quality-1,l=0;l threshold) {\n gl_FragColor = color;\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n}\n"),this.threshold=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={threshold:{configurable:!0}};return r.threshold.get=function(){return this.uniforms.threshold},r.threshold.set=function(e){this.uniforms.threshold=e},Object.defineProperties(e.prototype,r),e}(l.Filter),i=function(a){function e(e){a.call(this,s,"uniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D bloomTexture;\nuniform float bloomScale;\nuniform float brightness;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n color.rgb *= brightness;\n vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0);\n bloomColor.rgb *= bloomScale;\n gl_FragColor = color + bloomColor;\n}\n"),"number"==typeof e&&(e={threshold:e}),e=Object.assign({threshold:.5,bloomScale:1,brightness:1,kernels:null,blur:8,quality:4,pixelSize:1,resolution:l.settings.RESOLUTION},e),this.bloomScale=e.bloomScale,this.brightness=e.brightness;var t=e.kernels,r=e.blur,i=e.quality,n=e.pixelSize,o=e.resolution;this._extractFilter=new u(e.threshold),this._extractFilter.resolution=o,this._blurFilter=t?new d(t):new d(r,i),this.pixelSize=n,this.resolution=o}a&&(e.__proto__=a);var t={resolution:{configurable:!0},threshold:{configurable:!0},kernels:{configurable:!0},blur:{configurable:!0},quality:{configurable:!0},pixelSize:{configurable:!0}};return((e.prototype=Object.create(a&&a.prototype)).constructor=e).prototype.apply=function(e,t,r,i,n){var o=e.getRenderTarget(!0);this._extractFilter.apply(e,t,o,!0,n);var a=e.getRenderTarget(!0);this._blurFilter.apply(e,o,a,!0,n),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=a,e.applyFilter(this,t,r,i),e.returnRenderTarget(a),e.returnRenderTarget(o)},t.resolution.get=function(){return this._resolution},t.resolution.set=function(e){this._resolution=e,this._extractFilter&&(this._extractFilter.resolution=e),this._blurFilter&&(this._blurFilter.resolution=e)},t.threshold.get=function(){return this._extractFilter.threshold},t.threshold.set=function(e){this._extractFilter.threshold=e},t.kernels.get=function(){return this._blurFilter.kernels},t.kernels.set=function(e){this._blurFilter.kernels=e},t.blur.get=function(){return this._blurFilter.blur},t.blur.set=function(e){this._blurFilter.blur=e},t.quality.get=function(){return this._blurFilter.quality},t.quality.set=function(e){this._blurFilter.quality=e},t.pixelSize.get=function(){return this._blurFilter.pixelSize},t.pixelSize.set=function(e){this._blurFilter.pixelSize=e},Object.defineProperties(e.prototype,t),e}(l.Filter),n=function(t){function e(e){void 0===e&&(e=8),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\n\nuniform vec4 filterArea;\nuniform float pixelSize;\nuniform sampler2D uSampler;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 pixelate(vec2 coord, vec2 size)\n{\n return floor( coord / size ) * size;\n}\n\nvec2 getMod(vec2 coord, vec2 size)\n{\n return mod( coord , size) / size;\n}\n\nfloat character(float n, vec2 p)\n{\n p = floor(p*vec2(4.0, -4.0) + 2.5);\n\n if (clamp(p.x, 0.0, 4.0) == p.x)\n {\n if (clamp(p.y, 0.0, 4.0) == p.y)\n {\n if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0;\n }\n }\n return 0.0;\n}\n\nvoid main()\n{\n vec2 coord = mapCoord(vTextureCoord);\n\n // get the rounded color..\n vec2 pixCoord = pixelate(coord, vec2(pixelSize));\n pixCoord = unmapCoord(pixCoord);\n\n vec4 color = texture2D(uSampler, pixCoord);\n\n // determine the character to use\n float gray = (color.r + color.g + color.b) / 3.0;\n\n float n = 65536.0; // .\n if (gray > 0.2) n = 65600.0; // :\n if (gray > 0.3) n = 332772.0; // *\n if (gray > 0.4) n = 15255086.0; // o\n if (gray > 0.5) n = 23385164.0; // &\n if (gray > 0.6) n = 15252014.0; // 8\n if (gray > 0.7) n = 13199452.0; // @\n if (gray > 0.8) n = 11512810.0; // #\n\n // get the mod..\n vec2 modd = getMod(coord, vec2(pixelSize));\n\n gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0);\n\n}\n"),this.size=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={size:{configurable:!0}};return r.size.get=function(){return this.uniforms.pixelSize},r.size.set=function(e){this.uniforms.pixelSize=e},Object.defineProperties(e.prototype,r),e}(l.Filter),o=function(t){function e(e){void 0===e&&(e={}),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform float transformX;\nuniform float transformY;\nuniform vec3 lightColor;\nuniform float lightAlpha;\nuniform vec3 shadowColor;\nuniform float shadowAlpha;\n\nvoid main(void) {\n vec2 transform = vec2(1.0 / filterArea) * vec2(transformX, transformY);\n vec4 color = texture2D(uSampler, vTextureCoord);\n float light = texture2D(uSampler, vTextureCoord - transform).a;\n float shadow = texture2D(uSampler, vTextureCoord + transform).a;\n\n color.rgb = mix(color.rgb, lightColor, clamp((color.a - light) * lightAlpha, 0.0, 1.0));\n color.rgb = mix(color.rgb, shadowColor, clamp((color.a - shadow) * shadowAlpha, 0.0, 1.0));\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"),this.uniforms.lightColor=new Float32Array(3),this.uniforms.shadowColor=new Float32Array(3),e=Object.assign({rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7},e),this.rotation=e.rotation,this.thickness=e.thickness,this.lightColor=e.lightColor,this.lightAlpha=e.lightAlpha,this.shadowColor=e.shadowColor,this.shadowAlpha=e.shadowAlpha}t&&(e.__proto__=t);var r={rotation:{configurable:!0},thickness:{configurable:!0},lightColor:{configurable:!0},lightAlpha:{configurable:!0},shadowColor:{configurable:!0},shadowAlpha:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._updateTransform=function(){this.uniforms.transformX=this._thickness*Math.cos(this._angle),this.uniforms.transformY=this._thickness*Math.sin(this._angle)},r.rotation.get=function(){return this._angle/l.DEG_TO_RAD},r.rotation.set=function(e){this._angle=e*l.DEG_TO_RAD,this._updateTransform()},r.thickness.get=function(){return this._thickness},r.thickness.set=function(e){this._thickness=e,this._updateTransform()},r.lightColor.get=function(){return l.utils.rgb2hex(this.uniforms.lightColor)},r.lightColor.set=function(e){l.utils.hex2rgb(e,this.uniforms.lightColor)},r.lightAlpha.get=function(){return this.uniforms.lightAlpha},r.lightAlpha.set=function(e){this.uniforms.lightAlpha=e},r.shadowColor.get=function(){return l.utils.rgb2hex(this.uniforms.shadowColor)},r.shadowColor.set=function(e){l.utils.hex2rgb(e,this.uniforms.shadowColor)},r.shadowAlpha.get=function(){return this.uniforms.shadowAlpha},r.shadowAlpha.set=function(e){this.uniforms.shadowAlpha=e},Object.defineProperties(e.prototype,r),e}(l.Filter),a=l.filters,h=a.BlurXFilter,c=a.BlurYFilter,f=a.AlphaFilter,p=function(a){function e(e,t,r,i){var n,o;void 0===e&&(e=2),void 0===t&&(t=4),void 0===r&&(r=l.settings.RESOLUTION),void 0===i&&(i=5),a.call(this),"number"==typeof e?o=n=e:e instanceof l.Point?(n=e.x,o=e.y):Array.isArray(e)&&(n=e[0],o=e[1]),this.blurXFilter=new h(n,t,r,i),this.blurYFilter=new c(o,t,r,i),this.blurYFilter.blendMode=l.BLEND_MODES.SCREEN,this.defaultFilter=new f}a&&(e.__proto__=a);var t={blur:{configurable:!0},blurX:{configurable:!0},blurY:{configurable:!0}};return((e.prototype=Object.create(a&&a.prototype)).constructor=e).prototype.apply=function(e,t,r){var i=e.getRenderTarget(!0);this.defaultFilter.apply(e,t,r),this.blurXFilter.apply(e,t,i),this.blurYFilter.apply(e,i,r),e.returnRenderTarget(i)},t.blur.get=function(){return this.blurXFilter.blur},t.blur.set=function(e){this.blurXFilter.blur=this.blurYFilter.blur=e},t.blurX.get=function(){return this.blurXFilter.blur},t.blurX.set=function(e){this.blurXFilter.blur=e},t.blurY.get=function(){return this.blurYFilter.blur},t.blurY.set=function(e){this.blurYFilter.blur=e},Object.defineProperties(e.prototype,t),e}(l.Filter),m=function(i){function e(e,t,r){i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","uniform float radius;\nuniform float strength;\nuniform vec2 center;\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\n\nvoid main()\n{\n vec2 coord = vTextureCoord * filterArea.xy;\n coord -= center * dimensions.xy;\n float distance = length(coord);\n if (distance < radius) {\n float percent = distance / radius;\n if (strength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);\n }\n }\n coord += center * dimensions.xy;\n coord /= filterArea.xy;\n vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw);\n vec4 color = texture2D(uSampler, clampedCoord);\n if (coord != clampedCoord) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n gl_FragColor = color;\n}\n"),this.uniforms.dimensions=new Float32Array(2),this.center=e||[.5,.5],this.radius="number"==typeof t?t:100,this.strength="number"==typeof r?r:1}i&&(e.__proto__=i);var t={radius:{configurable:!0},strength:{configurable:!0},center:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,e.applyFilter(this,t,r,i)},t.radius.get=function(){return this.uniforms.radius},t.radius.set=function(e){this.uniforms.radius=e},t.strength.get=function(){return this.uniforms.strength},t.strength.set=function(e){this.uniforms.strength=e},t.center.get=function(){return this.uniforms.center},t.center.set=function(e){this.uniforms.center=e},Object.defineProperties(e.prototype,t),e}(l.Filter),v=function(i){function e(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=1),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform sampler2D colorMap;\nuniform float _mix;\nuniform float _size;\nuniform float _sliceSize;\nuniform float _slicePixelSize;\nuniform float _sliceInnerSize;\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord.xy);\n\n vec4 adjusted;\n if (color.a > 0.0) {\n color.rgb /= color.a;\n float innerWidth = _size - 1.0;\n float zSlice0 = min(floor(color.b * innerWidth), innerWidth);\n float zSlice1 = min(zSlice0 + 1.0, innerWidth);\n float xOffset = _slicePixelSize * 0.5 + color.r * _sliceInnerSize;\n float s0 = xOffset + (zSlice0 * _sliceSize);\n float s1 = xOffset + (zSlice1 * _sliceSize);\n float yOffset = _sliceSize * 0.5 + color.g * (1.0 - _sliceSize);\n vec4 slice0Color = texture2D(colorMap, vec2(s0,yOffset));\n vec4 slice1Color = texture2D(colorMap, vec2(s1,yOffset));\n float zOffset = fract(color.b * innerWidth);\n adjusted = mix(slice0Color, slice1Color, zOffset);\n\n color.rgb *= color.a;\n }\n gl_FragColor = vec4(mix(color, adjusted, _mix).rgb, color.a);\n\n}"),this._size=0,this._sliceSize=0,this._slicePixelSize=0,this._sliceInnerSize=0,this._scaleMode=null,this._nearest=!1,this.nearest=t,this.mix=r,this.colorMap=e}i&&(e.__proto__=i);var t={colorSize:{configurable:!0},colorMap:{configurable:!0},nearest:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms._mix=this.mix,e.applyFilter(this,t,r,i)},t.colorSize.get=function(){return this._size},t.colorMap.get=function(){return this._colorMap},t.colorMap.set=function(e){e instanceof l.Texture||(e=l.Texture.from(e)),e&&e.baseTexture&&(e.baseTexture.scaleMode=this._scaleMode,e.baseTexture.mipmap=!1,this._size=e.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms._size=this._size,this.uniforms._sliceSize=this._sliceSize,this.uniforms._slicePixelSize=this._slicePixelSize,this.uniforms._sliceInnerSize=this._sliceInnerSize,this.uniforms.colorMap=e),this._colorMap=e},t.nearest.get=function(){return this._nearest},t.nearest.set=function(e){this._nearest=e,this._scaleMode=e?l.SCALE_MODES.NEAREST:l.SCALE_MODES.LINEAR;var t=this._colorMap;t&&t.baseTexture&&(t.baseTexture._glTextures={},t.baseTexture.scaleMode=this._scaleMode,t.baseTexture.mipmap=!1,t._updateID++,t.baseTexture.emit("update",t.baseTexture))},e.prototype.updateColorMap=function(){var e=this._colorMap;e&&e.baseTexture&&(e._updateID++,e.baseTexture.emit("update",e.baseTexture),this.colorMap=e)},e.prototype.destroy=function(e){this._colorMap&&this._colorMap.destroy(e),i.prototype.destroy.call(this)},Object.defineProperties(e.prototype,t),e}(l.Filter),b=function(i){function e(e,t,r){void 0===e&&(e=16711680),void 0===t&&(t=0),void 0===r&&(r=.4),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec3 originalColor;\nuniform vec3 newColor;\nuniform float epsilon;\nvoid main(void) {\n vec4 currentColor = texture2D(uSampler, vTextureCoord);\n vec3 colorDiff = originalColor - (currentColor.rgb / max(currentColor.a, 0.0000000001));\n float colorDistance = length(colorDiff);\n float doReplace = step(colorDistance, epsilon);\n gl_FragColor = vec4(mix(currentColor.rgb, (newColor + colorDiff) * currentColor.a, doReplace), currentColor.a);\n}\n"),this.uniforms.originalColor=new Float32Array(3),this.uniforms.newColor=new Float32Array(3),this.originalColor=e,this.newColor=t,this.epsilon=r}i&&(e.__proto__=i),(e.prototype=Object.create(i&&i.prototype)).constructor=e;var t={originalColor:{configurable:!0},newColor:{configurable:!0},epsilon:{configurable:!0}};return t.originalColor.set=function(e){var t=this.uniforms.originalColor;"number"==typeof e?(l.utils.hex2rgb(e,t),this._originalColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._originalColor=l.utils.rgb2hex(t))},t.originalColor.get=function(){return this._originalColor},t.newColor.set=function(e){var t=this.uniforms.newColor;"number"==typeof e?(l.utils.hex2rgb(e,t),this._newColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._newColor=l.utils.rgb2hex(t))},t.newColor.get=function(){return this._newColor},t.epsilon.set=function(e){this.uniforms.epsilon=e},t.epsilon.get=function(){return this.uniforms.epsilon},Object.defineProperties(e.prototype,t),e}(l.Filter),g=function(i){function e(e,t,r){void 0===t&&(t=200),void 0===r&&(r=200),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying mediump vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec2 texelSize;\nuniform float matrix[9];\n\nvoid main(void)\n{\n vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left\n vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center\n vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right\n\n vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left\n vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center\n vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right\n\n vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left\n vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center\n vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right\n\n gl_FragColor =\n c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] +\n c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] +\n c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8];\n\n gl_FragColor.a = c22.a;\n}\n"),this.uniforms.texelSize=new Float32Array(2),this.uniforms.matrix=new Float32Array(9),void 0!==e&&(this.matrix=e),this.width=t,this.height=r}i&&(e.__proto__=i),(e.prototype=Object.create(i&&i.prototype)).constructor=e;var t={matrix:{configurable:!0},width:{configurable:!0},height:{configurable:!0}};return t.matrix.get=function(){return this.uniforms.matrix},t.matrix.set=function(e){var r=this;e.forEach(function(e,t){return r.uniforms.matrix[t]=e})},t.width.get=function(){return 1/this.uniforms.texelSize[0]},t.width.set=function(e){this.uniforms.texelSize[0]=1/e},t.height.get=function(){return 1/this.uniforms.texelSize[1]},t.height.set=function(e){this.uniforms.texelSize[1]=1/e},Object.defineProperties(e.prototype,t),e}(l.Filter),y=function(e){function t(){e.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);\n\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n\n if (lum < 1.00)\n {\n if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.75)\n {\n if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.50)\n {\n if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.3)\n {\n if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n}\n")}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t}(l.Filter),_=function(t){function e(e){t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec2 dimensions;\n\nconst float SQRT_2 = 1.414213;\n\nconst float light = 1.0;\n\nuniform float curvature;\nuniform float lineWidth;\nuniform float lineContrast;\nuniform bool verticalLine;\nuniform float noise;\nuniform float noiseSize;\n\nuniform float vignetting;\nuniform float vignettingAlpha;\nuniform float vignettingBlur;\n\nuniform float seed;\nuniform float time;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main(void)\n{\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n vec2 coord = pixelCoord / dimensions;\n\n vec2 dir = vec2(coord - vec2(0.5, 0.5));\n\n float _c = curvature > 0. ? curvature : 1.;\n float k = curvature > 0. ?(length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.;\n vec2 uv = dir * k;\n\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n vec3 rgb = gl_FragColor.rgb;\n\n\n if (noise > 0.0 && noiseSize > 0.0)\n {\n pixelCoord.x = floor(pixelCoord.x / noiseSize);\n pixelCoord.y = floor(pixelCoord.y / noiseSize);\n float _noise = rand(pixelCoord * noiseSize * seed) - 0.5;\n rgb += _noise * noise;\n }\n\n if (lineWidth > 0.0) {\n float v = (verticalLine ? uv.x * dimensions.x : uv.y * dimensions.y) * min(1.0, 2.0 / lineWidth ) / _c;\n float j = 1. + cos(v * 1.2 - time) * 0.5 * lineContrast;\n rgb *= j;\n float segment = verticalLine ? mod((dir.x + .5) * dimensions.x, 4.) : mod((dir.y + .5) * dimensions.y, 4.);\n rgb *= 0.99 + ceil(segment) * 0.015;\n }\n\n if (vignetting > 0.0)\n {\n float outter = SQRT_2 - vignetting * SQRT_2;\n float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0);\n rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha);\n }\n\n gl_FragColor.rgb = rgb;\n}\n"),this.uniforms.dimensions=new Float32Array(2),this.time=0,this.seed=0,Object.assign(this,{curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,seed:0,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0},e)}t&&(e.__proto__=t);var r={curvature:{configurable:!0},lineWidth:{configurable:!0},lineContrast:{configurable:!0},verticalLine:{configurable:!0},noise:{configurable:!0},noiseSize:{configurable:!0},vignetting:{configurable:!0},vignettingAlpha:{configurable:!0},vignettingBlur:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,this.uniforms.seed=this.seed,this.uniforms.time=this.time,e.applyFilter(this,t,r,i)},r.curvature.set=function(e){this.uniforms.curvature=e},r.curvature.get=function(){return this.uniforms.curvature},r.lineWidth.set=function(e){this.uniforms.lineWidth=e},r.lineWidth.get=function(){return this.uniforms.lineWidth},r.lineContrast.set=function(e){this.uniforms.lineContrast=e},r.lineContrast.get=function(){return this.uniforms.lineContrast},r.verticalLine.set=function(e){this.uniforms.verticalLine=e},r.verticalLine.get=function(){return this.uniforms.verticalLine},r.noise.set=function(e){this.uniforms.noise=e},r.noise.get=function(){return this.uniforms.noise},r.noiseSize.set=function(e){this.uniforms.noiseSize=e},r.noiseSize.get=function(){return this.uniforms.noiseSize},r.vignetting.set=function(e){this.uniforms.vignetting=e},r.vignetting.get=function(){return this.uniforms.vignetting},r.vignettingAlpha.set=function(e){this.uniforms.vignettingAlpha=e},r.vignettingAlpha.get=function(){return this.uniforms.vignettingAlpha},r.vignettingBlur.set=function(e){this.uniforms.vignettingBlur=e},r.vignettingBlur.get=function(){return this.uniforms.vignettingBlur},Object.defineProperties(e.prototype,r),e}(l.Filter),w=function(r){function e(e,t){void 0===e&&(e=1),void 0===t&&(t=5),r.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec4 filterArea;\nuniform sampler2D uSampler;\n\nuniform float angle;\nuniform float scale;\n\nfloat pattern()\n{\n float s = sin(angle), c = cos(angle);\n vec2 tex = vTextureCoord * filterArea.xy;\n vec2 point = vec2(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float average = (color.r + color.g + color.b) / 3.0;\n gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);\n}\n"),this.scale=e,this.angle=t}r&&(e.__proto__=r),(e.prototype=Object.create(r&&r.prototype)).constructor=e;var t={scale:{configurable:!0},angle:{configurable:!0}};return t.scale.get=function(){return this.uniforms.scale},t.scale.set=function(e){this.uniforms.scale=e},t.angle.get=function(){return this.uniforms.angle},t.angle.set=function(e){this.uniforms.angle=e},Object.defineProperties(e.prototype,t),e}(l.Filter),x=function(f){function e(e){e&&e.constructor!==Object&&(console.warn("DropShadowFilter now uses options instead of (rotation, distance, blur, color, alpha)"),e={rotation:e},void 0!==arguments[1]&&(e.distance=arguments[1]),void 0!==arguments[2]&&(e.blur=arguments[2]),void 0!==arguments[3]&&(e.color=arguments[3]),void 0!==arguments[4]&&(e.alpha=arguments[4])),e=Object.assign({rotation:45,distance:5,color:0,alpha:.5,shadowOnly:!1,kernels:null,blur:2,quality:3,pixelSize:1,resolution:l.settings.RESOLUTION},e),f.call(this);var t=e.kernels,r=e.blur,i=e.quality,n=e.pixelSize,o=e.resolution;this._tintFilter=new l.Filter("attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform vec3 color;\nvoid main(void){\n vec4 sample = texture2D(uSampler, vTextureCoord);\n\n // Un-premultiply alpha before applying the color\n if (sample.a > 0.0) {\n sample.rgb /= sample.a;\n }\n\n // Premultiply alpha again\n sample.rgb = color.rgb * sample.a;\n\n // alpha user alpha\n sample *= alpha;\n\n gl_FragColor = sample;\n}"),this._tintFilter.uniforms.color=new Float32Array(4),this._tintFilter.resolution=o,this._blurFilter=t?new d(t):new d(r,i),this.pixelSize=n,this.resolution=o,this.targetTransform=new l.Matrix;var a=e.shadowOnly,s=e.rotation,u=e.distance,h=e.alpha,c=e.color;this.shadowOnly=a,this.rotation=s,this.distance=u,this.alpha=h,this.color=c,this._updatePadding()}f&&(e.__proto__=f);var t={resolution:{configurable:!0},distance:{configurable:!0},rotation:{configurable:!0},alpha:{configurable:!0},color:{configurable:!0},kernels:{configurable:!0},blur:{configurable:!0},quality:{configurable:!0},pixelSize:{configurable:!0}};return((e.prototype=Object.create(f&&f.prototype)).constructor=e).prototype.apply=function(e,t,r,i){var n=e.getRenderTarget();n.transform=this.targetTransform,this._tintFilter.apply(e,t,n,!0),n.transform=null,this._blurFilter.apply(e,n,r,i),!0!==this.shadowOnly&&e.applyFilter(this,t,r,!1),e.returnRenderTarget(n)},e.prototype._updatePadding=function(){this.padding=this.distance+2*this.blur},e.prototype._updateTargetTransform=function(){this.targetTransform.tx=this.distance*Math.cos(this.angle),this.targetTransform.ty=this.distance*Math.sin(this.angle)},t.resolution.get=function(){return this._resolution},t.resolution.set=function(e){this._resolution=e,this._tintFilter&&(this._tintFilter.resolution=e),this._blurFilter&&(this._blurFilter.resolution=e)},t.distance.get=function(){return this._distance},t.distance.set=function(e){this._distance=e,this._updatePadding(),this._updateTargetTransform()},t.rotation.get=function(){return this.angle/l.DEG_TO_RAD},t.rotation.set=function(e){this.angle=e*l.DEG_TO_RAD,this._updateTargetTransform()},t.alpha.get=function(){return this._tintFilter.uniforms.alpha},t.alpha.set=function(e){this._tintFilter.uniforms.alpha=e},t.color.get=function(){return l.utils.rgb2hex(this._tintFilter.uniforms.color)},t.color.set=function(e){l.utils.hex2rgb(e,this._tintFilter.uniforms.color)},t.kernels.get=function(){return this._blurFilter.kernels},t.kernels.set=function(e){this._blurFilter.kernels=e},t.blur.get=function(){return this._blurFilter.blur},t.blur.set=function(e){this._blurFilter.blur=e,this._updatePadding()},t.quality.get=function(){return this._blurFilter.quality},t.quality.set=function(e){this._blurFilter.quality=e},t.pixelSize.get=function(){return this._blurFilter.pixelSize},t.pixelSize.set=function(e){this._blurFilter.pixelSize=e},Object.defineProperties(e.prototype,t),e}(l.Filter),T=function(t){function e(e){void 0===e&&(e=5),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float strength;\nuniform vec4 filterArea;\n\n\nvoid main(void)\n{\n\tvec2 onePixel = vec2(1.0 / filterArea);\n\n\tvec4 color;\n\n\tcolor.rgb = vec3(0.5);\n\n\tcolor -= texture2D(uSampler, vTextureCoord - onePixel) * strength;\n\tcolor += texture2D(uSampler, vTextureCoord + onePixel) * strength;\n\n\tcolor.rgb = vec3((color.r + color.g + color.b) / 3.0);\n\n\tfloat alpha = texture2D(uSampler, vTextureCoord).a;\n\n\tgl_FragColor = vec4(color.rgb * alpha, alpha);\n}\n"),this.strength=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={strength:{configurable:!0}};return r.strength.get=function(){return this.uniforms.strength},r.strength.set=function(e){this.uniforms.strength=e},Object.defineProperties(e.prototype,r),e}(l.Filter),S=function(t){function e(e){void 0===e&&(e={}),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","// precision highp float;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\nuniform float aspect;\n\nuniform sampler2D displacementMap;\nuniform float offset;\nuniform float sinDir;\nuniform float cosDir;\nuniform int fillMode;\n\nuniform float seed;\nuniform vec2 red;\nuniform vec2 green;\nuniform vec2 blue;\n\nconst int TRANSPARENT = 0;\nconst int ORIGINAL = 1;\nconst int LOOP = 2;\nconst int CLAMP = 3;\nconst int MIRROR = 4;\n\nvoid main(void)\n{\n vec2 coord = (vTextureCoord * filterArea.xy) / dimensions;\n\n if (coord.x > 1.0 || coord.y > 1.0) {\n return;\n }\n\n float cx = coord.x - 0.5;\n float cy = (coord.y - 0.5) * aspect;\n float ny = (-sinDir * cx + cosDir * cy) / aspect + 0.5;\n\n // displacementMap: repeat\n // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny);\n\n // displacementMap: mirror\n ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny);\n\n vec4 dc = texture2D(displacementMap, vec2(0.5, ny));\n\n float displacement = (dc.r - dc.g) * (offset / filterArea.x);\n\n coord = vTextureCoord + vec2(cosDir * displacement, sinDir * displacement * aspect);\n\n if (fillMode == CLAMP) {\n coord = clamp(coord, filterClamp.xy, filterClamp.zw);\n } else {\n if( coord.x > filterClamp.z ) {\n if (fillMode == ORIGINAL) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n } else if (fillMode == LOOP) {\n coord.x -= filterClamp.z;\n } else if (fillMode == MIRROR) {\n coord.x = filterClamp.z * 2.0 - coord.x;\n } else {\n gl_FragColor = vec4(0., 0., 0., 0.);\n return;\n }\n } else if( coord.x < filterClamp.x ) {\n if (fillMode == ORIGINAL) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n } else if (fillMode == LOOP) {\n coord.x += filterClamp.z;\n } else if (fillMode == MIRROR) {\n coord.x *= -filterClamp.z;\n } else {\n gl_FragColor = vec4(0., 0., 0., 0.);\n return;\n }\n }\n\n if( coord.y > filterClamp.w ) {\n if (fillMode == ORIGINAL) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n } else if (fillMode == LOOP) {\n coord.y -= filterClamp.w;\n } else if (fillMode == MIRROR) {\n coord.y = filterClamp.w * 2.0 - coord.y;\n } else {\n gl_FragColor = vec4(0., 0., 0., 0.);\n return;\n }\n } else if( coord.y < filterClamp.y ) {\n if (fillMode == ORIGINAL) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n } else if (fillMode == LOOP) {\n coord.y += filterClamp.w;\n } else if (fillMode == MIRROR) {\n coord.y *= -filterClamp.w;\n } else {\n gl_FragColor = vec4(0., 0., 0., 0.);\n return;\n }\n }\n }\n\n gl_FragColor.r = texture2D(uSampler, coord + red * (1.0 - seed * 0.4) / filterArea.xy).r;\n gl_FragColor.g = texture2D(uSampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g;\n gl_FragColor.b = texture2D(uSampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b;\n gl_FragColor.a = texture2D(uSampler, coord).a;\n}\n"),this.uniforms.dimensions=new Float32Array(2),e=Object.assign({slices:5,offset:100,direction:0,fillMode:0,average:!1,seed:0,red:[0,0],green:[0,0],blue:[0,0],minSize:8,sampleSize:512},e),this.direction=e.direction,this.red=e.red,this.green=e.green,this.blue=e.blue,this.offset=e.offset,this.fillMode=e.fillMode,this.average=e.average,this.seed=e.seed,this.minSize=e.minSize,this.sampleSize=e.sampleSize,this._canvas=document.createElement("canvas"),this._canvas.width=4,this._canvas.height=this.sampleSize,this.texture=l.Texture.fromCanvas(this._canvas,l.SCALE_MODES.NEAREST),this._slices=0,this.slices=e.slices}t&&(e.__proto__=t);var r={sizes:{configurable:!0},offsets:{configurable:!0},slices:{configurable:!0},direction:{configurable:!0},red:{configurable:!0},green:{configurable:!0},blue:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.apply=function(e,t,r,i){var n=t.sourceFrame.width,o=t.sourceFrame.height;this.uniforms.dimensions[0]=n,this.uniforms.dimensions[1]=o,this.uniforms.aspect=o/n,this.uniforms.seed=this.seed,this.uniforms.offset=this.offset,this.uniforms.fillMode=this.fillMode,e.applyFilter(this,t,r,i)},e.prototype._randomizeSizes=function(){var e=this._sizes,t=this._slices-1,r=this.sampleSize,i=Math.min(this.minSize/r,.9/this._slices);if(this.average){for(var n=this._slices,o=1,a=0;a>0,i=e[t];e[t]=e[r],e[r]=i}},e.prototype._randomizeOffsets=function(){for(var e=0;e>0,t,1+a>>0),n+=a}r.baseTexture.update(),this.uniforms.displacementMap=r},r.sizes.set=function(e){for(var t=Math.min(this._slices,e.length),r=0;rthis._maxColors)throw"Length of replacements ("+i+") exceeds the maximum colors length ("+this._maxColors+")";t[3*i]=-1;for(var n=0;n 0.5) then: 1 - 2 * (1 - dst) * (1 - src)\n return vec3((dst.x <= 0.5) ? (2.0 * src.x * dst.x) : (1.0 - 2.0 * (1.0 - dst.x) * (1.0 - src.x)),\n (dst.y <= 0.5) ? (2.0 * src.y * dst.y) : (1.0 - 2.0 * (1.0 - dst.y) * (1.0 - src.y)),\n (dst.z <= 0.5) ? (2.0 * src.z * dst.z) : (1.0 - 2.0 * (1.0 - dst.z) * (1.0 - src.z)));\n}\n\n\nvoid main()\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n vec3 color = gl_FragColor.rgb;\n\n if (sepia > 0.0)\n {\n float gray = (color.x + color.y + color.z) / 3.0;\n vec3 grayscale = vec3(gray);\n\n color = Overlay(SEPIA_RGB, grayscale);\n\n color = grayscale + sepia * (color - grayscale);\n }\n\n vec2 coord = vTextureCoord * filterArea.xy / dimensions.xy;\n\n if (vignetting > 0.0)\n {\n float outter = SQRT_2 - vignetting * SQRT_2;\n vec2 dir = vec2(vec2(0.5, 0.5) - coord);\n dir.y *= dimensions.y / dimensions.x;\n float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0);\n color.rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha);\n }\n\n if (scratchDensity > seed && scratch != 0.0)\n {\n float phase = seed * 256.0;\n float s = mod(floor(phase), 2.0);\n float dist = 1.0 / scratchDensity;\n float d = distance(coord, vec2(seed * dist, abs(s - seed * dist)));\n if (d < seed * 0.6 + 0.4)\n {\n highp float period = scratchDensity * 10.0;\n\n float xx = coord.x * period + phase;\n float aa = abs(mod(xx, 0.5) * 4.0);\n float bb = mod(floor(xx / 0.5), 2.0);\n float yy = (1.0 - bb) * aa + bb * (2.0 - aa);\n\n float kk = 2.0 * period;\n float dw = scratchWidth / dimensions.x * (0.75 + seed);\n float dh = dw * kk;\n\n float tine = (yy - (2.0 - dh));\n\n if (tine > 0.0) {\n float _sign = sign(scratch);\n\n tine = s * tine / period + scratch + 0.1;\n tine = clamp(tine + 1.0, 0.5 + _sign * 0.5, 1.5 + _sign * 0.5);\n\n color.rgb *= tine;\n }\n }\n }\n\n if (noise > 0.0 && noiseSize > 0.0)\n {\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n pixelCoord.x = floor(pixelCoord.x / noiseSize);\n pixelCoord.y = floor(pixelCoord.y / noiseSize);\n // vec2 d = pixelCoord * noiseSize * vec2(1024.0 + seed * 512.0, 1024.0 - seed * 512.0);\n // float _noise = snoise(d) * 0.5;\n float _noise = rand(pixelCoord * noiseSize * seed) - 0.5;\n color += _noise * noise;\n }\n\n gl_FragColor.rgb = color;\n}\n"),this.uniforms.dimensions=new Float32Array(2),"number"==typeof e?(this.seed=e,e=null):this.seed=t,Object.assign(this,{sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3},e)}r&&(e.__proto__=r);var t={sepia:{configurable:!0},noise:{configurable:!0},noiseSize:{configurable:!0},scratch:{configurable:!0},scratchDensity:{configurable:!0},scratchWidth:{configurable:!0},vignetting:{configurable:!0},vignettingAlpha:{configurable:!0},vignettingBlur:{configurable:!0}};return((e.prototype=Object.create(r&&r.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,this.uniforms.seed=this.seed,e.applyFilter(this,t,r,i)},t.sepia.set=function(e){this.uniforms.sepia=e},t.sepia.get=function(){return this.uniforms.sepia},t.noise.set=function(e){this.uniforms.noise=e},t.noise.get=function(){return this.uniforms.noise},t.noiseSize.set=function(e){this.uniforms.noiseSize=e},t.noiseSize.get=function(){return this.uniforms.noiseSize},t.scratch.set=function(e){this.uniforms.scratch=e},t.scratch.get=function(){return this.uniforms.scratch},t.scratchDensity.set=function(e){this.uniforms.scratchDensity=e},t.scratchDensity.get=function(){return this.uniforms.scratchDensity},t.scratchWidth.set=function(e){this.uniforms.scratchWidth=e},t.scratchWidth.get=function(){return this.uniforms.scratchWidth},t.vignetting.set=function(e){this.uniforms.vignetting=e},t.vignetting.get=function(){return this.uniforms.vignetting},t.vignettingAlpha.set=function(e){this.uniforms.vignettingAlpha=e},t.vignettingAlpha.get=function(){return this.uniforms.vignettingAlpha},t.vignettingBlur.set=function(e){this.uniforms.vignettingBlur=e},t.vignettingBlur.get=function(){return this.uniforms.vignettingBlur},Object.defineProperties(e.prototype,t),e}(l.Filter),k=function(o){function a(e,t,r){void 0===e&&(e=1),void 0===t&&(t=0),void 0===r&&(r=.1);var i=Math.max(r*a.MAX_SAMPLES,a.MIN_SAMPLES),n=(2*Math.PI/i).toFixed(7);o.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 thickness;\nuniform vec4 outlineColor;\nuniform vec4 filterClamp;\n\nconst float DOUBLE_PI = 3.14159265358979323846264 * 2.;\n\nvoid main(void) {\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\n vec4 curColor;\n float maxAlpha = 0.;\n vec2 displaced;\n for (float angle = 0.; angle <= DOUBLE_PI; angle += ${angleStep}) {\n displaced.x = vTextureCoord.x + thickness.x * cos(angle);\n displaced.y = vTextureCoord.y + thickness.y * sin(angle);\n curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw));\n maxAlpha = max(maxAlpha, curColor.a);\n }\n float resultAlpha = max(maxAlpha, ownColor.a);\n gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha);\n}\n".replace(/\$\{angleStep\}/,n)),this.uniforms.thickness=new Float32Array([0,0]),this.thickness=e,this.uniforms.outlineColor=new Float32Array([0,0,0,1]),this.color=t,this.quality=r}o&&(a.__proto__=o);var e={color:{configurable:!0}};return((a.prototype=Object.create(o&&o.prototype)).constructor=a).prototype.apply=function(e,t,r,i){this.uniforms.thickness[0]=this.thickness/t.size.width,this.uniforms.thickness[1]=this.thickness/t.size.height,e.applyFilter(this,t,r,i)},e.color.get=function(){return l.utils.rgb2hex(this.uniforms.outlineColor)},e.color.set=function(e){l.utils.hex2rgb(e,this.uniforms.outlineColor)},Object.defineProperties(a.prototype,e),a}(l.Filter);k.MIN_SAMPLES=1,k.MAX_SAMPLES=100;var I=function(t){function e(e){void 0===e&&(e=10),t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform vec2 size;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 pixelate(vec2 coord, vec2 size)\n{\n\treturn floor( coord / size ) * size;\n}\n\nvoid main(void)\n{\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = pixelate(coord, size);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord);\n}\n"),this.size=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={size:{configurable:!0}};return r.size.get=function(){return this.uniforms.size},r.size.set=function(e){"number"==typeof e&&(e=[e,e]),this.uniforms.size=e},Object.defineProperties(e.prototype,r),e}(l.Filter),R=function(n){function e(e,t,r,i){void 0===e&&(e=0),void 0===t&&(t=[0,0]),void 0===r&&(r=5),void 0===i&&(i=-1),n.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform float uRadian;\nuniform vec2 uCenter;\nuniform float uRadius;\nuniform int uKernelSize;\n\nconst int MAX_KERNEL_SIZE = 2048;\n\nvoid main(void)\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n if (uKernelSize == 0)\n {\n gl_FragColor = color;\n return;\n }\n\n float aspect = filterArea.y / filterArea.x;\n vec2 center = uCenter.xy / filterArea.xy;\n float gradient = uRadius / filterArea.x * 0.3;\n float radius = uRadius / filterArea.x - gradient * 0.5;\n int k = uKernelSize - 1;\n\n vec2 coord = vTextureCoord;\n vec2 dir = vec2(center - coord);\n float dist = length(vec2(dir.x, dir.y * aspect));\n\n float radianStep = uRadian;\n if (radius >= 0.0 && dist > radius) {\n float delta = dist - radius;\n float gap = gradient;\n float scale = 1.0 - abs(delta / gap);\n if (scale <= 0.0) {\n gl_FragColor = color;\n return;\n }\n radianStep *= scale;\n }\n radianStep /= float(k);\n\n float s = sin(radianStep);\n float c = cos(radianStep);\n mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c));\n\n for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) {\n if (i == k) {\n break;\n }\n\n coord -= center;\n coord.y *= aspect;\n coord = rotationMatrix * coord;\n coord.y /= aspect;\n coord += center;\n\n vec4 sample = texture2D(uSampler, coord);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample;\n }\n\n gl_FragColor = color / float(uKernelSize);\n}\n"),this._angle=0,this.angle=e,this.center=t,this.kernelSize=r,this.radius=i}n&&(e.__proto__=n);var t={angle:{configurable:!0},center:{configurable:!0},radius:{configurable:!0}};return((e.prototype=Object.create(n&&n.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.uKernelSize=0!==this._angle?this.kernelSize:0,e.applyFilter(this,t,r,i)},t.angle.set=function(e){this._angle=e,this.uniforms.uRadian=e*Math.PI/180},t.angle.get=function(){return this._angle},t.center.get=function(){return this.uniforms.uCenter},t.center.set=function(e){this.uniforms.uCenter=e},t.radius.get=function(){return this.uniforms.uRadius},t.radius.set=function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},Object.defineProperties(e.prototype,t),e}(l.Filter),O=function(t){function e(e){t.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\n\nuniform bool mirror;\nuniform float boundary;\nuniform vec2 amplitude;\nuniform vec2 waveLength;\nuniform vec2 alpha;\nuniform float time;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main(void)\n{\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n vec2 coord = pixelCoord / dimensions;\n\n if (coord.y < boundary) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n\n float k = (coord.y - boundary) / (1. - boundary + 0.0001);\n float areaY = boundary * dimensions.y / filterArea.y;\n float v = areaY + areaY - vTextureCoord.y;\n float y = mirror ? v : vTextureCoord.y;\n\n float _amplitude = ((amplitude.y - amplitude.x) * k + amplitude.x ) / filterArea.x;\n float _waveLength = ((waveLength.y - waveLength.x) * k + waveLength.x) / filterArea.y;\n float _alpha = (alpha.y - alpha.x) * k + alpha.x;\n\n float x = vTextureCoord.x + cos(v * 6.28 / _waveLength - time) * _amplitude;\n x = clamp(x, filterClamp.x, filterClamp.z);\n\n vec4 color = texture2D(uSampler, vec2(x, y));\n\n gl_FragColor = color * _alpha;\n}\n"),this.uniforms.amplitude=new Float32Array(2),this.uniforms.waveLength=new Float32Array(2),this.uniforms.alpha=new Float32Array(2),this.uniforms.dimensions=new Float32Array(2),Object.assign(this,{mirror:!0,boundary:.5,amplitude:[0,20],waveLength:[30,100],alpha:[1,1],time:0},e)}t&&(e.__proto__=t);var r={mirror:{configurable:!0},boundary:{configurable:!0},amplitude:{configurable:!0},waveLength:{configurable:!0},alpha:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,this.uniforms.time=this.time,e.applyFilter(this,t,r,i)},r.mirror.set=function(e){this.uniforms.mirror=e},r.mirror.get=function(){return this.uniforms.mirror},r.boundary.set=function(e){this.uniforms.boundary=e},r.boundary.get=function(){return this.uniforms.boundary},r.amplitude.set=function(e){this.uniforms.amplitude[0]=e[0],this.uniforms.amplitude[1]=e[1]},r.amplitude.get=function(){return this.uniforms.amplitude},r.waveLength.set=function(e){this.uniforms.waveLength[0]=e[0],this.uniforms.waveLength[1]=e[1]},r.waveLength.get=function(){return this.uniforms.waveLength},r.alpha.set=function(e){this.uniforms.alpha[0]=e[0],this.uniforms.alpha[1]=e[1]},r.alpha.get=function(){return this.uniforms.alpha},Object.defineProperties(e.prototype,r),e}(l.Filter),D=function(i){function e(e,t,r){void 0===e&&(e=[-10,0]),void 0===t&&(t=[0,10]),void 0===r&&(r=[0,0]),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\nuniform vec2 red;\nuniform vec2 green;\nuniform vec2 blue;\n\nvoid main(void)\n{\n gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r;\n gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g;\n gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b;\n gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;\n}\n"),this.red=e,this.green=t,this.blue=r}i&&(e.__proto__=i),(e.prototype=Object.create(i&&i.prototype)).constructor=e;var t={red:{configurable:!0},green:{configurable:!0},blue:{configurable:!0}};return t.red.get=function(){return this.uniforms.red},t.red.set=function(e){this.uniforms.red=e},t.green.get=function(){return this.uniforms.green},t.green.set=function(e){this.uniforms.green=e},t.blue.get=function(){return this.uniforms.blue},t.blue.set=function(e){this.uniforms.blue=e},Object.defineProperties(e.prototype,t),e}(l.Filter),L=function(i){function e(e,t,r){void 0===e&&(e=[0,0]),void 0===t&&(t={}),void 0===r&&(r=0),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\n\nuniform vec2 center;\n\nuniform float amplitude;\nuniform float wavelength;\n// uniform float power;\nuniform float brightness;\nuniform float speed;\nuniform float radius;\n\nuniform float time;\n\nconst float PI = 3.14159;\n\nvoid main()\n{\n float halfWavelength = wavelength * 0.5 / filterArea.x;\n float maxRadius = radius / filterArea.x;\n float currentRadius = time * speed / filterArea.x;\n\n float fade = 1.0;\n\n if (maxRadius > 0.0) {\n if (currentRadius > maxRadius) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n fade = 1.0 - pow(currentRadius / maxRadius, 2.0);\n }\n\n vec2 dir = vec2(vTextureCoord - center / filterArea.xy);\n dir.y *= filterArea.y / filterArea.x;\n float dist = length(dir);\n\n if (dist <= 0.0 || dist < currentRadius - halfWavelength || dist > currentRadius + halfWavelength) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n\n vec2 diffUV = normalize(dir);\n\n float diff = (dist - currentRadius) / halfWavelength;\n\n float p = 1.0 - pow(abs(diff), 2.0);\n\n // float powDiff = diff * pow(p, 2.0) * ( amplitude * fade );\n float powDiff = 1.25 * sin(diff * PI) * p * ( amplitude * fade );\n\n vec2 offset = diffUV * powDiff / filterArea.xy;\n\n // Do clamp :\n vec2 coord = vTextureCoord + offset;\n vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw);\n vec4 color = texture2D(uSampler, clampedCoord);\n if (coord != clampedCoord) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n // No clamp :\n // gl_FragColor = texture2D(uSampler, vTextureCoord + offset);\n\n color.rgb *= 1.0 + (brightness - 1.0) * p * fade;\n\n gl_FragColor = color;\n}\n"),this.center=e,Array.isArray(t)&&(console.warn("Deprecated Warning: ShockwaveFilter params Array has been changed to options Object."),t={}),t=Object.assign({amplitude:30,wavelength:160,brightness:1,speed:500,radius:-1},t),this.amplitude=t.amplitude,this.wavelength=t.wavelength,this.brightness=t.brightness,this.speed=t.speed,this.radius=t.radius,this.time=r}i&&(e.__proto__=i);var t={center:{configurable:!0},amplitude:{configurable:!0},wavelength:{configurable:!0},brightness:{configurable:!0},speed:{configurable:!0},radius:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.time=this.time,e.applyFilter(this,t,r,i)},t.center.get=function(){return this.uniforms.center},t.center.set=function(e){this.uniforms.center=e},t.amplitude.get=function(){return this.uniforms.amplitude},t.amplitude.set=function(e){this.uniforms.amplitude=e},t.wavelength.get=function(){return this.uniforms.wavelength},t.wavelength.set=function(e){this.uniforms.wavelength=e},t.brightness.get=function(){return this.uniforms.brightness},t.brightness.set=function(e){this.uniforms.brightness=e},t.speed.get=function(){return this.uniforms.speed},t.speed.set=function(e){this.uniforms.speed=e},t.radius.get=function(){return this.uniforms.radius},t.radius.set=function(e){this.uniforms.radius=e},Object.defineProperties(e.prototype,t),e}(l.Filter),F=function(i){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=1),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform sampler2D uLightmap;\nuniform vec4 filterArea;\nuniform vec2 dimensions;\nuniform vec4 ambientColor;\nvoid main() {\n vec4 diffuseColor = texture2D(uSampler, vTextureCoord);\n vec2 lightCoord = (vTextureCoord * filterArea.xy) / dimensions;\n vec4 light = texture2D(uLightmap, lightCoord);\n vec3 ambient = ambientColor.rgb * ambientColor.a;\n vec3 intensity = ambient + light.rgb;\n vec3 finalColor = diffuseColor.rgb * intensity;\n gl_FragColor = vec4(finalColor, diffuseColor.a);\n}\n"),this.uniforms.dimensions=new Float32Array(2),this.uniforms.ambientColor=new Float32Array([0,0,0,r]),this.texture=e,this.color=t}i&&(e.__proto__=i);var t={texture:{configurable:!0},color:{configurable:!0},alpha:{configurable:!0}};return((e.prototype=Object.create(i&&i.prototype)).constructor=e).prototype.apply=function(e,t,r,i){this.uniforms.dimensions[0]=t.sourceFrame.width,this.uniforms.dimensions[1]=t.sourceFrame.height,e.applyFilter(this,t,r,i)},t.texture.get=function(){return this.uniforms.uLightmap},t.texture.set=function(e){this.uniforms.uLightmap=e},t.color.set=function(e){var t=this.uniforms.ambientColor;"number"==typeof e?(l.utils.hex2rgb(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._color=l.utils.rgb2hex(t))},t.color.get=function(){return this._color},t.alpha.get=function(){return this.uniforms.ambientColor[3]},t.alpha.set=function(e){this.uniforms.ambientColor[3]=e},Object.defineProperties(e.prototype,t),e}(l.Filter),j=function(n){function e(e,t,r,i){void 0===e&&(e=100),void 0===t&&(t=600),void 0===r&&(r=null),void 0===i&&(i=null),n.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float blur;\nuniform float gradientBlur;\nuniform vec2 start;\nuniform vec2 end;\nuniform vec2 delta;\nuniform vec2 texSize;\n\nfloat random(vec3 scale, float seed)\n{\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur;\n\n for (float t = -30.0; t <= 30.0; t++)\n {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius);\n sample.rgb *= sample.a;\n color += sample * weight;\n total += weight;\n }\n\n color /= total;\n color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n"),this.uniforms.blur=e,this.uniforms.gradientBlur=t,this.uniforms.start=r||new l.Point(0,window.innerHeight/2),this.uniforms.end=i||new l.Point(600,window.innerHeight/2),this.uniforms.delta=new l.Point(30,30),this.uniforms.texSize=new l.Point(window.innerWidth,window.innerHeight),this.updateDelta()}n&&(e.__proto__=n);var t={blur:{configurable:!0},gradientBlur:{configurable:!0},start:{configurable:!0},end:{configurable:!0}};return((e.prototype=Object.create(n&&n.prototype)).constructor=e).prototype.updateDelta=function(){this.uniforms.delta.x=0,this.uniforms.delta.y=0},t.blur.get=function(){return this.uniforms.blur},t.blur.set=function(e){this.uniforms.blur=e},t.gradientBlur.get=function(){return this.uniforms.gradientBlur},t.gradientBlur.set=function(e){this.uniforms.gradientBlur=e},t.start.get=function(){return this.uniforms.start},t.start.set=function(e){this.uniforms.start=e,this.updateDelta()},t.end.get=function(){return this.uniforms.end},t.end.set=function(e){this.uniforms.end=e,this.updateDelta()},Object.defineProperties(e.prototype,t),e}(l.Filter),B=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,r=Math.sqrt(e*e+t*t);this.uniforms.delta.x=e/r,this.uniforms.delta.y=t/r},t}(j),N=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,r=Math.sqrt(e*e+t*t);this.uniforms.delta.x=-t/r,this.uniforms.delta.y=e/r},t}(j),U=function(n){function e(e,t,r,i){void 0===e&&(e=100),void 0===t&&(t=600),void 0===r&&(r=null),void 0===i&&(i=null),n.call(this),this.tiltShiftXFilter=new B(e,t,r,i),this.tiltShiftYFilter=new N(e,t,r,i)}n&&(e.__proto__=n);var t={blur:{configurable:!0},gradientBlur:{configurable:!0},start:{configurable:!0},end:{configurable:!0}};return((e.prototype=Object.create(n&&n.prototype)).constructor=e).prototype.apply=function(e,t,r){var i=e.getRenderTarget(!0);this.tiltShiftXFilter.apply(e,t,i),this.tiltShiftYFilter.apply(e,i,r),e.returnRenderTarget(i)},t.blur.get=function(){return this.tiltShiftXFilter.blur},t.blur.set=function(e){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=e},t.gradientBlur.get=function(){return this.tiltShiftXFilter.gradientBlur},t.gradientBlur.set=function(e){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=e},t.start.get=function(){return this.tiltShiftXFilter.start},t.start.set=function(e){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=e},t.end.get=function(){return this.tiltShiftXFilter.end},t.end.set=function(e){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=e},Object.defineProperties(e.prototype,t),e}(l.Filter),z=function(i){function e(e,t,r){void 0===e&&(e=200),void 0===t&&(t=4),void 0===r&&(r=20),i.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 twist(vec2 coord)\n{\n coord -= offset;\n\n float dist = length(coord);\n\n if (dist < radius)\n {\n float ratioDist = (radius - dist) / radius;\n float angleMod = ratioDist * ratioDist * angle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n coord += offset;\n\n return coord;\n}\n\nvoid main(void)\n{\n\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = twist(coord);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord );\n\n}\n"),this.radius=e,this.angle=t,this.padding=r}i&&(e.__proto__=i),(e.prototype=Object.create(i&&i.prototype)).constructor=e;var t={offset:{configurable:!0},radius:{configurable:!0},angle:{configurable:!0}};return t.offset.get=function(){return this.uniforms.offset},t.offset.set=function(e){this.uniforms.offset=e},t.radius.get=function(){return this.uniforms.radius},t.radius.set=function(e){this.uniforms.radius=e},t.angle.get=function(){return this.uniforms.angle},t.angle.set=function(e){this.uniforms.angle=e},Object.defineProperties(e.prototype,t),e}(l.Filter),X=function(n){function e(e,t,r,i){void 0===e&&(e=.1),void 0===t&&(t=[0,0]),void 0===r&&(r=0),void 0===i&&(i=-1),n.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform vec2 uCenter;\nuniform float uStrength;\nuniform float uInnerRadius;\nuniform float uRadius;\n\nconst float MAX_KERNEL_SIZE = 32.0;\n\n// author: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand(vec2 co, float seed) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);\n return fract(sin(sn) * c + seed);\n}\n\nvoid main() {\n\n float minGradient = uInnerRadius * 0.3;\n float innerRadius = (uInnerRadius + minGradient * 0.5) / filterArea.x;\n\n float gradient = uRadius * 0.3;\n float radius = (uRadius - gradient * 0.5) / filterArea.x;\n\n float countLimit = MAX_KERNEL_SIZE;\n\n vec2 dir = vec2(uCenter.xy / filterArea.xy - vTextureCoord);\n float dist = length(vec2(dir.x, dir.y * filterArea.y / filterArea.x));\n\n float strength = uStrength;\n\n float delta = 0.0;\n float gap;\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (radius >= 0.0 && dist > radius) { // radius < 0 means it's infinity\n delta = dist - radius;\n gap = gradient;\n }\n\n if (delta > 0.0) {\n float normalCount = gap / filterArea.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n if (countLimit < 1.0)\n {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n float offset = rand(vTextureCoord, 0.0);\n\n float total = 0.0;\n vec4 color = vec4(0.0);\n\n dir *= strength;\n\n for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {\n float percent = (t + offset) / MAX_KERNEL_SIZE;\n float weight = 4.0 * (percent - percent * percent);\n vec2 p = vTextureCoord + dir * percent;\n vec4 sample = texture2D(uSampler, p);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n\n if (t > countLimit){\n break;\n }\n }\n\n color /= total;\n // switch back from pre-multiplied alpha\n // color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n"),this.center=t,this.strength=e,this.innerRadius=r,this.radius=i}n&&(e.__proto__=n),(e.prototype=Object.create(n&&n.prototype)).constructor=e;var t={center:{configurable:!0},strength:{configurable:!0},innerRadius:{configurable:!0},radius:{configurable:!0}};return t.center.get=function(){return this.uniforms.uCenter},t.center.set=function(e){this.uniforms.uCenter=e},t.strength.get=function(){return this.uniforms.uStrength},t.strength.set=function(e){this.uniforms.uStrength=e},t.innerRadius.get=function(){return this.uniforms.uInnerRadius},t.innerRadius.set=function(e){this.uniforms.uInnerRadius=e},t.radius.get=function(){return this.uniforms.uRadius},t.radius.set=function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},Object.defineProperties(e.prototype,t),e}(l.Filter);return e.AdjustmentFilter=t,e.AdvancedBloomFilter=i,e.AsciiFilter=n,e.BevelFilter=o,e.BloomFilter=p,e.BulgePinchFilter=m,e.ColorMapFilter=v,e.ColorReplaceFilter=b,e.ConvolutionFilter=g,e.CrossHatchFilter=y,e.CRTFilter=_,e.DotFilter=w,e.DropShadowFilter=x,e.EmbossFilter=T,e.GlitchFilter=S,e.GlowFilter=E,e.GodrayFilter=A,e.KawaseBlurFilter=d,e.MotionBlurFilter=P,e.MultiColorReplaceFilter=M,e.OldFilmFilter=C,e.OutlineFilter=k,e.PixelateFilter=I,e.RadialBlurFilter=R,e.ReflectionFilter=O,e.RGBSplitFilter=D,e.ShockwaveFilter=L,e.SimpleLightmapFilter=F,e.TiltShiftFilter=U,e.TiltShiftAxisFilter=j,e.TiltShiftXFilter=B,e.TiltShiftYFilter=N,e.TwistFilter=z,e.ZoomBlurFilter=X,e}({},PIXI),pixi_projection,pixi_projection;Object.assign(PIXI.filters,this?this.__filters:__filters),this.PIXI=this.PIXI||{},function(d,v){"use strict";var l,p=function(){function l(e,t,r){this.value=e,this.time=t,this.next=null,this.isStepped=!1,this.ease=r?"function"==typeof r?r:d.ParticleUtils.generateEase(r):null}return l.createList=function(e){if("list"in e){var t=e.list,r=void 0,i=void 0,n=t[0],o=n.value,a=n.time;if(i=r=new l("string"==typeof o?d.ParticleUtils.hexToRGB(o):o,a,e.ease),2a.time;)n=a,a=e[++o];u=(u-n.time)/(a.time-n.time);var h=l.hexToRGB(n.value),c=l.hexToRGB(a.value),f={r:(c.r-h.r)*u+h.r,g:(c.g-h.g)*u+h.g,b:(c.b-h.b)*u+h.b};i.next=new p(f,s/t),i=i.next}return r};var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function t(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var n=function(){function e(e){void 0===e&&(e=!1),this.current=null,this.next=null,this.isColor=!!e,this.interpolate=null,this.ease=null}return e.prototype.reset=function(e){this.current=e,this.next=e.next,this.next&&1<=this.next.time?this.interpolate=this.isColor?o:r:e.isStepped?this.interpolate=this.isColor?h:u:this.interpolate=this.isColor?s:a,this.ease=this.current.ease},e}();function r(e){return this.ease&&(e=this.ease(e)),(this.next.value-this.current.value)*e+this.current.value}function o(e){this.ease&&(e=this.ease(e));var t=this.current.value,r=this.next.value,i=(r.r-t.r)*e+t.r,n=(r.g-t.g)*e+t.g,o=(r.b-t.b)*e+t.b;return d.ParticleUtils.combineRGBComponents(i,n,o)}function a(e){for(this.ease&&(e=this.ease(e));e>this.next.time;)this.current=this.next,this.next=this.next.next;return e=(e-this.current.time)/(this.next.time-this.current.time),(this.next.value-this.current.value)*e+this.current.value}function s(e){for(this.ease&&(e=this.ease(e));e>this.next.time;)this.current=this.next,this.next=this.next.next;e=(e-this.current.time)/(this.next.time-this.current.time);var t=this.current.value,r=this.next.value,i=(r.r-t.r)*e+t.r,n=(r.g-t.g)*e+t.g,o=(r.b-t.b)*e+t.b;return d.ParticleUtils.combineRGBComponents(i,n,o)}function u(e){for(this.ease&&(e=this.ease(e));this.next&&e>this.next.time;)this.current=this.next,this.next=this.next.next;return this.current.value}function h(e){for(this.ease&&(e=this.ease(e));this.next&&e>this.next.time;)this.current=this.next,this.next=this.next.next;var t=this.current.value;return d.ParticleUtils.combineRGBComponents(t.r,t.g,t.b)}var c,f=function(r){function i(e){var t=r.call(this)||this;return t.emitter=e,t.anchor.x=t.anchor.y=.5,t.velocity=new v.Point,t.rotationSpeed=0,t.rotationAcceleration=0,t.maxLife=0,t.age=0,t.ease=null,t.extraData=null,t.alphaList=new n,t.speedList=new n,t.speedMultiplier=1,t.acceleration=new v.Point,t.maxSpeed=NaN,t.scaleList=new n,t.scaleMultiplier=1,t.colorList=new n(!0),t._doAlpha=!1,t._doScale=!1,t._doSpeed=!1,t._doAcceleration=!1,t._doColor=!1,t._doNormalMovement=!1,t._oneOverLife=0,t.next=null,t.prev=null,t.init=t.init,t.Particle_init=i.prototype.init,t.update=t.update,t.Particle_update=i.prototype.update,t.Sprite_destroy=r.prototype.destroy,t.Particle_destroy=i.prototype.destroy,t.applyArt=t.applyArt,t.kill=t.kill,t}return t(i,r),i.prototype.init=function(){this.age=0,this.velocity.x=this.speedList.current.value*this.speedMultiplier,this.velocity.y=0,d.ParticleUtils.rotatePoint(this.rotation,this.velocity),this.noRotation?this.rotation=0:this.rotation*=d.ParticleUtils.DEG_TO_RADS,this.rotationSpeed*=d.ParticleUtils.DEG_TO_RADS,this.rotationAcceleration*=d.ParticleUtils.DEG_TO_RADS,this.alpha=this.alphaList.current.value,this.scale.x=this.scale.y=this.scaleList.current.value,this._doAlpha=!!this.alphaList.current.next,this._doSpeed=!!this.speedList.current.next,this._doScale=!!this.scaleList.current.next,this._doColor=!!this.colorList.current.next,this._doAcceleration=0!==this.acceleration.x||0!==this.acceleration.y,this._doNormalMovement=this._doSpeed||0!==this.speedList.current.value||this._doAcceleration,this._oneOverLife=1/this.maxLife;var e=this.colorList.current.value;this.tint=d.ParticleUtils.combineRGBComponents(e.r,e.g,e.b),this.visible=!0},i.prototype.applyArt=function(e){this.texture=e||v.Texture.EMPTY},i.prototype.update=function(e){if(this.age+=e,this.age>=this.maxLife||this.age<0)return this.kill(),-1;var t=this.age*this._oneOverLife;if(this.ease&&(t=4==this.ease.length?this.ease(t,0,1,1):this.ease(t)),this._doAlpha&&(this.alpha=this.alphaList.interpolate(t)),this._doScale){var r=this.scaleList.interpolate(t)*this.scaleMultiplier;this.scale.x=this.scale.y=r}if(this._doNormalMovement){var i=void 0,n=void 0;if(this._doSpeed){var o=this.speedList.interpolate(t)*this.speedMultiplier;d.ParticleUtils.normalize(this.velocity),d.ParticleUtils.scaleBy(this.velocity,o),i=this.velocity.x*e,n=this.velocity.y*e}else if(this._doAcceleration){var a=this.velocity.x,s=this.velocity.y;if(this.velocity.x+=this.acceleration.x*e,this.velocity.y+=this.acceleration.y*e,this.maxSpeed){var u=d.ParticleUtils.length(this.velocity);u>this.maxSpeed&&d.ParticleUtils.scaleBy(this.velocity,this.maxSpeed/u)}i=(a+this.velocity.x)/2*e,n=(s+this.velocity.y)/2*e}else i=this.velocity.x*e,n=this.velocity.y*e;this.position.x+=i,this.position.y+=n}if(this._doColor&&(this.tint=this.colorList.interpolate(t)),0!==this.rotationAcceleration){var h=this.rotationSpeed+this.rotationAcceleration*e;this.rotation+=(this.rotationSpeed+h)/2*e,this.rotationSpeed=h}else 0!==this.rotationSpeed?this.rotation+=this.rotationSpeed*e:this.acceleration&&!this.noRotation&&(this.rotation=Math.atan2(this.velocity.y,this.velocity.x));return t},i.prototype.kill=function(){this.emitter.recycle(this)},i.prototype.destroy=function(){this.parent&&this.parent.removeChild(this),this.Sprite_destroy(),this.emitter=this.velocity=this.colorList=this.scaleList=this.alphaList=this.speedList=this.ease=this.next=this.prev=null},i.parseArt=function(e){var t;for(t=e.length;0<=t;--t)"string"==typeof e[t]&&(e[t]=v.Texture.fromImage(e[t]));if(d.ParticleUtils.verbose)for(t=e.length-1;0=this.maxParticles)this._spawnTimer+=this._frequency;else{var u=void 0;if(u=this.minLifetime==this.maxLifetime?this.minLifetime:Math.random()*(this.maxLifetime-this.minLifetime)+this.minLifetime,-this._spawnTimer=this.spawnChance)){var d=void 0;if(this._poolFirst?(d=this._poolFirst,this._poolFirst=this._poolFirst.next,d.next=null):d=new this.particleConstructor(this),1this.duration&&(this.loop?this.elapsed=this.elapsed%this.duration:this.elapsed=this.duration-1e-6);var r=this.elapsed*this.framerate+1e-7|0;this.texture=this.textures[r]||v.Texture.EMPTY}return t},e.prototype.destroy=function(){this.Particle_destroy(),this.textures=null},e.parseArt=function(e){for(var t,r,i,n,o,a=[],s=0;s>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,1+(e|=e>>>16)},t.log2=function(e){var t,r;return t=+(65535>>=t))<<3,t|=r=+(15<(e>>>=r))<<2,(t|=r=+(3<(e>>>=r))<<1)|(e>>>=r)>>1},t.getIntersectionFactor=function(e,t,r,i,n){var o=t.x-e.x,a=r.x-i.x,s=r.x-e.x,u=t.y-e.y,h=r.y-i.y,c=r.y-e.y,f=o*h-u*a;if(Math.abs(f)<1e-7)return n.x=o,n.y=u,0;var l=(s*h-c*a)/f,d=(o*c-u*s)/f;return d<1e-6||-1e-6=this.size&&this.flush(),e._texture._uvs&&e._texture.baseTexture&&(this.sprites[this.currentIndex++]=e)},e.prototype.flush=function(){if(0!==this.currentIndex){var e,t,r,i=this.renderer.gl,n=this.MAX_TEXTURES,o=O.utils.nextPow2(this.currentIndex),a=O.utils.log2(o),s=this.buffers[a],u=this.sprites,h=this.groups,c=s.float32View,f=s.uint32View,l=0,d=null,p=1,m=0,v=h[0],b=I[u[0]._texture.baseTexture.premultipliedAlpha?1:0][u[0].blendMode];for(v.textureCount=0,v.start=0,v.blend=b,R++,r=0;rt[s]&&(i=t[s]),ot[s+1]&&(n=t[s+1]),al[h]){u=f[s];f[s]=f[h],f[h]=u;var c=l[s];l[s]=l[h],l[h]=c}if(t[0]=f[0].x,t[1]=f[0].y,t[2]=f[1].x,t[3]=f[1].y,t[4]=f[2].x,t[5]=f[2].y,t[6]=f[3].x,t[7]=f[3].y,(f[3].x-f[2].x)*(f[1].y-f[2].y)-(f[1].x-f[2].x)*(f[3].y-f[2].y)<0)return t[4]=f[3].x,void(t[5]=f[3].y)}},e}();e.Surface=t}(pixi_projection||(pixi_projection={})),function(e){var S=new PIXI.Matrix,n=new PIXI.Rectangle,E=new PIXI.Point,t=function(t){function e(){var e=t.call(this)||this;return e.distortion=new PIXI.Point,e}return __extends(e,t),e.prototype.clear=function(){this.distortion.set(0,0)},e.prototype.apply=function(e,t){t=t||new PIXI.Point;var r=this.distortion,i=e.x*e.y;return t.x=e.x+r.x*i,t.y=e.y+r.y*i,t},e.prototype.applyInverse=function(e,t){t=t||new PIXI.Point;var r=e.x,i=e.y,n=this.distortion.x,o=this.distortion.y;if(0==n)t.x=r,t.y=i/(1+o*r);else if(0==o)t.y=i,t.x=r/(1+n*i);else{var a=.5*(i*n-r*o+1)/o,s=a*a+r/o;if(s<=1e-5)return void t.set(NaN,NaN);t.x=0 vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n uv.x = vTrans1.x * surface2.x + vTrans1.y * surface2.y + vTrans1.z;\n uv.y = vTrans2.x * surface2.x + vTrans2.y * surface2.y + vTrans2.z;\n pixels = uv * samplerSize[0];\n \n if (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n discard;\n }\n}\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = 1.0; //edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\nvec4 color;\nvec2 textureCoord = uv;\n%forloop%\ngl_FragColor = color * rColor;\n}",e.defUniforms={worldTransform:new Float32Array([1,0,0,0,1,0,0,0,1]),distortion:new Float32Array([0,0])},e}return __extends(e,t),e.prototype.getUniforms=function(e){var t=e.proj;this.shader;return null!==t.surface?t.uniforms:null!==t._activeProjection?t._activeProjection.uniforms:this.defUniforms},e.prototype.createVao=function(e){var t=this.shader.attributes;this.vertSize=14,this.vertByteSize=4*this.vertSize;var r=this.renderer.gl,i=this.renderer.createVao().addIndex(this.indexBuffer).addAttribute(e,t.aVertexPosition,r.FLOAT,!1,this.vertByteSize,0).addAttribute(e,t.aTrans1,r.FLOAT,!1,this.vertByteSize,8).addAttribute(e,t.aTrans2,r.FLOAT,!1,this.vertByteSize,20).addAttribute(e,t.aFrame,r.FLOAT,!1,this.vertByteSize,32).addAttribute(e,t.aColor,r.UNSIGNED_BYTE,!0,this.vertByteSize,48);return t.aTextureId&&i.addAttribute(e,t.aTextureId,r.FLOAT,!1,this.vertByteSize,52),i},e.prototype.fillVertices=function(e,t,r,i,n,o){for(var a=i.vertexData,s=i._texture,u=(s.orig.width,s.orig.height,i._anchor._x,i._anchor._y,s._frame),h=i.aTrans,c=0;c<4;c++)e[r]=a[2*c],e[r+1]=a[2*c+1],e[r+2]=h.a,e[r+3]=h.c,e[r+4]=h.tx,e[r+5]=h.b,e[r+6]=h.d,e[r+7]=h.ty,e[r+8]=u.x,e[r+9]=u.y,e[r+10]=u.x+u.width,e[r+11]=u.y+u.height,t[r+12]=n,e[r+13]=o,r+=14},e}((pixi_projection||(pixi_projection={})).webgl.MultiTextureSpriteRenderer);PIXI.WebGLRenderer.registerPlugin("sprite_bilinear",t)}(),function(e){var t=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.size=100,e.MAX_TEXTURES_LOCAL=1,e.shaderVert="precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec3 aTrans1;\nattribute vec3 aTrans2;\nattribute vec4 aFrame;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 worldTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * worldTransform * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n \n vTextureCoord = aVertexPosition;\n vTrans1 = aTrans1;\n vTrans2 = aTrans2;\n vTextureId = aTextureId;\n vColor = aColor;\n vFrame = aFrame;\n}\n",e.shaderFrag="precision highp float;\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nuniform sampler2D uSamplers[%count%];\nuniform vec2 samplerSize[%count%]; \nuniform vec4 params;\n\nvoid main(void){\nvec2 surface;\n\nfloat vx = vTextureCoord.x;\nfloat vy = vTextureCoord.y;\nfloat aleph = params.x;\nfloat bet = params.y;\nfloat A = params.z;\nfloat B = params.w;\n\nif (aleph == 0.0) {\n\tsurface.y = vy / (1.0 + vx * bet);\n\tsurface.x = vx;\n}\nelse if (bet == 0.0) {\n\tsurface.x = vx / (1.0 + vy * aleph);\n\tsurface.y = vy;\n} else {\n\tsurface.x = vx * (bet + 1.0) / (bet + 1.0 + vy * aleph);\n\tsurface.y = vy * (aleph + 1.0) / (aleph + 1.0 + vx * bet);\n}\n\nvec2 uv;\nuv.x = vTrans1.x * surface.x + vTrans1.y * surface.y + vTrans1.z;\nuv.y = vTrans2.x * surface.x + vTrans2.y * surface.y + vTrans2.z;\n\nvec2 pixels = uv * samplerSize[0];\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\nvec4 color;\nvec2 textureCoord = uv;\n%forloop%\ngl_FragColor = color * rColor;\n}",e.defUniforms={worldTransform:new Float32Array([1,0,0,0,1,0,0,0,1]),distortion:new Float32Array([0,0])},e}return __extends(e,t),e.prototype.getUniforms=function(e){var t=e.proj;this.shader;return null!==t.surface?t.uniforms:null!==t._activeProjection?t._activeProjection.uniforms:this.defUniforms},e.prototype.createVao=function(e){var t=this.shader.attributes;this.vertSize=14,this.vertByteSize=4*this.vertSize;var r=this.renderer.gl,i=this.renderer.createVao().addIndex(this.indexBuffer).addAttribute(e,t.aVertexPosition,r.FLOAT,!1,this.vertByteSize,0).addAttribute(e,t.aTrans1,r.FLOAT,!1,this.vertByteSize,8).addAttribute(e,t.aTrans2,r.FLOAT,!1,this.vertByteSize,20).addAttribute(e,t.aFrame,r.FLOAT,!1,this.vertByteSize,32).addAttribute(e,t.aColor,r.UNSIGNED_BYTE,!0,this.vertByteSize,48);return t.aTextureId&&i.addAttribute(e,t.aTextureId,r.FLOAT,!1,this.vertByteSize,52),i},e.prototype.fillVertices=function(e,t,r,i,n,o){for(var a=i.vertexData,s=i._texture,u=(s.orig.width,s.orig.height,i._anchor._x,i._anchor._y,s._frame),h=i.aTrans,c=0;c<4;c++)e[r]=a[2*c],e[r+1]=a[2*c+1],e[r+2]=h.a,e[r+3]=h.c,e[r+4]=h.tx,e[r+5]=h.b,e[r+6]=h.d,e[r+7]=h.ty,e[r+8]=u.x,e[r+9]=u.y,e[r+10]=u.x+u.width,e[r+11]=u.y+u.height,t[r+12]=n,e[r+13]=o,r+=14},e}((pixi_projection||(pixi_projection={})).webgl.MultiTextureSpriteRenderer);PIXI.WebGLRenderer.registerPlugin("sprite_strange",t)}(),function(e){var S=new PIXI.Matrix,n=new PIXI.Rectangle,E=new PIXI.Point,t=function(t){function e(){var e=t.call(this)||this;return e.params=[0,0,NaN,NaN],e}return __extends(e,t),e.prototype.clear=function(){var e=this.params;e[0]=0,e[1]=0,e[2]=NaN,e[3]=NaN},e.prototype.setAxisX=function(e,t,r){var i=e.x,n=e.y,o=Math.sqrt(i*i+n*n),a=r.rotation;0!==a&&(r.skew._x-=a,r.skew._y+=a,r.rotation=0),r.skew.y=Math.atan2(n,i);var s=this.params;s[2]=0!==t?-o*t:NaN,this._calc01()},e.prototype.setAxisY=function(e,t,r){var i=e.x,n=e.y,o=Math.sqrt(i*i+n*n),a=r.rotation;0!==a&&(r.skew._x-=a,r.skew._y+=a,r.rotation=0),r.skew.x=-Math.atan2(n,i)+Math.PI/2;var s=this.params;s[3]=0!==t?-o*t:NaN,this._calc01()},e.prototype._calc01=function(){var e=this.params;if(isNaN(e[2]))e[1]=0,isNaN(e[3])?e[0]=0:e[0]=1/e[3];else if(isNaN(e[3]))e[0]=0,e[1]=1/e[2];else{var t=1-e[2]*e[3];e[0]=(1-e[2])/t,e[1]=(1-e[3])/t}},e.prototype.apply=function(e,t){t=t||new PIXI.Point;var r=this.params[0],i=this.params[1],n=this.params[2],o=this.params[3],a=e.x,s=e.y;if(0===r)t.y=s*(1+a*i),t.x=a;else if(0===i)t.x=a*(1+s*r),t.y=s;else{var u=n*o-s*a;t.x=n*a*(o+s)/u,t.y=o*s*(n+a)/u}return t},e.prototype.applyInverse=function(e,t){t=t||new PIXI.Point;var r=this.params[0],i=this.params[1],n=(this.params[2],this.params[3],e.x),o=e.y;return 0===r?(t.y=o/(1+n*i),t.x=n):0===i?(t.x=n*(1+o*r),t.y=o):(t.x=n*(i+1)/(i+1+o*r),t.y=o*(r+1)/(r+1+n*i)),t},e.prototype.mapSprite=function(e,t,r){var i=e.texture;return n.x=-e.anchor.x*i.orig.width,n.y=-e.anchor.y*i.orig.height,n.width=i.orig.width,n.height=i.orig.height,this.mapQuad(n,t,r||e.transform)},e.prototype.mapQuad=function(e,t,r){var i=-e.x/e.width,n=-e.y/e.height,o=(1-e.x)/e.width,a=(1-e.y)/e.height,s=t[0].x*(1-i)+t[1].x*i,u=t[0].y*(1-i)+t[1].y*i,h=t[0].x*(1-o)+t[1].x*o,c=t[0].y*(1-o)+t[1].y*o,f=t[3].x*(1-i)+t[2].x*i,l=t[3].y*(1-i)+t[2].y*i,d=t[3].x*(1-o)+t[2].x*o,p=t[3].y*(1-o)+t[2].y*o,m=s*(1-n)+f*n,v=u*(1-n)+l*n,b=h*(1-n)+d*n,g=c*(1-n)+p*n,y=s*(1-a)+f*a,_=u*(1-a)+l*a,w=h*(1-a)+d*a,x=c*(1-a)+p*a,T=S;return T.tx=m,T.ty=v,T.a=b-m,T.b=g-v,T.c=y-m,T.d=_-v,E.set(w,x),T.applyInverse(E,E),r.setFromMatrix(T),this},e.prototype.fillUniforms=function(e){var t=this.params,r=e.params||new Float32Array([0,0,0,0]);(e.params=r)[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3]},e}(e.Surface);e.StrangeSurface=t}(pixi_projection||(pixi_projection={})),function(e){PIXI.Sprite.prototype.convertTo2s=function(){this.proj||(this.pluginName="sprite_bilinear",this.aTrans=new PIXI.Matrix,this.calculateVertices=e.Sprite2s.prototype.calculateVertices,this.calculateTrimmedVertices=e.Sprite2s.prototype.calculateTrimmedVertices,this._calculateBounds=e.Sprite2s.prototype._calculateBounds,PIXI.Container.prototype.convertTo2s.call(this))},PIXI.Container.prototype.convertTo2s=function(){this.proj||(this.proj=new e.Projection2d(this.transform),Object.defineProperty(this,"worldTransform",{get:function(){return this.proj},enumerable:!0,configurable:!0}))},PIXI.Container.prototype.convertSubtreeTo2s=function(){this.convertTo2s();for(var e=0;e=o.TRANSFORM_STEP.PROJ?(i||this.displayObjectUpdateTransform(),this.proj.affine?this.transform.worldTransform.applyInverse(e,r):this.proj.world.applyInverse(e,r)):(this.parent?r=this.parent.worldTransform.applyInverse(e,r):r.copy(e),n===o.TRANSFORM_STEP.NONE?r:this.transform.localTransform.applyInverse(r,r))},Object.defineProperty(e.prototype,"worldTransform",{get:function(){return this.proj.affine?this.transform.worldTransform:this.proj.world},enumerable:!0,configurable:!0}),e}(PIXI.Container);o.Container2d=e,o.container2dToLocal=e.prototype.toLocal}(pixi_projection||(pixi_projection={})),function(e){var u,t,b=PIXI.Point,r=[1,0,0,0,1,0,0,0,1];(t=u=e.AFFINE||(e.AFFINE={}))[t.NONE=0]="NONE",t[t.FREE=1]="FREE",t[t.AXIS_X=2]="AXIS_X",t[t.AXIS_Y=3]="AXIS_Y",t[t.POINT=4]="POINT",t[t.AXIS_XR=5]="AXIS_XR";var i=function(){function e(e){this.floatArray=null,this.mat3=new Float64Array(e||r)}return Object.defineProperty(e.prototype,"a",{get:function(){return this.mat3[0]/this.mat3[8]},set:function(e){this.mat3[0]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"b",{get:function(){return this.mat3[1]/this.mat3[8]},set:function(e){this.mat3[1]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"c",{get:function(){return this.mat3[3]/this.mat3[8]},set:function(e){this.mat3[3]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"d",{get:function(){return this.mat3[4]/this.mat3[8]},set:function(e){this.mat3[4]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tx",{get:function(){return this.mat3[6]/this.mat3[8]},set:function(e){this.mat3[6]=e*this.mat3[8]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ty",{get:function(){return this.mat3[7]/this.mat3[8]},set:function(e){this.mat3[7]=e*this.mat3[8]},enumerable:!0,configurable:!0}),e.prototype.set=function(e,t,r,i,n,o){var a=this.mat3;return a[0]=e,a[1]=t,a[2]=0,a[3]=r,a[4]=i,a[5]=0,a[6]=n,a[7]=o,a[8]=1,this},e.prototype.toArray=function(e,t){this.floatArray||(this.floatArray=new Float32Array(9));var r=t||this.floatArray,i=this.mat3;return e?(r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7]):(r[0]=i[0],r[1]=i[3],r[2]=i[6],r[3]=i[1],r[4]=i[4],r[5]=i[7],r[6]=i[2],r[7]=i[5]),r[8]=i[8],r},e.prototype.apply=function(e,t){t=t||new PIXI.Point;var r=this.mat3,i=e.x,n=e.y,o=1/(r[2]*i+r[5]*n+r[8]);return t.x=o*(r[0]*i+r[3]*n+r[6]),t.y=o*(r[1]*i+r[4]*n+r[7]),t},e.prototype.translate=function(e,t){var r=this.mat3;return r[0]+=e*r[2],r[1]+=t*r[2],r[3]+=e*r[5],r[4]+=t*r[5],r[6]+=e*r[8],r[7]+=t*r[8],this},e.prototype.scale=function(e,t){var r=this.mat3;return r[0]*=e,r[1]*=t,r[3]*=e,r[4]*=t,r[6]*=e,r[7]*=t,this},e.prototype.scaleAndTranslate=function(e,t,r,i){var n=this.mat3;n[0]=e*n[0]+r*n[2],n[1]=t*n[1]+i*n[2],n[3]=e*n[3]+r*n[5],n[4]=t*n[4]+i*n[5],n[6]=e*n[6]+r*n[8],n[7]=t*n[7]+i*n[8]},e.prototype.applyInverse=function(e,t){t=t||new b;var r=this.mat3,i=e.x,n=e.y,o=r[0],a=r[3],s=r[6],u=r[1],h=r[4],c=r[7],f=r[2],l=r[5],d=r[8],p=(d*h-c*l)*i+(-d*a+s*l)*n+(c*a-s*h),m=(-d*u+c*f)*i+(d*o-s*f)*n+(-c*o+s*u),v=(l*u-h*f)*i+(-l*o+a*f)*n+(h*o-a*u);return t.x=p/v,t.y=m/v,t},e.prototype.invert=function(){var e=this.mat3,t=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],s=e[6],u=e[7],h=e[8],c=h*o-a*u,f=-h*n+a*s,l=u*n-o*s,d=t*c+r*f+i*l;return d&&(d=1/d,e[0]=c*d,e[1]=(-h*r+i*u)*d,e[2]=(a*r-i*o)*d,e[3]=f*d,e[4]=(h*t-i*s)*d,e[5]=(-a*t+i*n)*d,e[6]=l*d,e[7]=(-u*t+r*s)*d,e[8]=(o*t-r*n)*d),this},e.prototype.identity=function(){var e=this.mat3;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this},e.prototype.clone=function(){return new e(this.mat3)},e.prototype.copyTo=function(e){var t=this.mat3,r=e.mat3;return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],e},e.prototype.copyTo2dOr3d=function(e){return this.copyTo(e)},e.prototype.copy=function(e,t,r){var i=this.mat3,n=1/i[8],o=i[6]*n,a=i[7]*n;if(e.a=(i[0]-i[2]*o)*n,e.b=(i[1]-i[2]*a)*n,e.c=(i[3]-i[5]*o)*n,e.d=(i[4]-i[5]*a)*n,e.tx=o,e.ty=a,2<=t){var s=e.a*e.d-e.b*e.c;r||(s=Math.abs(s)),t===u.POINT?(s=0=r&&ethis._duration?this._duration:e,t)):this._time},n.totalTime=function(e,t,r){if(b||v.wake(),!arguments.length)return this._totalTime;if(this._timeline){if(e<0&&!r&&(e+=this.totalDuration()),this._timeline.smoothChildTiming){this._dirty&&this.totalDuration();var i=this._totalDuration,n=this._timeline;if(io;)n=n._prev;return n?(e._next=n._next,n._next=e):(e._next=this._first,this._first=e),e._next?e._next._prev=e:this._last=e,e._prev=n,this._recent=e,this._timeline&&this._uncache(!0),this},n._remove=function(e,t){return e.timeline===this&&(t||e._enabled(!1,!0),e._prev?e._prev._next=e._next:this._first===e&&(this._first=e._next),e._next?e._next._prev=e._prev:this._last===e&&(this._last=e._prev),e._next=e._prev=e.timeline=null,e===this._recent&&(this._recent=this._last),this._timeline&&this._uncache(!0)),this},n.render=function(e,t,r){var i,n=this._first;for(this._totalTime=this._time=this._rawPrevTime=e;n;)i=n._next,(n._active||e>=n._startTime&&!n._paused&&!n._gc)&&(n._reversed?n.render((n._dirty?n.totalDuration():n._totalDuration)-(e-n._startTime)*n._timeScale,t,r):n.render((e-n._startTime)*n._timeScale,t,r)),n=i},n.rawTime=function(){return b||v.wake(),this._totalTime};var L=S("TweenLite",function(e,t,r){if(R.call(this,t,r),this.render=L.prototype.render,null==e)throw"Cannot tween a null target.";this.target=e="string"!=typeof e?e:L.selector(e)||e;var i,n,o,a=e.jquery||e.length&&e!==l&&e[0]&&(e[0]===l||e[0].nodeType&&e[0].style&&!e.nodeType),s=this.vars.overwrite;if(this._overwrite=s=null==s?K[L.defaultOverwrite]:"number"==typeof s?s>>0:K[s],(a||e instanceof Array||e.push&&w(e))&&"number"!=typeof e[0])for(this._targets=o=u(e),this._propLookup=[],this._siblings=[],i=0;i=$){for(r in $=v.frame+(parseInt(L.autoSleep,10)||120),Y){for(e=(t=Y[r].tweens).length;-1<--e;)t[e]._gc&&t.splice(e,1);0===t.length&&delete Y[r]}if((!(r=Q._first)||r._paused)&&L.autoSleep&&!Z._first&&1===v._listeners.tick.length){for(;r&&r._paused;)r=r._next;r||v.sleep()}}},v.addEventListener("tick",R._updateRoot);var te=function(e,t,r){var i,n,o=e._gsTweenID;if(Y[o||(e._gsTweenID=o="t"+W++)]||(Y[o]={target:e,tweens:[]}),t&&((i=Y[o].tweens)[n=i.length]=t,r))for(;-1<--n;)i[n]===t&&i.splice(n,1);return Y[o].tweens},re=function(e,t,r,i){var n,o,a=e.vars.onOverwrite;return a&&(n=a(e,t,r,i)),(a=L.onOverwrite)&&(o=a(e,t,r,i)),!1!==n&&!1!==o},ie=function(e,t,r,i,n){var o,a,s,u;if(1===i||4<=i){for(u=n.length,o=0;oc&&((d||!s._initted)&&c-s._startTime<=2e-8||(f[l++]=s)));for(o=l;-1<--o;)if(u=(s=f[o])._firstPT,2===i&&s._kill(r,e,t)&&(a=!0),2!==i||!s._firstPT&&s._initted&&u){if(2!==i&&!re(s,t))continue;s._enabled(!1,!1)&&(a=!0)}return a},ne=function(e,t,r){for(var i=e._timeline,n=i._timeScale,o=e._startTime;i._timeline;){if(o+=i._startTime,n*=i._timeScale,i._paused)return-100;i=i._timeline}return t<(o/=n)?o-t:r&&o===t||!e._initted&&o-t<2e-8?y:(o+=e.totalDuration()/e._timeScale/n)>t+y?0:o-t-y};n._init=function(){var e,t,r,i,n,o,a=this.vars,s=this._overwrittenProps,u=this._duration,h=!!a.immediateRender,c=a.ease,f=this._startAt;if(a.startAt){for(i in f&&(f.render(-1,!0),f.kill()),n={},a.startAt)n[i]=a.startAt[i];if(n.data="isStart",n.overwrite=!1,n.immediateRender=!0,n.lazy=h&&!1!==a.lazy,n.startAt=n.delay=null,n.onUpdate=a.onUpdate,n.onUpdateParams=a.onUpdateParams,n.onUpdateScope=a.onUpdateScope||a.callbackScope||this,this._startAt=L.to(this.target||{},0,n),h)if(0s.pr;)i=i._next;(s._prev=i?i._prev:o)?s._prev._next=s:n=s,(s._next=i)?i._prev=s:o=s,s=a}s=t._firstPT=n}for(;s;)s.pg&&"function"==typeof s.t[e]&&s.t[e]()&&(r=!0),s=s._next;return r},oe.activate=function(e){for(var t=e.length;-1<--t;)e[t].API===oe.API&&(V[(new e[t])._propName]=e[t]);return!0},s.plugin=function(e){if(!(e&&e.propName&&e.init&&e.API))throw"illegal plugin definition.";var t,r=e.propName,i=e.priority||0,n=e.overwriteProps,o={init:"_onInitTween",set:"setRatio",kill:"_kill",round:"_mod",mod:"_mod",initAll:"_onInitAllProps"},a=S("plugins."+r.charAt(0).toUpperCase()+r.substr(1)+"Plugin",function(){oe.call(this,r,i),this._overwriteProps=n||[]},!0===e.global),s=a.prototype=new oe(r);for(t in(s.constructor=a).API=e.API,o)"function"==typeof e[t]&&(s[o[t]]=e[t]);return a.version=e.version,oe.activate([a]),a},t=l._gsQueue){for(r=0;r