fancy-webgl-sparkles
Version:
PIXI.js library to add glitter particles with bokeh and special effects to your DOM elements
25 lines • 278 kB
JavaScript
!function t(e,r,i){function n(s,a){if(!r[s]){if(!e[s]){var h="function"==typeof require&&require;if(!a&&h)return h(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[s]={exports:{}};e[s][0].call(l.exports,(function(t){return n(e[s][1][t]||t)}),l,l.exports,t,e,r,i)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,e,r){
/*!
* @pixi/app - v5.2.1
* Compiled Tue, 28 Jan 2020 23:33:11 UTC
*
* @pixi/app is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("@pixi/display"),n=t("@pixi/core"),o=function t(e){var r=this;e=Object.assign({forceCanvas:!1},e),this.renderer=n.autoDetectRenderer(e),this.stage=new i.Container,t._plugins.forEach((function(t){t.init.call(r,e)}))},s={view:{configurable:!0},screen:{configurable:!0}};o.registerPlugin=function(t){o._plugins.push(t)},o.prototype.render=function(){this.renderer.render(this.stage)},s.view.get=function(){return this.renderer.view},s.screen.get=function(){return this.renderer.screen},o.prototype.destroy=function(t,e){var r=this,i=o._plugins.slice(0);i.reverse(),i.forEach((function(t){t.destroy.call(r)})),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null,this._options=null},Object.defineProperties(o.prototype,s),o._plugins=[];var a=function(){};a.init=function(t){var e=this;Object.defineProperty(this,"resizeTo",{set:function(t){window.removeEventListener("resize",this.resize),this._resizeTo=t,t&&(window.addEventListener("resize",this.resize),this.resize())},get:function(){return this._resizeTo}}),this.resize=function(){e._resizeTo&&(e._resizeTo===window?e.renderer.resize(window.innerWidth,window.innerHeight):e.renderer.resize(e._resizeTo.clientWidth,e._resizeTo.clientHeight))},this._resizeTo=null,this.resizeTo=t.resizeTo||null},a.destroy=function(){this.resizeTo=null,this.resize=null},o.registerPlugin(a),r.Application=o},{"@pixi/core":3,"@pixi/display":4}],2:[function(t,e,r){
/*!
* @pixi/constants - v5.2.1
* Compiled Tue, 28 Jan 2020 23:33:11 UTC
*
* @pixi/constants is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";var i,n,o,s,a,h,u,l,c,d,p,f,m,y;Object.defineProperty(r,"__esModule",{value:!0}),(i=r.ENV||(r.ENV={}))[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",(n=r.RENDERER_TYPE||(r.RENDERER_TYPE={}))[n.UNKNOWN=0]="UNKNOWN",n[n.WEBGL=1]="WEBGL",n[n.CANVAS=2]="CANVAS",(o=r.BLEND_MODES||(r.BLEND_MODES={}))[o.NORMAL=0]="NORMAL",o[o.ADD=1]="ADD",o[o.MULTIPLY=2]="MULTIPLY",o[o.SCREEN=3]="SCREEN",o[o.OVERLAY=4]="OVERLAY",o[o.DARKEN=5]="DARKEN",o[o.LIGHTEN=6]="LIGHTEN",o[o.COLOR_DODGE=7]="COLOR_DODGE",o[o.COLOR_BURN=8]="COLOR_BURN",o[o.HARD_LIGHT=9]="HARD_LIGHT",o[o.SOFT_LIGHT=10]="SOFT_LIGHT",o[o.DIFFERENCE=11]="DIFFERENCE",o[o.EXCLUSION=12]="EXCLUSION",o[o.HUE=13]="HUE",o[o.SATURATION=14]="SATURATION",o[o.COLOR=15]="COLOR",o[o.LUMINOSITY=16]="LUMINOSITY",o[o.NORMAL_NPM=17]="NORMAL_NPM",o[o.ADD_NPM=18]="ADD_NPM",o[o.SCREEN_NPM=19]="SCREEN_NPM",o[o.NONE=20]="NONE",o[o.SRC_OVER=0]="SRC_OVER",o[o.SRC_IN=21]="SRC_IN",o[o.SRC_OUT=22]="SRC_OUT",o[o.SRC_ATOP=23]="SRC_ATOP",o[o.DST_OVER=24]="DST_OVER",o[o.DST_IN=25]="DST_IN",o[o.DST_OUT=26]="DST_OUT",o[o.DST_ATOP=27]="DST_ATOP",o[o.ERASE=26]="ERASE",o[o.SUBTRACT=28]="SUBTRACT",o[o.XOR=29]="XOR",(s=r.DRAW_MODES||(r.DRAW_MODES={}))[s.POINTS=0]="POINTS",s[s.LINES=1]="LINES",s[s.LINE_LOOP=2]="LINE_LOOP",s[s.LINE_STRIP=3]="LINE_STRIP",s[s.TRIANGLES=4]="TRIANGLES",s[s.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",s[s.TRIANGLE_FAN=6]="TRIANGLE_FAN",(a=r.FORMATS||(r.FORMATS={}))[a.RGBA=6408]="RGBA",a[a.RGB=6407]="RGB",a[a.ALPHA=6406]="ALPHA",a[a.LUMINANCE=6409]="LUMINANCE",a[a.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",a[a.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",a[a.DEPTH_STENCIL=34041]="DEPTH_STENCIL",(h=r.TARGETS||(r.TARGETS={}))[h.TEXTURE_2D=3553]="TEXTURE_2D",h[h.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",h[h.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",h[h.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",h[h.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",h[h.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",h[h.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",h[h.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",h[h.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",(u=r.TYPES||(r.TYPES={}))[u.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",u[u.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",u[u.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",u[u.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",u[u.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",u[u.FLOAT=5126]="FLOAT",u[u.HALF_FLOAT=36193]="HALF_FLOAT",(l=r.SCALE_MODES||(r.SCALE_MODES={}))[l.NEAREST=0]="NEAREST",l[l.LINEAR=1]="LINEAR",(c=r.WRAP_MODES||(r.WRAP_MODES={}))[c.CLAMP=33071]="CLAMP",c[c.REPEAT=10497]="REPEAT",c[c.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",(d=r.MIPMAP_MODES||(r.MIPMAP_MODES={}))[d.OFF=0]="OFF",d[d.POW2=1]="POW2",d[d.ON=2]="ON",(p=r.ALPHA_MODES||(r.ALPHA_MODES={}))[p.NPM=0]="NPM",p[p.UNPACK=1]="UNPACK",p[p.PMA=2]="PMA",p[p.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",p[p.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",p[p.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",(f=r.GC_MODES||(r.GC_MODES={}))[f.AUTO=0]="AUTO",f[f.MANUAL=1]="MANUAL",(m=r.PRECISION||(r.PRECISION={})).LOW="lowp",m.MEDIUM="mediump",m.HIGH="highp",(y=r.MASK_TYPES||(r.MASK_TYPES={}))[y.NONE=0]="NONE",y[y.SCISSOR=1]="SCISSOR",y[y.STENCIL=2]="STENCIL",y[y.SPRITE=3]="SPRITE"},{}],3:[function(t,e,r){
/*!
* @pixi/core - v5.2.1
* Compiled Tue, 28 Jan 2020 23:33:11 UTC
*
* @pixi/core is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("@pixi/runner"),n=t("@pixi/utils"),o=t("@pixi/constants"),s=t("@pixi/settings"),a=t("@pixi/ticker"),h=t("@pixi/math"),u=t("@pixi/display"),l=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new i.Runner("setRealSize",2),this.onUpdate=new i.Runner("update"),this.onError=new i.Runner("onError",1)},c={valid:{configurable:!0},width:{configurable:!0},height:{configurable:!0}};l.prototype.bind=function(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.run(this._width,this._height)},l.prototype.unbind=function(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)},l.prototype.resize=function(t,e){t===this._width&&e===this._height||(this._width=t,this._height=e,this.onResize.run(t,e))},c.valid.get=function(){return!!this._width&&!!this._height},l.prototype.update=function(){this.destroyed||this.onUpdate.run()},l.prototype.load=function(){return Promise.resolve()},c.width.get=function(){return this._width},c.height.get=function(){return this._height},l.prototype.upload=function(t,e,r){return!1},l.prototype.style=function(t,e,r){return!1},l.prototype.dispose=function(){},l.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)},Object.defineProperties(l.prototype,c);var d=function(t){function e(e){var r=e.naturalWidth||e.videoWidth||e.width,i=e.naturalHeight||e.videoHeight||e.height;t.call(this,r,i),this.source=e,this.noSubImage=!1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.crossOrigin=function(t,e,r){void 0===r&&0!==e.indexOf("data:")?t.crossOrigin=n.determineCrossOrigin(e):!1!==r&&(t.crossOrigin="string"==typeof r?r:"anonymous")},e.prototype.upload=function(t,e,r,i){var n=t.gl,s=e.realWidth,a=e.realHeight;return i=i||this.source,n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===o.ALPHA_MODES.UNPACK),this.noSubImage||e.target!==n.TEXTURE_2D||r.width!==s||r.height!==a?(r.width=s,r.height=a,n.texImage2D(e.target,0,e.format,e.format,e.type,i)):n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,e.type,i),!0},e.prototype.update=function(){if(!this.destroyed){var e=this.source.naturalWidth||this.source.videoWidth||this.source.width,r=this.source.naturalHeight||this.source.videoHeight||this.source.height;this.resize(e,r),t.prototype.update.call(this)}},e.prototype.dispose=function(){this.source=null},e}(l),p=function(t){function e(e,r){if(r=r||{},!(e instanceof HTMLImageElement)){var i=new Image;t.crossOrigin(i,e,r.crossorigin),i.src=e,e=i}t.call(this,e),!e.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=e.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(void 0!==r.createBitmap?r.createBitmap:s.settings.CREATE_IMAGE_BITMAP)&&!!window.createImageBitmap,this.alphaMode="number"==typeof r.alphaMode?r.alphaMode:null,void 0!==r.premultiplyAlpha&&(this.premultiplyAlpha=r.premultiplyAlpha),this.bitmap=null,this._load=null,!1!==r.autoLoad&&this.load()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.load=function(t){var e=this;return void 0!==t&&(this.createBitmap=t),this._load?this._load:(this._load=new Promise((function(t){e.url=e.source.src;var r=e.source,i=function(){e.destroyed||(r.onload=null,r.onerror=null,e.resize(r.width,r.height),e._load=null,e.createBitmap?t(e.process()):t(e))};r.complete&&r.src?i():(r.onload=i,r.onerror=function(t){return e.onError.run(t)})})),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===o.ALPHA_MODES.UNPACK?"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,r,i){if("number"==typeof this.alphaMode&&(r.alphaMode=this.alphaMode),!this.createBitmap)return t.prototype.upload.call(this,e,r,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(t.prototype.upload.call(this,e,r,i,this.bitmap),!this.preserveBitmap){var n=!0;for(var o in r._glTextures){var s=r._glTextures[o];if(s!==i&&s.dirtyId!==r.dirtyId){n=!1;break}}n&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0},e.prototype.dispose=function(){this.source.onload=null,this.source.onerror=null,t.prototype.dispose.call(this),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null},e}(d),f=[];function m(t,e){if(!t)return null;var r="";if("string"==typeof t){var i=/\.(\w{3,4})(?:$|\?|#)/i.exec(t);i&&(r=i[1].toLowerCase())}for(var n=f.length-1;n>=0;--n){var o=f[n];if(o.test&&o.test(t,r))return new o(t,e)}return new p(t,e)}var y=function(t){function e(e,r){var i=r||{},n=i.width,o=i.height;if(!n||!o)throw new Error("BufferResource width or height invalid");t.call(this,n,o),this.data=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.upload=function(t,e,r){var i=t.gl;return i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===o.ALPHA_MODES.UNPACK),r.width===e.width&&r.height===e.height?i.texSubImage2D(e.target,0,0,0,e.width,e.height,e.format,e.type,this.data):(r.width=e.width,r.height=e.height,i.texImage2D(e.target,0,r.internalFormat,e.width,e.height,0,e.format,r.type,this.data)),!0},e.prototype.dispose=function(){this.data=null},e.test=function(t){return t instanceof Float32Array||t instanceof Uint8Array||t instanceof Uint32Array},e}(l),_={scaleMode:o.SCALE_MODES.NEAREST,format:o.FORMATS.RGBA,alphaMode:o.ALPHA_MODES.NPM},v=function(t){function e(e,r){void 0===e&&(e=null),void 0===r&&(r=null),t.call(this);var i=(r=r||{}).alphaMode,a=r.mipmap,h=r.anisotropicLevel,u=r.scaleMode,c=r.width,d=r.height,p=r.wrapMode,f=r.format,y=r.type,_=r.target,v=r.resolution,g=r.resourceOptions;!e||e instanceof l||((e=m(e,g)).internal=!0),this.width=c||0,this.height=d||0,this.resolution=v||s.settings.RESOLUTION,this.mipmap=void 0!==a?a:s.settings.MIPMAP_TEXTURES,this.anisotropicLevel=void 0!==h?h:s.settings.ANISOTROPIC_LEVEL,this.wrapMode=p||s.settings.WRAP_MODE,this.scaleMode=void 0!==u?u:s.settings.SCALE_MODE,this.format=f||o.FORMATS.RGBA,this.type=y||o.TYPES.UNSIGNED_BYTE,this.target=_||o.TARGETS.TEXTURE_2D,this.alphaMode=void 0!==i?i:o.ALPHA_MODES.UNPACK,void 0!==r.premultiplyAlpha&&(this.premultiplyAlpha=r.premultiplyAlpha),this.uid=n.uid(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=c>0&&d>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.setResource(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={realWidth:{configurable:!0},realHeight:{configurable:!0}};return r.realWidth.get=function(){return Math.ceil(this.width*this.resolution-1e-4)},r.realHeight.get=function(){return Math.ceil(this.height*this.resolution-1e-4)},e.prototype.setStyle=function(t,e){var r;return void 0!==t&&t!==this.scaleMode&&(this.scaleMode=t,r=!0),void 0!==e&&e!==this.mipmap&&(this.mipmap=e,r=!0),r&&this.dirtyStyleId++,this},e.prototype.setSize=function(t,e,r){return this.resolution=r||this.resolution,this.width=t,this.height=e,this._refreshPOT(),this.update(),this},e.prototype.setRealSize=function(t,e,r){return this.resolution=r||this.resolution,this.width=t/this.resolution,this.height=e/this.resolution,this._refreshPOT(),this.update(),this},e.prototype._refreshPOT=function(){this.isPowerOfTwo=n.isPow2(this.realWidth)&&n.isPow2(this.realHeight)},e.prototype.setResolution=function(t){var e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=this.width*e/t,this.height=this.height*e/t,this.emit("update",this)),this._refreshPOT(),this)},e.prototype.setResource=function(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this},e.prototype.update=function(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))},e.prototype.onError=function(t){this.emit("error",this,t)},e.prototype.destroy=function(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete n.BaseTextureCache[this.cacheId],delete n.TextureCache[this.cacheId],this.cacheId=null),this.dispose(),e.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0},e.prototype.dispose=function(){this.emit("dispose",this)},e.from=function(t,r,i){void 0===i&&(i=s.settings.STRICT_TEXTURE_CACHE);var o="string"==typeof t,a=null;o?a=t:(t._pixiId||(t._pixiId="pixiid_"+n.uid()),a=t._pixiId);var h=n.BaseTextureCache[a];if(o&&i&&!h)throw new Error('The cacheId "'+a+'" does not exist in BaseTextureCache.');return h||((h=new e(t,r)).cacheId=a,e.addToCache(h,a)),h},e.fromBuffer=function(t,r,i,n){t=t||new Float32Array(r*i*4);var s=new y(t,{width:r,height:i}),a=t instanceof Float32Array?o.TYPES.FLOAT:o.TYPES.UNSIGNED_BYTE;return new e(s,Object.assign(_,n||{width:r,height:i,type:a}))},e.addToCache=function(t,e){e&&(-1===t.textureCacheIds.indexOf(e)&&t.textureCacheIds.push(e),n.BaseTextureCache[e]&&console.warn("BaseTexture added to the cache with an id ["+e+"] that already had an entry"),n.BaseTextureCache[e]=t)},e.removeFromCache=function(t){if("string"==typeof t){var e=n.BaseTextureCache[t];if(e){var r=e.textureCacheIds.indexOf(t);return r>-1&&e.textureCacheIds.splice(r,1),delete n.BaseTextureCache[t],e}}else if(t&&t.textureCacheIds){for(var i=0;i<t.textureCacheIds.length;++i)delete n.BaseTextureCache[t.textureCacheIds[i]];return t.textureCacheIds.length=0,t}return null},Object.defineProperties(e.prototype,r),e}(n.EventEmitter);v._globalBatch=0;var g=function(t){function e(e,r){var i;r=r||{};var n=e;Array.isArray(e)&&(i=e,n=e.length),t.call(this,r.width,r.height),this.items=[],this.itemDirtyIds=[];for(var o=0;o<n;o++){var s=new v;this.items.push(s),this.itemDirtyIds.push(-1)}if(this.length=n,this._load=null,i)for(var a=0;a<n;a++)this.addResourceAt(m(i[a],r),a)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.dispose=function(){for(var t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null},e.prototype.addResourceAt=function(t,e){if(!this.items[e])throw new Error("Index "+e+" is out of bounds");return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this},e.prototype.bind=function(e){t.prototype.bind.call(this,e),e.target=o.TARGETS.TEXTURE_2D_ARRAY;for(var r=0;r<this.length;r++)this.items[r].on("update",e.update,e)},e.prototype.unbind=function(e){t.prototype.unbind.call(this,e);for(var r=0;r<this.length;r++)this.items[r].off("update",e.update,e)},e.prototype.load=function(){var t=this;if(this._load)return this._load;var e=this.items.map((function(t){return t.resource})),r=e.map((function(t){return t.load()}));return this._load=Promise.all(r).then((function(){var r=e[0],i=r.width,n=r.height;return t.resize(i,n),Promise.resolve(t)})),this._load},e.prototype.upload=function(t,e,r){var i=this.length,n=this.itemDirtyIds,o=this.items,s=t.gl;r.dirtyId<0&&s.texImage3D(s.TEXTURE_2D_ARRAY,0,e.format,this._width,this._height,i,0,e.format,e.type,null);for(var a=0;a<i;a++){var h=o[a];n[a]<h.dirtyId&&(n[a]=h.dirtyId,h.valid&&s.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,a,h.resource.width,h.resource.height,1,e.format,e.type,h.resource.source))}return!0},e}(l),x=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.test=function(t){var e=window.OffscreenCanvas;return!!(e&&t instanceof e)||t instanceof HTMLCanvasElement},e}(d),b=function(t){function e(r,i){if(i=i||{},t.call(this,r,i),this.length!==e.SIDES)throw new Error("Invalid length. Got "+this.length+", expected 6");for(var n=0;n<e.SIDES;n++)this.items[n].target=o.TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X+n;!1!==i.autoLoad&&this.load()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.bind=function(e){t.prototype.bind.call(this,e),e.target=o.TARGETS.TEXTURE_CUBE_MAP},e.prototype.upload=function(t,r,i){for(var n=this.itemDirtyIds,o=0;o<e.SIDES;o++){var s=this.items[o];n[o]<s.dirtyId&&(n[o]=s.dirtyId,s.valid&&s.resource.upload(t,s,i))}return!0},e}(g);b.SIDES=6;var E=function(t){function e(e,r){r=r||{},t.call(this,document.createElement("canvas")),this._width=0,this._height=0,this.svg=e,this.scale=r.scale||1,this._overrideWidth=r.width,this._overrideHeight=r.height,this._resolve=null,this._crossorigin=r.crossorigin,this._load=null,!1!==r.autoLoad&&this.load()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.load=function(){var t=this;return this._load?this._load:(this._load=new Promise((function(e){if(t._resolve=function(){t.resize(t.source.width,t.source.height),e(t)},/^\<svg/.test(t.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");t.svg="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(t.svg)))}t._loadSvg()})),this._load)},e.prototype._loadSvg=function(){var e=this,r=new Image;t.crossOrigin(r,this.svg,this._crossorigin),r.src=this.svg,r.onerror=function(t){r.onerror=null,e.onError.run(t)},r.onload=function(){var t=r.width,i=r.height;if(!t||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");var o=t*e.scale,s=i*e.scale;(e._overrideWidth||e._overrideHeight)&&(o=e._overrideWidth||e._overrideHeight/i*t,s=e._overrideHeight||e._overrideWidth/t*i),o=Math.round(o),s=Math.round(s);var a=e.source;a.width=o,a.height=s,a._pixiId="canvas_"+n.uid(),a.getContext("2d").drawImage(r,0,0,t,i,0,0,o,s),e._resolve(),e._resolve=null}},e.getSize=function(t){var r=e.SVG_SIZE.exec(t),i={};return r&&(i[r[1]]=Math.round(parseFloat(r[3])),i[r[5]]=Math.round(parseFloat(r[7]))),i},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._resolve=null,this._crossorigin=null},e.test=function(t,e){return"svg"===e||"string"==typeof t&&0===t.indexOf("data:image/svg+xml;base64")||"string"==typeof t&&0===t.indexOf("<svg")},e}(d);E.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var T=function(t){function e(e,r){if(r=r||{},!(e instanceof HTMLVideoElement)){var i=document.createElement("video");i.setAttribute("preload","auto"),i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline",""),"string"==typeof e&&(e=[e]),t.crossOrigin(i,e[0].src||e[0],r.crossorigin);for(var n=0;n<e.length;++n){var o=document.createElement("source"),s=e[n],a=s.src,h=s.mime,u=(a=a||e[n]).split("?").shift().toLowerCase(),l=u.substr(u.lastIndexOf(".")+1);h=h||"video/"+l,o.src=a,o.type=h,i.appendChild(o)}e=i}t.call(this,e),this.noSubImage=!0,this._autoUpdate=!0,this._isAutoUpdating=!1,this._updateFPS=r.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==r.autoPlay,this._load=null,this._resolve=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),!1!==r.autoLoad&&this.load()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={autoUpdate:{configurable:!0},updateFPS:{configurable:!0}};return e.prototype.update=function(e){if(void 0===e&&(e=0),!this.destroyed){var r=a.Ticker.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-r),(!this._updateFPS||this._msToNextUpdate<=0)&&(t.prototype.update.call(this,e),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}},e.prototype.load=function(){var t=this;if(this._load)return this._load;var e=this.source;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart.bind(this)),e.addEventListener("pause",this._onPlayStop.bind(this)),this._isSourceReady()?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._load=new Promise((function(r){t.valid?r(t):(t._resolve=r,e.load())})),this._load},e.prototype._onError=function(){this.source.removeEventListener("error",this._onError,!0),this.onError.run(event)},e.prototype._isSourcePlaying=function(){var t=this.source;return t.currentTime>0&&!1===t.paused&&!1===t.ended&&t.readyState>2},e.prototype._isSourceReady=function(){return 3===this.source.readyState||4===this.source.readyState},e.prototype._onPlayStart=function(){this.valid||this._onCanPlay(),!this._isAutoUpdating&&this.autoUpdate&&(a.Ticker.shared.add(this.update,this),this._isAutoUpdating=!0)},e.prototype._onPlayStop=function(){this._isAutoUpdating&&(a.Ticker.shared.remove(this.update,this),this._isAutoUpdating=!1)},e.prototype._onCanPlay=function(){var t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);var e=this.valid;this.resize(t.videoWidth,t.videoHeight),!e&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()},e.prototype.dispose=function(){this._isAutoUpdating&&a.Ticker.shared.remove(this.update,this),this.source&&(this.source.removeEventListener("error",this._onError,!0),this.source.pause(),this.source.src="",this.source.load()),t.prototype.dispose.call(this)},r.autoUpdate.get=function(){return this._autoUpdate},r.autoUpdate.set=function(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isAutoUpdating?(a.Ticker.shared.remove(this.update,this),this._isAutoUpdating=!1):this._autoUpdate&&!this._isAutoUpdating&&(a.Ticker.shared.add(this.update,this),this._isAutoUpdating=!0))},r.updateFPS.get=function(){return this._updateFPS},r.updateFPS.set=function(t){t!==this._updateFPS&&(this._updateFPS=t)},e.test=function(t,r){return t instanceof HTMLVideoElement||e.TYPES.indexOf(r)>-1},Object.defineProperties(e.prototype,r),e}(d);T.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"];var w=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.test=function(t){return!!window.createImageBitmap&&t instanceof ImageBitmap},e}(d);f.push(p,w,x,T,E,y,b,g);var S={INSTALLED:f,autoDetectResource:m,ArrayResource:g,BufferResource:y,CanvasResource:x,CubeResource:b,ImageResource:p,ImageBitmapResource:w,SVGResource:E,VideoResource:T,Resource:l,BaseImageResource:d},O=function(t){this.renderer=t};O.prototype.destroy=function(){this.renderer=null};var A=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.upload=function(t,e,r){var i=t.gl;return i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===o.ALPHA_MODES.UNPACK),r.width===e.width&&r.height===e.height?i.texSubImage2D(e.target,0,0,0,e.width,e.height,e.format,e.type,this.data):(r.width=e.width,r.height=e.height,i.texImage2D(e.target,0,i.DEPTH_COMPONENT16,e.width,e.height,0,e.format,e.type,this.data)),!0},e}(y),P=function(t,e){this.width=Math.ceil(t||100),this.height=Math.ceil(e||100),this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new i.Runner("disposeFramebuffer",2)},C={colorTexture:{configurable:!0}};C.colorTexture.get=function(){return this.colorTextures[0]},P.prototype.addColorTexture=function(t,e){return void 0===t&&(t=0),this.colorTextures[t]=e||new v(null,{scaleMode:0,resolution:1,mipmap:!1,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this},P.prototype.addDepthTexture=function(t){return this.depthTexture=t||new v(new A(null,{width:this.width,height:this.height}),{scaleMode:0,resolution:1,width:this.width,height:this.height,mipmap:!1,format:o.FORMATS.DEPTH_COMPONENT,type:o.TYPES.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this},P.prototype.enableDepth=function(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this},P.prototype.enableStencil=function(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this},P.prototype.resize=function(t,e){if(t=Math.ceil(t),e=Math.ceil(e),t!==this.width||e!==this.height){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(var r=0;r<this.colorTextures.length;r++){var i=this.colorTextures[r],n=i.resolution;i.setSize(t/n,e/n)}if(this.depthTexture){var o=this.depthTexture.resolution;this.depthTexture.setSize(t/o,e/o)}}},P.prototype.dispose=function(){this.disposeRunner.run(this,!1)},Object.defineProperties(P.prototype,C);var M=function(t){function e(e){if("number"==typeof e){var r=arguments[0],i=arguments[1],n=arguments[2],o=arguments[3];e={width:r,height:i,scaleMode:n,resolution:o}}t.call(this,null,e);var s=e||{},a=s.width,h=s.height;this.mipmap=!1,this.width=Math.ceil(a)||100,this.height=Math.ceil(h)||100,this.valid=!0,this._canvasRenderTarget=null,this.clearColor=[0,0,0,0],this.framebuffer=new P(this.width*this.resolution,this.height*this.resolution).addColorTexture(0,this),this.maskStack=[],this.filterStack=[{}]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.resize=function(t,e){t=Math.ceil(t),e=Math.ceil(e),this.framebuffer.resize(t*this.resolution,e*this.resolution)},e.prototype.dispose=function(){this.framebuffer.dispose(),t.prototype.dispose.call(this)},e.prototype.destroy=function(){t.prototype.destroy.call(this,!0),this.framebuffer=null},e}(v),I=function(){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)};I.prototype.set=function(t,e,r){var i=e.width,n=e.height;if(r){var o=t.width/2/i,s=t.height/2/n,a=t.x/i+o,u=t.y/n+s;r=h.groupD8.add(r,h.groupD8.NW),this.x0=a+o*h.groupD8.uX(r),this.y0=u+s*h.groupD8.uY(r),r=h.groupD8.add(r,2),this.x1=a+o*h.groupD8.uX(r),this.y1=u+s*h.groupD8.uY(r),r=h.groupD8.add(r,2),this.x2=a+o*h.groupD8.uX(r),this.y2=u+s*h.groupD8.uY(r),r=h.groupD8.add(r,2),this.x3=a+o*h.groupD8.uX(r),this.y3=u+s*h.groupD8.uY(r)}else this.x0=t.x/i,this.y0=t.y/n,this.x1=(t.x+t.width)/i,this.y1=t.y/n,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/n,this.x3=t.x/i,this.y3=(t.y+t.height)/n;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 R=new I,D=function(t){function e(r,i,n,o,s,a){if(t.call(this),this.noFrame=!1,i||(this.noFrame=!0,i=new h.Rectangle(0,0,1,1)),r instanceof e&&(r=r.baseTexture),this.baseTexture=r,this._frame=i,this.trim=o,this.valid=!1,this.requiresUpdate=!1,this._uvs=R,this.uvMatrix=null,this.orig=n||i,this._rotate=Number(s||0),!0===s)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");this.defaultAnchor=a?new h.Point(a.x,a.y):new h.Point(0,0),this._updateID=0,this.textureCacheIds=[],r.valid?this.noFrame?r.valid&&this.onBaseTextureUpdated(r):this.frame=i:r.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&r.on("update",this.onBaseTextureUpdated,this)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={resolution:{configurable:!0},frame:{configurable:!0},rotate:{configurable:!0},width:{configurable:!0},height:{configurable:!0}};return e.prototype.update=function(){this.baseTexture.resource&&this.baseTexture.resource.update()},e.prototype.onBaseTextureUpdated=function(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)},e.prototype.destroy=function(t){if(this.baseTexture){if(t){var r=this.baseTexture.resource;r&&n.TextureCache[r.url]&&e.removeFromCache(r.url),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=!1,e.removeFromCache(this),this.textureCacheIds=null},e.prototype.clone=function(){return new e(this.baseTexture,this.frame,this.orig,this.trim,this.rotate,this.defaultAnchor)},e.prototype.updateUvs=function(){this._uvs===R&&(this._uvs=new I),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++},e.from=function(t,r,i){void 0===r&&(r={}),void 0===i&&(i=s.settings.STRICT_TEXTURE_CACHE);var o="string"==typeof t,a=null;o?a=t:(t._pixiId||(t._pixiId="pixiid_"+n.uid()),a=t._pixiId);var h=n.TextureCache[a];if(o&&i&&!h)throw new Error('The cacheId "'+a+'" does not exist in TextureCache.');return h||(r.resolution||(r.resolution=n.getResolutionOfUrl(t)),(h=new e(new v(t,r))).baseTexture.cacheId=a,v.addToCache(h.baseTexture,a),e.addToCache(h,a)),h},e.fromBuffer=function(t,r,i,n){return new e(v.fromBuffer(t,r,i,n))},e.fromLoader=function(t,r,i){var o=new p(t);o.url=r;var a=new e(new v(o,{scaleMode:s.settings.SCALE_MODE,resolution:n.getResolutionOfUrl(r)}));return i||(i=r),v.addToCache(a.baseTexture,i),e.addToCache(a,i),i!==r&&(v.addToCache(a.baseTexture,r),e.addToCache(a,r)),a},e.addToCache=function(t,e){e&&(-1===t.textureCacheIds.indexOf(e)&&t.textureCacheIds.push(e),n.TextureCache[e]&&console.warn("Texture added to the cache with an id ["+e+"] that already had an entry"),n.TextureCache[e]=t)},e.removeFromCache=function(t){if("string"==typeof t){var e=n.TextureCache[t];if(e){var r=e.textureCacheIds.indexOf(t);return r>-1&&e.textureCacheIds.splice(r,1),delete n.TextureCache[t],e}}else if(t&&t.textureCacheIds){for(var i=0;i<t.textureCacheIds.length;++i)n.TextureCache[t.textureCacheIds[i]]===t&&delete n.TextureCache[t.textureCacheIds[i]];return t.textureCacheIds.length=0,t}return null},r.resolution.get=function(){return this.baseTexture.resolution},r.frame.get=function(){return this._frame},r.frame.set=function(t){this._frame=t,this.noFrame=!1;var e=t.x,r=t.y,i=t.width,n=t.height,o=e+i>this.baseTexture.width,s=r+n>this.baseTexture.height;if(o||s){var a=o&&s?"and":"or",h="X: "+e+" + "+i+" = "+(e+i)+" > "+this.baseTexture.width,u="Y: "+r+" + "+n+" = "+(r+n)+" > "+this.baseTexture.height;throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: "+h+" "+a+" "+u)}this.valid=i&&n&&this.baseTexture.valid,this.trim||this.rotate||(this.orig=t),this.valid&&this.updateUvs()},r.rotate.get=function(){return this._rotate},r.rotate.set=function(t){this._rotate=t,this.valid&&this.updateUvs()},r.width.get=function(){return this.orig.width},r.height.get=function(){return this.orig.height},Object.defineProperties(e.prototype,r),e}(n.EventEmitter);function N(t){t.destroy=function(){},t.on=function(){},t.once=function(){},t.emit=function(){}}D.EMPTY=new D(new v),N(D.EMPTY),N(D.EMPTY.baseTexture),D.WHITE=function(){var t=document.createElement("canvas");t.width=16,t.height=16;var e=t.getContext("2d");return e.fillStyle="white",e.fillRect(0,0,16,16),new D(new v(new x(t)))}(),N(D.WHITE),N(D.WHITE.baseTexture);var L=function(t){function e(e,r){var i=null;if(!(e instanceof M)){var n=arguments[1],o=arguments[2],s=arguments[3],a=arguments[4];console.warn("Please use RenderTexture.create("+n+", "+o+") instead of the ctor directly."),i=arguments[0],r=null,e=new M({width:n,height:o,scaleMode:s,resolution:a})}t.call(this,e,r),this.legacyRenderer=i,this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.resize=function(t,e,r){void 0===r&&(r=!0),t=Math.ceil(t),e=Math.ceil(e),this.valid=t>0&&e>0,this._frame.width=this.orig.width=t,this._frame.height=this.orig.height=e,r&&this.baseTexture.resize(t,e),this.updateUvs()},e.prototype.setResolution=function(t){var e=this.baseTexture;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))},e.create=function(t){return"number"==typeof t&&(t={width:t,height:arguments[1],scaleMode:arguments[2],resolution:arguments[3]}),new e(new M(t))},e}(D),F=function(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0};F.prototype.createTexture=function(t,e){var r=new M(Object.assign({width:t,height:e,resolution:1},this.textureOptions));return new L(r)},F.prototype.getOptimalTexture=function(t,e,r){void 0===r&&(r=1);var i=F.SCREEN_KEY;t*=r,e*=r,this.enableFullScreen&&t===this._pixelsWidth&&e===this._pixelsHeight||(i=(65535&(t=n.nextPow2(t)))<<16|65535&(e=n.nextPow2(e))),this.texturePool[i]||(this.texturePool[i]=[]);var o=this.texturePool[i].pop();return o||(o=this.createTexture(t,e)),o.filterPoolKey=i,o.setResolution(r),o},F.prototype.getFilterTexture=function(t,e){var r=this.getOptimalTexture(t.width,t.height,e||t.resolution);return r.filterFrame=t.filterFrame,r},F.prototype.returnTexture=function(t){var e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)},F.prototype.returnFilterTexture=function(t){this.returnTexture(t)},F.prototype.clear=function(t){if(t=!1!==t)for(var e in this.texturePool){var r=this.texturePool[e];if(r)for(var i=0;i<r.length;i++)r[i].destroy(!0)}this.texturePool={}},F.prototype.setScreenSize=function(t){if(t.width!==this._pixelsWidth||t.height!==this._pixelsHeight){var e=F.SCREEN_KEY,r=this.texturePool[e];if(this.enableFullScreen=t.width>0&&t.height>0,r)for(var i=0;i<r.length;i++)r[i].destroy(!0);this.texturePool[e]=[],this._pixelsWidth=t.width,this._pixelsHeight=t.height}},F.SCREEN_KEY="screen";var U=function(t,e,r,i,n,o,s){void 0===r&&(r=!1),void 0===i&&(i=5126),this.buffer=t,this.size=e,this.normalized=r,this.type=i,this.stride=n,this.start=o,this.instance=s};U.prototype.destroy=function(){this.buffer=null},U.from=function(t,e,r,i,n){return new U(t,e,r,i,n)};var B=0,k=function(t,e,r){void 0===e&&(e=!0),void 0===r&&(r=!1),this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=r,this.static=e,this.id=B++,this.disposeRunner=new i.Runner("disposeBuffer",2)};function j(t){if(4===t.BYTES_PER_ELEMENT)return t instanceof Float32Array?"Float32Array":t instanceof Uint32Array?"Uint32Array":"Int32Array";if(2===t.BYTES_PER_ELEMENT){if(t instanceof Uint16Array)return"Uint16Array"}else if(1===t.BYTES_PER_ELEMENT&&t instanceof Uint8Array)return"Uint8Array";return null}k.prototype.update=function(t){this.data=t||this.data,this._updateID++},k.prototype.dispose=function(){this.disposeRunner.run(this,!1)},k.prototype.destroy=function(){this.dispose(),this.data=null},k.from=function(t){return t instanceof Array&&(t=new Float32Array(t)),new k(t)};var G={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array};var X={5126:4,5123:2,5121:1},z=0,Y={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},H=function(t,e){void 0===t&&(t=[]),void 0===e&&(e={}),this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=z++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new i.Runner("disposeGeometry",2),this.refCount=0};H.prototype.addAttribute=function(t,e,r,i,n,o,s,a){if(void 0===i&&(i=!1),void 0===a&&(a=!1),!e)throw new Error("You must pass a buffer when creating an attribute");e.data||(e instanceof Array&&(e=new Float32Array(e)),e=new k(e));var h=t.split("|");if(h.length>1){for(var u=0;u<h.length;u++)this.addAttribute(h[u],e,r,i,n);return this}var l=this.buffers.indexOf(e);return-1===l&&(this.buffers.push(e),l=this.buffers.length-1),this.attributes[t]=new U(l,r,i,n,o,s,a),this.instanced=this.instanced||a,this},H.prototype.getAttribute=function(t){return this.attributes[t]},H.prototype.getBuffer=function(t){return this.buffers[this.getAttribute(t).buffer]},H.prototype.addIndex=function(t){return t.data||(t instanceof Array&&(t=new Uint16Array(t)),t=new k(t)),t.index=!0,this.indexBuffer=t,-1===this.buffers.indexOf(t)&&this.buffers.push(t),this},H.prototype.getIndex=function(){return this.indexBuffer},H.prototype.interleave=function(){if(1===this.buffers.length||2===this.buffers.length&&this.indexBuffer)return this;var t,e=[],r=[],i=new k;for(t in this.attributes){var n=this.attributes[t],o=this.buffers[n.buffer];e.push(o.data),r.push(n.size*X[n.type]/4),n.buffer=0}for(i.data=function(t,e){for(var r=0,i=0,n={},o=0;o<t.length;o++)i+=e[o],r+=t[o].length;for(var s=new ArrayBuffer(4*r),a=null,h=0,u=0;u<t.length;u++){var l=e[u],c=t[u],d=j(c);n[d]||(n[d]=new G[d](s)),a=n[d];for(var p=0;p<c.length;p++){a[(p/l|0)*i+h+p%l]=c[p]}h+=l}return new Float32Array(s)}(e,r),t=0;t<this.buffers.length;t++)this.buffers[t]!==this.indexBuffer&&this.buffers[t].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this},H.prototype.getSize=function(){for(var t in this.attributes){var e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0},H.prototype.dispose=function(){this.disposeRunner.run(this,!1)},H.prototype.destroy=function(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null},H.prototype.clone=function(){for(var t=new H,e=0;e<this.buffers.length;e++)t.buffers[e]=new k(this.buffers[e].data.slice());for(var r in this.attributes){var i=this.attributes[r];t.attributes[r]=new U(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.index=!0),t},H.merge=function(t){for(var e,r=new H,i=[],n=[],o=[],s=0;s<t.length;s++){e=t[s];for(var a=0;a<e.buffers.length;a++)n[a]=n[a]||0,n[a]+=e.buffers[a].data.length,o[a]=0}for(var h=0;h<e.buffers.length;h++)i[h]=new(Y[j(e.buffers[h].data)])(n[h]),r.buffers[h]=new k(i[h]);for(var u=0;u<t.length;u++){e=t[u];for(var l=0;l<e.buffers.length;l++)i[l].set(e.buffers[l].data,o[l]),o[l]+=e.buffers[l].data.length}if(r.attributes=e.attributes,e.indexBuffer){r.indexBuffer=r.buffers[e.buffers.indexOf(e.indexBuffer)],r.indexBuffer.index=!0;for(var c=0,d=0,p=0,f=0,m=0;m<e.buffers.length;m++)if(e.buffers[m]!==e.indexBuffer){f=m;break}for(var y in e.attributes){var _=e.attributes[y];(0|_.buffer)===f&&(d+=_.size*X[_.type]/4)}for(var v=0;v<t.length;v++){for(var g=t[v].indexBuffer.data,x=0;x<g.length;x++)r.indexBuffer.data[x+p]+=c;c+=e.buffers[f].data.length/d,p+=g.length}}return r};var V=function(t){function e(){t.call(this),this.addAttribute("aVertexPosition",[0,0,1,0,1,1,0,1]).addIndex([0,1,3,2])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(H),W=function(t){function e(){t.call(this),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new k(this.vertices),this.uvBuffer=new k(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(t,e){var r=0,i=0;return this.uvs[0]=r,this.uvs[1]=i,this.uvs[2]=r+e.width/t.width,this.uvs[3]=i,this.uvs[4]=r+e.width/t.width,this.uvs[5]=i+e.height/t.height,this.uvs[6]=r,this.uvs[7]=i+e.height/t.height,r=e.x,i=e.y,this.vertices[0]=r,this.vertices[1]=i,this.vertices[2]=r+e.width,this.vertices[3]=i,this.vertices[4]=r+e.width,this.vertices[5]=i+e.height,this.vertices[6]=r,this.vertices[7]=i+e.height,this.invalidate(),this},e.prototype.invalidate=function(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this},e}(H),q=0,K=function(t,e){this.uniforms=t,this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=q++,this.static=!!e};K.prototype.update=function(){this.dirtyId++},K.prototype.add=function(t,e,r){this.uniforms[t]=new K(e,r)},K.from=function(t,e){return new K(t,e)};var Z=function(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.sourceFrame=new h.Rectangle,this.destinationFrame=new h.Rectangle,this.filters=[]};Z.prototype.clear=function(){this.target=null,this.filters=null,this.renderTexture=null};var J=function(t){function e(e){t.call(this,e),this.defaultFilterStack=[{}],this.texturePool=new F,this.texturePool.setScreenSize(e.view),this.statePool=[],this.quad=new V,this.quadUv=new W,this.tempRect=new h.Rectangle,this.activeState={},this.globalUniforms=new K({outputFrame:this.tempRect,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this._pixelsWidth=e.view.width,this._pixelsHeight=e.view.height}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.push=function(t,e){for(var r=this.renderer,i=this.defaultFilterStack,n=this.statePool.pop()||new Z,o=e[0].resolution,s=e[0].padding,a=e[0].autoFit,h=e[0].legacy,u=1;u<e.length;u++){var l=e[u];o=Math.min(o,l.resolution),s=Math.max(s,l.padding),a=a||l.autoFit,h=h||l.legacy}1===i.length&&(this.defaultFilterStack[0].renderTexture=r.renderTexture.current),i.push(n),n.resolution=o,n.legacy=h,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(s),a&&n.sourceFrame.fit(this.renderer.renderTexture.sourceFrame),n.sourceFrame.ceil(o),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,o),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height,n.renderTexture.filterFrame=n.sourceFrame,r.renderTexture.bind(n.renderTexture,n.sourceFrame),r.renderTexture.clear()},e.prototype.pop=function(){var t=this.defaultFilterStack,e=t.pop(),r=e.filters;this.activeState=e;var i=this.globalUniforms.uniforms;i.outputFrame=e.sourceFrame,i.resolution=e.resolution;var n=i.inputSize,o=i.inputPixel,s=i.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=n[0]*e.resolution,o[1]=n[1]*e.resolution,o[2]=1/o[0],o[3]=1/o[1],s[0]=.5*o[2],s[1]=.5*o[3],s[2]=e.sourceFrame.width*n[2]-.5*o[2],s[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){var a=i.filterArea;a[0]=e.destinationFrame.width,a[1]=e.destinationFrame.height,a[2]=e.sourceFrame.x,a[3]=e.sourceFrame.y,i.filterClamp=i.inputClamp}this.globalUniforms.update();var h=t[t.length-1];if(1===r.length)r[0].apply(this,e.renderTexture,h.renderTexture,!1,e),this.returnFilterTexture(e.renderTexture);else{var u=e.renderTexture,l=this.getOptimalFilterTexture(u.width,u.height,e.resolution);l.filterFrame=u.filterFrame;var c=0;for(c=0;c<r.length-1;++c){r[c].apply(this,u,l,!0,e);var d=u;u=l,l=d}r[c].apply(this,u,h.renderTexture,!1,e),this.returnFilterTexture(u),this.returnFilterTexture(l)}e.clear(),this.statePool.push(e)},e.prototype.applyFilter=function(t,e,r,i){var n=this.renderer;n.renderTexture.bind(r,r?r.filterFrame:null),i&&n.renderTexture.clear(),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.state.set(t.state),n.shader.bind(t),t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(o.DRAW_MODES.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(o.DRAW_MODES.TRIANGLE_STRIP))},e.prototype.calculateSpriteMatrix=function(t,e){var r=this.activeState,i=r.sourceFrame,n=r.destinationFrame,o=e._texture.orig,s=t.set(n.width,0,0,n.height,i.x,i.y),a=e.worldTransform.copyTo(h.Matrix.TEMP_MATRIX);return a.invert(),s.prepend(a),s.scale(1/o.width,1/o.height),s.translate(e.anchor.x,e.anchor.y),s},e.prototype.destroy=function(){this.texturePool.clear(!1)},e.prototype.getOptimalFilterTexture=function(t,e,r){return void 0===r&&(r=1),this.texturePool.getOptimalTexture(t,e,r)},e.prototype.getFilterTexture=function(t,e){if("number"==typeof t){var r=t;t=e,e=r}t=t||this.activeState.renderTexture;var i=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution);return i.filterFrame=t.filterFrame,i},e.prototype.returnFilterTexture=function(t){this.texturePool.returnTexture(t)},e.prototype.emptyPool=function(){this.texturePool.clear(!0)},e.prototype.resize=function(){this.texturePool.setScreenSize(this.renderer.view)},e}(O),Q=function(t){this.renderer=t};Q.prototype.flush=function(){},Q.prototype.destroy=function(){this.renderer=null},Q.prototype.start=function(){},Q.prototype.stop=function(){this.flush()},Q.prototype.render=function(t){};var $=function(t){function e(e){t.call(this,e),this.emptyRenderer=new Q(e),this.currentRenderer=this.emptyRenderer}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setObjectRenderer=function(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())},e.prototype.flush=function(){this.setObjectRenderer(this.emptyRenderer)},e.prototype.reset=function(){this.setObjectRenderer(this.emptyRenderer)},e.prototype.copyBoundTextures=function(t,e){for(var r=this.renderer.texture.boundTextures,i=e-1;i>=0;--i)t[i]=r[i]||null,t[i]&&(t[i]._batchLocation=i)},e.prototype.boundArray=function(t,e,r,i){for(var n=t.elements,o=t.ids,s=t.count,a=0,h=0;h<s;h++){var u=n[h],l=u._batchLocation;if(l>=0&&l<i&&e[l]===u)o[h]=l;else for(;a<i;){var c=e[a];if(!c||c._batchEnabled!==r||c._batchLocation!==a){o[h]=a,u._batchLocation=a,e[a]=u;break}a++}}},e}(O);s.settings.PREFER_ENV=n.isMobile.any?o.ENV.WEBGL:o.ENV.WEBGL2,s.settings.STRICT_TEXTURE_CACHE=!1;var tt=0,et=function(t){function e(e){t.call(this,e),this.webGLVersion=1,this.extensions={},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this),e.view.addEventListener("webglcontextlost",this.handleContextLost,!1),e.view.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={isLost:{configurable:!0}};return r.isLost.get=function(){return!this.gl||this.gl.isContextLost()},e.prototype.contextChange=function(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=tt++,t.isContextLost()&&t.getExtension("WEBGL_lose_context")&&t.getExtension("WEBGL_lose_context").restoreContext()},e.prototype.initFromContext=function(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=tt++,this.renderer.runners.contextChange.run(t)},e.prototype.initFromOptions=function(t){var e=this.createContext(this.renderer.view,t);this.initFromContext(e)},e.prototype.createContext=function(t,e){var r;if(s.settings.PREFER_ENV>=o.ENV.WEBGL2&&(r=t.getContext("webgl2",e)),r)this.webGLVersion=2;else if(this.webGLVersion=1,!(r=t.getContext("webgl",e)||t.getContext("experimental-webgl",e)))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 t=this.gl;1===this.webGLVersion?Object.assign(this.extensions,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBKIT_WEBGL_depth_texture"),loseContext:t.getExtension("WEBGL_lose_context"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic")